[gen] appyclass.getIcons now receives the nav param, in case one wants to reproduce, on an icon or a picture, the link to the element. For example, on a artist's site that presents its artworks, getIcons can be used to create a clickable link to a small version of the artwork, that leads to the full-size picture. Bugfix in result.pt (numbering of elements in the grid view).

This commit is contained in:
Gaetan Delannay 2013-03-10 08:29:53 +01:00
parent c5ec54f0e5
commit da4f502ddc
2 changed files with 19 additions and 14 deletions

View file

@ -915,10 +915,10 @@ class BaseMixin:
return None return None
return res return res
def getIcons(self): def getIcons(self, navInfo=''):
'''Gets the icons that can be shown besides the title of an object.''' '''Gets the icons that can be shown besides the title of an object.'''
appyObj = self.appy() appyObj = self.appy()
if hasattr(appyObj, 'getIcons'): return appyObj.getIcons() if hasattr(appyObj, 'getIcons'): return appyObj.getIcons(navInfo)
return '' return ''
def getSubTitle(self): def getSubTitle(self):

View file

@ -2,12 +2,11 @@
<metal:field define-macro="field"> <metal:field define-macro="field">
<tal:comment replace="nothing">Title</tal:comment> <tal:comment replace="nothing">Title</tal:comment>
<tal:title condition="python: widget['name'] == 'title'"> <tal:title condition="python: widget['name'] == 'title'">
<tal:icons replace="structure obj/getIcons"/> <tal:nav define="navInfo python:'search.%s.%s.%d.%d' % (className, searchName, startNumber+currentNumber, totalNumber)">
<a tal:define="navInfo python:'search.%s.%s.%d.%d' % (className, searchName, repeat['obj'].number()+startNumber, totalNumber);" <tal:icons replace="structure python: obj.getIcons(navInfo)"/>
tal:content="obj/Title" tal:attributes="href python: obj.getUrl(nav=navInfo, page=obj.getDefaultViewPage())"></a> <a tal:content="obj/Title" tal:attributes="href python: obj.getUrl(nav=navInfo, page=obj.getDefaultViewPage())"></a>
<div name="subTitle" tal:content="structure obj/getSubTitle" <div name="subTitle" tal:content="structure obj/getSubTitle"
tal:attributes="style python: showSubTitles and 'display:block' or 'display:none'"></div> tal:attributes="style python: showSubTitles and 'display:block' or 'display:none'"></div>
<tal:comment replace="nothing">Actions: edit, delete</tal:comment> <tal:comment replace="nothing">Actions: edit, delete</tal:comment>
<div tal:attributes="align dright" tal:condition="obj/mayAct"> <div tal:attributes="align dright" tal:condition="obj/mayAct">
<a tal:define="navInfo python:'search.%s.%s.%d.%d' % (className, searchName, repeat['obj'].number()+startNumber, totalNumber);" <a tal:define="navInfo python:'search.%s.%s.%d.%d' % (className, searchName, repeat['obj'].number()+startNumber, totalNumber);"
@ -20,6 +19,7 @@
title python: _('object_delete'); title python: _('object_delete');
onClick python:'onDeleteObject(\'%s\')' % obj.UID()"/> onClick python:'onDeleteObject(\'%s\')' % obj.UID()"/>
</div> </div>
</tal:nav>
</tal:title> </tal:title>
<tal:comment replace="nothing">Any other field</tal:comment> <tal:comment replace="nothing">Any other field</tal:comment>
<tal:other condition="python: widget['name'] != 'title'"> <tal:other condition="python: widget['name'] != 'title'">
@ -50,7 +50,9 @@
<tal:comment replace="nothing">Results</tal:comment> <tal:comment replace="nothing">Results</tal:comment>
<tal:row repeat="obj objs"> <tal:row repeat="obj objs">
<tr id="query_row" valign="top" tal:define="odd repeat/obj/odd" <tr id="query_row" valign="top"
tal:define="odd repeat/obj/odd;
global currentNumber python: currentNumber + 1"
tal:attributes="class python:test(odd, 'even', 'odd')"> tal:attributes="class python:test(odd, 'even', 'odd')">
<tal:fields repeat="column columns"> <tal:fields repeat="column columns">
@ -71,12 +73,14 @@
rows python: tool.splitList(objs, cols)"> rows python: tool.splitList(objs, cols)">
<tr tal:repeat="row rows" valign="middle"> <tr tal:repeat="row rows" valign="middle">
<td tal:repeat="obj row" tal:attributes="width python: '%d%%'%(100/cols)" <td tal:repeat="obj row" tal:attributes="width python: '%d%%'%(100/cols)"
align="center" style="padding-top: 8px"> align="center" style="padding-top: 25px">
<tal:def define="global currentNumber python: currentNumber + 1">
<tal:col repeat="column columns"> <tal:col repeat="column columns">
<tal:field define="widget column/field"> <tal:field define="widget column/field">
<metal:f use-macro="context/ui/result/macros/field"/> <metal:f use-macro="context/ui/result/macros/field"/>
</tal:field> </tal:field>
</tal:col> </tal:col>
</tal:def>
</td> </td>
</tr> </tr>
</table> </table>
@ -144,7 +148,8 @@
<tal:comment replace="nothing">Results, as a list or grid</tal:comment> <tal:comment replace="nothing">Results, as a list or grid</tal:comment>
<tal:res define="columnLayouts python: tool.getResultColumnsLayouts(className, refInfo); <tal:res define="columnLayouts python: tool.getResultColumnsLayouts(className, refInfo);
columns python: objs[0].getColumnsSpecifiers(columnLayouts, dir)"> columns python: objs[0].getColumnsSpecifiers(columnLayouts, dir);
global currentNumber python: 0">
<tal:asList condition="python: resultMode == 'list'"> <tal:asList condition="python: resultMode == 'list'">
<metal:list use-macro="context/ui/result/macros/list"/> <metal:list use-macro="context/ui/result/macros/list"/>
</tal:asList> </tal:asList>