[gen] Searches can now be grouped into groups of groups of..., creating a tree structure in the portlet.

This commit is contained in:
Gaetan Delannay 2012-11-14 11:36:48 +01:00
parent 6cf29778b6
commit 4872e5d8b8
6 changed files with 92 additions and 78 deletions

View file

@ -80,7 +80,7 @@ img { border: 0; vertical-align: middle}
.portletPage { font-style: italic; }
.portletGroup { font-variant: small-caps; font-weight: bold; font-style: normal;
margin-top: 0.1em }
.portletSearch { font-size: 90%; font-style: italic; padding-left: 1em}
.portletSearch { font-size: 90%; font-style: italic }
.phase { border-style: dashed; border-width: thin; padding: 4px 0.6em 5px 1em;}
.phaseSelected { background-color: #F4F5F6; }
.content { padding: 14px 14px 9px 15px; background-color: #f1f1f1 }

View file

@ -1,9 +1,51 @@
<tal:comment replace="nothing">
This macro displays the content of the application portlet.
</tal:comment>
<tal:comment replace="nothing">Macro for displaying a search</tal:comment>
<div metal:define-macro="search" class="portletSearch">
<a tal:attributes="href python: '%s?className=%s&search=%s' % (queryUrl, rootClass, search['name']);
title search/descr;
class python: test(search['name'] == currentSearch, 'portletCurrent', '');"
tal:content="structure search/label"></a>
</div>
<tal:comment replace="nothing">Macro for displaying a group of searches</tal:comment>
<metal:group define-macro="group"
tal:define="expanded python: request.get(widget['labelId'], 'collapsed') == 'expanded'">
<tal:comment replace="nothing">Group name</tal:comment>
<div class="portletGroup">
<img style="cursor:pointer; margin-right: 3px"
tal:attributes="id python: '%s_img' % widget['labelId'];
src python:test(expanded, 'ui/collapse.gif', 'ui/expand.gif');
onClick python:'toggleCookie(\'%s\')' % widget['labelId'];
align dleft"/>
<span tal:replace="python: _(widget['labelId'])"/>
</div>
<tal:comment replace="nothing">Group content</tal:comment>
<div tal:define="display python:test(expanded, 'display:block', 'display:none')"
tal:attributes="id widget/labelId;
style python: 'padding-left: 10px;; %s' % display">
<tal:searchRows repeat="searches widget/widgets">
<tal:searchElem repeat="searchElem searches">
<tal:comment replace="nothing">An inner group within this group</tal:comment>
<tal:group condition="python: searchElem['type'] == 'group'">
<tal:g define="widget searchElem">
<metal:s use-macro="app/ui/portlet/macros/group"/>
</tal:g>
</tal:group>
<tal:search condition="python: searchElem['type'] != 'group'">
<tal:s define="search searchElem">
<metal:s use-macro="app/ui/portlet/macros/search"/>
</tal:s>
</tal:search>
</tal:searchElem>
</tal:searchRows>
</div>
</metal:group>
<tal:comment replace="nothing">Macro displaying the whole portlet</tal:comment>
<metal:portlet define-macro="portlet"
tal:define="queryUrl python: '%s/ui/query' % tool.absolute_url();
toolUrl tool/absolute_url;
app tool/getApp;
appUrl app/absolute_url;
currentSearch req/search|nothing;
currentClass req/className|nothing;
contextObj tool/getPublishedObject;
@ -16,7 +58,7 @@
<img tal:attributes="src string: $appUrl/ui/gotoSource.png"/>
</a>
</div>
<metal:phases use-macro="here/ui/portlet/macros/phases"/>
<metal:phases use-macro="app/ui/portlet/macros/phases"/>
</div>
<tal:comment replace="nothing">One section for every searchable root class.</tal:comment>
@ -26,7 +68,7 @@
<div class="portletSep" tal:define="nb repeat/rootClass/number"
tal:condition="python: (nb == 1 and contextObj) or (nb != 1)"></div>
<div class="portletContent" tal:define="searchInfo python: tool.getSearches(rootClass)">
<div class="portletContent" tal:define="searchInfo python: tool.getGroupedSearches(rootClass)">
<tal:comment replace="nothing">Section title (link triggers the default search), with action icons</tal:comment>
<a tal:define="queryParam python: searchInfo['default'] and ('&search=%s' % searchInfo['default']['name']) or ''"
tal:attributes="href python: '%s?className=%s%s' % (queryUrl, rootClass, queryParam);
@ -56,40 +98,17 @@
<img tal:attributes="src string: $appUrl/ui/search.gif"/>
</a>
</span>
<tal:comment replace="nothing">Searches for this content type.</tal:comment>
<tal:searchOrGroup repeat="searchOrGroup searchInfo/searches">
<tal:group condition="searchOrGroup/isGroup">
<tal:expanded define="group searchOrGroup;
expanded python: request.get(group['labelId'], 'collapsed') == 'expanded'">
<tal:comment replace="nothing">Group name</tal:comment>
<div class="portletGroup">
<img style="cursor:pointer; margin-right: 3px"
tal:attributes="id python: '%s_img' % group['labelId'];
src python:test(expanded, 'ui/collapse.gif', 'ui/expand.gif');
onClick python:'toggleCookie(\'%s\')' % group['labelId'];
align dleft"/>
<span tal:replace="group/label"/>
</div>
<tal:comment replace="nothing">Group searches</tal:comment>
<div tal:attributes="id group/labelId;
style python:test(expanded, 'display:block', 'display:none')">
<div class="portletSearch" tal:repeat="search group/searches">
<a tal:attributes="href python: '%s?className=%s&search=%s' % (queryUrl, rootClass, search['name']);
title search/descr;
class python: test(search['name'] == currentSearch, 'portletCurrent', '');"
tal:content="structure search/label"></a>
</div>
</div>
</tal:expanded>
</tal:group>
<dt tal:define="search searchOrGroup" tal:condition="not: searchOrGroup/isGroup"
class="portletAppyItem portletSearch">
<a tal:attributes="href python: '%s?className=%s&search=%s' % (queryUrl, rootClass, search['name']);
title search/descr;
class python: test(search['name'] == currentSearch, 'portletCurrent', '');"
tal:content="structure search/label"></a>
</dt>
</tal:searchOrGroup>
<tal:comment replace="nothing">Searches for this content type</tal:comment>
<tal:widget repeat="widget searchInfo/searches">
<tal:group condition="python: widget['type'] == 'group'">
<metal:s use-macro="app/ui/portlet/macros/group"/>
</tal:group>
<tal:search condition="python: widget['type'] != 'group'">
<tal:s define="search widget">
<metal:s use-macro="app/ui/portlet/macros/search"/>
</tal:s>
</tal:search>
</tal:widget>
</div>
</tal:section>
</metal:portlet>