{% if obj %}
  {% set doc = obj %}
{% endif %}
<div class="modal fade" id="modal-edit" role="dialog" data-keyboard="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <form id="modal-edit-form" method="POST"
            action="{{ url_for('.document_edit', doc_id=doc.id,folder_id=folder.id, community_id=doc.community.slug) }}"
            enctype="multipart/form-data">

        {{ csrf.field() }}

        <div class="modal-header">
          <button class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title">{{ _("Edit document properties") }}</h4>
        </div>

        <div class="modal-body">
          <div class="form-group">
            <label class="control-label" for="inputName">{{ _("Name") }}</label>

            <input type="text" class="form-control form-document-title" id="inputName" name="title"
                   data-check-url="{{ url_for('.check_valid_name', community_id=g.community.slug) }}"
                   value="{{ doc.title }}">
            <span class="help-block"></span>
          </div>

          <div class="form-group">
            <label class="control-label"
                   for="inputDescription">{{ _("Description") }}</label>

            <textarea class="form-control resizeable-vertical form-document-description" rows="5"
                      cols="80" id="inputDescription"
                      name="description">{{ doc.description }}</textarea>
          </div>
        </div>

        <div class="modal-footer">
          <button data-dismiss="modal" class="btn">{{ _("Cancel") }}</button>
          <button class="btn btn-primary" type="submit" name="action"
                  value="edit">{{ _("Save changes") }}</button>
        </div>
      </form>
    </div>
  </div>
</div>

{%- deferJS %}
  <script>
    require(
        ['Abilian', 'SBEFolderEditSetup'],
        function (Abilian, setupFolderEdit) {
          Abilian.fn.onAppInit(function () {
            setupFolderEdit(
                $('#modal-edit'),
                '{{ doc.id }}',
                'document-edit');

            $('#modal-edit input[type="text"]').preventEnterKey();
          });
        });
  </script>
{%- enddeferJS %}
