appy.gen: first Ploneless version.
This commit is contained in:
parent
5672c81553
commit
d0cbe7e573
360 changed files with 1003 additions and 1017 deletions
33
gen/ui/widgets/action.pt
Normal file
33
gen/ui/widgets/action.pt
Normal file
|
@ -0,0 +1,33 @@
|
|||
<tal:comment replace="nothing">View macro for an Action.</tal:comment>
|
||||
<metal:view define-macro="view">
|
||||
<form name="executeAppyAction"
|
||||
tal:define="formId python: '%s_%s' % (contextObj.UID(), name);
|
||||
label python: contextObj.translate(widget['labelId'])"
|
||||
tal:attributes="id formId; action python: tool.absolute_url()+'/do'">
|
||||
<input type="hidden" name="action" value="ExecuteAppyAction"/>
|
||||
<input type="hidden" name="objectUid" tal:attributes="value contextObj/UID"/>
|
||||
<input type="hidden" name="fieldName" tal:attributes="value name"/>
|
||||
<tal:confirm condition="widget/confirm">
|
||||
<input type="button"
|
||||
tal:define="labelConfirm python: contextObj.translate(widget['labelId'] + '_confirm')"
|
||||
tal:attributes="value label;
|
||||
onClick python: 'askConfirm(\'form\', \'%s\', "%s")' % (formId, labelConfirm)"/>
|
||||
</tal:confirm>
|
||||
<input type="submit" name="do" tal:condition="not: widget/confirm"
|
||||
tal:attributes="value label" onClick="javascript:;"/>
|
||||
<tal:comment replace="nothing">The previous onClick is simply used to prevent Plone
|
||||
from adding a CSS class that displays a popup when the user triggers the form multiple
|
||||
times.</tal:comment>
|
||||
</form>
|
||||
</metal:view>
|
||||
|
||||
<tal:comment replace="nothing">Edit macro for an Action.</tal:comment>
|
||||
<metal:edit define-macro="edit"></metal:edit>
|
||||
|
||||
<tal:comment replace="nothing">Cell macro for an Action.</tal:comment>
|
||||
<metal:cell define-macro="cell">
|
||||
<metal:call use-macro="app/ui/widgets/action/macros/view"/>
|
||||
</metal:cell>
|
||||
|
||||
<tal:comment replace="nothing">Search macro for an Action.</tal:comment>
|
||||
<metal:search define-macro="search"></metal:search>
|
42
gen/ui/widgets/boolean.pt
Normal file
42
gen/ui/widgets/boolean.pt
Normal file
|
@ -0,0 +1,42 @@
|
|||
<tal:comment replace="nothing">View macro for a Boolean.</tal:comment>
|
||||
<metal:view define-macro="view">
|
||||
<span tal:replace="value"></span>
|
||||
<input type="hidden" tal:condition="masterCss"
|
||||
tal:attributes="class masterCss; value rawValue; name name; id name"/>
|
||||
</metal:view>
|
||||
|
||||
<tal:comment replace="nothing">Edit macro for an Boolean.</tal:comment>
|
||||
<metal:edit define-macro="edit">
|
||||
<input type="checkbox"
|
||||
tal:attributes="name python: name + '_visible'; id name;
|
||||
checked python:contextObj.checkboxChecked(name, rawValue);
|
||||
onClick python:'toggleCheckbox(\'%s\', \'%s_hidden\');;updateSlaves(this)' % (name, name);
|
||||
class masterCss"/>
|
||||
<input type="hidden"
|
||||
tal:attributes="name name;
|
||||
id string:${name}_hidden;
|
||||
value python: test(contextObj.checkboxChecked(name, rawValue), 'True', 'False')"/>
|
||||
</metal:edit>
|
||||
|
||||
<tal:comment replace="nothing">Cell macro for an Boolean.</tal:comment>
|
||||
<metal:cell define-macro="cell">
|
||||
<metal:call use-macro="app/ui/widgets/boolean/macros/view"/>
|
||||
</metal:cell>
|
||||
|
||||
<tal:comment replace="nothing">Search macro for an Boolean.</tal:comment>
|
||||
<metal:search define-macro="search"
|
||||
tal:define="typedWidget python:'%s*bool' % widgetName">
|
||||
<label tal:attributes="for widgetName" tal:content="python: tool.translate(widget['labelId'])"></label><br>
|
||||
<tal:yes define="valueId python:'%s_yes' % name">
|
||||
<input type="radio" value="True" tal:attributes="name typedWidget; id valueId"/>
|
||||
<label tal:attributes="for valueId" i18n:translate="yes" i18n:domain="plone"></label>
|
||||
</tal:yes>
|
||||
<tal:no define="valueId python:'%s_no' % name">
|
||||
<input type="radio" value="False" tal:attributes="name typedWidget; id valueId"/>
|
||||
<label tal:attributes="for valueId" i18n:translate="no" i18n:domain="plone"></label>
|
||||
</tal:no>
|
||||
<tal:whatever define="valueId python:'%s_whatever' % name">
|
||||
<input type="radio" value="" tal:attributes="name typedWidget; id valueId" checked="checked"/>
|
||||
<label tal:attributes="for valueId" tal:content="python: tool.translate('whatever')"></label>
|
||||
</tal:whatever><br/>
|
||||
</metal:search>
|
37
gen/ui/widgets/computed.pt
Normal file
37
gen/ui/widgets/computed.pt
Normal file
|
@ -0,0 +1,37 @@
|
|||
<tal:comment replace="nothing">View macro for a Computed.</tal:comment>
|
||||
<metal:view define-macro="view">
|
||||
<tal:sync condition="sync">
|
||||
<span tal:condition="widget/plainText" tal:replace="value"/>
|
||||
<span tal:condition="not: widget/plainText" tal:replace="structure value"/>
|
||||
</tal:sync>
|
||||
<tal:async condition="not: sync">
|
||||
<div tal:define= "ajaxHookId python: contextObj.UID() + name"
|
||||
tal:attributes = "id ajaxHookId">
|
||||
<script language="javascript"
|
||||
tal:content="python: 'askComputedField(\'%s\',\'%s\',\'%s\')' % (ajaxHookId, contextObj.absolute_url(), name)">
|
||||
</script>
|
||||
</div>
|
||||
</tal:async>
|
||||
</metal:view>
|
||||
|
||||
<tal:comment replace="nothing">Ajax-called view content of a non sync Computed field.</tal:comment>
|
||||
<metal:view define-macro="viewContent"
|
||||
tal:define="name request/fieldName;
|
||||
widget python: contextObj.getAppyType(name, asDict=True);
|
||||
value python: contextObj.getFieldValue(name);
|
||||
sync python:True">
|
||||
<metal:call use-macro="app/ui/widgets/computed/macros/view"/>
|
||||
</metal:view>
|
||||
|
||||
<tal:comment replace="nothing">Edit macro for a Computed.</tal:comment>
|
||||
<metal:edit define-macro="edit">
|
||||
<metal:call use-macro="app/ui/widgets/computed/macros/view"/>
|
||||
</metal:edit>
|
||||
|
||||
<tal:comment replace="nothing">Cell macro for a Computed.</tal:comment>
|
||||
<metal:cell define-macro="cell">
|
||||
<metal:call use-macro="app/ui/widgets/computed/macros/view"/>
|
||||
</metal:cell>
|
||||
|
||||
<tal:comment replace="nothing">Search macro for a Computed.</tal:comment>
|
||||
<metal:search define-macro="search"></metal:search>
|
149
gen/ui/widgets/date.pt
Normal file
149
gen/ui/widgets/date.pt
Normal file
|
@ -0,0 +1,149 @@
|
|||
<tal:comment replace="nothing">View macro for a Date.</tal:comment>
|
||||
<metal:view define-macro="view"><span tal:replace="value"/></metal:view>
|
||||
|
||||
<tal:comment replace="nothing">Edit macro for an Date.</tal:comment>
|
||||
<metal:edit define-macro="edit"
|
||||
tal:define="years python: contextObj.getSelectableYears(widget['name']);
|
||||
dummyName python: '_d_ummy_%s' % name">
|
||||
<tal:comment replace="nothing">This field is not used but required by the Javascript popup.</tal:comment>
|
||||
<input type="hidden" tal:attributes="name dummyName; id dummyName"/>
|
||||
<tal:comment replace="nothing">Day</tal:comment>
|
||||
<select tal:define="days python:range(1,32)"
|
||||
tal:attributes="name string:${name}_day;
|
||||
id string:${name}_day;">
|
||||
<option value="">-</option>
|
||||
<tal:days repeat="day days">
|
||||
<option tal:define="zDay python: str(day).zfill(2)"
|
||||
tal:attributes="value zDay;
|
||||
selected python:contextObj.dateValueSelected(name, 'day', day, rawValue)"
|
||||
tal:content="zDay"></option>
|
||||
</tal:days>
|
||||
</select>
|
||||
|
||||
<tal:comment replace="nothing">Month</tal:comment>
|
||||
<select tal:define="months python:range(1,13)"
|
||||
tal:attributes="name string:${name}_month;
|
||||
id string:${name}_month;">
|
||||
<option value="">-</option>
|
||||
<tal:months repeat="month months">
|
||||
<option tal:define="zMonth python: str(month).zfill(2)"
|
||||
tal:attributes="value zMonth;
|
||||
selected python:contextObj.dateValueSelected(name, 'month', month, rawValue)"
|
||||
tal:content="zMonth"></option>
|
||||
</tal:months>
|
||||
</select>
|
||||
|
||||
<tal:comment replace="nothing">Year</tal:comment>
|
||||
<select tal:attributes="name string:${name}_year;
|
||||
id string:${name}_year;">
|
||||
<option value="">-</option>
|
||||
<option tal:repeat="year years"
|
||||
tal:attributes="value year;
|
||||
selected python:contextObj.dateValueSelected(name, 'year', year, rawValue)"
|
||||
tal:content="year"></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_month\', \'%s\', \'%s_year\', \'%s_month\', \'%s_day\', null, null, %d, %d)' % (name, dummyName, name, name, name, years[0], years[-1])"><img tal:attributes="src string: $appUrl/calendar.gif"/></a>
|
||||
|
||||
<tal:hour condition="python: widget['format'] == 0">
|
||||
<select tal:define="hours python:range(0,24);"
|
||||
tal:attributes="name string:${name}_hour;
|
||||
id string:${name}_hour;">
|
||||
<option value="">-</option>
|
||||
<tal:hours repeat="hour hours">
|
||||
<option tal:define="zHour python: str(hour).zfill(2)"
|
||||
tal:attributes="value zHour;
|
||||
selected python:contextObj.dateValueSelected(name, 'hour', hour, rawValue)"
|
||||
tal:content="zHour"></option>
|
||||
</tal:hours>
|
||||
</select> :
|
||||
<select tal:define="minutes python:range(0,60,5);"
|
||||
tal:attributes="name string:${name}_minute;
|
||||
id string:${name}_minute;">
|
||||
<option value="">-</option>
|
||||
<tal:minutes repeat="minute minutes">
|
||||
<option tal:define="zMinute python: str(minute).zfill(2)"
|
||||
tal:attributes="value zMinute;
|
||||
selected python:contextObj.dateValueSelected(name, 'minute', minute, rawValue)"
|
||||
tal:content="zMinute"></option>
|
||||
</tal:minutes>
|
||||
</select>
|
||||
</tal:hour>
|
||||
</metal:edit>
|
||||
|
||||
<tal:comment replace="nothing">Cell macro for an Date.</tal:comment>
|
||||
<metal:cell define-macro="cell">
|
||||
<metal:call use-macro="app/ui/widgets/date/macros/view"/>
|
||||
</metal:cell>
|
||||
|
||||
<tal:comment replace="nothing">Search macro for an Date.</tal:comment>
|
||||
<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>
|
||||
<tal:comment replace="nothing">From</tal:comment>
|
||||
<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"> </td>
|
||||
<td>
|
||||
<label tal:content="python: tool.translate('search_from')"></label>
|
||||
</td>
|
||||
<td>
|
||||
<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: [str(v).zfill(2) for v in range(1, 32)]"
|
||||
tal:content="value" tal:attributes="value value"></option>
|
||||
</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="id yearFromName; name yearFromName">
|
||||
<option value="">--</option>
|
||||
<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: $appUrl/calendar.gif"/></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tal:comment replace="nothing">To</tal:comment>
|
||||
<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>
|
||||
</td>
|
||||
<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: [str(v).zfill(2) for v in range(1, 32)]"
|
||||
tal:content="value" tal:attributes="value value"></option>
|
||||
</select> /
|
||||
<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="id yearToName; name yearToName">
|
||||
<option 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: $appUrl/calendar.gif"/></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</metal:search>
|
73
gen/ui/widgets/file.pt
Normal file
73
gen/ui/widgets/file.pt
Normal file
|
@ -0,0 +1,73 @@
|
|||
<tal:comment replace="nothing">View macro for a File.</tal:comment>
|
||||
<metal:view define-macro="view"
|
||||
tal:define="info python: contextObj.getFileInfo(value);
|
||||
empty not: info/size;
|
||||
imageSrc string:${contextObj/absolute_url}/download?name=$name">
|
||||
<tal:file condition="python: not empty and not widget['isImage']">
|
||||
<a tal:attributes="href imageSrc"
|
||||
tal:content="info/filename">
|
||||
</a> -
|
||||
<i class="discreet" tal:content="python:'%sKb' % (info['size'] / 1024)"></i>
|
||||
</tal:file>
|
||||
<tal:image condition="python: not empty and widget['isImage']">
|
||||
<img tal:attributes="src python: imageSrc" />
|
||||
</tal:image>
|
||||
<tal:nothing tal:condition="empty">-</tal:nothing>
|
||||
</metal:view>
|
||||
|
||||
<tal:comment replace="nothing">Edit macro for an File.</tal:comment>
|
||||
<metal:edit define-macro="edit"
|
||||
tal:define="info python: contextObj.getFileInfo(value);
|
||||
empty not: info/size;">
|
||||
|
||||
<tal:showFile condition="not: empty">
|
||||
<metal:call use-macro="app/ui/widgets/file/macros/view"/><br/>
|
||||
</tal:showFile>
|
||||
<tal:editButtons condition="not: empty">
|
||||
<tal:comment replace="nothing">Keep the file untouched.</tal:comment>
|
||||
<input type="radio" value="nochange"
|
||||
tal:attributes="checked python:test(info['size']!=0, 'checked', None);
|
||||
name string:${name}_delete;
|
||||
id string:${name}_nochange;
|
||||
onclick string:document.getElementById('${name}_file').disabled=true;"/>
|
||||
<label tal:attributes="for string:${name}_nochange"
|
||||
i18n:translate="nochange_file" i18n:domain="plone">Keep the file unchanged</label>
|
||||
<br/>
|
||||
<tal:comment replace="nothing">Delete the file.</tal:comment>
|
||||
<tal:delete condition="not: widget/required">
|
||||
<input type="radio" value="delete"
|
||||
tal:attributes="name string:${name}_delete;
|
||||
id string:${name}_delete;
|
||||
onclick string:document.getElementById('${name}_file').disabled=true;"/>
|
||||
<label tal:attributes="for string:${name}_delete"
|
||||
i18n:translate="delete_file" i18n:domain="plone">Delete the file</label>
|
||||
<br/>
|
||||
</tal:delete>
|
||||
<tal:comment replace="nothing">Replace with a new file.</tal:comment>
|
||||
<input type="radio" value=""
|
||||
tal:attributes="checked python:test(info['size']==0, 'checked', None);
|
||||
name string:${name}_delete;
|
||||
id string:${name}_upload;
|
||||
onclick string:document.getElementById('${name}_file').disabled=false"/>
|
||||
<label tal:attributes="for string:${name}_upload;"
|
||||
i18n:translate="upload_file" i18n:domain="plone">Replace it with a new file</label>
|
||||
<br/>
|
||||
</tal:editButtons>
|
||||
<tal:comment replace="nothing">The upload field.</tal:comment>
|
||||
<input type="file"
|
||||
tal:attributes="name string:${name}_file;
|
||||
id string:${name}_file;
|
||||
size widget/width"/>
|
||||
<script type="text/javascript"
|
||||
tal:define="isDisabled python:test(empty, 'false', 'true')"
|
||||
tal:content="string: document.getElementById('${name}_file').disabled=$isDisabled;">
|
||||
</script>
|
||||
</metal:edit>
|
||||
|
||||
<tal:comment replace="nothing">Cell macro for an File.</tal:comment>
|
||||
<metal:cell define-macro="cell">
|
||||
<metal:call use-macro="app/ui/widgets/file/macros/view"/>
|
||||
</metal:cell>
|
||||
|
||||
<tal:comment replace="nothing">Search macro for an File.</tal:comment>
|
||||
<metal:search define-macro="search"></metal:search>
|
32
gen/ui/widgets/float.pt
Normal file
32
gen/ui/widgets/float.pt
Normal file
|
@ -0,0 +1,32 @@
|
|||
<tal:comment replace="nothing">View macro for a Float.</tal:comment>
|
||||
<metal:view define-macro="view">
|
||||
<span tal:replace="value"></span>
|
||||
<input type="hidden" tal:condition="masterCss"
|
||||
tal:attributes="class masterCss; value value; name name; id name"/>
|
||||
</metal:view>
|
||||
|
||||
<tal:comment replace="nothing">Edit macro for an Float.</tal:comment>
|
||||
<metal:edit define-macro="edit">
|
||||
<input tal:define="maxChars python: test(widget['maxChars'], widget['maxChars'], '')"
|
||||
tal:attributes="id name; name name; size widget/width; maxlength maxChars;
|
||||
value python: test(inRequest, requestValue, value)" type="text"/>
|
||||
</metal:edit>
|
||||
|
||||
<tal:comment replace="nothing">Cell macro for an Float.</tal:comment>
|
||||
<metal:cell define-macro="cell">
|
||||
<metal:call use-macro="app/ui/widgets/float/macros/view"/>
|
||||
</metal:cell>
|
||||
|
||||
<tal:comment replace="nothing">Search macro for an Float.</tal:comment>
|
||||
<metal:search define-macro="search"
|
||||
tal:define="maxChars python: test(widget['maxChars'], widget['maxChars'], '')">
|
||||
<label tal:content="python: tool.translate(widget['labelId'])"></label><br>
|
||||
<tal:from define="fromName python: '%s*float' % widgetName">
|
||||
<label tal:attributes="for fromName" tal:content="python: tool.translate('search_from')"></label>
|
||||
<input type="text" tal:attributes="name fromName; maxlength maxChars" size="4"/>
|
||||
</tal:from>
|
||||
<tal:to define="toName python: '%s_to' % name">
|
||||
<label tal:attributes="for toName" tal:content="python: tool.translate('search_to')"></label>
|
||||
<input type="text" tal:attributes="name toName; maxlength maxChars" size="4"/>
|
||||
</tal:to><br/>
|
||||
</metal:search>
|
11
gen/ui/widgets/info.pt
Normal file
11
gen/ui/widgets/info.pt
Normal file
|
@ -0,0 +1,11 @@
|
|||
<tal:comment replace="nothing">View macro for an Info.</tal:comment>
|
||||
<metal:view define-macro="view"><tal:comment replace="nothing">Shows nothing more.</tal:comment></metal:view>
|
||||
|
||||
<tal:comment replace="nothing">Edit macro for an Info.</tal:comment>
|
||||
<metal:edit define-macro="edit"></metal:edit>
|
||||
|
||||
<tal:comment replace="nothing">Cell macro for an Info.</tal:comment>
|
||||
<metal:cell define-macro="cell"></metal:cell>
|
||||
|
||||
<tal:comment replace="nothing">Search macro for an Info.</tal:comment>
|
||||
<metal:search define-macro="search"></metal:search>
|
32
gen/ui/widgets/integer.pt
Normal file
32
gen/ui/widgets/integer.pt
Normal file
|
@ -0,0 +1,32 @@
|
|||
<tal:comment replace="nothing">View macro for an Integer.</tal:comment>
|
||||
<metal:view define-macro="view">
|
||||
<span tal:replace="value"></span>
|
||||
<input type="hidden" tal:condition="masterCss"
|
||||
tal:attributes="class masterCss; value value; name name; id name"/>
|
||||
</metal:view>
|
||||
|
||||
<tal:comment replace="nothing">Edit macro for an Integer.</tal:comment>
|
||||
<metal:edit define-macro="edit">
|
||||
<input tal:define="maxChars python: test(widget['maxChars'], widget['maxChars'], '')"
|
||||
tal:attributes="id name; name name; size widget/width; maxlength maxChars;
|
||||
value python: test(inRequest, requestValue, value)" type="text"/>
|
||||
</metal:edit>
|
||||
|
||||
<tal:comment replace="nothing">Cell macro for an Integer.</tal:comment>
|
||||
<metal:cell define-macro="cell">
|
||||
<metal:call use-macro="app/ui/widgets/integer/macros/view"/>
|
||||
</metal:cell>
|
||||
|
||||
<tal:comment replace="nothing">Search macro for an Integer.</tal:comment>
|
||||
<metal:search define-macro="search"
|
||||
tal:define="maxChars python: test(widget['maxChars'], widget['maxChars'], '')">
|
||||
<label tal:content="python: tool.translate(widget['labelId'])"></label><br>
|
||||
<tal:from define="fromName python: '%s*int' % widgetName">
|
||||
<label tal:attributes="for fromName" tal:content="python: tool.translate('search_from')"></label>
|
||||
<input type="text" tal:attributes="name fromName; maxlength maxChars" size="4"/>
|
||||
</tal:from>
|
||||
<tal:to define="toName python: '%s_to' % name">
|
||||
<label tal:attributes="for toName" tal:content="python: tool.translate('search_to')"></label>
|
||||
<input type="text" tal:attributes="name toName; maxlength maxChars" size="4"/>
|
||||
</tal:to><br/>
|
||||
</metal:search>
|
72
gen/ui/widgets/list.pt
Normal file
72
gen/ui/widgets/list.pt
Normal file
|
@ -0,0 +1,72 @@
|
|||
<tal:comment replace="nothing">Single row.</tal:comment>
|
||||
<tr metal:define-macro="row"
|
||||
tal:attributes="style python: (rowIndex==-1) and 'display: none' or ''">
|
||||
<td align="center" tal:repeat="fieldInfo widget/fieldsd">
|
||||
<tal:show define="widget python: fieldInfo[1];
|
||||
tagCss python: 'noStyle';
|
||||
widgetName python: '%s*%d' % (widget['name'], rowIndex)">
|
||||
<metal:call use-macro="app/ui/widgets/show/macros/field"/>
|
||||
</tal:show>
|
||||
</td>
|
||||
<tal:comment replace="nothing">Icon for removing the row</tal:comment>
|
||||
<td align="right" tal:condition="python: layoutType=='edit'">
|
||||
<img style="cursor:pointer"
|
||||
tal:attributes="src string:$appUrl/ui/delete.png;
|
||||
title python: 'Delete';
|
||||
onClick python: 'deleteRow(\'list_%s\',this)' % name"/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tal:comment replace="nothing">The whole table, edit or view.</tal:comment>
|
||||
<table metal:define-macro="table" class="grid"
|
||||
tal:define="isEdit python: layoutType == 'edit'"
|
||||
tal:condition="python: isEdit or value"
|
||||
tal:attributes="id python: 'list_%s' % name">
|
||||
<tal:comment replace="nothing">Header</tal:comment>
|
||||
<tr valign="bottom">
|
||||
<th tal:repeat="fieldInfo widget/fieldsd"
|
||||
tal:content="structure python: _(fieldInfo[1]['labelId'])">
|
||||
</th>
|
||||
<tal:comment replace="nothing">Icon for adding a new row.</tal:comment>
|
||||
<th tal:condition="isEdit">
|
||||
<img style="cursor:pointer"
|
||||
tal:attributes="src string:$appUrl/ui/plus.png;
|
||||
title python: _('add_ref');
|
||||
onClick python: 'insertRow(\'list_%s\')' % name"/>
|
||||
</th>
|
||||
</tr>
|
||||
<tal:comment replace="nothing">Template row (edit only)</tal:comment>
|
||||
<tal:templateRow define="rowIndex python:-1" condition="isEdit">
|
||||
<metal:call use-macro="app/ui/widgets/list/macros/row"/>
|
||||
</tal:templateRow>
|
||||
<tr height="7px"><td></td></tr>
|
||||
<tal:comment replace="nothing">Rows of data</tal:comment>
|
||||
<tal:rows define="rows python: inRequest and requestValue or value"
|
||||
repeat="row rows">
|
||||
<tal:row define="rowIndex repeat/row/index">
|
||||
<metal:call use-macro="app/ui/widgets/list/macros/row"/>
|
||||
</tal:row>
|
||||
</tal:rows>
|
||||
</table>
|
||||
|
||||
<tal:comment replace="nothing">View</tal:comment>
|
||||
<metal:view define-macro="view">
|
||||
<metal:call use-macro="app/ui/widgets/list/macros/table"/>
|
||||
</metal:view>
|
||||
|
||||
<tal:comment replace="nothing">Edit</tal:comment>
|
||||
<metal:edit define-macro="edit">
|
||||
<tal:comment replace="nothing">
|
||||
The following input makes Appy aware that this field is in the request.
|
||||
</tal:comment>
|
||||
<input type="hidden" tal:attributes="name name" value="">
|
||||
<metal:call use-macro="app/ui/widgets/list/macros/table"/>
|
||||
</metal:edit>
|
||||
|
||||
<tal:comment replace="nothing">Cell</tal:comment>
|
||||
<metal:cell define-macro="cell">
|
||||
<metal:call use-macro="app/ui/widgets/list/macros/table"/>
|
||||
</metal:cell>
|
||||
|
||||
<tal:comment replace="nothing">Search</tal:comment>
|
||||
<metal:search define-macro="search"></metal:search>
|
26
gen/ui/widgets/pod.pt
Normal file
26
gen/ui/widgets/pod.pt
Normal file
|
@ -0,0 +1,26 @@
|
|||
<tal:comment replace="nothing">View macro for a Pod.</tal:comment>
|
||||
<metal:view define-macro="view">
|
||||
<tal:askAction condition="widget/askAction"
|
||||
define="doLabel python:'%s_askaction' % widget['labelId'];
|
||||
chekboxId python: '%s_%s' % (contextObj.UID(), name)">
|
||||
<input type="checkbox" tal:attributes="name doLabel; id chekboxId"/>
|
||||
<label tal:attributes="for chekboxId" class="discreet"
|
||||
tal:content="python: tool.translate(doLabel)"></label>
|
||||
</tal:askAction>
|
||||
<img tal:repeat="podFormat python: tool.getPodInfo(contextObj, name)[1]"
|
||||
tal:attributes="src string: $appUrl/ui/${podFormat}.png;
|
||||
onClick python: 'generatePodDocument(\'%s\',\'%s\',\'%s\',\'%s\')' % (contextObj.UID(), name, podFormat, tool.getQueryInfo());
|
||||
title podFormat/capitalize"
|
||||
style="cursor:pointer"/>
|
||||
</metal:view>
|
||||
|
||||
<tal:comment replace="nothing">Edit macro for a Pod.</tal:comment>
|
||||
<metal:edit define-macro="edit"></metal:edit>
|
||||
|
||||
<tal:comment replace="nothing">Cell macro for a Pod.</tal:comment>
|
||||
<metal:cell define-macro="cell">
|
||||
<metal:call use-macro="app/ui/widgets/pod/macros/view"/>
|
||||
</metal:cell>
|
||||
|
||||
<tal:comment replace="nothing">Search macro for a Pod.</tal:comment>
|
||||
<metal:search define-macro="search"></metal:search>
|
260
gen/ui/widgets/ref.pt
Normal file
260
gen/ui/widgets/ref.pt
Normal file
|
@ -0,0 +1,260 @@
|
|||
<tal:comment replace="nothing">
|
||||
We begin with some sub-macros used within macro "show" defined below.
|
||||
</tal:comment>
|
||||
|
||||
<metal:objectTitle define-macro="objectTitle">
|
||||
<tal:comment replace="nothing">Displays the title of a referenced object, with a link on
|
||||
it to reach the consult view for this object. If we are on a back reference, the link
|
||||
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>
|
||||
<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);
|
||||
pageName python: appyType['isBack'] and appyType['backd']['pageName'] or 'main';
|
||||
fullUrl python: obj.getUrl(page=pageName, nav=navInfo)"
|
||||
tal:attributes="href fullUrl" tal:content="python: (not includeShownInfo) and obj.Title() or contextObj.getReferenceLabel(fieldName, obj.appy())"></a>
|
||||
</metal:objectTitle>
|
||||
|
||||
<metal:objectActions define-macro="objectActions">
|
||||
<tal:comment replace="nothing">Displays icons for triggering actions on a given
|
||||
referenced object (edit, delete, etc).</tal:comment>
|
||||
<table class="noStyle">
|
||||
<tr>
|
||||
<tal:comment replace="nothing">Arrows for moving objects up or down</tal:comment>
|
||||
<td tal:condition="python: not appyType['isBack'] and (len(objs)>1) and context.allows('Modify portal content')">
|
||||
<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 > 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 < (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 the element</tal:comment>
|
||||
<td tal:condition="python: obj.allows('Modify portal content') and not appyType['noForm']">
|
||||
<a tal:define="navInfo python:'ref.%s.%s:%s.%d.%d' % (contextObj.UID(), fieldName, appyType['pageName'], repeat['obj'].number()+startNumber, totalNumber);"
|
||||
tal:attributes="href python: obj.getUrl(mode='edit', page='main', nav=navInfo)">
|
||||
<img title="label_edit" i18n:domain="plone" i18n:attributes="title"
|
||||
tal:attributes="src string: $appUrl/ui/edit.gif"/>
|
||||
</a>
|
||||
</td>
|
||||
<tal:comment replace="nothing">Delete the element</tal:comment>
|
||||
<td>
|
||||
<img tal:condition="python: not appyType['isBack'] and obj.allows('Delete objects') and obj.mayDelete()"
|
||||
title="Delete" i18n:domain="plone" i18n:attributes="title" style="cursor:pointer"
|
||||
tal:attributes="src string: $appUrl/ui/delete.png;
|
||||
onClick python:'onDeleteObject(\'%s\')' % obj.UID()"/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</metal:objectActions>
|
||||
|
||||
<metal:plusIcon define-macro="plusIcon">
|
||||
<tal:comment replace="nothing">Displays the "plus" icon that allows to add new object
|
||||
through a reference widget. Indeed, If field was declared as "addable", we must provide
|
||||
an icon for creating a new linked object (at least if multiplicities allow it).</tal:comment>
|
||||
<img style="cursor:pointer" tal:condition="showPlusIcon"
|
||||
tal:define="navInfo python:'ref.%s.%s:%s.%d.%d' % (contextObj.UID(), fieldName, appyType['pageName'], 0, totalNumber);
|
||||
formCall python:'window.location=\'%s/do?action=Create&className=%s&nav=%s\'' % (folder.absolute_url(), linkedPortalType, navInfo);
|
||||
formCall python: test(appyType['addConfirm'], 'askConfirm(\'script\', "%s", "%s")' % (formCall, addConfirmMsg), formCall);
|
||||
noFormCall python: navBaseCall.replace('**v**', '%d, \'CreateWithoutForm\'' % startNumber);
|
||||
noFormCall python: test(appyType['addConfirm'], 'askConfirm(\'script\', "%s", "%s")' % (noFormCall, addConfirmMsg), noFormCall)"
|
||||
tal:attributes="src string:$appUrl/ui/plus.png;
|
||||
title python: _('add_ref');
|
||||
onClick python: test(appyType['noForm'], noFormCall, formCall)"/>
|
||||
</metal:plusIcon>
|
||||
|
||||
<tal:comment replace="nothing">
|
||||
This macro displays, in a cell header from a ref table, icons for sorting the
|
||||
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, widget['name']))"
|
||||
tal:condition="python: canWrite and tool.isSortable(widget['name'], objs[0].meta_type, 'ref')">
|
||||
<img style="cursor:pointer"
|
||||
tal:attributes="src string:$appUrl/ui/sortAsc.png;
|
||||
onClick python: ajaxBaseCall.replace('**v**', 'False')"/>
|
||||
<img style="cursor:pointer"
|
||||
tal:attributes="src string:$appUrl/ui/sortDesc.png;
|
||||
onClick python: ajaxBaseCall.replace('**v**', 'True')"/>
|
||||
</metal:sortIcons>
|
||||
|
||||
<tal:comment replace="nothing">View macro for a Ref.</tal:comment>
|
||||
<div metal:define-macro="view"
|
||||
tal:define= "innerRef innerRef|python:False;
|
||||
ajaxHookId python: contextObj.UID() + name"
|
||||
tal:attributes = "id ajaxHookId">
|
||||
<script name="appyHook" tal:content="python: 'askRefField(\'%s\',\'%s\',\'%s\',\'%s\',0)' % (ajaxHookId, contextObj.absolute_url(), name, innerRef)">
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<tal:comment replace="nothing">
|
||||
This macro is called by a XmlHttpRequest for displaying the paginated
|
||||
referred objects of a reference field.
|
||||
</tal:comment>
|
||||
<div metal:define-macro="viewContent"
|
||||
tal:define="fieldName request/fieldName;
|
||||
appyType python: contextObj.getAppyType(fieldName, asDict=True);
|
||||
innerRef python: test(request['innerRef']=='True', True, False);
|
||||
ajaxHookId python: contextObj.UID()+fieldName;
|
||||
startNumber python: int(request.get('%s_startNumber' % ajaxHookId, 0));
|
||||
tool contextObj/getTool;
|
||||
_ python: tool.translate;
|
||||
refObjects python:contextObj.getAppyRefs(fieldName, startNumber);
|
||||
objs refObjects/objects;
|
||||
totalNumber refObjects/totalNumber;
|
||||
batchSize refObjects/batchSize;
|
||||
folder python: contextObj.isPrincipiaFolderish and contextObj or contextObj.getParentNode();
|
||||
linkedPortalType python: tool.getPortalType(appyType['klass']);
|
||||
addPermission python: '%s: Add %s' % (tool.getAppName(), linkedPortalType);
|
||||
canWrite python: not appyType['isBack'] and contextObj.allows(appyType['writePermission']);
|
||||
multiplicity appyType/multiplicity;
|
||||
maxReached python:(multiplicity[1] != None) and (len(objs) >= multiplicity[1]);
|
||||
showPlusIcon python:not appyType['isBack'] and appyType['add'] and not maxReached and user.has_permission(addPermission, folder) and canWrite;
|
||||
atMostOneRef python: (multiplicity[1] == 1) and (len(objs)<=1);
|
||||
label python: contextObj.translate('label', field=appyType);
|
||||
addConfirmMsg python: appyType['addConfirm'] and _('%s_addConfirm' % appyType['labelId']) or '';
|
||||
navBaseCall python: 'askRefField(\'%s\',\'%s\',\'%s\',\'%s\',**v**)' % (ajaxHookId, contextObj.absolute_url(), fieldName, innerRef)">
|
||||
|
||||
<tal:comment replace="nothing">This macro displays the Reference widget on a "view" page.
|
||||
|
||||
The definition of "atMostOneRef" above may sound strange: we shouldn't check the actual number
|
||||
of referenced objects. But for back references people often forget to specify multiplicities.
|
||||
So concretely, multiplicities (0,None) are coded as (0,1).</tal:comment>
|
||||
<tal:atMostOneReference condition="atMostOneRef">
|
||||
<tal:comment replace="nothing">Display a simplified widget if maximum number of
|
||||
referenced objects is 1.</tal:comment>
|
||||
<table><tr valign="top">
|
||||
<td><span class="appyLabel" tal:condition="python: not innerRef and not appyType['link']"
|
||||
tal:content="structure label"></span></td>
|
||||
|
||||
<tal:comment replace="nothing">If there is no object...</tal:comment>
|
||||
<tal:noObject condition="not:objs">
|
||||
<td tal:content="python: _('no_ref')"></td>
|
||||
<td><metal:plusIcon use-macro="app/ui/widgets/ref/macros/plusIcon"/></td>
|
||||
</tal:noObject>
|
||||
|
||||
<tal:comment replace="nothing">If there is an object...</tal:comment>
|
||||
<tal:objectIsPresent condition="python: objs">
|
||||
<tal:obj repeat="obj objs">
|
||||
<td tal:define="includeShownInfo python:True"><metal:showObjectTitle use-macro="app/ui/widgets/ref/macros/objectTitle" /></td>
|
||||
</tal:obj>
|
||||
</tal:objectIsPresent>
|
||||
</tr></table>
|
||||
</tal:atMostOneReference>
|
||||
|
||||
<tal:comment replace="nothing">Display a fieldset in all other cases.</tal:comment>
|
||||
<tal:anyNumberOfReferences condition="not: atMostOneRef">
|
||||
<fieldset tal:attributes="class python:test(innerRef, 'innerAppyFieldset', '')">
|
||||
<legend tal:condition="python: not innerRef or showPlusIcon">
|
||||
<span tal:condition="not: innerRef" tal:content="label"/>
|
||||
(<span tal:replace="totalNumber"/>)
|
||||
<metal:plusIcon use-macro="app/ui/widgets/ref/macros/plusIcon"/>
|
||||
<tal:comment replace="nothing">The search icon if field is queryable</tal:comment>
|
||||
<a tal:condition="python: objs and appyType['queryable']"
|
||||
tal:attributes="href python: '%s/ui/search?className=%s&ref=%s:%s' % (tool.absolute_url(), linkedPortalType, contextObj.UID(), appyType['name'])">
|
||||
<img src="search.gif" tal:attributes="title python: _('search_objects')"/></a>
|
||||
</legend>
|
||||
|
||||
<tal:comment replace="nothing">Object description</tal:comment>
|
||||
<p class="discreet" tal:condition="python: not innerRef and appyType['hasDescr']"
|
||||
tal:content="python: contextObj.translate('descr', field=appyType)"></p>
|
||||
|
||||
<tal:comment replace="nothing">Appy (top) navigation</tal:comment>
|
||||
<metal:nav use-macro="here/ui/navigate/macros/appyNavigate"/>
|
||||
|
||||
<tal:comment replace="nothing">No object is present</tal:comment>
|
||||
<p tal:condition="not:objs" tal:content="python: _('no_ref')"></p>
|
||||
|
||||
<table width="100%" tal:condition="python: objs"
|
||||
tal:attributes="class python:test(innerRef, 'innerAppyTable', '')">
|
||||
<tr valign="bottom"><td>
|
||||
|
||||
<tal:comment replace="nothing">Show forward or backward reference(s)</tal:comment>
|
||||
<table tal:attributes="class python:test(innerRef, '', 'list');
|
||||
width python:test(innerRef, '100%', appyType['layouts']['view']['width']);">
|
||||
<tal:widgets define="widgets python: objs[0].getAppyTypesFromNames(appyType['shownInfo'])">
|
||||
<tr tal:condition="appyType/showHeaders">
|
||||
<th tal:repeat="widget widgets">
|
||||
<span tal:content="python: _(widget['labelId'])"></span>
|
||||
<metal:sortIcons use-macro="app/ui/widgets/ref/macros/sortIcons" />
|
||||
</th>
|
||||
<th tal:content="python: _('ref_actions')"></th>
|
||||
</tr>
|
||||
<tal:row repeat="obj objs">
|
||||
<tr valign="middle" 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"/>
|
||||
</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:field define="contextObj python:obj;
|
||||
layoutType python: 'cell';
|
||||
innerRef python:True">
|
||||
<metal:field use-macro="app/ui/widgets/show/macros/field" />
|
||||
</tal:field>
|
||||
</tal:other>
|
||||
</td>
|
||||
<tal:comment replace="nothing">Actions</tal:comment>
|
||||
<td align="right">
|
||||
<metal:showObjectActions use-macro="app/ui/widgets/ref/macros/objectActions" />
|
||||
</td>
|
||||
</tr>
|
||||
</tal:row>
|
||||
</tal:widgets>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
|
||||
<tal:comment replace="nothing">Appy (bottom) navigation</tal:comment>
|
||||
<metal:nav use-macro="context/ui/navigate/macros/appyNavigate"/>
|
||||
|
||||
</fieldset>
|
||||
<tal:comment replace="nothing">A carriage return needed in some cases.</tal:comment>
|
||||
</tal:anyNumberOfReferences>
|
||||
</div>
|
||||
|
||||
<tal:comment replace="nothing">Edit macro for an Ref.</tal:comment>
|
||||
<metal:editRef define-macro="edit"
|
||||
tal:condition="widget/link"
|
||||
tal:define="requestValue python: request.get(name, []);
|
||||
inRequest python: request.has_key(name);
|
||||
allObjects python: contextObj.getSelectableAppyRefs(name);
|
||||
refUids python: [o.UID() for o in contextObj.getAppyRefs(name)['objects']];
|
||||
isBeingCreated python: contextObj.isTemporary() or ('/portal_factory/' in contextObj.absolute_url())">
|
||||
|
||||
<select tal:attributes="name name;
|
||||
size python: test(isMultiple, widget['height'], '');
|
||||
multiple python: test(isMultiple, 'multiple', '')">
|
||||
<option tal:condition="not: isMultiple" tal:content="python: _('choose_a_value')"></option>
|
||||
<tal:ref repeat="refObj allObjects">
|
||||
<option tal:define="uid python: contextObj.getReferenceUid(refObj)"
|
||||
tal:content="python: contextObj.getReferenceLabel(name, refObj)"
|
||||
tal:attributes="value uid;
|
||||
selected python:(inRequest and (uid in requestValue) or (not inRequest and ((uid in refUids)))) and True or False">
|
||||
</option>
|
||||
</tal:ref>
|
||||
</select>
|
||||
</metal:editRef>
|
||||
|
||||
<tal:comment replace="nothing">Cell macro for a Ref.</tal:comment>
|
||||
<metal:cell define-macro="cell">
|
||||
<metal:call use-macro="app/ui/widgets/ref/macros/view"/>
|
||||
</metal:cell>
|
||||
|
||||
<tal:comment replace="nothing">Search macro for a Ref.</tal:comment>
|
||||
<metal:search define-macro="search"></metal:search>
|
214
gen/ui/widgets/show.pt
Normal file
214
gen/ui/widgets/show.pt
Normal file
|
@ -0,0 +1,214 @@
|
|||
<tal:comment replace="nothing">
|
||||
This macro shows the content of a layouted object, like a page or widget.
|
||||
It requires:
|
||||
contextObj The Zope object on which we are working
|
||||
layoutType The kind of layout: "view"? "edit"? "cell"?
|
||||
layout The layout object that will dictate how object content
|
||||
will be rendered.
|
||||
Options:
|
||||
contextMacro The base folder containing the macros to call for
|
||||
rendering the elements within the layout.
|
||||
Defaults to app.ui
|
||||
tagId The name and id of the main tag for this layout (used
|
||||
a.o. for master/slave relationships).
|
||||
tagCss Some additional CSS class for the main tag
|
||||
(ie, the CSS class for a slave).
|
||||
</tal:comment>
|
||||
<metal:show define-macro="layout"
|
||||
tal:define="contextMacro contextMacro| python: app.ui;
|
||||
tagId tagId|python:'';
|
||||
tagCss tagCss|python:'';
|
||||
layoutCss layout/css_class;">
|
||||
<table tal:attributes="cellpadding layout/cellpadding;
|
||||
cellspacing layout/cellspacing;
|
||||
width layout/width;
|
||||
align layout/align;
|
||||
class python: tagCss and ('%s %s' % (tagCss, layoutCss)).strip() or layoutCss;
|
||||
style layout/style;
|
||||
id tagId;
|
||||
name tagId;">
|
||||
<tal:comment replace="nothing">The table header row</tal:comment>
|
||||
<tr tal:condition="layout/headerRow" tal:attributes="valign layout/headerRow/valign">
|
||||
<th tal:repeat="cell layout/headerRow/cells"
|
||||
tal:attributes="align cell/align; width cell/width;">
|
||||
</th>
|
||||
</tr>
|
||||
<tal:comment replace="nothing">The table content</tal:comment>
|
||||
<tr tal:repeat="row layout/rows" tal:attributes="valign row/valign">
|
||||
<td tal:repeat="cell row/cells"
|
||||
tal:attributes="align cell/align; colspan cell/colspan;
|
||||
style python: test(repeat['cell'].end, '', 'padding-right: 0.4em')"><tal:content repeat="elem cell/content"><tal:field condition="python: elem == '?'"><metal:call use-macro="python: getattr(contextMacro, widget['type'].lower()).macros[layoutType]"/></tal:field><tal:other condition="python: elem != '?'"><metal:call use-macro="python: getattr(contextMacro, elem[0]).macros[elem[1]]"/></tal:other><img tal:condition="not: repeat/elem/end" tal:attributes="src string: $appUrl/ui/space.gif"/></tal:content>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</metal:show>
|
||||
|
||||
<tal:comment replace="nothing">
|
||||
This macro displays the widget corresponding to a given field. It requires:
|
||||
contextObj The Zope object for which this widget must be rendered
|
||||
page The page where the widget lies
|
||||
layoutType "edit"? "view"? "cell?"
|
||||
widget The widget to render
|
||||
|
||||
Optionally:
|
||||
widgetName If the field to show is within a List, we cheat and
|
||||
include, within the widgetName, the row index.
|
||||
</tal:comment>
|
||||
<metal:field define-macro="field"
|
||||
tal:define="contextMacro python: app.ui.widgets;
|
||||
layout python: widget['layouts'][layoutType];
|
||||
name widgetName| widget/name;
|
||||
sync python: widget['sync'][layoutType];
|
||||
outerValue value|nothing;
|
||||
rawValue python: contextObj.getFieldValue(name,onlyIfSync=True,layoutType=layoutType,outerValue=outerValue);
|
||||
value python: contextObj.getFormattedFieldValue(name, rawValue);
|
||||
requestValue python: contextObj.getRequestFieldValue(name);
|
||||
inRequest python: request.has_key(name);
|
||||
errors errors | python: ();
|
||||
inError python: name in errors;
|
||||
isMultiple python: (widget['multiplicity'][1] == None) or (widget['multiplicity'][1] > 1);
|
||||
masterCss python: widget['slaves'] and ('master_%s' % name) or '';
|
||||
slaveCss python: widget['master'] and ('slave_%s_%s' % (widget['masterName'], '_'.join(widget['masterValue']))) or '';
|
||||
tagCss tagCss | python:'';
|
||||
tagCss python: ('%s %s' % (slaveCss, tagCss)).strip();
|
||||
tagId python: widget['master'] and 'slave' or ''">
|
||||
<metal:layout use-macro="context/ui/widgets/show/macros/layout"/>
|
||||
</metal:field>
|
||||
|
||||
<tal:comment replace="nothing">
|
||||
This macro displays the widget corresponding to a group of widgets.
|
||||
It requires:
|
||||
contextObj The Zope object for which this widget must be rendered
|
||||
page The page where the widget lies
|
||||
layoutType "edit"? "view"? "cell?"
|
||||
widget The widget to render
|
||||
</tal:comment>
|
||||
<metal:group define-macro="group"
|
||||
tal:define="tagCss python: widget['master'] and ('slave_%s_%s' % (widget['masterName'], '_'.join(widget['masterValue']))) or '';
|
||||
widgetCss widget/css_class;
|
||||
groupCss python: tagCss and ('%s %s' % (tagCss, widgetCss)) or widgetCss;
|
||||
tagId python: widget['master'] and 'slave' or ''">
|
||||
<fieldset tal:condition="python: widget['style'] == 'fieldset'">
|
||||
<legend tal:condition="widget/hasLabel">
|
||||
<i tal:content="structure python: contextObj.translate(widget['labelId'])"></i>
|
||||
<tal:help condition="widget/hasHelp">
|
||||
<metal:call use-macro="app/ui/widgets/show/macros/help"/>
|
||||
</tal:help>
|
||||
</legend>
|
||||
<div tal:condition="widget/hasDescr" class="discreet"
|
||||
tal:content="structure python: contextObj.translate(widget['descrId'])"></div>
|
||||
<metal:content use-macro="app/ui/widgets/show/macros/groupContent"/>
|
||||
</fieldset>
|
||||
<tal:asSection condition="python: widget['style'] not in ('fieldset', 'tabs')">
|
||||
<metal:content use-macro="app/ui/widgets/show/macros/groupContent"/>
|
||||
</tal:asSection>
|
||||
<tal:asTabs condition="python: widget['style'] == 'tabs'">
|
||||
<table tal:attributes="width widget/wide;
|
||||
class groupCss;
|
||||
id tagId; name tagId">
|
||||
<tal:comment replace="nothing">First row: the tabs.</tal:comment>
|
||||
<tr valign="middle"><td style="border-bottom: 1px solid #ff8040">
|
||||
<table style="position:relative; bottom:-1px;">
|
||||
<tr valign="middle">
|
||||
<tal:tab repeat="widgetRow widget/widgets">
|
||||
<tal:id define="tabId python:'tab_%s_%d_%d' % (widget['name'], repeat['widgetRow'].number(), len(widget['widgets']))">
|
||||
<td><img tal:attributes="src string: $appUrl/ui/tabLeft.png;
|
||||
id python: '%s_left' % tabId"/><td>
|
||||
<td tal:attributes="style python:'background-image: url(%s/ui/tabBg.png)' % appUrl;
|
||||
id tabId">
|
||||
<a style="cursor:pointer"
|
||||
tal:content="python: tool.translate('%s_col%d' % (widget['labelId'], repeat['widgetRow'].number()))"
|
||||
tal:attributes="onClick python: 'showTab(\'%s_%d_%d\')' % (widget['name'], repeat['widgetRow'].number(), len(widget['widgets']))"></a>
|
||||
</td>
|
||||
<td><img tal:attributes="src string: $appUrl/ui/tabRight.png;
|
||||
id python: '%s_right' % tabId"/><td>
|
||||
</tal:id>
|
||||
</tal:tab>
|
||||
</tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
<tal:comment replace="nothing">Other rows: the widgets.</tal:comment>
|
||||
<tr tal:repeat="widgetRow widget/widgets"
|
||||
tal:attributes="id python: 'tabcontent_%s_%d_%d' % (widget['name'], repeat['widgetRow'].number(), len(widget['widgets']));
|
||||
style python: test(repeat['widgetRow'].number()==1, 'display:table-row', 'display:none')">
|
||||
<td tal:define="widget python: widgetRow[0]">
|
||||
<tal:group condition="python: widget['type'] == 'group'">
|
||||
<metal:call use-macro="app/ui/widgets/show/macros/group"/>
|
||||
</tal:group>
|
||||
<tal:field condition="python: widget['type'] != 'group'">
|
||||
<metal:call use-macro="app/ui/widgets/show/macros/field"/>
|
||||
</tal:field>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<script language="javascript"
|
||||
tal:content="python: 'initTab(\'tab_%s\', \'%s_1_%d\')' % (widget['name'], widget['name'], len(widget['widgets']))"></script>
|
||||
</tal:asTabs>
|
||||
</metal:group>
|
||||
|
||||
<tal:comment replace="nothing">
|
||||
This macro displays the content of a group of widgets.
|
||||
It is exclusively called by macro "group" above.
|
||||
</tal:comment>
|
||||
<table metal:define-macro="groupContent"
|
||||
tal:define="cellgap widget/cellgap"
|
||||
tal:attributes="width widget/wide;
|
||||
align widget/align;
|
||||
class groupCss;
|
||||
cellspacing widget/cellspacing;
|
||||
cellpadding widget/cellpadding;
|
||||
id tagId; name tagId">
|
||||
<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']);
|
||||
class widget/style" align="left">
|
||||
<span tal:replace="structure python: contextObj.translate(widget['labelId'])"/>
|
||||
<tal:help condition="widget/hasHelp">
|
||||
<metal:call use-macro="app/ui/widgets/show/macros/help"/>
|
||||
</tal:help>
|
||||
</td>
|
||||
</tr>
|
||||
<tr tal:condition="python: (widget['style'] != 'fieldset') and widget['hasDescr']">
|
||||
<td tal:attributes="colspan python: len(widget['columnsWidths'])" class="discreet"
|
||||
tal:content="structure python: contextObj.translate(widget['descrId'])">
|
||||
</td>
|
||||
</tr>
|
||||
<tr> <tal:comment replace="nothing">The column headers</tal:comment>
|
||||
<th tal:repeat="colNb python:range(len(widget['columnsWidths']))"
|
||||
tal:attributes="width python:widget['columnsWidths'][colNb];
|
||||
align python:widget['columnsAligns'][colNb]"
|
||||
tal:content="structure python: widget['hasHeaders'] and contextObj.translate('%s_col%d' % (widget['labelId'], colNb+1)) or ''">
|
||||
</th>
|
||||
</tr>
|
||||
<tal:comment replace="nothing">The rows of widgets</tal:comment>
|
||||
<tr tal:attributes="valign widget/valign" tal:repeat="widgetRow widget/widgets">
|
||||
<td tal:repeat="widget widgetRow"
|
||||
tal:attributes="colspan widget/colspan|python:1;
|
||||
style python: test(repeat['widget'].number() != len(widgetRow), 'padding-right: %s'%cellgap, '')">
|
||||
<tal:showWidget condition="widget">
|
||||
<tal:group condition="python: widget['type'] == 'group'">
|
||||
<metal:call use-macro="app/ui/widgets/show/macros/group"/>
|
||||
</tal:group>
|
||||
<tal:field condition="python: widget['type'] != 'group'">
|
||||
<metal:call use-macro="app/ui/widgets/show/macros/field"/>
|
||||
</tal:field>
|
||||
</tal:showWidget>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<tal:comment replace="nothing">Displays a field label.</tal:comment>
|
||||
<tal:label metal:define-macro="label" condition="widget/hasLabel"><label tal:attributes="for widget/name" tal:condition="python: not ((widget['type'] == 'Action') or ((widget['type'] == 'Ref') and (widget['add'])))" tal:content="structure python: contextObj.translate('label', field=widget)"></label></tal:label>
|
||||
|
||||
<tal:comment replace="nothing">Displays a field description.</tal:comment>
|
||||
<tal:description metal:define-macro="description" condition="widget/hasDescr"><span class="discreet" tal:content="structure python: contextObj.translate('descr', field=widget)"></span>
|
||||
</tal:description>
|
||||
|
||||
<tal:comment replace="nothing">Displays a field help.</tal:comment>
|
||||
<tal:help metal:define-macro="help"><acronym tal:attributes="title python: contextObj.translate('help', field=widget)"><img tal:attributes="src string: $appUrl/ui/help.png"/></acronym></tal:help>
|
||||
|
||||
<tal:comment replace="nothing">Displays validation-error-related info about a field.</tal:comment>
|
||||
<tal:validation metal:define-macro="validation"><acronym tal:condition="inError" tal:attributes="title python: errors[name]"><img tal:attributes="src string: $appUrl/ui/warning.png"/></acronym><img tal:condition="not: inError" tal:attributes="src string: $appUrl/ui/warning_no.gif"/></tal:validation>
|
||||
|
||||
<tal:comment replace="nothing">Displays the fact that a field is required.</tal:comment>
|
||||
<tal:required metal:define-macro="required"><img tal:attributes="src string: $appUrl/ui/required.gif"/></tal:required>
|
107
gen/ui/widgets/string.pt
Normal file
107
gen/ui/widgets/string.pt
Normal file
|
@ -0,0 +1,107 @@
|
|||
<tal:comment replace="nothing">View macro for a String.</tal:comment>
|
||||
<metal:view define-macro="view"
|
||||
tal:define="fmt widget/format">
|
||||
<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"/>
|
||||
<span tal:condition="python: fmt == 3">********</span>
|
||||
</tal:singleValue>
|
||||
</span>
|
||||
<tal:formattedString condition="python: fmt not in (0, 3)">
|
||||
<span tal:condition="python: value and (fmt == 1)"
|
||||
tal:replace="structure python: contextObj.formatText(value, format='html')"/>
|
||||
<span tal:condition="python: value and (fmt == 2)" tal:replace="structure value"/>
|
||||
</tal:formattedString>
|
||||
<input type="hidden" tal:condition="masterCss"
|
||||
tal:attributes="class masterCss; value rawValue; name name; id name"/>
|
||||
</metal:view>
|
||||
|
||||
<tal:comment replace="nothing">Edit macro for a String.</tal:comment>
|
||||
<metal:edit define-macro="edit"
|
||||
tal:define="fmt widget/format;
|
||||
isSelect widget/isSelect;
|
||||
isMaster widget/slaves;
|
||||
isOneLine python: fmt in (0,3);
|
||||
maxChars python: test(widget['maxChars'], widget['maxChars'], '')">
|
||||
|
||||
<tal:choice condition="isSelect">
|
||||
<select tal:define="possibleValues python:contextObj.getPossibleValues(name, withTranslations=True, withBlankValue=True)"
|
||||
tal:attributes="name name;
|
||||
id name;
|
||||
multiple python: isMultiple and 'multiple' or '';
|
||||
onchange python: isMaster and 'updateSlaves(this)' or '';
|
||||
class masterCss;
|
||||
size python: isMultiple and widget['height'] or 1">
|
||||
<option tal:repeat="possibleValue possibleValues"
|
||||
tal:attributes="value python: possibleValue[0];
|
||||
selected python:contextObj.fieldValueSelected(name, possibleValue[0], rawValue);
|
||||
title python: possibleValue[1]"
|
||||
tal:content="python:tool.truncateValue(possibleValue[1], widget)"></option>
|
||||
</select>
|
||||
</tal:choice>
|
||||
<tal:line condition="python: isOneLine and not isSelect">
|
||||
<input tal:attributes="id name; name name; size widget/width; maxlength maxChars;
|
||||
value python: test(inRequest, requestValue, value);
|
||||
style python: 'text-transform:%s' % widget['transform'];
|
||||
type python: (widget['format'] == 3) and 'password' or 'text'"/>
|
||||
</tal:line>
|
||||
<tal:textarea condition="python: fmt in (1,2)">
|
||||
<script tal:condition="python: fmt == 2"
|
||||
tal:content="python: contextObj.getEditorInit(name)">
|
||||
</script>
|
||||
<textarea tal:attributes="id name; name name;
|
||||
cols widget/width;
|
||||
rows widget/height;
|
||||
style python: 'text-transform:%s' % widget['transform'];
|
||||
class python: (fmt==2) and ('rich_%s' % name) or ''"
|
||||
tal:content="python: test(inRequest, requestValue, value)">
|
||||
</textarea>
|
||||
</tal:textarea>
|
||||
</metal:edit>
|
||||
|
||||
<tal:comment replace="nothing">Cell macro for a String.</tal:comment>
|
||||
<metal:cell define-macro="cell"
|
||||
tal:define="multipleValues python: value and isMultiple">
|
||||
<tal:multiple condition="multipleValues"
|
||||
content="python: ', '.join(value)">
|
||||
</tal:multiple>
|
||||
<tal:notMultiple condition="not: multipleValues">
|
||||
<metal:call use-macro="app/ui/widgets/string/macros/view"/>
|
||||
</tal:notMultiple>
|
||||
</metal:cell>
|
||||
|
||||
<tal:comment replace="nothing">Search macro for a String.</tal:comment>
|
||||
<metal:search define-macro="search">
|
||||
<label tal:attributes="for widgetName" tal:content="python: tool.translate(widget['labelId'])"></label><br>
|
||||
<tal:comment replace="nothing">Show a simple search field for most String fields.</tal:comment>
|
||||
<tal:simpleSearch condition="not: widget/isSelect">
|
||||
<input type="text" tal:define="maxChars python: test(widget['maxChars'], widget['maxChars'], '')"
|
||||
tal:attributes="name python: '%s*string-%s' % (widgetName, widget['transform']);
|
||||
maxlength maxChars;
|
||||
style python: 'text-transform:%s' % widget['transform']"/>
|
||||
</tal:simpleSearch>
|
||||
<tal:comment replace="nothing">Show a multi-selection box for fields whose
|
||||
validator defines a list of values, with a "AND/OR" checkbox.</tal:comment>
|
||||
<tal:selectSearch condition="widget/isSelect">
|
||||
<tal:comment replace="nothing">The "and" / "or" radio buttons</tal:comment>
|
||||
<tal:operator define="operName python: 'o_%s' % name;
|
||||
orName python: '%s_or' % operName;
|
||||
andName python: '%s_and' % operName;"
|
||||
condition="python: widget['multiplicity'][1]!=1">
|
||||
<input type="radio" tal:attributes="name operName; id orName" checked="checked" value="or"/>
|
||||
<label tal:attributes="for orName" tal:content="python: tool.translate('search_or')"></label>
|
||||
<input type="radio" tal:attributes="name operName; id andName" value="and"/>
|
||||
<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; 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)">
|
||||
</option>
|
||||
</select>
|
||||
</tal:selectSearch><br/>
|
||||
</metal:search>
|
Loading…
Add table
Add a link
Reference in a new issue