[gen] Bugfixes.

This commit is contained in:
Gaetan Delannay 2013-09-18 15:57:34 +02:00
parent 809a553cf4
commit 59dc619c7f
4 changed files with 29 additions and 15 deletions

View file

@ -81,7 +81,7 @@ class Field:
class="discreet">::zobj.translate('descr', field=field)</span>''')
# Displays a field help.
pxHelp = Px('''<acronym title="zobj.translate('help', field=field)"><img
pxHelp = Px('''<acronym title=":zobj.translate('help', field=field)"><img
src=":url('help')"/></acronym>''')
# Displays validation-error-related info about a field.

View file

@ -26,14 +26,14 @@ class List(Field):
# PX for rendering a single row.
pxRow = Px('''
<tr valign="top" style="(rowIndex==-1) and 'display: none' or ''">
<td align="center" for="info in field.fields"
<tr valign="top" style=":(rowIndex==-1) and 'display: none' or ''">
<td for="info in field.fields" align="center"
var2="field=info[1];
tagCss='noStyle';
widgetName='%s*%d' % (field.name, rowIndex)">:field.pxView</td>
fieldName='%s*%d' % (field.name, rowIndex);
tagCss='noStyle'">:field.pxRender</td>
<!-- Icon for removing the row -->
<td if="layoutType=='edit'" align=":dright">
<img class="clickable" src=":url(delete')" title=":_('object_delete')"
<img class="clickable" src=":url('delete')" title=":_('object_delete')"
onclick=":'deleteRow(%s, this)' % q('list_%s' % name)"/>
</td>
</tr>''')
@ -41,10 +41,12 @@ class List(Field):
# PX for rendering the list (shared between pxView and pxEdit).
pxTable = Px('''
<table var="isEdit=layoutType == 'edit'" if="isEdit or value"
id=":'list_%s' % name" class="isEdit and 'grid' or 'list'">
id=":'list_%s' % name" class=":isEdit and 'grid' or 'list'"
width=":field.width">
<!-- Header -->
<tr valign="bottom">
<th for="info in field.fields">::_(info[1].labelId)</th>
<th for="info in field.fields"
width=":field.widths[loop.info.nb]">::_(info[1].labelId)</th>
<!-- Icon for adding a new row. -->
<th if="isEdit">
<img class="clickable" src=":url('plus')" title=":_('add_ref')"
@ -72,10 +74,10 @@ class List(Field):
def __init__(self, fields, validator=None, multiplicity=(0,1), default=None,
show=True, page='main', group=None, layouts=None, move=0,
indexed=False, searchable=False, specificReadPermission=False,
specificWritePermission=False, width=None, height=None,
specificWritePermission=False, width='', height=None,
maxChars=None, colspan=1, master=None, masterValue=None,
focus=False, historized=False, mapping=None, label=None,
subLayouts=Table('fv', width=None)):
subLayouts=Table('frv', width=None), widths=None):
Field.__init__(self, validator, multiplicity, default, show, page,
group, layouts, move, indexed, False,
specificReadPermission, specificWritePermission, width,
@ -91,6 +93,12 @@ class List(Field):
if subLayouts:
for name, field in self.fields:
field.layouts = field.formatLayouts(subLayouts)
# One may specify the width of every column in the list. Indeed, using
# widths and layouts of sub-fields may not be sufficient.
if not widths:
self.widths = [''] * len(self.fields)
else:
self.widths = widths
def getField(self, name):
'''Gets the field definition whose name is p_name.'''

View file

@ -115,7 +115,7 @@ class String(Field):
onchange=":isMaster and 'updateSlaves(this)' or ''"
size=":isMultiple and field.height or 1">
<option for="val in possibleValues" value=":val[0]"
selected=":field.isSelected(zobj, val[0], rawValue)"
selected=":field.isSelected(zobj, name, val[0], rawValue)"
title=":val[1]">:ztool.truncateValue(val[1],field.width)</option>
</select>
<x if="isOneLine and not isSelect">
@ -669,13 +669,15 @@ class String(Field):
"null, evalInnerScripts);}}});"% \
(uid, self.name, uid, self.name, obj.absolute_url(), self.name)
def isSelected(self, obj, vocabValue, dbValue):
def isSelected(self, obj, fieldName, vocabValue, dbValue):
'''When displaying a selection box (only for fields with a validator
being a list), must the _vocabValue appear as selected?'''
being a list), must the _vocabValue appear as selected? p_fieldName
is given and used instead of field.name because it may be a a fake
name containing a row number from a field within a list field.'''
rq = obj.REQUEST
# Get the value we must compare (from request or from database)
if rq.has_key(self.name):
compValue = rq.get(self.name)
if rq.has_key(fieldName):
compValue = rq.get(fieldName)
else:
compValue = dbValue
# Compare the value

View file

@ -326,6 +326,10 @@ class FieldDescriptor:
for name, field in self.appyType.fields:
label = '%s_%s_%s' % (self.classDescr.name, self.fieldName, name)
self.i18n(label, name)
if field.hasDescr:
self.i18n('%s_descr' % label, ' ')
if field.hasHelp:
self.i18n('%s_help' % label, ' ')
def walkCalendar(self):
# Add i18n-specific messages