<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      metal:use-macro="here/main_template/macros/master"
      i18n:domain="senaite.core">
  <body>

    <metal:content-title fill-slot="content-title">
      <h1>
        <img tal:condition="view/icon|nothing" tal:attributes="src view/icon"/>
        <span class="documentFirstHeading" tal:content="view/title|nothing"/>
      </h1>
    </metal:content-title>

    <metal:content-description fill-slot="content-description">
      <div class="text-muted"
           tal:content="view/description|nothing"/>
    </metal:content-description>

    <metal:content-core fill-slot="content-core">
      <div class="row">
        <div class="col-sm-12">
          <!-- WS Template Select Form -->
          <form id="applytemplate_form"
                class="form form-inline"
                method="POST">
            <input type="hidden" name="submitted" value="1"/>
            <input tal:replace="structure context/@@authenticator/authenticator"/>

            <div class="input-group input-group-sm flex-nowrap d-inline-flex w-auto">
              <div class="input-group-prepend">
                <span class="input-group-text" i18n:translate="">
                  Select template
                </span>
                <!-- Template selector -->
                <select id="ProfileSelector"
                        name="getWorksheetTemplate"
                        class="selectpicker"
                        data-style="dropdown-toggle btn-sm btn-light border rounded-0"
                        data-live-search="true"
                        tal:define="ws_templates_list view/getWorksheetTemplates">
                  <option value=""></option>
                  <tal:profile repeat="profile ws_templates_list">
                    <option tal:attributes="value python:profile;
                                            selected python: view.request.get('WorksheetTemplate', '') == profile[0] and 'selected' or ''"
                            tal:content="python:ws_templates_list.getValue(profile)"/>
                  </tal:profile>
                </select>
              </div>
              <div class="input-group input-group-append">
                <input type="submit"
                       class="btn btn-sm btn-primary"
                       value="Apply template"
                       i18n:attributes="value"/>
              </div>
            </div>

            <!-- Link to Worksheet Templates -->
            <div class="ml-4 form-text text-muted" tal:condition="view/is_manage_allowed">
              <a href=""
                 class="text-muted"
                 tal:attributes="href view/worksheet_template_setup_url"
                 i18n:translate="">
                <i class="fas fa-link" aria-hidden="true"/>
                Go to worksheet template setup
              </a>
            </div>
          </form>
          <!-- /WS Template Select Form -->

        </div>
      </div>

      <div class="row">
        <div class="col-sm-12">
          <!-- Listing Table -->
          <div tal:replace="structure view/contents_table"/>
          <!-- /Listing Table -->
        </div>
      </div>

    </metal:content-core>

  </body>
</html>
