<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      lang="en"
      metal:use-macro="context/main_template/macros/master"
      i18n:domain="xmldirector.plonecore">
<body>

    <metal:slot fill-slot="style_slot">
        <link rel="stylesheet" type="text/css" tal:attributes="href string:$portal_url/++resource++xmldirector.plonecore/DataTables/media/css/jquery.dataTables.css" />
        <link rel="stylesheet" type="text/css" tal:attributes="href string:$portal_url/++resource++xmldirector.plonecore/DataTables/extensions/FixedHeader/css/fixedHeader.dataTables.min.css" />
    </metal:slot>

    <metal:slot fill-slot="javascript_head_slot">
        <script type="text/javascript" charset="utf8" tal:attributes="src string:$portal_url/++resource++xmldirector.plonecore/DataTables/media/js/jquery.dataTables.js"></script>
        <script type="text/javascript" charset="utf8" tal:attributes="src string:$portal_url/++resource++xmldirector.plonecore/DataTables/extensions/FixedHeader/js/dataTables.fixedHeader.min.js"></script>
    </metal:slot>

<metal:main fill-slot="content-core">
  <metal:content-core define-macro="content-core">

      <div id="connection-url">
          <label i18n:translate="">Connected to:</label>
          <span tal:content="context/connector_url" />
      </div>

      <form tal:attributes="action string:${context/absolute_url}/collection-action" method="POST">
          <table class="datatable">
              <thead>
                  <tr>
                      <th i18n:translate="">Name</th>
                      <th i18n:translate="">Type</th>
                      <th i18n:translate="">Size</th>
                      <th i18n:translate="">Last modified</th>
                      <th i18n:translate="">Permissions</th>
                      <th i18n:translate="">Action</th>
                  </tr>
              </thead>
              <tbody>
                  <tr>
                      <td>                                     
                          <a class="dir" 
                             title="One level up"
                             i18n:attributes="title"
                             tal:attributes="href python: '{}/@@view/{}'.format(context.absolute_url(), '/'.join(view.subpath[:-1]))">..</a>
                      </td>
                      <td>
                          <span i18n:translate="">COLLECTION</span>
                      </td>
                      <td data-order="0"/>
                      <td data-order="0"/>
                      <td />
                      <td />
                  </tr>
                  <tr tal:repeat="item options/dirs">
                      <td>
                          <input type="checkbox" name="paths:list" tal:attributes="value item/fullpath" />
                          <a class="dir" tal:attributes="href item/url"><span tal:replace="item/title" /></a>
                      </td>
                      <td>
                          <span i18n:translate="">COLLECTION</span>
                      </td>
                      <td data-order="0"></td>
                      <td tal:attributes="data-order python: item['modified_original'].isoformat()" tal:on-error="nothing">
                          <span tal:replace="item/modified" />
                      </td>
                      <td>
                          <span tal:replace="item/st_mode_text" />
                      </td>
                      <td>
                          <a class="confirm-action" 
                             data-text="Do you really want to remove this collection?"
                             i18n:attributes="data-text"
                              tal:attributes="href string:${context/absolute_url}/@@remove-collection?subpath=${options/subpath}&name=${item/title}"
                             i18n:translate="">
                             <img src="++resource++xmldirector.plonecore/images/remove.png" title="Remove collection" i18n:attributes="title"/>
                         </a>
                      </td>
                  </tr>
                  <tr tal:repeat="item options/files">
                      <td>
                          <input type="checkbox" name="paths:list" tal:attributes="value item/fullpath" />
                          <a class="file" tal:attributes="href item/url"><span tal:replace="item/title" /></a>
                      </td>
                      <td>
                          <span i18n:translate="">FILE</span>
                      </td>
                      <td tal:attributes="data-sort item/size_original">
                          <span tal:replace="item/size" />
                      </td>
                      <td tal:attributes="data-order python: item['modified_original'].isoformat()" tal:on-error="nothing">
                          <span tal:replace="item/modified" />
                      </td>
                      <td>
                          <span tal:replace="item/st_mode_text" />
                      </td>
                      <td>
                          <a tal:attributes="href item/remove_url"
                             class="confirm-action" 
                             data-text="Do you really want to remove this item?"
                             i18n:attributes="data-text"
                             i18n:translate=""
                             title="Remove"
                             ><img src="++resource++xmldirector.plonecore/images/remove.png" title="Remove item" i18n:attributes="title"/> </a>
                          <a tal:condition="item/editable"
                             tal:attributes="href item/edit_url"
                             i18n:attributes="title"
                             title="Edit"
                              ><img src="++resource++xmldirector.plonecore/images/edit.png" /></a>
                      </td>
                  </tr>
              </tbody>
              <tfoot>
                  <tr>
                      <th class="searchable"></th>
                      <th class="searchable"></th>
                      <th></th>
                      <th></th>
                      <th></th>
                      <th></th>
                  </tr>
              </tfoot>
          </table>

          <button class="button" type="submit" name="action" action="delete" value="delete">Delete</button>
      </form>

      <div class="actions">
          <ul>
              <li>
                  <a class="action" 
                     href="javascript: void()"
                     id="action-create-collection">
                      New collection
                  </a>
              </li>
              <li>
                  <a class="action" 
                     href="javascript: void()"
                     i18n:translate=""
                     tal:condition="options/dirs"
                     id="action-rename-collection">
                      Rename collection
                  </a>
              </li>
              <li>
                  <a id="connector-zip-import" class="action" tal:attributes="href string:${context/absolute_url}/connector-zip-import?subpath=${options/subpath}" i18n:translate="">ZIP import</a>
              </li>
              <li>
                  <a id="connector-zip-export" class="action" tal:attributes="href string:${context/absolute_url}/connector-zip-export?subpath=${options/subpath}" i18n:translate="">ZIP export</a>
              </li>
              <li>
                  <a id="connector-reindex" class="action" tal:attributes="href string:${context/absolute_url}/connector-reindex" i18n:translate="">Reindex</a>
              </li>
              <li>
                  <a id="connector-log" class="action" tal:attributes="href string:${context/absolute_url}/connector-log" i18n:translate="">Log</a>
              </li>
              <li>
                  <a id="connector-log-clear" class="action" tal:attributes="href string:${context/absolute_url}/connector-log-clear" i18n:translate="">Clear log</a>
              </li>
          </ul>
          <form tal:attributes="action string:${context/absolute_url}/create-collection" method="post" id="create-collection-form" style="display: none">
              <label for="name" i18n:translate="">Create collection</label>
              <input type="text" name="name" size="20" />
              <input name="subpath" type="hidden" tal:attributes="value options/subpath" />
              <input type="submit" i18n:attributes="value" value="Create" />
          </form>
          <form tal:attributes="action string:${context/absolute_url}/rename-collection" method="post" id="rename-collection-form" style="display: none">
              <label for="name" i18n:translate="">Rename collection</label>
              <select name="name">
                  <option tal:repeat="item options/dirs" 
                      tal:attributes="value item/title"
                      tal:content="item/title" />
              </select>
              <input name="subpath" type="hidden" tal:attributes="value options/subpath" />
              <label for="new_name" i18n:translate="">to</label>
              <input type="text" name="new_name" size="20" />
              <input type="submit" i18n:attributes="value" value="Rename" />
          </form>
      </div>

      <script type="text/javascript">
          DATATABLES_ORDER = [1, "asc"];

          $(document).ready(function() {
            $('#action-create-collection').click(function() {
                $('.actions form').hide();
                $('#create-collection-form').toggle();
            });
            $('#action-remove-collection').click(function() {
                $('.actions form').hide();
                $('#remove-collection-form').toggle();
            });
            $('#action-rename-collection').click(function() {
                $('.actions form').hide();
                $('#rename-collection-form').toggle();
            });
          });
      </script>

  </metal:content-core>
</metal:main>

</body>
</html>

