Improved management of indexes; always provide str and not unicode strings as index values; search screen may now include javascripts and css like those required by the date chooser; removed CSS parser, basic XmlUnmarshaller can do it by itself.

This commit is contained in:
Gaetan Delannay 2010-12-17 14:46:55 +01:00
parent 2124cffa5e
commit a30949a621
15 changed files with 213 additions and 132 deletions

View file

@ -6,12 +6,10 @@
tool contextObj/getTool;
appFolder tool/getAppFolder;
appName appFolder/getId;
phaseInfo python: contextObj.getAppyPhases(currentOnly=True, layoutType='edit');
phaseInfo python: contextObj.getAppyPhases(currentOnly=True, layoutType=layoutType);
phase phaseInfo/name;
page request/page|python:'main';
cssAndJs python: contextObj.getCssAndJs(layoutType, page);
css python: cssAndJs[0];
js python: cssAndJs[1];
cssJs python: contextObj.getCssAndJs(contextObj.getAppyTypes(layoutType, page), layoutType);
confirmMsg request/confirmMsg | nothing;">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
@ -28,7 +26,7 @@
<tal:comment replace="nothing">Include type-specific CSS and JS.</tal:comment>
<metal:js fill-slot="javascript_head_slot">
<tal:js condition="js" repeat="jsFile js">
<tal:js condition="cssJs/js" repeat="jsFile cssJs/js">
<script type="text/javascript" charset="iso-8859-1"
tal:condition="python:exists('portal/%s' % jsFile)"
tal:attributes="src string:$portal_url/$jsFile">
@ -36,7 +34,7 @@
</tal:js>
</metal:js>
<metal:css fill-slot="css_slot">
<tal:css condition="css" repeat="cssFile css">
<tal:css condition="cssJs/css" repeat="cssFile cssJs/css">
<style type="text/css" media="all"
tal:condition="python:exists('portal/%s' % cssFile)"
tal:content="structure string:<!-- @import url($portal_url/$cssFile); -->">

View file

@ -114,7 +114,7 @@
</a></td>
<tal:comment replace="nothing">Delete the element</tal:comment>
<td class="noPadding">
<img tal:condition="python: member.has_permission('Delete objects', obj)"
<img tal:condition="python: member.has_permission('Delete objects', obj) and obj.mayDelete()"
title="Delete" i18n:domain="plone" i18n:attributes="title" style="cursor:pointer"
tal:attributes="src string: $portal_url/skyn/delete.png;
onClick python:'onDeleteObject(\'%s\')' % obj.UID()"/>

View file

@ -28,7 +28,7 @@
</td>
</dt>
<tal:publishedObject condition="python: contextObj and tool.userMayNavigate(contextObj)">
<tal:publishedObject condition="python: contextObj and contextObj.mayNavigate()">
<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

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

View file

@ -1,25 +1,43 @@
<tal:search metal:define-macro="master"
define="appFolder context/getParentNode;
contentType request/type_name;
refInfo request/ref|nothing;
tool python: here.portal_url.getPortalObject().get('portal_%s' % appFolder.id.lower());
searchInfo python: tool.getSearchInfo(contentType, refInfo);
cssJs python: tool.getCssAndJs(searchInfo['fields'], 'edit')">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
metal:use-macro="here/main_template/macros/master">
<tal:comment replace="nothing">Disable standard Plone green tabs</tal:comment>
<div metal:fill-slot="top_slot">
<metal:block metal:use-macro="here/global_defines/macros/defines" />
<div tal:define="dummy python:request.set('disable_border', 1)" />
</div>
<tal:comment replace="nothing">Disable standard Plone green tabs</tal:comment>
<div metal:fill-slot="top_slot">
<metal:block metal:use-macro="here/global_defines/macros/defines" />
<div tal:define="dummy python:request.set('disable_border', 1)" />
</div>
<tal:comment replace="nothing">Fill main slot of Plone main_template</tal:comment>
<body>
<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());
searchInfo python: tool.getSearchInfo(contentType, refInfo);
searchableFields python: searchInfo[0];
numberOfColumns python: searchInfo[1]">
<tal:comment replace="nothing">Include type-specific CSS and JS.</tal:comment>
<metal:js fill-slot="javascript_head_slot">
<tal:js condition="cssJs/js" repeat="jsFile cssJs/js">
<script type="text/javascript" charset="iso-8859-1"
tal:condition="python:exists('portal/%s' % jsFile)"
tal:attributes="src string:$portal_url/$jsFile">
</script>
</tal:js>
</metal:js>
<metal:css fill-slot="css_slot">
<tal:css condition="cssJs/css" repeat="cssFile cssJs/css">
<style type="text/css" media="all"
tal:condition="python:exists('portal/%s' % cssFile)"
tal:content="structure string:<!-- @import url($portal_url/$cssFile); -->">
</style>
</tal:css>
</metal:css>
<body>
<metal:fill fill-slot="main">
<tal:comment replace="nothing">Search title</tal:comment>
<h1><span tal:replace="python: tool.translate('%s_plural' % contentType)"/> —
@ -32,8 +50,9 @@
<input tal:condition="refInfo" type="hidden" name="ref" tal:attributes="value refInfo"/>
<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)">
<tr tal:repeat="searchRow python: tool.tabularize(searchInfo['fieldDicts'], searchInfo['nbOfColumns'])"
valign="top">
<td tal:repeat="widget searchRow" tal:attributes="width python:'%d%%' % (100/searchInfo['nbOfColumns'])">
<tal:field condition="widget">
<tal:show define="name widget/name;
widgetName python: 'w_%s' % name;
@ -53,3 +72,4 @@
</metal:fill>
</body>
</html>
</tal:search>

View file

@ -78,55 +78,71 @@
</metal:cell>
<tal:comment replace="nothing">Search macro for an Date.</tal:comment>
<metal:search define-macro="search">
<metal:search define-macro="search"
tal:define="years python:range(widget['startYear'], widget['endYear']+1)">
<label tal:content="python: tool.translate(widget['labelId'])"></label>
<table cellpadding="0" cellspacing="0">
<tal:comment replace="nothing">From</tal:comment>
<tr tal:define="fromName python: '%s*date' % widgetName">
<tr tal:define="yearFromName python: '%s*date' % widgetName;
monthFromName python: '%s_from_month' % name;
dayFromName python: '%s_from_day' % name;
dummyFromName python: '_d_ummy_from_%s' % name;">
<td width="10px">&nbsp;</td>
<td>
<label tal:content="python: tool.translate('search_from')"></label>
</td>
<td>
<select tal:attributes="name fromName">
<input type="hidden" tal:attributes="id dummyFromName; name dummyFromName" originalvalue=""/>
<select tal:attributes="id dayFromName; name dayFromName">
<option value="">--</option>
<option tal:repeat="value python:range(widget['startYear'], widget['endYear']+1)"
<option tal:repeat="value python: [str(v).zfill(2) for v in range(1, 32)]"
tal:content="value" tal:attributes="value value"></option>
</select> /
<select tal:attributes="name python: '%s_from_month' % name">
</select> /
<select tal:attributes="id monthFromName; name monthFromName">
<option value="">--</option>
<option tal:repeat="value python: [str(v).zfill(2) for v in range(1, 13)]"
tal:content="python:tool.getMonthName(value)" tal:attributes="value value"></option>
</select> /
<select tal:attributes="name python: '%s_from_day' % name">
<select tal:attributes="id yearFromName; name yearFromName">
<option value="">--</option>
<option tal:repeat="value python: [str(v).zfill(2) for v in range(1, 32)]"
<option tal:repeat="value python:range(widget['startYear'], widget['endYear']+1)"
tal:content="value" tal:attributes="value value"></option>
</select>
<tal:comment replace="nothing">The icon for displaying the calendar (=date chooser)</tal:comment>
<a tal:condition="widget/calendar"
tal:attributes="onclick python: 'return showJsCalendar(\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', null, null, %d, %d)' % (monthFromName, dummyFromName, yearFromName, monthFromName, dayFromName, years[0], years[-1])">
<img tal:attributes="src string: $portal_url/popup_calendar.gif"/></a>
</td>
</tr>
<tal:comment replace="nothing">To</tal:comment>
<tr>
<tr tal:define="dummyToName python: '_d_ummy_to_%s' % name;
yearToName python: '%s_to_year' % name;
monthToName python: '%s_to_month' % name;
dayToName python: '%s_to_day' % name">
<td></td>
<td>
<label tal:content="python: tool.translate('search_to')"></label>
<label tal:content="python: tool.translate('search_to')"></label>&nbsp;&nbsp;&nbsp;&nbsp;
</td>
<td>
<select tal:attributes="name python: '%s_to_year' % name">
<td height="20px;">
<input type="hidden" tal:attributes="id dummyToName; name dummyToName" originalvalue=""/>
<select tal:attributes="id dayToName; name dayToName">
<option value="">--</option>
<option tal:repeat="value python:range(widget['startYear'], widget['endYear']+1)"
tal:content="value" tal:attributes="value value"></option>
<option tal:repeat="value python: [str(v).zfill(2) for v in range(1, 32)]"
tal:content="value" tal:attributes="value value"></option>
</select> /
<select tal:attributes="name python: '%s_to_month' % name">
<select tal:attributes="id monthToName; name monthToName">
<option value="">--</option>
<option tal:repeat="value python: [str(v).zfill(2) for v in range(1, 13)]"
tal:content="python:tool.getMonthName(value)" tal:attributes="value value"></option>
</select> /
<select tal:attributes="name python: '%s_to_day' % name">
<select tal:attributes="id yearToName; name yearToName">
<option value="">--</option>
<option tal:repeat="value python: [str(v).zfill(2) for v in range(1, 32)]"
tal:content="value" tal:attributes="value value"></option>
<option tal:repeat="value python:range(widget['startYear'], widget['endYear']+1)"
tal:content="value" tal:attributes="value value"></option>
</select>
<a tal:condition="widget/calendar"
tal:attributes="onclick python: 'return showJsCalendar(\'%s\', \'%s\', \'%s\', \'%s\', \'%s\', null, null, %d, %d)' % (monthToName, dummyToName, yearToName, monthToName, dayToName, years[0], years[-1])">
<img tal:attributes="src string: $portal_url/popup_calendar.gif"/></a>
</td>
</tr>
</table>

View file

@ -22,7 +22,7 @@
<table class="no-style-table" cellpadding="0" cellspacing="0">
<tr>
<tal:comment replace="nothing">Arrows for moving objects up or down</tal:comment>
<td class="noPadding" tal:condition="python: (len(objs)&gt;1) and member.has_permission('Modify portal content', contextObj)">
<td class="noPadding" tal:condition="python: not appyType['isBack'] and (len(objs)&gt;1) and member.has_permission('Modify portal content', contextObj)">
<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>
@ -49,7 +49,7 @@
</td>
<tal:comment replace="nothing">Delete the element</tal:comment>
<td class="noPadding">
<img tal:condition="python: member.has_permission('Delete objects', obj)"
<img tal:condition="python: not appyType['isBack'] and member.has_permission('Delete objects', obj) and obj.mayDelete()"
title="Delete" i18n:domain="plone" i18n:attributes="title" style="cursor:pointer"
tal:attributes="src string: $portal_url/skyn/delete.png;
onClick python:'onDeleteObject(\'%s\')' % obj.UID()"/>
@ -179,19 +179,10 @@
tal:attributes="class python:test(innerRef, 'innerAppyTable', '')">
<tr valign="bottom"><td>
<tal:comment replace="nothing">Show backward reference(s)</tal:comment>
<table class="no-style-table" cellspacing="0" cellpadding="0"
tal:condition="python: appyType['isBack'] and objs">
<tr tal:repeat="obj objs">
<td><metal:showObjectTitle use-macro="portal/skyn/widgets/ref/macros/objectTitle" />
</td>
</tr>
</table>
<tal:comment replace="nothing">Show forward reference(s)</tal:comment>
<tal:comment replace="nothing">Show forward or backward 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">
align="right" tal:condition="python: objs" cellpadding="0" cellspacing="0">
<tal:widgets define="widgets python: objs[0].getAppyTypesFromNames(appyType['shownInfo'])">
<tr tal:condition="appyType/showHeaders">
<th tal:repeat="widget widgets">

View file

@ -101,7 +101,7 @@
<label tal:attributes="for andName" tal:content="python: tool.translate('search_and')"></label><br/>
</tal:operator>
<tal:comment replace="nothing">The list of values</tal:comment>
<select tal:attributes="name widgetName" multiple="multiple" size="5">
<select tal:attributes="name widgetName; size widget/height" multiple="multiple">
<option tal:repeat="v python:tool.getPossibleValues(name, withTranslations=True, withBlankValue=False, className=contentType)"
tal:attributes="value python:v[0]; title python: v[1]"
tal:content="python: tool.truncateValue(v[1], widget)">