{% extends "wiki/base.html" %}
{% set title = _('Move "{t}"')|f(t=document.title) %}
{% block title %}{{ page_title(title) }}{% endblock %}
{% set meta = [('robots', 'noindex, nofollow')] %}
{% block bodyclass %}move-page{% endblock %}

{% block site_css %}
    {{ super() }}
    {{ css('wiki-edit') }}
    {{ css('jquery-ui') }}
{% endblock %}

{% block content %}

      <h1>{{ title }}</h1>
      <p>{{ _('Please provide a new slug for this page using the field below.') }}</p>

      {% if conflicts: %}
      <div class="warning">
        <p>{{ _('Your requested move cannot be completed due to slug conflicts:') }}</p>

        <ul class="move-descendants-list">
        {% for doc in descendants %}
          <li>{{ doc }}</li>
        {% endfor %}
        </ul>

        <p>{{ _('Please choose a different slug value.') }}</p>
      </div>
      {% endif %}

      {% if form.errors %}
      <div class="warning">
        {{ form.errors.as_ul() }}
      </div>
      {% endif %}

      <form action="" method="post">
        {{ csrf() }}
        <ul class="description">
          <li>
            <dl>
              <dt>{{ _('Current Slug:') }} </dt>
              <dd>{{ document.slug }}</dd>
            </dl>
          </li>
          <li>
            <dl>
              <dt><label for="title">{{ _('Title:') }}</label> </dt>
              <dd><input id="title" type="text" name="title" value="{{ document.title }}" autofocus /></dd>
            </dl>
          </li>
          <li>
            <dl>
              <dt>{{ _('Preview URL:') }}</dt>
              <dd id="preview-url" data-url="{{ settings.SITE_URL  }}/{{ document.locale }}/docs/" data-specific="{{ specific_slug }}">
                {{ request.build_absolute_uri(url('wiki.document', document.full_path)) }}
              </dd>
            </dl>
          </li>
          <li>
            <dl>
              <dt><label for="move-slug">{{ _('New Slug:') }}</label> </dt>
              <dd>
                <input type="text" name="slug" id="move-slug" value="" required="required" data-validator="{{ SLUG_CLEANSING_REGEX }}" />
                <input type="hidden" value="{{ specific_slug }}" id="current-slug" />
                <input type="hidden" value="{{ document.locale }}" id="locale" name="locale"/>
              </dd>
              <dd class="parent-suggest-container">
                <button class="transparent move-lookup-link" type="button">{{ _('Lookup by Document Title') }}</button>

                <div id="parent-suggest-input-container">
                    <input type="text" placeholder="{{ _('Parent Title') }}" id="parent-suggestion" disabled />
                </div>
              </dd>
            </dl>
          </li>
        </ul>

        <ul id="page-buttons">
          <li><button type="submit">{{ _('Move {d} Pages')|f(d=descendants_count) if descendants_count else _('Move Page') }}</button></li>
          <li><a class="button negative" href="{{ url('wiki.document', document.full_path, locale=document.locale) }}">{{ _('Cancel') }}</a></li>
        </ul>

        {% if descendants_count: %}
          <p><strong>{{ _('The following {d} subpages will be affected by this move:')|f(d=descendants_count) }}</strong></p>
          <div class="move-descendants"><ul class="move-descendants-list">
            {% for doc in descendants %}
              <li>{{ doc }}</li>
            {% endfor %}
          </ul></div>
        {% else %}
          <p><strong>{{ _('No other documents will be affected by this change.') }}</strong></p>
        {% endif %}

      </form>

{% endblock %}

{% block js %}
  {{ js('jquery-ui') }}
  {{ js('wiki-move', async=True) }}
{% endblock %}
