<div id="pat-modal-panel-space"
     tal:define="
       read_only view/read_only;
       disabled python:'disabled' if read_only else None;
       authenticator_view nocall:here/@@authenticator;
     "
>

  <dialog class="medium pat-modal-panel"
          id="pat-modal-panel"
          open
  >
    <div class="modal-panel-contents">
      <div class="modal-panel-header">
        <h1 class="modal-panel-title"
            i18n:translate=""
        >Metadata</h1>
      </div>
      <div class="modal-panel-body">
        <form class="pat-form pat-validation pat-inject"
              action="${context/absolute_url}/view"
              enctype="multipart/form-data"
              method="POST"
              data-pat-doclock="${python: 'url: ' + here.absolute_url() + '/@@toggle-lock' if not read_only else ''}"
              data-pat-inject="${view/form_pat_inject_options}"
        >

          <fieldset class="horizontal">
            <label>
              <tal:label i18n:translate="">Title</tal:label>
              <input disabled="${disabled}"
                     name="title"
                     size=""
                     type="text"
                     value="${context/title}"
              />
            </label>
            <label>
              <tal:label i18n:translate="">Tags</tal:label>
              <input class="pat-autosuggest"
                     disabled="${disabled}"
                     name="subjects"
                     placeholder="Tags"
                     type="text"
                     value="${python:','.join(context.subject)}"
                     data-pat-autosuggest="ajax-data-type: json; ajax-search-index: text; ajax-url:${context/absolute_url}/@@getVocabulary?resultsonly=1&amp;name=ploneintranet.network.vocabularies.Keywords&amp;field=subjects"
                     i18n:attributes="placeholder"
                     i18n:domain="plone"
              />
            </label>
            <label>
              <tal:label i18n:translate="">Description</tal:label>
              <textarea disabled="${disabled}"
                        name="description"
                        placeholder="Description"
                        rows="8"
                        title="Description"
                        i18n:attributes="placeholder title"
              >${context/description}</textarea>
            </label>
          </fieldset>

          <fieldset class="horizontal versioning pat-inject pat-subform"
                    data-pat-inject="source: #document-content; target: #document-content &amp;&amp; source: fieldset.versioning; target: fieldset.versioning &amp;&amp; source: #workflow-menu; target: #workflow-menu"
                    tal:condition="python:not read_only and context.portal_type in ('File', 'Image')"
          >
            <span tal:replace="structure authenticator_view/authenticator"></span>
            <fieldset class="pat-form-field-toggle group">
              <legend i18n:translate="">Save a new version</legend>
              <label class="pat-toggle-switch">
                <input id="cmfeditions_save_new_version"
                       disabled="${disabled}"
                       name="cmfeditions_save_new_version"
                       type="checkbox"
                />
              </label>
            </fieldset>
            <fieldset class="horizontal condensed pat-depends new-version-details pat-inject"
                      data-pat-depends="cmfeditions_save_new_version"
            >
              <label tal:condition="python: context.portal_type == 'File'">
                <span tal:omit-tag=""
                      i18n:translate=""
                >Upload a new file</span>
                <input class="file"
                       name="file"
                       type="file"
                />
              </label>
              <label tal:condition="python: context.portal_type == 'Image'">
                <span tal:omit-tag=""
                      i18n:translate=""
                >Upload a new image</span>
                <input class="image"
                       name="image"
                       type="file"
                />
              </label>

              <label>
                <textarea id="cmfeditions_version_comment"
                          cols="80"
                          name="cmfeditions_version_comment"
                          placeholder="Change notes"
                          rows="4"
                          tal:condition="view/is_versionable"
                          tal:attributes="
                            value request/form/cmfeditions_version_comment | nothing;
                          "
                          i18n:attributes="placeholder"
                ></textarea>
              </label>
            </fieldset>
          </fieldset>
          <fieldset class="horizontal link pat-inject pat-subform"
                    data-pat-inject="source: #document-content; target: #document-content;"
                    tal:condition="python:context.portal_type in ('Link')"
          >
            <label>
              <tal:label i18n:translate="">Web URL</tal:label>
              <input name="remoteUrl"
                     required="required"
                     size="80"
                     type="text"
                     value="${context/remoteUrl}"
                     tal:condition="not:read_only"
              />

              <a href="${context/remoteUrl}"
                 tal:condition="read_only"
              >${context/remoteUrl}</a>
            </label>
          </fieldset>

          <div class="pat-button-bar">
            <tal:save condition="not:read_only">
              <button class="pat-button default icon-ok-circle close-panel focus"
                      type="submit"
                      i18n:translate=""
              >Save</button>
              <button class="pat-button icon-cancel-circle close-panel validate-ignore"
                      type="button"
                      i18n:translate=""
              >Cancel</button>
            </tal:save>
            <tal:readonly condition="read_only">
              <button class="pat-button default icon-cancel-circle close-panel validate-ignore"
                      type="button"
                      i18n:translate=""
              >Close</button>
            </tal:readonly>
          </div>

        </form>
      </div>
    </div>
  </dialog>
</div>
