[gen] For Strings with validator=String.URL, an HTML link is rendered in view layouts; added a 'real' 'state' field to any Appy class, allowing to use it in search screens for example; added 2 hook methods: getIcons and getSubTitles, allowing to add, in lists of objects (Refs or queries), icons besides the title and anything below it; optimized query.pt: for every new query, 1 server request is done (previously, one standard request + one ajax request were done); removed columns 'actions' (Refs, query): action icons are not included in the column containing the title (we avoid having empty columns whhen no action is available).

This commit is contained in:
Gaetan Delannay 2012-10-31 21:17:31 +01:00
parent 7240561f7f
commit 4a69a3beb2
20 changed files with 142 additions and 131 deletions

View file

@ -8,6 +8,7 @@
allows to reach the correct page where the forward reference is defined. If we are
on a forward reference, the "nav" parameter is added to the URL for allowing to navigate
from one object to the next/previous on ui/view.</tal:comment>
<tal:icons replace="structure obj/getIcons"/>
<a tal:define="includeShownInfo includeShownInfo | python:False;
navInfo python:'ref.%s.%s:%s.%d.%d' % (contextObj.UID(), fieldName, appyType['pageName'], repeat['obj'].number()+startNumber, totalNumber);
navInfo python: test(appyType['isBack'], '', navInfo);
@ -22,24 +23,6 @@
<table class="noStyle"
tal:define="isBack appyType/isBack">
<tr>
<tal:comment replace="nothing">Arrows for moving objects up or down</tal:comment>
<td tal:condition="python: not isBack and (len(objs)&gt;1) and changeOrder and canWrite">
<tal:moveRef define="objectIndex python: contextObj.getAppyRefIndex(fieldName, obj);
ajaxBaseCall python: navBaseCall.replace('**v**', '\'%s\',\'ChangeRefOrder\', {\'refObjectUid\':\'%s\', \'move\':\'**v**\'}' % (startNumber, obj.UID()))">
<tal:comment replace="nothing">Move up</tal:comment>
<img tal:condition="python: objectIndex &gt; 0"
tal:attributes="src string: $appUrl/ui/arrowUp.png;
title python: _('move_up');
onClick python: ajaxBaseCall.replace('**v**', 'up')"
style="cursor:pointer"/>
<tal:comment replace="nothing">Move down</tal:comment>
<img tal:condition="python: objectIndex &lt; (totalNumber-1)"
tal:attributes="src string: $appUrl/ui/arrowDown.png;
title python: _('move_down');
onClick python: ajaxBaseCall.replace('**v**', 'down')"
style="cursor:pointer"/>
</tal:moveRef>
</td>
<tal:comment replace="nothing">Edit</tal:comment>
<td tal:condition="python: not appyType['noForm'] and obj.mayEdit() and appyType['delete']">
<a tal:define="navInfo python:'ref.%s.%s:%s.%d.%d' % (contextObj.UID(), fieldName, appyType['pageName'], repeat['obj'].number()+startNumber, totalNumber);"
@ -62,6 +45,20 @@
onClick python:'onUnlinkObject(\'%s\',\'%s\',\'%s\')' % (contextObj.UID(), appyType['name'], obj.UID());
title python: _('object_unlink')"/>
</td>
<tal:comment replace="nothing">Arrows for moving objects up or down</tal:comment>
<td tal:condition="python: not isBack and (len(objs)&gt;1) and changeOrder and canWrite">
<tal:moveRef define="objectIndex python: contextObj.getAppyRefIndex(fieldName, obj);
ajaxBaseCall python: navBaseCall.replace('**v**', '\'%s\',\'ChangeRefOrder\', {\'refObjectUid\':\'%s\', \'move\':\'**v**\'}' % (startNumber, obj.UID()))">
<img tal:condition="python: objectIndex &gt; 0" style="cursor:pointer"
tal:attributes="src string: $appUrl/ui/arrowUp.png;
title python: _('move_up');
onClick python: ajaxBaseCall.replace('**v**', 'up')"/><img style="cursor:pointer"
tal:condition="python: objectIndex &lt; (totalNumber-1)"
tal:attributes="src string: $appUrl/ui/arrowDown.png;
title python: _('move_down');
onClick python: ajaxBaseCall.replace('**v**', 'down')"/>
</tal:moveRef>
</td>
</tr>
</table>
</metal:objectActions>
@ -125,7 +122,8 @@
atMostOneRef python: (appyType['multiplicity'][1] == 1) and (len(objs)&lt;=1);
addConfirmMsg python: appyType['addConfirm'] and _('%s_addConfirm' % appyType['labelId']) or '';
navBaseCall python: 'askRefField(\'%s\',\'%s\',\'%s\',\'%s\',**v**)' % (ajaxHookId, contextObj.absolute_url(), fieldName, innerRef);
changeOrder python: contextObj.callField(fieldName, 'changeOrderEnabled', contextObj)"
changeOrder python: contextObj.callField(fieldName, 'changeOrderEnabled', contextObj);
showSubTitles python: request.get('showSubTitles', 'true') == 'true'"
tal:attributes="id ajaxHookId">
<tal:comment replace="nothing">This macro displays the Reference widget on a "view" page.
@ -181,21 +179,25 @@
<th tal:repeat="widget widgets">
<span tal:content="python: _(widget['labelId'])"></span>
<metal:sortIcons use-macro="app/ui/widgets/ref/macros/sortIcons" />
<tal:sd define="className linkedPortalType">
<metal:details use-macro="context/ui/navigate/macros/showDetails"/>
</tal:sd>
</th>
<th tal:content="python: _('ref_actions')"></th>
</tr>
<tal:row repeat="obj objs">
<tr valign="middle" tal:define="odd repeat/obj/odd"
<tr valign="top" tal:define="odd repeat/obj/odd"
tal:attributes="class python:test(odd, 'even', 'odd')">
<td tal:repeat="widget widgets"
tal:attributes="width python: appyType['shownInfoWidths'][repeat['widget'].index]">
<tal:title condition="python: widget['name'] == 'title'">
<metal:showObjectTitle use-macro="app/ui/widgets/ref/macros/objectTitle"/>
<div name="subTitle" tal:content="structure obj/getSubTitle"
tal:attributes="style python: showSubTitles and 'display:block' or 'display:none'"></div>
<div tal:attributes="align dright" tal:condition="obj/mayAct">
<metal:showObjectActions use-macro="app/ui/widgets/ref/macros/objectActions" />
</div>
</tal:title>
<tal:state condition="python: widget['name'] == 'state'"
content="python: _(obj.getWorkflowLabel())">
</tal:state>
<tal:other condition="python: widget['name'] not in ('title', 'state')">
<tal:other condition="python: widget['name'] != 'title'">
<tal:field define="contextObj python:obj;
layoutType python: 'cell';
innerRef python:True">
@ -203,12 +205,6 @@
</tal:field>
</tal:other>
</td>
<tal:comment replace="nothing">Actions</tal:comment>
<td tal:attributes="align dright">
<tal:show condition="obj/mayAct">
<metal:showObjectActions use-macro="app/ui/widgets/ref/macros/objectActions" />
</tal:show>
</td>
</tr>
</tal:row>
</tal:widgets>

View file

@ -1,13 +1,19 @@
<tal:comment replace="nothing">View macro for a String.</tal:comment>
<metal:view define-macro="view"
tal:define="fmt widget/format">
tal:define="fmt widget/format; isUrl widget/isUrl">
<span tal:condition="python: fmt in (0, 3)">
<ul tal:condition="python: value and isMultiple">
<li tal:repeat="sv value"><i tal:content="structure sv"></i></li>
</ul>
<tal:singleValue condition="python: value and not isMultiple">
<span tal:condition="python: fmt != 3" tal:replace="structure value"/>
<tal:comment replace="nothing">A password</tal:comment>
<span tal:condition="python: fmt == 3">********</span>
<tal:comment replace="nothing">A URL</tal:comment>
<a tal:condition="python: (fmt != 3) and isUrl" target="_blank"
tal:attributes="href value" tal:content="value"></a>
<tal:comment replace="nothing">Any other value</tal:comment>
<span tal:condition="python: (fmt != 3) and not isUrl"
tal:replace="structure value"/>
</tal:singleValue>
</span>
<tal:comment replace="nothing">Text</tal:comment>