<div id="workspace-documents"
     tal:define="
       absolute_url here/absolute_url;
       can_add view/can_add;
       can_edit view/can_edit;
       request_headers context/@@http-cache-headers;
       token context/@@authenticator/token;
       view_name view/__name__;
       context_trashed view/is_trashed;
       is_trash python: context_trashed or 'trash' in view_name;
       items view/items;
       ws view/workspace;
       ws_view nocall:ws/view;
       can_manage_workspace ws_view/can_manage_workspace;
       parent view/logical_parent;
       has_parent python:bool(parent);
       ztu modules/ZTUtils;
     "
     i18n:domain="ploneintranet"
>
  <div class="item-selector mode-follow"
       id="selector"
  >
    <div class="pat-toolbar functions sticky"
         id="selector-functions"
    >
      <div class="toolbar-functions-area">

        <tal:has_parent condition="has_parent">
          <a class="ueber-back-button pat-inject"
             id="button-folder-up"
             href="${url}"
             data-pat-inject="source: #workspace-documents; target: #workspace-documents"
             tal:define="
               url parent/url;
               url python: url + '/@@sidebar.documents' if not '/@@' in url else url;
             "
          >${parent/title}</a>
        </tal:has_parent>
        <form class="pat-inject pat-autosubmit toolbar-section view-options"
              action="${absolute_url}/@@${view_name}#workspace-documents"
              method="post"
              data-pat-inject="source: #workspace-documents; target: #workspace-documents"
              tal:define="
                grouping view/grouping;
              "
              tal:condition="not:has_parent"
        >
          <input tal:replace="structure context/@@authenticator/authenticator" />
          <label class="pat-select">
            <input name="grouping.submitted"
                   type="hidden"
                   value="1"
            />
            <select id="browse-mode"
                    name="grouping"
            >
              <option selected="${option/selected|nothing}"
                      value="${option/value}"
                      tal:repeat="option view/grouping_options"
              >
                ${option/title}
                <tal:default condition="option/default"
                             i18n:translate=""
                >(default)</tal:default>
              </option>
            </select>
          </label>
        </form>

        <div class="toolbar-section quick-functions">
          <tal:not_trash condition="not:is_trash">
            <tal:can_add condition="can_add">
              <a class="create-document pat-tooltip icon create"
                 href="${absolute_url}/${view_name}#create-document-menu"
                 data-pat-tooltip="source: ajax; position-list: tl"
                 i18n:translate=""
              >Create</a>
              <div id="create-document-menu"
                   hidden
              >
                <ul class="menu">
                  <li>
                    <a class="create-document pat-modal icon-document close-panel"
                       href="${absolute_url}/@@add_content#document-content"
                       title="Create document"
                       data-pat-modal="class: panel medium panel-create-document"
                       tal:condition="can_add"
                       i18n:attributes="title"
                       i18n:translate="label_create_document"
                    >Create document</a>
                  </li>
                  <li>
                    <a class="icon-folder create-folder pat-modal close-panel"
                       href="${absolute_url}/@@add_folder#document-content"
                       data-pat-modal="class: panel medium;"
                       i18n:translate="label_create_folder"
                    >Create folder</a>
                  </li>
                  <li>
                    <a class="icon-link create-document pat-modal close-panel"
                       href="${absolute_url}/@@add_link#document-content"
                       data-pat-modal="class: panel medium"
                       i18n:translate="label_create_link"
                    >Create link</a>
                  </li>
                </ul>
              </div>
            </tal:can_add>
            <a class="pat-toggle toggle-select icon select"
               id="sidebar-batch-functions-trigger"
               data-pat-toggle="selector: #selector; value: mode-select mode-follow"
               i18n:translate=""
            >Select</a>
            <a class="icon more pat-tooltip"
               href="#more-menu-workspace-documents"
               data-pat-tooltip="source: ajax; position-list: tl;"
               i18n:translate=""
            >More&hellip;</a>
            <template id="more-menu-workspace-documents">
              <form class="pat-autosubmit pat-inject"
                    action="${absolute_url}/${view_name}#workspace-documents"
                    method="post"
                    tal:define="
                      show_extra view/show_extra;
                    "
              >
                <ul class="menu">
                  <tal:can_add condition="can_add">
                    <li>
                      <a class="icon-paste create-document pat-inject"
                         href="${absolute_url}/@@sidebar.paste?_authenticator=${token}#workspace-documents"
                         i18n:translate=""
                      >Paste</a>
                    </li>
                    <li tal:condition="nothing">
                    Removed until fixed, see ploneintranet.prototype#329
                      <label class="icon-upload-cloud"><input multiple="multiple"
                               type="file"
                        />
                        <span tal:omit-tag=""
                              i18n:translate=""
                        >Upload file(s)</span>
                      </label>
                    </li>
                  </tal:can_add>
                  <tal:can_edit_folder condition="view/can_change_label">
                    <li>
                      <a class="icon-pencil create-folder pat-modal"
                         href="${absolute_url}/@@edit_folder#document-content"
                         data-pat-modal="class: medium panel"
                         i18n:translate=""
                      >
                      Edit folder properties
                      </a>
                    </li>
                  </tal:can_edit_folder>
                </ul>
                <ul class="menu">
                  <li>
                    <label class="pat-checklist">
                      <input checked="${python:'archived_documents' in show_extra and 'checked' or None}"
                             name="show_archived_documents"
                             type="checkbox"
                      />
                      <span tal:omit-tag=""
                            i18n:translate=""
                      >Show archived documents</span>
                      <input name="show_archived_documents-empty-marker"
                             type="hidden"
                             value="1"
                      />
                    </label>
                  </li>
                  <li>
                    <label class="pat-checklist">
                      <input checked="${python:'deleted_documents' in show_extra and 'checked' or None}"
                             name="show_deleted_documents"
                             type="checkbox"
                      />
                      <span tal:omit-tag=""
                            i18n:translate=""
                      >Show trashed items</span>
                      <input name="show_deleted_documents-empty-marker"
                             type="hidden"
                             value="1"
                      />
                    </label>
                  </li>
                  <li>
                    <label class="pat-checklist">
                      <input checked="${python:'archived_tags' in show_extra and 'checked' or None}"
                             name="show_archived_tags"
                             type="checkbox"
                      />
                      <span tal:omit-tag=""
                            i18n:translate=""
                      >Show archived tags</span>
                      <input name="show_archived_tags-empty-marker"
                             type="hidden"
                             value="1"
                      />
                    </label>
                  </li>
                  <li>
                    <label class="pat-checklist">
                      <input checked="${python:'my_documents' in show_extra and 'checked' or None}"
                             name="show_my_documents"
                             type="checkbox"
                      />
                      <span tal:omit-tag=""
                            i18n:translate=""
                      >Show my documents only</span>
                      <input name="show_my_documents-empty-marker"
                             type="hidden"
                             value="1"
                      />
                    </label>
                  </li>
                </ul>
                <input name="grouping"
                       type="hidden"
                       value="${view/grouping}"
                />
              </form>
            </template>
          </tal:not_trash>

          <tal:trash condition="is_trash">
            <tal:if tal:define="
                      show_empty python: items and can_manage_workspace and here == ws;
                      show_restore python: can_edit and here != ws;
                    "
                    tal:condition="python:show_empty or show_restore"
            >
              <a class="icon more pat-tooltip"
                 id="more-menu-trigger-workspaces"
                 aria-expanded="true"
                 href="#more-menu-workspaces"
                 title="More functions"
                 data-pat-tooltip="source: ajax; position-list: tl;"
                 i18n:attributes="title;"
              >More&hellip;</a>

              <template id="more-menu-workspaces"
                        hidden
              >
                <ul class="menu"
                    id="more-menu-contents-workspaces"
                >
                  <li tal:condition="python: show_empty">
                    <a class="pat-modal icon-trash-empty"
                       href="${absolute_url}/@@empty-trash#document-content"
                       data-pat-modal="class: panel medium;"
                       tal:condition="python:items and can_manage_workspace"
                       i18n:translate=""
                    >Empty trash</a>
                  </li>
                  <li tal:condition="python: True or show_restore">
                    <a class="pat-modal icon-ccw pat-inject"
                       href="${absolute_url}/@@untrash#global-statusmessage"
                       title="Restore this folder and its content to the original location"
                       i18n:attributes="title;"
                       i18n:translate=""
                    >Restore</a>
                  </li>
                </ul>
              </template>
            </tal:if>
          </tal:trash>
          <a class="toggle-sidebar-size pat-toggle icon resize-full"
             title="expand/reduce sidebar"
             data-pat-toggle="selector: #application-body; value: sidebar-normal sidebar-large"
             i18n:attributes="title"
             i18n:translate=""
          >Expand sidebar</a>
        </div>
      </div>
    </div>

    <form class="pat-form search-box pat-inject pat-autosubmit"
          id="sidebar-search-form"
          action="${absolute_url}/@@${view/__name__}#items"
    >
      <label>
        <input name="sidebar-search"
               placeholder="Search"
               type="search"
               value="${request/sidebar-search|nothing}"
               i18n:attributes="placeholder"
        />
        <button type="submit"
                i18n:translate=""
        >Search</button>
      </label>
    </form>

    <form class="pat-form pat-inject search-result docs"
          id="items"
          action="#"
          data-pat-inject="target: body::after"
    >
      <aside id="global-statusmessage"
             tal:condition="not:request/suppress_message|python:0"
      >
        <tal:message tal:content="structure provider:plone.globalstatusmessage" />
      </aside>

      <fieldset class="checklist pat-checklist pat-navigation docs">

        <div class="batch-functions pat-bumper sticky-supported">
          <input name="groupname"
                 type="hidden"
                 value="${request/groupname|nothing}"
          />
          <div class="button-bar">
            <span class="float-before button-cluster select-buttons">
              <button class="pat-button select-all"
                      title="Select all"
                      type="button"
                      i18n:attributes="title"
                      i18n:translate="select_all"
              >All</button>
              <button class="pat-button deselect-all"
                      title="Deselect all"
                      type="button"
                      i18n:attributes="title"
                      i18n:translate="select_none"
              >None</button>
            </span>
            <button class="pat-button pat-toggle float-before icon-cancel"
                    type="button"
                    data-pat-toggle="selector: #selector; value: mode-select mode-follow"
                    i18n:translate=""
            >Cancel</button>
          </div>
          <div class="button-bar">
            <span class="float-before button-cluster">
              <button class="pat-button float-before pat-toggle icon-cut no-label pat-depends"
                      formaction="${context/absolute_url}/cart-cut?_authenticator=${token}"
                      title="Cut"
                      type="submit"
                      data-pat-depends="condition: items; action: enable;"
                      data-pat-toggle="selector: #selector; value: mode-select mode-follow"
                      i18n:attributes="title"
                      i18n:translate=""
              >Cut</button>
              <button class="pat-button float-before icon-copy no-label pat-depends"
                      formaction="${context/absolute_url}/cart-copy?_authenticator=${token}"
                      title="Copy"
                      type="submit"
                      data-pat-depends="condition: items; action: enable;"
                      i18n:attributes="title"
                      i18n:translate=""
              >Copy</button>
              <button class="pat-button float-before icon-paste no-label"
                      formaction="${context/absolute_url}/cart-paste?_authenticator=${token}"
                      title="Paste"
                      type="submit"
                      i18n:attributes="title"
                      i18n:translate=""
              >Paste</button>
            </span>

            <!-- <button type="submit" name="batch-function" value="move" class="float-before icon-move" title="Move">Move</button> -->

            <span class="float-before button-cluster">
              <button class="pat-button float-before no-label icon-mail pat-depends"
                      formaction="${context/absolute_url}/cart-mail-confirm?_authenticator=${token}#content"
                      title="Send selected document(s)"
                      type="submit"
                      data-pat-depends="condition: items; action: enable;"
                      i18n:attributes="title"
                      i18n:translate=""
              >Send</button>
              <!-- <button formaction="/feedback/batch-share.html#content" -->
              <!--         type="submit" -->
              <!--         name="batch-function" -->
              <!--         value="send" -->
              <!--         class="float-before icon-export pat-depends" -->
              <!--         data-pat-depends="condition: false; action: enable" -->
              <!--         title="Post selected document(s) on a timeline">Share</button> -->
            </span>
            <div class="pat-collapsible pat-context-menu closed"
                 id="batch-more"
                 data-pat-collapsible="close-trigger: *:not(#batch-more)"
            >
              <strong class="pat-button iconified more-menu-trigger context-menu-label"
                      i18n:translate=""
              >More...</strong>
              <ul class="menu">
                <li>
                  <button class="icon-archive pat-depends"
                          formaction="${context/absolute_url}/cart-archive?_authenticator=${token}"
                          title="Archive"
                          type="submit"
                          data-pat-depends="condition: items; action: enable;"
                          i18n:attributes="title"
                          i18n:translate=""
                  >Archive</button>
                </li>
                <li tal:condition="view/can_subscribe">
                  <button class="icon-subscribe pat-depends"
                          formaction="${context/absolute_url}/cart-subscribe?_authenticator=${token}"
                          title="Subscribe"
                          type="submit"
                          data-pat-depends="condition: items; action: enable;"
                          i18n:attributes="title"
                          i18n:translate=""
                  >Subscribe</button>
                </li>
                <li>
                  <button class="icon-download pat-depends"
                          formaction="${context/absolute_url}/cart-download-confirm?_authenticator=${token}#content"
                          title="Download"
                          type="submit"
                          data-pat-depends="condition: items; action: enable;"
                          i18n:attributes="title"
                          i18n:translate=""
                  >Download</button>
                </li>
                <li>
                  <button class="icon-speedometer pat-depends"
                          formaction="${context/absolute_url}/cart-change-workflow-confirm?_authenticator=${token}#content"
                          title="Change workflow"
                          type="submit"
                          data-pat-depends="condition: items; action: enable;"
                          i18n:attributes="title"
                          i18n:translate=""
                  >Change the workflow state</button>
                </li>
                <li>
                  <button class="icon-pencil pat-depends"
                          formaction="${context/absolute_url}/cart-changemetadata-confirm?_authenticator=${token}#content"
                          title="Change metadata, including names, tags and descriptions."
                          type="submit"
                          data-pat-depends="condition: items; action: enable;"
                          i18n:attributes="title"
                          i18n:translate=""
                  >Change metadata</button>
                </li>
                <li>
                  <button class="icon-tags pat-depends"
                          formaction="${context/absolute_url}/cart-retag-confirm?_authenticator=${token}#content"
                          title="Re-tag"
                          type="submit"
                          data-pat-depends="condition: items; action: enable;"
                          i18n:attributes="title"
                          i18n:translate=""
                  >Re-tag</button>
                </li>
                <li>
                  <button class="icon-rename pat-depends"
                          formaction="${context/absolute_url}/cart-rename-confirm?_authenticator=${token}#content"
                          title="Rename"
                          type="submit"
                          data-pat-depends="condition: items; action: enable;"
                          i18n:attributes="title"
                          i18n:translate=""
                  >Rename</button>
                </li>
                <li>
                  <button class="icon-trash pat-depends"
                          formaction="${context/absolute_url}/cart-delete-confirm?_authenticator=${token}#content"
                          title="Move to trash"
                          type="submit"
                          data-pat-depends="condition: items; action: enable;"
                          i18n:attributes="title"
                          i18n:translate=""
                  >Move to trash</button>
                </li>
              </ul>
            </div>
          </div>
        </div>
        <!-- The introduction is never shown on the top-level, see quaive/ploneintranet.prototype#550 -->
        <div class="introduction folder-intro"
             tal:condition="has_parent"
        >

          <h4 class="folder-title">

            <tal:not_trash condition="not:is_trash">
              <tal:ancestors condition="exists:context/ancestor_folders"
                             repeat="folder context/ancestor_folders"
              >
                <a class="pat-inject"
                   href="${folder/absolute_url}/@@${view_name}#workspace-documents"
                   data-pat-inject="source: #workspace-documents; target: #workspace-documents"
                >${folder/title}</a>
                &gt;
              </tal:ancestors>
              ${parent/grp_title}
            </tal:not_trash>
            <tal:trash condition="is_trash">
              <tal:context_trashed condition="context_trashed">
                <span class="icon-trash">${here/title}</span>
              </tal:context_trashed>
              <tal:context_not_trashed condition="not:context_trashed">
                <tal:i18n i18n:translate="">Trash</tal:i18n>
                <a class="pat-modal pat-button float-after small"
                   href="${absolute_url}/@@empty-trash#document-content"
                   data-pat-modal="class: panel medium;"
                   tal:condition="python:items and can_manage_workspace"
                   i18n:translate=""
                >Empty trash</a>
              </tal:context_not_trashed>
            </tal:trash>
          </h4>
          <p class="folder-description"
             tal:condition="not:is_trash"
          >
            ${parent/grp_description}
          </p>
          <figure class="folder-infographic"
                  tal:condition="here/image|nothing"
          >
            <img src="${context/absolute_url}/@@images/image/large?timestamp=${modified/ISO}"
                 tal:define="
                   modified here/modified;
                 "
            />
            <a class="pat-gallery icon icon-zoom-in"
               href="/media/stappenplan/stappenplan_Probleem.svg"
               tal:condition="here/allow_magnification|XXX|nothing"
               i18n:translate=""
            >
              XXX this needs a behavior to set allow_magnification
              Enlarge
            </a>
          </figure>
        </div>
        <tal:noitems condition="not:items">
          <p class="pat-message notice"
             i18n:translate=""
          >
              No items to display
          </p>
        </tal:noitems>
        <tal:items condition="items">
          <a class="pat-inject infinite-scrolling-trigger"
             href="${here/absolute_url}/@@sidebar.content.${python:'trash' if is_trash else 'documents'}?${python:ztu.make_query(request.form.copy())}"
             data-pat-inject="source: #item-list; target: self::element; trigger: autoload;"
             i18n:translate=""
          >Loading&hellip;</a>
        </tal:items>

        <label class="item group type-trash has-description"
               tal:condition="view/show_trash_item"
        >
          <a class="follow pat-inject"
             href="${here/absolute_url}/@@sidebar.trash"
             data-pat-inject="source: #selector; target: #selector;"
          >
            <strong class="title"
                    i18n:translate=""
            >Trash</strong>
            <dfn class="byline"
                 i18n:translate=""
            >Deleted documents</dfn>
          </a>
        </label>
      </fieldset>
    </form>

    <tal:can_add condition="python:can_add and not is_trash">
      <form class="pat-inject"
            action="${view/bulk_upload_url}"
            enctype="multipart/form-data"
            method="POST"
            data-pat-inject="#items"
      >
        <fieldset class="pat-upload"
                  data-pat-upload="label: ${view/drop_files_label}; trigger: auto; timeout: 1800000"
        >
          <label class="accessibility-options">
            <input multiple="multiple"
                   name="file"
                   type="file"
            />
            <span tal:omit-tag=""
                  i18n:translate=""
            >Upload files</span>
          </label>
        </fieldset>
        <button hidden="hidden"
                type="submit"
                i18n:translate=""
        >Upload</button>
      </form>
    </tal:can_add>

    <div id="selector-create-menu"
         hidden="hidden"
    >
      <ul class="menu">
        <li>
          <a class="icon-document"
             href="#"
             i18n:translate=""
          >Text document</a>
        </li>

        <li tal:condition="view/can_slides">
          <a class="icon-slides"
             i18n:translate=""
          >Slideshow</a>
        </li>

        <li>
          <a class="icon-calendar"
             i18n:translate=""
          >Event</a>
        </li>

        <li>
          <a class="icon-linkdd"
             i18n:translate=""
          >Weblink</a>
        </li>

        <li>
          <a class="icon-upload"
             href="#"
             i18n:translate=""
          >Upload file(s)</a>
        </li>
      </ul>
    </div>
  </div>
</div>
