[gen] Bugfixes.
This commit is contained in:
parent
809a553cf4
commit
59dc619c7f
|
@ -81,7 +81,7 @@ class Field:
|
||||||
class="discreet">::zobj.translate('descr', field=field)</span>''')
|
class="discreet">::zobj.translate('descr', field=field)</span>''')
|
||||||
|
|
||||||
# Displays a field help.
|
# 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>''')
|
src=":url('help')"/></acronym>''')
|
||||||
|
|
||||||
# Displays validation-error-related info about a field.
|
# Displays validation-error-related info about a field.
|
||||||
|
|
|
@ -26,14 +26,14 @@ class List(Field):
|
||||||
|
|
||||||
# PX for rendering a single row.
|
# PX for rendering a single row.
|
||||||
pxRow = Px('''
|
pxRow = Px('''
|
||||||
<tr valign="top" style="(rowIndex==-1) and 'display: none' or ''">
|
<tr valign="top" style=":(rowIndex==-1) and 'display: none' or ''">
|
||||||
<td align="center" for="info in field.fields"
|
<td for="info in field.fields" align="center"
|
||||||
var2="field=info[1];
|
var2="field=info[1];
|
||||||
tagCss='noStyle';
|
fieldName='%s*%d' % (field.name, rowIndex);
|
||||||
widgetName='%s*%d' % (field.name, rowIndex)">:field.pxView</td>
|
tagCss='noStyle'">:field.pxRender</td>
|
||||||
<!-- Icon for removing the row -->
|
<!-- Icon for removing the row -->
|
||||||
<td if="layoutType=='edit'" align=":dright">
|
<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)"/>
|
onclick=":'deleteRow(%s, this)' % q('list_%s' % name)"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>''')
|
</tr>''')
|
||||||
|
@ -41,10 +41,12 @@ class List(Field):
|
||||||
# PX for rendering the list (shared between pxView and pxEdit).
|
# PX for rendering the list (shared between pxView and pxEdit).
|
||||||
pxTable = Px('''
|
pxTable = Px('''
|
||||||
<table var="isEdit=layoutType == 'edit'" if="isEdit or value"
|
<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 -->
|
<!-- Header -->
|
||||||
<tr valign="bottom">
|
<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. -->
|
<!-- Icon for adding a new row. -->
|
||||||
<th if="isEdit">
|
<th if="isEdit">
|
||||||
<img class="clickable" src=":url('plus')" title=":_('add_ref')"
|
<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,
|
def __init__(self, fields, validator=None, multiplicity=(0,1), default=None,
|
||||||
show=True, page='main', group=None, layouts=None, move=0,
|
show=True, page='main', group=None, layouts=None, move=0,
|
||||||
indexed=False, searchable=False, specificReadPermission=False,
|
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,
|
maxChars=None, colspan=1, master=None, masterValue=None,
|
||||||
focus=False, historized=False, mapping=None, label=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,
|
Field.__init__(self, validator, multiplicity, default, show, page,
|
||||||
group, layouts, move, indexed, False,
|
group, layouts, move, indexed, False,
|
||||||
specificReadPermission, specificWritePermission, width,
|
specificReadPermission, specificWritePermission, width,
|
||||||
|
@ -91,6 +93,12 @@ class List(Field):
|
||||||
if subLayouts:
|
if subLayouts:
|
||||||
for name, field in self.fields:
|
for name, field in self.fields:
|
||||||
field.layouts = field.formatLayouts(subLayouts)
|
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):
|
def getField(self, name):
|
||||||
'''Gets the field definition whose name is p_name.'''
|
'''Gets the field definition whose name is p_name.'''
|
||||||
|
|
|
@ -115,7 +115,7 @@ class String(Field):
|
||||||
onchange=":isMaster and 'updateSlaves(this)' or ''"
|
onchange=":isMaster and 'updateSlaves(this)' or ''"
|
||||||
size=":isMultiple and field.height or 1">
|
size=":isMultiple and field.height or 1">
|
||||||
<option for="val in possibleValues" value=":val[0]"
|
<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>
|
title=":val[1]">:ztool.truncateValue(val[1],field.width)</option>
|
||||||
</select>
|
</select>
|
||||||
<x if="isOneLine and not isSelect">
|
<x if="isOneLine and not isSelect">
|
||||||
|
@ -669,13 +669,15 @@ class String(Field):
|
||||||
"null, evalInnerScripts);}}});"% \
|
"null, evalInnerScripts);}}});"% \
|
||||||
(uid, self.name, uid, self.name, obj.absolute_url(), self.name)
|
(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
|
'''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
|
rq = obj.REQUEST
|
||||||
# Get the value we must compare (from request or from database)
|
# Get the value we must compare (from request or from database)
|
||||||
if rq.has_key(self.name):
|
if rq.has_key(fieldName):
|
||||||
compValue = rq.get(self.name)
|
compValue = rq.get(fieldName)
|
||||||
else:
|
else:
|
||||||
compValue = dbValue
|
compValue = dbValue
|
||||||
# Compare the value
|
# Compare the value
|
||||||
|
|
|
@ -326,6 +326,10 @@ class FieldDescriptor:
|
||||||
for name, field in self.appyType.fields:
|
for name, field in self.appyType.fields:
|
||||||
label = '%s_%s_%s' % (self.classDescr.name, self.fieldName, name)
|
label = '%s_%s_%s' % (self.classDescr.name, self.fieldName, name)
|
||||||
self.i18n(label, name)
|
self.i18n(label, name)
|
||||||
|
if field.hasDescr:
|
||||||
|
self.i18n('%s_descr' % label, ' ')
|
||||||
|
if field.hasHelp:
|
||||||
|
self.i18n('%s_help' % label, ' ')
|
||||||
|
|
||||||
def walkCalendar(self):
|
def walkCalendar(self):
|
||||||
# Add i18n-specific messages
|
# Add i18n-specific messages
|
||||||
|
|
Loading…
Reference in a new issue