2010-08-05 11:23:17 -05:00
|
|
|
<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:
|
2011-01-28 07:36:30 -06:00
|
|
|
contextMacro The base folder containing the macros to call for
|
2010-08-05 11:23:17 -05:00
|
|
|
rendering the elements within the layout.
|
2011-11-25 11:01:20 -06:00
|
|
|
Defaults to app.ui
|
2011-10-19 02:37:44 -05:00
|
|
|
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).
|
2010-08-05 11:23:17 -05:00
|
|
|
</tal:comment>
|
|
|
|
<metal:show define-macro="layout"
|
2011-11-25 11:01:20 -06:00
|
|
|
tal:define="contextMacro contextMacro| python: app.ui;
|
2011-10-19 02:37:44 -05:00
|
|
|
tagId tagId|python:'';
|
|
|
|
tagCss tagCss|python:'';
|
2011-10-01 15:40:13 -05:00
|
|
|
layoutCss layout/css_class;">
|
2010-08-05 11:23:17 -05:00
|
|
|
<table tal:attributes="cellpadding layout/cellpadding;
|
|
|
|
cellspacing layout/cellspacing;
|
|
|
|
width layout/width;
|
|
|
|
align layout/align;
|
2011-10-27 10:55:17 -05:00
|
|
|
class python: tagCss and ('%s %s' % (tagCss, layoutCss)).strip() or layoutCss;
|
2011-10-01 15:40:13 -05:00
|
|
|
style layout/style;
|
2011-10-19 02:37:44 -05:00
|
|
|
id tagId;
|
|
|
|
name tagId;">
|
2010-08-05 11:23:17 -05:00
|
|
|
<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;
|
2011-11-25 11:01:20 -06:00
|
|
|
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>
|
2010-08-05 11:23:17 -05:00
|
|
|
</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
|
2011-10-19 02:37:44 -05:00
|
|
|
|
|
|
|
Optionally:
|
|
|
|
widgetName If the field to show is within a List, we cheat and
|
|
|
|
include, within the widgetName, the row index.
|
2010-08-05 11:23:17 -05:00
|
|
|
</tal:comment>
|
|
|
|
<metal:field define-macro="field"
|
2011-11-25 11:01:20 -06:00
|
|
|
tal:define="contextMacro python: app.ui.widgets;
|
2011-10-01 15:40:13 -05:00
|
|
|
layout python: widget['layouts'][layoutType];
|
2011-10-19 02:37:44 -05:00
|
|
|
name widgetName| widget/name;
|
2011-10-01 15:40:13 -05:00
|
|
|
sync python: widget['sync'][layoutType];
|
2011-10-26 03:21:09 -05:00
|
|
|
outerValue value|nothing;
|
|
|
|
rawValue python: contextObj.getFieldValue(name,onlyIfSync=True,layoutType=layoutType,outerValue=outerValue);
|
2011-10-01 15:40:13 -05:00
|
|
|
value python: contextObj.getFormattedFieldValue(name, rawValue);
|
2011-10-19 02:37:44 -05:00
|
|
|
requestValue python: contextObj.getRequestFieldValue(name);
|
2011-10-01 15:40:13 -05:00
|
|
|
inRequest python: request.has_key(name);
|
|
|
|
errors errors | python: ();
|
2011-10-19 02:37:44 -05:00
|
|
|
inError python: name in errors;
|
2011-10-01 15:40:13 -05:00
|
|
|
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 '';
|
2011-10-27 10:55:17 -05:00
|
|
|
tagCss tagCss | python:'';
|
|
|
|
tagCss python: ('%s %s' % (slaveCss, tagCss)).strip();
|
2011-10-19 02:37:44 -05:00
|
|
|
tagId python: widget['master'] and 'slave' or ''">
|
2011-11-25 11:01:20 -06:00
|
|
|
<metal:layout use-macro="context/ui/widgets/show/macros/layout"/>
|
2010-08-05 11:23:17 -05:00
|
|
|
</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>
|
2011-10-01 15:40:13 -05:00
|
|
|
<metal:group define-macro="group"
|
2011-10-19 02:37:44 -05:00
|
|
|
tal:define="tagCss python: widget['master'] and ('slave_%s_%s' % (widget['masterName'], '_'.join(widget['masterValue']))) or '';
|
2011-10-01 15:40:13 -05:00
|
|
|
widgetCss widget/css_class;
|
2011-10-19 02:37:44 -05:00
|
|
|
groupCss python: tagCss and ('%s %s' % (tagCss, widgetCss)) or widgetCss;
|
|
|
|
tagId python: widget['master'] and 'slave' or ''">
|
2010-08-05 11:23:17 -05:00
|
|
|
<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">
|
2011-11-25 11:01:20 -06:00
|
|
|
<metal:call use-macro="app/ui/widgets/show/macros/help"/>
|
2010-08-05 11:23:17 -05:00
|
|
|
</tal:help>
|
|
|
|
</legend>
|
|
|
|
<div tal:condition="widget/hasDescr" class="discreet"
|
|
|
|
tal:content="structure python: contextObj.translate(widget['descrId'])"></div>
|
2011-11-25 11:01:20 -06:00
|
|
|
<metal:content use-macro="app/ui/widgets/show/macros/groupContent"/>
|
2010-08-05 11:23:17 -05:00
|
|
|
</fieldset>
|
|
|
|
<tal:asSection condition="python: widget['style'] not in ('fieldset', 'tabs')">
|
2011-11-25 11:01:20 -06:00
|
|
|
<metal:content use-macro="app/ui/widgets/show/macros/groupContent"/>
|
2010-08-05 11:23:17 -05:00
|
|
|
</tal:asSection>
|
|
|
|
<tal:asTabs condition="python: widget['style'] == 'tabs'">
|
2011-10-01 15:40:13 -05:00
|
|
|
<table tal:attributes="width widget/wide;
|
|
|
|
class groupCss;
|
2011-10-19 02:37:44 -05:00
|
|
|
id tagId; name tagId">
|
2010-08-05 11:23:17 -05:00
|
|
|
<tal:comment replace="nothing">First row: the tabs.</tal:comment>
|
2010-08-27 01:59:53 -05:00
|
|
|
<tr valign="middle"><td style="border-bottom: 1px solid #ff8040">
|
2011-12-09 01:56:37 -06:00
|
|
|
<table style="position:relative; bottom:-2px;" cellpadding="0" cellspacing="0">
|
|
|
|
<tr valign="bottom">
|
2010-08-05 11:23:17 -05:00
|
|
|
<tal:tab repeat="widgetRow widget/widgets">
|
|
|
|
<tal:id define="tabId python:'tab_%s_%d_%d' % (widget['name'], repeat['widgetRow'].number(), len(widget['widgets']))">
|
2011-11-25 11:01:20 -06:00
|
|
|
<td><img tal:attributes="src string: $appUrl/ui/tabLeft.png;
|
2010-08-05 11:23:17 -05:00
|
|
|
id python: '%s_left' % tabId"/><td>
|
2011-11-25 11:01:20 -06:00
|
|
|
<td tal:attributes="style python:'background-image: url(%s/ui/tabBg.png)' % appUrl;
|
2010-08-05 11:23:17 -05:00
|
|
|
id tabId">
|
|
|
|
<a style="cursor:pointer"
|
2012-06-03 11:34:56 -05:00
|
|
|
tal:content="python: _('%s_col%d' % (widget['labelId'], repeat['widgetRow'].number()))"
|
2010-09-17 08:32:48 -05:00
|
|
|
tal:attributes="onClick python: 'showTab(\'%s_%d_%d\')' % (widget['name'], repeat['widgetRow'].number(), len(widget['widgets']))"></a>
|
2010-08-05 11:23:17 -05:00
|
|
|
</td>
|
2011-11-25 11:01:20 -06:00
|
|
|
<td><img tal:attributes="src string: $appUrl/ui/tabRight.png;
|
2010-08-05 11:23:17 -05:00
|
|
|
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'">
|
2011-11-25 11:01:20 -06:00
|
|
|
<metal:call use-macro="app/ui/widgets/show/macros/group"/>
|
2010-08-05 11:23:17 -05:00
|
|
|
</tal:group>
|
|
|
|
<tal:field condition="python: widget['type'] != 'group'">
|
2011-11-25 11:01:20 -06:00
|
|
|
<metal:call use-macro="app/ui/widgets/show/macros/field"/>
|
2010-08-05 11:23:17 -05:00
|
|
|
</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>
|
2010-09-13 14:04:10 -05:00
|
|
|
<table metal:define-macro="groupContent"
|
2011-03-24 10:21:57 -05:00
|
|
|
tal:define="cellgap widget/cellgap"
|
2011-09-10 18:59:22 -05:00
|
|
|
tal:attributes="width widget/wide;
|
2010-10-14 07:43:56 -05:00
|
|
|
align widget/align;
|
2011-10-01 15:40:13 -05:00
|
|
|
class groupCss;
|
2010-12-06 04:11:40 -06:00
|
|
|
cellspacing widget/cellspacing;
|
2011-10-01 15:40:13 -05:00
|
|
|
cellpadding widget/cellpadding;
|
2011-10-19 02:37:44 -05:00
|
|
|
id tagId; name tagId">
|
2010-08-05 11:23:17 -05:00
|
|
|
<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']);
|
2010-09-13 14:04:10 -05:00
|
|
|
class widget/style" align="left">
|
2010-08-05 11:23:17 -05:00
|
|
|
<span tal:replace="structure python: contextObj.translate(widget['labelId'])"/>
|
|
|
|
<tal:help condition="widget/hasHelp">
|
2011-11-25 11:01:20 -06:00
|
|
|
<metal:call use-macro="app/ui/widgets/show/macros/help"/>
|
2010-08-05 11:23:17 -05:00
|
|
|
</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]"
|
2011-09-07 02:56:53 -05:00
|
|
|
tal:content="structure python: widget['hasHeaders'] and contextObj.translate('%s_col%d' % (widget['labelId'], colNb+1)) or ''">
|
2010-08-05 11:23:17 -05:00
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
<tal:comment replace="nothing">The rows of widgets</tal:comment>
|
2010-08-27 01:59:53 -05:00
|
|
|
<tr tal:attributes="valign widget/valign" tal:repeat="widgetRow widget/widgets">
|
2010-08-05 11:23:17 -05:00
|
|
|
<td tal:repeat="widget widgetRow"
|
|
|
|
tal:attributes="colspan widget/colspan|python:1;
|
2011-03-24 10:21:57 -05:00
|
|
|
style python: test(repeat['widget'].number() != len(widgetRow), 'padding-right: %s'%cellgap, '')">
|
2010-08-05 11:23:17 -05:00
|
|
|
<tal:showWidget condition="widget">
|
|
|
|
<tal:group condition="python: widget['type'] == 'group'">
|
2011-11-25 11:01:20 -06:00
|
|
|
<metal:call use-macro="app/ui/widgets/show/macros/group"/>
|
2010-08-05 11:23:17 -05:00
|
|
|
</tal:group>
|
|
|
|
<tal:field condition="python: widget['type'] != 'group'">
|
2011-11-25 11:01:20 -06:00
|
|
|
<metal:call use-macro="app/ui/widgets/show/macros/field"/>
|
2010-08-05 11:23:17 -05:00
|
|
|
</tal:field>
|
|
|
|
</tal:showWidget>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<tal:comment replace="nothing">Displays a field label.</tal:comment>
|
2012-03-23 17:26:35 -05:00
|
|
|
<tal:label metal:define-macro="label" condition="widget/hasLabel"><label tal:attributes="for widget/name" tal:condition="python: (widget['type'] != 'Action')" tal:content="structure python: contextObj.translate('label', field=widget)"></label></tal:label>
|
2010-08-05 11:23:17 -05:00
|
|
|
|
|
|
|
<tal:comment replace="nothing">Displays a field description.</tal:comment>
|
2011-09-10 18:59:22 -05:00
|
|
|
<tal:description metal:define-macro="description" condition="widget/hasDescr"><span class="discreet" tal:content="structure python: contextObj.translate('descr', field=widget)"></span>
|
2010-08-05 11:23:17 -05:00
|
|
|
</tal:description>
|
|
|
|
|
|
|
|
<tal:comment replace="nothing">Displays a field help.</tal:comment>
|
2011-11-25 11:01:20 -06:00
|
|
|
<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>
|
2010-08-05 11:23:17 -05:00
|
|
|
|
|
|
|
<tal:comment replace="nothing">Displays validation-error-related info about a field.</tal:comment>
|
2011-11-25 11:01:20 -06:00
|
|
|
<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>
|
2010-08-05 11:23:17 -05:00
|
|
|
|
|
|
|
<tal:comment replace="nothing">Displays the fact that a field is required.</tal:comment>
|
2011-11-25 11:01:20 -06:00
|
|
|
<tal:required metal:define-macro="required"><img tal:attributes="src string: $appUrl/ui/required.gif"/></tal:required>
|