[gen] Bugfix for result-tied POD templates.

This commit is contained in:
Gaetan Delannay 2013-01-08 13:28:35 +01:00
parent 240ce59519
commit 7b94bfb85e
7 changed files with 29 additions and 16 deletions

View file

@ -1206,9 +1206,15 @@ class String(Type):
def getDefaultLayouts(self): def getDefaultLayouts(self):
'''Returns the default layouts for this type. Default layouts can vary '''Returns the default layouts for this type. Default layouts can vary
acccording to format or multiplicity.''' acccording to format, multiplicity or history.'''
if self.format in (String.TEXT, String.XHTML): if self.format == String.TEXT:
return {'view': 'l-f', 'edit': 'lrv-d-f'} return {'view': 'l-f', 'edit': 'lrv-d-f'}
elif self.format == String.XHTML:
if self.historized:
view = 'lc-f'
else:
view = 'l-f'
return {'view': view, 'edit': 'lrv-d-f'}
elif self.isMultiValued(): elif self.isMultiValued():
return {'view': 'l-f', 'edit': 'lrv-f'} return {'view': 'l-f', 'edit': 'lrv-f'}

View file

@ -25,6 +25,7 @@
# r - "required" The icon that specified that the field is required (if # r - "required" The icon that specified that the field is required (if
# relevant; typically only used on "edit" layouts) # relevant; typically only used on "edit" layouts)
# f - "field" The field value, or input for entering a value. # f - "field" The field value, or input for entering a value.
# c - "changes" The button for displaying changes to a field
# For every field of a Appy class, you can define, for every layout context, # For every field of a Appy class, you can define, for every layout context,
# what field-related information will appear, and how it will be rendered. # what field-related information will appear, and how it will be rendered.
@ -48,7 +49,7 @@ macroDict = {
# Field-related elements # Field-related elements
'l': ('show', 'label'), 'd': ('show', 'description'), 'l': ('show', 'label'), 'd': ('show', 'description'),
'h': ('show', 'help'), 'v': ('show', 'validation'), 'h': ('show', 'help'), 'v': ('show', 'validation'),
'r': ('show', 'required') 'r': ('show', 'required'), 'c': ('show', 'changes'),
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -119,7 +120,7 @@ class Table(LayoutElement):
'''Represents a table where to dispose graphical elements.''' '''Represents a table where to dispose graphical elements.'''
simpleParams = ('style', 'css_class', 'cellpadding', 'cellspacing', 'width', simpleParams = ('style', 'css_class', 'cellpadding', 'cellspacing', 'width',
'align') 'align')
derivedRepls = {'view': 'hrvd', 'cell': 'ld'} derivedRepls = {'view': 'hrvd', 'cell': 'ldc'}
def __init__(self, layoutString=None, style=None, css_class='', def __init__(self, layoutString=None, style=None, css_class='',
cellpadding=0, cellspacing=0, width='100%', align='left', cellpadding=0, cellspacing=0, width='100%', align='left',
other=None, derivedType=None): other=None, derivedType=None):

View file

@ -408,7 +408,7 @@ function generatePodDocument(contextUid, fieldName, podFormat, queryData) {
theForm.podFormat.value = podFormat; theForm.podFormat.value = podFormat;
theForm.askAction.value = "False"; theForm.askAction.value = "False";
theForm.queryData.value = queryData; theForm.queryData.value = queryData;
var askActionWidget = document.getElementById(contextUid + '_' + fieldName); var askActionWidget = document.getElementById(contextUid + '_' + fieldName + '_cb');
if (askActionWidget && askActionWidget.checked) { if (askActionWidget && askActionWidget.checked) {
theForm.askAction.value = "True"; theForm.askAction.value = "True";
} }

View file

@ -44,7 +44,7 @@
layout The layout object that will dictate how object content layout The layout object that will dictate how object content
will be rendered. will be rendered.
</tal:comment> </tal:comment>
<metal:show define-macro="show"> <metal:show define-macro="show" tal:define="tagId python: 'content'">
<metal:layout use-macro="context/ui/widgets/show/macros/layout"/> <metal:layout use-macro="context/ui/widgets/show/macros/layout"/>
</metal:show> </metal:show>

View file

@ -66,8 +66,8 @@
<div class="portletContent" tal:define="searchInfo python: tool.getGroupedSearches(rootClass)"> <div class="portletContent" tal:define="searchInfo python: tool.getGroupedSearches(rootClass)">
<tal:comment replace="nothing">Section title (link triggers the default search), with action icons</tal:comment> <tal:comment replace="nothing">Section title (link triggers the default search), with action icons</tal:comment>
<a tal:define="queryParam python: searchInfo['default'] and ('&search=%s' % searchInfo['default']['name']) or ''" <a tal:define="queryParam python: searchInfo['default'] and searchInfo['default']['name'] or ''"
tal:attributes="href python: '%s?className=%s%s' % (queryUrl, rootClass, queryParam); tal:attributes="href python: '%s?className=%s&search=%s' % (queryUrl, rootClass, queryParam);
class python:test(not currentSearch and (currentClass==rootClass), 'portletCurrent', '')" class python:test(not currentSearch and (currentClass==rootClass), 'portletCurrent', '')"
tal:content="structure python: _(rootClass + '_plural')"> tal:content="structure python: _(rootClass + '_plural')">
</a> </a>

View file

@ -2,7 +2,7 @@
<metal:view define-macro="view"> <metal:view define-macro="view">
<tal:askAction condition="widget/askAction" <tal:askAction condition="widget/askAction"
define="doLabel python:'%s_askaction' % widget['labelId']; define="doLabel python:'%s_askaction' % widget['labelId'];
chekboxId python: '%s_%s' % (contextObj.UID(), name)"> chekboxId python: '%s_%s_cb' % (contextObj.UID(), name)">
<input type="checkbox" tal:attributes="name doLabel; id chekboxId"/> <input type="checkbox" tal:attributes="name doLabel; id chekboxId"/>
<label tal:attributes="for chekboxId" class="discreet" <label tal:attributes="for chekboxId" class="discreet"
tal:content="python: _(doLabel)"></label> tal:content="python: _(doLabel)"></label>

View file

@ -9,7 +9,8 @@
contextMacro The base folder containing the macros to call for contextMacro The base folder containing the macros to call for
rendering the elements within the layout. rendering the elements within the layout.
Defaults to app.ui Defaults to app.ui
tagId The name and id of the main tag for this layout (used tagId The ID of the main tag for this layout.
tagName The name of the main tag for this layout (used
a.o. for master/slave relationships). a.o. for master/slave relationships).
tagCss Some additional CSS class for the main tag tagCss Some additional CSS class for the main tag
(ie, the CSS class for a slave). (ie, the CSS class for a slave).
@ -18,7 +19,7 @@
</tal:comment> </tal:comment>
<metal:show define-macro="layout" <metal:show define-macro="layout"
tal:define="contextMacro contextMacro| python: app.ui; tal:define="contextMacro contextMacro| python: app.ui;
tagId tagId|python:''; tagName tagName|python:'';
tagCss tagCss|python:''; tagCss tagCss|python:'';
layoutCss layout/css_class; layoutCss layout/css_class;
isCell python: layoutType == 'cell'"> isCell python: layoutType == 'cell'">
@ -29,7 +30,7 @@
class python: tagCss and ('%s %s' % (tagCss, layoutCss)).strip() or layoutCss; class python: tagCss and ('%s %s' % (tagCss, layoutCss)).strip() or layoutCss;
style layout/style; style layout/style;
id tagId; id tagId;
name tagId;"> name tagName;">
<tal:comment replace="nothing">The table header row</tal:comment> <tal:comment replace="nothing">The table header row</tal:comment>
<tr tal:condition="layout/headerRow" tal:attributes="valign layout/headerRow/valign"> <tr tal:condition="layout/headerRow" tal:attributes="valign layout/headerRow/valign">
<th tal:repeat="cell layout/headerRow/cells" <th tal:repeat="cell layout/headerRow/cells"
@ -76,7 +77,8 @@
slaveCss python: widget['master'] and ('slave_%s_%s' % (widget['masterName'], '_'.join(widget['masterValue']))) or ''; slaveCss python: widget['master'] and ('slave_%s_%s' % (widget['masterName'], '_'.join(widget['masterValue']))) or '';
tagCss tagCss | python:''; tagCss tagCss | python:'';
tagCss python: ('%s %s' % (slaveCss, tagCss)).strip(); tagCss python: ('%s %s' % (slaveCss, tagCss)).strip();
tagId python: widget['master'] and 'slave' or ''"> tagId python: '%s_%s' % (contextObj.UID(), name);
tagName python: widget['master'] and 'slave' or ''">
<metal:layout use-macro="context/ui/widgets/show/macros/layout"/> <metal:layout use-macro="context/ui/widgets/show/macros/layout"/>
</metal:field> </metal:field>
@ -92,7 +94,8 @@
tal:define="tagCss python: widget['master'] and ('slave_%s_%s' % (widget['masterName'], '_'.join(widget['masterValue']))) or ''; tal:define="tagCss python: widget['master'] and ('slave_%s_%s' % (widget['masterName'], '_'.join(widget['masterValue']))) or '';
widgetCss widget/css_class; widgetCss widget/css_class;
groupCss python: tagCss and ('%s %s' % (tagCss, widgetCss)) or widgetCss; groupCss python: tagCss and ('%s %s' % (tagCss, widgetCss)) or widgetCss;
tagId python: widget['master'] and 'slave' or ''"> tagName python: widget['master'] and 'slave' or '';
tagId python: '%s_%s' % (contextObj.UID(), widget['name'])">
<fieldset tal:condition="python: widget['style'] == 'fieldset'"> <fieldset tal:condition="python: widget['style'] == 'fieldset'">
<legend tal:condition="widget/hasLabel"> <legend tal:condition="widget/hasLabel">
<i tal:content="structure python: contextObj.translate(widget['labelId'])"></i> <i tal:content="structure python: contextObj.translate(widget['labelId'])"></i>
@ -110,7 +113,7 @@
<tal:asTabs condition="python: widget['style'] == 'tabs'"> <tal:asTabs condition="python: widget['style'] == 'tabs'">
<table tal:attributes="width widget/wide; <table tal:attributes="width widget/wide;
class groupCss; class groupCss;
id tagId; name tagId"> id tagId; name tagName">
<tal:comment replace="nothing">First row: the tabs.</tal:comment> <tal:comment replace="nothing">First row: the tabs.</tal:comment>
<tr valign="middle"><td style="border-bottom: 1px solid #ff8040"> <tr valign="middle"><td style="border-bottom: 1px solid #ff8040">
<table style="position:relative; bottom:-2px;" cellpadding="0" cellspacing="0"> <table style="position:relative; bottom:-2px;" cellpadding="0" cellspacing="0">
@ -162,7 +165,7 @@
class groupCss; class groupCss;
cellspacing widget/cellspacing; cellspacing widget/cellspacing;
cellpadding widget/cellpadding; cellpadding widget/cellpadding;
id tagId; name tagId"> id tagId; name tagName">
<tal:comment replace="nothing">Display the title of the group if it is not rendered a fieldset.</tal:comment> <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']"> <tr tal:condition="python: (widget['style'] != 'fieldset') and widget['hasLabel']">
<td tal:attributes="colspan python: len(widget['columnsWidths']); <td tal:attributes="colspan python: len(widget['columnsWidths']);
@ -218,3 +221,6 @@
<tal:comment replace="nothing">Displays the fact that a field is required.</tal:comment> <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> <tal:required metal:define-macro="required"><img tal:attributes="src string: $appUrl/ui/required.gif"/></tal:required>
<tal:comment replace="nothing">Button for showing changes to the field.</tal:comment>
<tal:changes metal:define-macro="changes"><img tal:attributes="src string: $appUrl/ui/changes.png"/></tal:changes>