<form class="search-result pat-navigation"
      id="search-result"
      action="${here/absolute_url}/@@${view/__name__}#search-result"
      tal:define="
        userprofiles nocall:view/userprofiles;
        authenticator here/@@authenticator/authenticator;
        token context/@@authenticator/token;
        allowed_columns view/allowed_columns;
        toLocalizedtime nocall:here/@@plone/toLocalizedTime;
        DateTime nocall:modules/DateTime/DateTime;
      "
      i18n:domain="ploneintranet"
>
  <p class="pat-message notice"
     tal:condition="view/show_lenght_warning"
     i18n:translate=""
  >You reached the search result limit, you may want to filter your search</p>
  <p class="applied-filters pat-inject pat-subform"
     tal:condition="view/show_reset_button"
  >
    <button class="icon-cancel-circle"
            formaction="${here/absolute_url}/@@${view/reset_url}#sidebar-content"
            name="reset-filters"
            type="submit"
            i18n:translate=""
    >Reset search and filters</button>
  </p>
  <tal:groups tal:define="
                seen python:[];
              "
              tal:repeat="beautified_key view/beautified_keys"
  >
    <h3 class="icon-workspace"
        tal:define="
          fieldset_header python:view.get_fieldset_header(beautified_key, seen);
        "
        tal:condition="fieldset_header"
    >${fieldset_header}</h3>
    <fieldset class="${python:'object-list pat-collapsible' if beautified_key.get('title') else ''} tasks ${beautified_key/klass|nothing} pat-checklist"
              id="${beautified_key/cssid|string:milestone-${request/browse-mode|nothing}-${repeat/beautified_key/index}}"
              data-pat-collapsible="${python:'store: local' if beautified_key.get('title') else ''}"
    >
      <h4 class="section-label ${beautified_key/icon|string:icon-workspace} collapsible-open"
          tal:condition="beautified_key/title"
      >
        <tal:title replace="beautified_key/title" />
        <a class="pat-modal iconified icon-info-circle"
           href="/#content"
           data-pat-modal="class: large"
           tal:condition="xxx_todo|nothing"
           i18n:translate=""
        >Info</a>
      </h4>
      <div class="panel-content"
           tal:define="
             tasks python:view.tasks_by_group[beautified_key['key']];
             actions python:view.get_actions_for(beautified_key);
           "
      >
        <label class="label"
               tal:repeat="item tasks"
        >
          <span class="pat-inject pat-autosubmit pat-subform"
                action="${item/absolute_url}"
                data-pat-inject="${view/dpi_on_toggle_task_state}"
          >
            <input checked="${python: 'checked' if is_done else None}"
                   name="task_action"
                   type="checkbox"
                   value="close"
                   tal:define="
                     is_done python:view.is_done(item);
                   "
            />
            <input name="toggle_action_marker"
                   type="hidden"
                   value="1"
            />
            <tal:authenticator replace="structure authenticator" />
          </span>
          <div class="item-info">
            <a class="pat-inject follow pat-switch ${python: view.get_prio_class(item.priority)}"
               href="${item/absolute_url}?${view/todo_link_suffix}#document-body"
               title="${item/title}"
               data-pat-inject="source: #document-body::element; target: #document-body::element; history: none"
               data-pat-switch="selector: #application-body; remove: focus-*; add: focus-document &amp;&amp; selector: #application-body; remove: sidebar-large; add: sidebar-normal"
            >${item/title}</a>
            <div class="additional-meta-data">
              <tal:assignee condition="python: 'assignee' in allowed_columns">
                <a class="assignee meta-column icon-user pat-modal"
                   href="${here/portal_url}/profiles/${item/assignee}/@@userprofile-info"
                   title="Assignee"
                   data-pat-inject="source: .contact-info::element"
                   tal:condition="item/assignee"
                   i18n:attributes="title;"
                >${python:userprofiles.get_fullname_for(item.assignee)}</a>
                <span class="meta-column assignee"
                      tal:condition="not:item/assignee"
                >
                &nbsp;
                </span>
              </tal:assignee>
              <tal:due condition="python: 'due' in allowed_columns">
                <time class="due-date meta-column icon-clock pat-display-time"
                      datetime="${item/due}"
                      title="${python: toLocalizedtime(DateTime(*item.due.timetuple()[:3]))}"
                      data-pat-display-time="from-now: true; locale: ${context/plone_portal_state/language}"
                      tal:condition="item/due"
                >${item/due}</time>
                <span class="meta-column"
                      tal:condition="not:item/due"
                >
                &nbsp;
                </span>
              </tal:due>
              <tal:milestone condition="python: 'milestone' in allowed_columns">
                <span class="milestone meta-column icon-${item/milestone|nothing}"
                      title="Milestone"
                      tal:condition="item/milestone"
                      i18n:attributes="title;"
                >${python: view.get_item_milestone_hr(item)}</span>
                <span class="meta-column"
                      tal:condition="not:item/milestone"
                >
                &nbsp;
                </span>
              </tal:milestone>
              <tal:initiator condition="python: 'initiator' in allowed_columns">
                <a class="initiator meta-column icon-manager pat-modal"
                   href="${here/portal_url}/profiles/${item/initiator}/@@userprofile-info"
                   title="Initiator of this task"
                   data-pat-inject="source: .contact-info::element"
                   tal:condition="item/initiator"
                   i18n:attributes="title;"
                >${python:userprofiles.get_fullname_for(item.initiator)}</a>
                <span class="meta-column"
                      tal:condition="not:item/initiator"
                >
                &nbsp;
                </span>
              </tal:initiator>
            </div>
          </div>
        </label>
        <p class="pat-button-bar"
           tal:condition="actions"
        >
          <tal:actions repeat="action actions">
            <a class="${action/cssclass|nothing}"
               href="${action/url}"
               title="${action/label}"
               data-pat-inject="${action/dpi|nothing}"
               data-pat-modal="${action/dpm|nothing}"
            >${action/label}</a>
          </tal:actions>
        </p>
      </div>
    </fieldset>
  </tal:groups>
  <tal:noresults>
    <p class="pat-message notice"
       tal:condition="view/show_no_results"
       i18n:translate=""
    >No results found</p>
  </tal:noresults>
</form>
