<tal:main define="tool python: context.config">
<html metal:use-macro="context/ui/template/macros/main">
 <metal:fill fill-slot="content"
   tal:define="className request/className;
               refInfo request/ref|nothing;
               searchInfo python: tool.getSearchInfo(className, refInfo);
               cssJs python: {};
               dummy python: tool.getCssJs(searchInfo['fields'], 'edit', cssJs)">

  <tal:comment replace="nothing">Include type-specific CSS and JS.</tal:comment>
  <link tal:repeat="cssFile cssJs/css" rel="stylesheet" type="text/css"
        tal:attributes="href string:$appUrl/ui/$cssFile"/>
  <script tal:repeat="jsFile cssJs/js" type="text/javascript"
          tal:attributes="src string:$appUrl/ui/$jsFile"></script>

  <tal:comment replace="nothing">Search title</tal:comment>  
  <h1><span tal:replace="python: _('%s_plural' % className)"/> —
      <span tal:replace="python: _('search_title')"/></h1><br/>

  <tal:comment replace="nothing">Form for searching objects of request/className.</tal:comment>
  <form name="search" tal:attributes="action python: tool.absolute_url()+'/do'" method="post">
    <input type="hidden" name="action" value="SearchObjects"/>
    <input type="hidden" name="className" tal:attributes="value className"/>
    <input tal:condition="refInfo" type="hidden" name="ref" tal:attributes="value refInfo"/>

    <table width="100%">
      <tr tal:repeat="searchRow python: tool.getGroupedSearchFields(searchInfo)"
          valign="top">
        <tal:widgets repeat="widget searchRow">
         <td tal:define="scolspan widget/scolspan|python: 1"
             tal:attributes="width python:'%d%%' % ((100/searchInfo['nbOfColumns'])*scolspan);
                             colspan scolspan">
           <tal:field condition="widget">
            <tal:show define="name widget/name;
                                   widgetName python: 'w_%s' % name;
                                   macroPage python: widget['type'].lower()">
              <metal:call use-macro="python: getattr(appFolder.ui.widgets, macroPage).macros['search']"/>
            </tal:show>
          </tal:field><br class="discreet"/>
         </td>
        </tal:widgets>
      </tr>
    </table>

  <tal:comment replace="nothing">Submit button</tal:comment>
  <p tal:attributes="align dright"><br/>
    <input type="submit" tal:attributes="value python: _('search_button')"/>
  </p>
  </form>
 </metal:fill>
</html>
</tal:main>