Worflow state can not be used in ref fields; mayNavigate is not static anymore, but an instance method.

This commit is contained in:
Gaetan Delannay 2010-12-06 11:11:40 +01:00
parent e62e00d367
commit 2124cffa5e
14 changed files with 187 additions and 161 deletions

View file

@ -1,6 +1,9 @@
<metal:queryResults define-macro="queryResult"
tal:define="tool python: contextObj;
contentType request/type_name;
refInfo tool/getRefInfo;
refField python: refInfo[1];
refInfo python: refInfo[0];
startNumber request/startNumber|python:'0';
startNumber python: int(startNumber);
searchName request/search;
@ -11,13 +14,13 @@
sortOrder request/sortOrder| python:'asc';
filterKey request/filterKey| python:'';
filterValue request/filterValue | python:'';
queryResult python: tool.executeQuery(contentType, searchName, startNumber, remember=True, sortBy=sortKey, sortOrder=sortOrder, filterKey=filterKey, filterValue=filterValue);
queryResult python: tool.executeQuery(contentType, searchName, startNumber, remember=True, sortBy=sortKey, sortOrder=sortOrder, filterKey=filterKey, filterValue=filterValue, refField=refField);
objs queryResult/objects;
totalNumber queryResult/totalNumber;
batchSize queryResult/batchSize;
ajaxHookId python:'queryResult';
navBaseCall python: 'askQueryResult(\'%s\',\'%s\',\'%s\',\'%s\',**v**)' % (ajaxHookId, tool.absolute_url(), contentType, searchName);
newSearchUrl python: '%s/skyn/search?type_name=%s&' % (tool.getAppFolder().absolute_url(), contentType);">
newSearchUrl python: '%s/skyn/search?type_name=%s&ref=%s' % (tool.getAppFolder().absolute_url(), contentType, refInfo);">
<tal:result condition="objs">
@ -42,44 +45,23 @@
</td>
</tr></table>
<table tal:define="fieldDescrs python: tool.getResultColumns(objs[0], contentType)"
class="listing nosort" width="100%" cellpadding="0" cellspacing="0">
<tal:comment replace="nothing">Every item in fieldDescrs is an Appy type (dict version),
excepted for workflow state (which is not a field): in this case it is simply the
string "workflow_state".</tal:comment>
<table tal:define="fieldNames python: tool.getResultColumnsNames(contentType, refField);
widgets python: objs[0].getAppyTypesFromNames(fieldNames);"
class="listing nosort" width="100%" cellpadding="0" cellspacing="0">
<tal:comment replace="nothing">Headers, with filters and sort arrows</tal:comment>
<tr>
<tal:comment replace="nothing">Mandatory column "Title"/"Name"</tal:comment>
<th tal:define="fieldName python:'title'; sortable python:True; filterable python:True">
<span tal:replace="structure python: tool.truncateText(tool.translate('ref_name'))"/>
<metal:sortAndFilter use-macro="here/skyn/navigate/macros/sortAndFilter"/>
</th>
<tal:comment replace="nothing">Columns corresponding to other fields</tal:comment>
<tal:columnHeader repeat="fieldDescr fieldDescrs">
<th tal:define="fieldName fieldDescr/name|string:workflow_state;
sortable python: tool.isSortable(fieldName, contentType, 'search');
filterable fieldDescr/filterable|nothing;">
<tal:comment replace="nothing">Display header for a "standard" field</tal:comment>
<tal:standardField condition="python: fieldName != 'workflow_state'">
<span tal:replace="structure python: tool.truncateText(tool.translate(fieldDescr['labelId']))"/>
</tal:standardField>
<tal:comment replace="nothing">Display header for the workflow state</tal:comment>
<tal:workflowState condition="python: fieldName == 'workflow_state'">
<span tal:replace="python: tool.translate('workflow_state')"/>
</tal:workflowState>
<metal:sortAndFilter use-macro="here/skyn/navigate/macros/sortAndFilter"/>
<tal:header repeat="widget widgets">
<th tal:define="sortable python: tool.isSortable(widget['name'], contentType, 'search');
filterable widget/filterable|nothing;">
<span tal:replace="structure python: tool.truncateText(tool.translate(widget['labelId']))"/>
<metal:icons use-macro="here/skyn/navigate/macros/sortAndFilter"/>
</th>
</tal:columnHeader>
<tal:comment replace="nothing">Column "Object type", shown if instances of several types are shown</tal:comment>
</tal:header>
<tal:comment replace="nothing">Object type, shown if instances of several types are shown</tal:comment>
<th tal:condition="severalTypes">
<span tal:replace="python: tool.translate('root_type')"/>
<span tal:replace="python: tool.translate('root_type')"></span>
</th>
<tal:comment replace="nothing">Column "Actions"</tal:comment>
<tal:comment replace="nothing">Actions</tal:comment>
<th tal:content="python: tool.translate('ref_actions')"></th>
</tr>
@ -88,31 +70,31 @@
<tr id="query_row" tal:define="odd repeat/obj/odd"
tal:attributes="class python:test(odd, 'even', 'odd')">
<tal:comment replace="nothing">Mandatory column "Title"/"Name"</tal:comment>
<td id="field_title"><a
tal:define="navInfo python:'search.%s.%s.%d.%d' % (contentType, searchName, repeat['obj'].number()+startNumber, totalNumber);"
tal:content="obj/Title" tal:attributes="href python: obj.getUrl(nav=navInfo, page='main')"></a></td>
<tal:fields repeat="widget widgets">
<tal:comment replace="nothing">Title</tal:comment>
<td id="field_title"
tal:condition="python: widget['name'] == 'title'">
<a tal:define="navInfo python:'search.%s.%s.%d.%d' % (contentType, searchName, repeat['obj'].number()+startNumber, totalNumber);"
tal:content="obj/Title" tal:attributes="href python: obj.getUrl(nav=navInfo, page='main')"></a>
</td>
<tal:comment replace="nothing">Columns corresponding to other fields</tal:comment>
<tal:otherFields repeat="widget fieldDescrs">
<tal:standardField condition="python: widget != 'workflowState'">
<td tal:condition="python: '_wrong' not in widget"
tal:attributes="id python:'field_%s' % widget['name']">
<tal:field define="contextObj python:obj;
layoutType python:'cell';
innerRef python:True"
condition="python: contextObj.showField(widget['name'], 'view')">
<metal:field use-macro="here/skyn/widgets/show/macros/field"/>
</tal:field>
</td>
<td tal:condition="python: '_wrong' in widget" style="color:red">Field
<span tal:replace="widget/name"/> not found.
</td>
</tal:standardField>
<tal:workflowState condition="python: widget == 'workflowState'">
<td id="field_workflow_state" tal:content="python: tool.translate(obj.getWorkflowLabel())"></td>
</tal:workflowState>
</tal:otherFields>
<tal:comment replace="nothing">Workflow state</tal:comment>
<td id="field_workflow_state"
tal:condition="python: widget['name'] == 'workflowState'"
tal:content="python: tool.translate(obj.getWorkflowLabel())">
</td>
<tal:comment replace="nothing">Any other field</tal:comment>
<td tal:condition="python: widget['name'] not in ('title', 'workflowState')"
tal:attributes="id python:'field_%s' % widget['name']">
<tal:field define="contextObj python:obj;
layoutType python:'cell';
innerRef python:True"
condition="python: contextObj.showField(widget['name'], 'view')">
<metal:field use-macro="here/skyn/widgets/show/macros/field"/>
</tal:field>
</td>
</tal:fields>
<tal:comment replace="nothing">Column "Object type", shown if instances of several types are shown</tal:comment>
<td tal:condition="severalTypes" id="field_root_type"

View file

@ -95,7 +95,7 @@
This macro displays up/down arrows in a table header column for sorting a given column.
It requires variables "sortable", 'filterable' and 'fieldName'.
</tal:comment>
<metal:sortAndFilter define-macro="sortAndFilter">
<metal:sortAndFilter define-macro="sortAndFilter" tal:define="fieldName widget/name">
<tal:sort condition="sortable">
<img tal:attributes="src string: $portal_url/skyn/sortDown.gif;
onClick python: navBaseCall.replace('**v**', '0,\'%s\',\'asc\',\'%s\'' % (fieldName, filterKey))"

View file

@ -28,7 +28,7 @@
</td>
</dt>
<tal:publishedObject condition="python: contextObj and tool.userMayNavigate(contextObj.meta_type)">
<tal:publishedObject condition="python: contextObj and tool.userMayNavigate(contextObj)">
<dt class="portletAppyItem portletCurrent"><b tal:content="contextObj/Title"></b></dt>
<dt class="portletAppyItem"><metal:phases use-macro="here/skyn/portlet/macros/phases"/></dt>
</tal:publishedObject>

View file

@ -15,8 +15,8 @@
tal:define="appFolder context/getParentNode;
appName appFolder/id;
tool python: portal.get('portal_%s' % appName.lower());
contentType python:context.REQUEST.get('type_name');
searchName python:context.REQUEST.get('search', '')">
contentType request/type_name;
searchName request/search|python:'';">
<div metal:use-macro="here/skyn/page/macros/prologue"/>
<tal:comment replace="nothing">Query result</tal:comment>

View file

@ -15,8 +15,11 @@
<metal:fill fill-slot="main"
tal:define="appFolder context/getParentNode;
contentType request/type_name;
refInfo request/ref|nothing;
tool python: portal.get('portal_%s' % appFolder.id.lower());
searchableFields python: tool.getSearchableFields(contentType)">
searchInfo python: tool.getSearchInfo(contentType, refInfo);
searchableFields python: searchInfo[0];
numberOfColumns python: searchInfo[1]">
<tal:comment replace="nothing">Search title</tal:comment>
<h1><span tal:replace="python: tool.translate('%s_plural' % contentType)"/> —
@ -26,9 +29,9 @@
<form name="search" tal:attributes="action python: appFolder.absolute_url()+'/skyn/do'" method="post">
<input type="hidden" name="action" value="SearchObjects"/>
<input type="hidden" name="type_name" tal:attributes="value contentType"/>
<input tal:condition="refInfo" type="hidden" name="ref" tal:attributes="value refInfo"/>
<table class="no-style-table" cellpadding="0" cellspacing="0" width="100%"
tal:define="numberOfColumns python: tool.getAttr('numberOfSearchColumnsFor%s' % contentType)">
<table class="no-style-table" cellpadding="0" cellspacing="0" width="100%">
<tr tal:repeat="searchRow python: tool.tabularize(searchableFields, numberOfColumns)" valign="top">
<td tal:repeat="widget searchRow" tal:attributes="width python:'%d%%' % (100/numberOfColumns)">
<tal:field condition="widget">

View file

@ -78,7 +78,7 @@
ref field according to the field that corresponds to this column.
</tal:comment>
<metal:sortIcons define-macro="sortIcons"
tal:define="ajaxBaseCall python: navBaseCall.replace('**v**', '\'%s\',\'SortReference\', {\'sortKey\':\'%s\', \'reverse\':\'**v**\'}' % (startNumber, shownField))" tal:condition="python: canWrite and tool.isSortable(shownField, objs[0].meta_type, 'ref')">
tal:define="ajaxBaseCall python: navBaseCall.replace('**v**', '\'%s\',\'SortReference\', {\'sortKey\':\'%s\', \'reverse\':\'**v**\'}' % (startNumber, widget['name']))" tal:condition="python: canWrite and tool.isSortable(widget['name'], objs[0].meta_type, 'ref')">
<img style="cursor:pointer"
tal:attributes="src string:$portal_url/skyn/sortAsc.png;
onClick python: ajaxBaseCall.replace('**v**', 'False')"/>
@ -159,6 +159,10 @@
<span tal:condition="not: innerRef" tal:content="label"/>
(<span tal:replace="totalNumber"/>)
<metal:plusIcon use-macro="portal/skyn/widgets/ref/macros/plusIcon"/>
<tal:comment replace="nothing">The search icon if field is queryable</tal:comment>
<a tal:condition="appyType/queryable"
tal:attributes="href python: '%s/skyn/search?type_name=%s&ref=%s:%s' % (tool.getAppFolder().absolute_url(), linkedPortalType, contextObj.meta_type, appyType['name'])">
<img src="search.gif" tal:attributes="title python: tool.translate('search_objects')"/></a>
</legend>
<tal:comment replace="nothing">Object description</tal:comment>
@ -185,44 +189,34 @@
</table>
<tal:comment replace="nothing">Show forward reference(s)</tal:comment>
<table tal:attributes="class python:test(innerRef, '', 'listing nosort');
width python:test(innerRef, '100%', appyType['layouts']['view']['width']);"
align="right" tal:condition="python: not appyType['isBack'] and objs" cellpadding="0" cellspacing="0">
<tal:widgets define="widgets python: objs[0].getAppyTypesFromNames(appyType['shownInfo'])">
<tr tal:condition="appyType/showHeaders">
<th tal:condition="python: 'title' not in appyType['shownInfo']"
tal:define="shownField python:'title'">
<span tal:content="python: tool.translate('ref_name')"></span>
<metal:sortIcons use-macro="portal/skyn/widgets/ref/macros/sortIcons" />
</th>
<th tal:repeat="widget widgets">
<tal:header define="shownField widget/name">
<span tal:content="python: tool.translate(widget['labelId'])"></span>
<metal:sortIcons use-macro="portal/skyn/widgets/ref/macros/sortIcons" />
</tal:header>
<span tal:content="python: tool.translate(widget['labelId'])"></span>
<metal:sortIcons use-macro="portal/skyn/widgets/ref/macros/sortIcons" />
</th>
<th tal:content="python: tool.translate('ref_actions')"></th>
</tr>
<tal:row repeat="obj objs">
<tr valign="top" tal:define="odd repeat/obj/odd"
tal:attributes="class python:test(odd, 'even', 'odd')">
<tal:comment replace="nothing">Object title, shown here if not specified somewhere
else in appyType.shownInfo.</tal:comment>
<td tal:condition="python: 'title' not in appyType['shownInfo']"><metal:showObjectTitle
use-macro="portal/skyn/widgets/ref/macros/objectTitle"/>
</td>
<tal:comment replace="nothing">Additional fields that must be shown</tal:comment>
<td tal:repeat="widget widgets">
<tal:showTitle condition="python: widget['name'] == 'title'">
<tal:title condition="python: widget['name'] == 'title'">
<metal:showObjectTitle use-macro="portal/skyn/widgets/ref/macros/objectTitle"/>
</tal:showTitle>
<tal:showOtherField define="contextObj python:obj;
layoutType python: 'cell';
innerRef python:True"
condition="python: widget['name'] != 'title'">
<metal:showField use-macro="portal/skyn/widgets/show/macros/field" />
</tal:showOtherField>
</tal:title>
<tal:state condition="python: widget['name'] == 'workflowState'"
content="python: tool.translate(obj.getWorkflowLabel())">
</tal:state>
<tal:other condition="python: widget['name'] not in ('title', 'workflowState')">
<tal:field define="contextObj python:obj;
layoutType python: 'cell';
innerRef python:True">
<metal:field use-macro="portal/skyn/widgets/show/macros/field" />
</tal:field>
</tal:other>
</td>
<tal:comment replace="nothing">Actions</tal:comment>
<td align="right">
@ -232,7 +226,6 @@
</tal:row>
</tal:widgets>
</table>
</td></tr>
</table>

View file

@ -140,7 +140,9 @@
<table metal:define-macro="groupContent"
tal:attributes="width python: test(widget['wide'], '100%', '');
align widget/align;
class widget/css_class">
class widget/css_class;
cellspacing widget/cellspacing;
cellpadding widget/cellpadding">
<tal:comment replace="nothing">Display the title of the group if it is not rendered a fieldset.</tal:comment>
<tr tal:condition="python: (widget['style'] != 'fieldset') and widget['hasLabel']">
<td tal:attributes="colspan python: len(widget['columnsWidths']);