<div class="dashnex-metabox">

    {% if page.post_status != 'publish' %}
        <div class="unpublished">
            You should publish page before assigning it to Site Manager Keywords.
        </div>
    {% else %}

        {% if availableKeywords|length == 0 and primaryKeyword.GetWPPageId is not null and  primaryKeyword.GetWPPageId != page.ID %}
            <div class="empty">
                There is no empty Site Manager Keywords available. Go to DashNex Site Manager to add more keywords.
            </div>
        {% else %}

            <div class="unassign-box {{ assignedTo ? '': 'hide' }}" data-action="dashnex-metabox-page-save"
                 data-method="post" data-post-id="{{ page.ID }}" data-name="dashnex-page-metabox">

                <div id="major-publishing-actions">

                    <div class="message">
                        Assigned to <strong class="keyword">{{ assignedTo.keyword }}</strong> keyword.
                    </div>
                    <div id="publishing-action">
                        <span class="spinner"></span>
                        <a href="#" class="button button-primary button-large" id="unassign">Unassign</a>
                    </div>
                    <div class="clear"></div>
                </div>
            </div>

            <div class="assign-box {{ assignedTo ? 'hide': '' }}" data-action="dashnex-metabox-page-save"
                 data-method="post" data-post-id="{{ page.ID }}" data-name="dashnex-page-metabox">

                <input id="keyword-id" type="hidden" name="dashnex_page_metabox[keyword_id]"
                       value="{{  assignedTo.id is defined ? assignedTo.id : 0 }}">

                <div id="keywords" init="{{ keywords | json_encode }}" ></div>

                <div id="major-publishing-actions">
                    <div id="publishing-action">
                        <span class="spinner"></span>
                        <a href="#" class="button button-primary button-large" id="assign">Assign</a>
                    </div>
                    <div class="clear"></div>
                </div>
            </div>
        {% endif %}
    {% endif %}
</div>
