improve reporting's state field
This commit is contained in:
parent
17012129b8
commit
583a75da9d
2 changed files with 9 additions and 3 deletions
|
@ -70,7 +70,8 @@
|
|||
|
||||
<metal:state define-macro="state">
|
||||
<tal:column define=" value python:col.getDisplayValue(row)">
|
||||
<img tal:attributes="src string:$resourceBase${value/icon};
|
||||
<img tal:condition="value"
|
||||
tal:attributes="src string:$resourceBase${value/icon};
|
||||
alt value/title;
|
||||
title value/title" />
|
||||
</tal:column>
|
||||
|
|
|
@ -124,14 +124,19 @@ class StateField(Field):
|
|||
def getDisplayValue(self, row):
|
||||
if IStateful.providedBy(row.context):
|
||||
stf = row.context
|
||||
elif row.context is None:
|
||||
return None
|
||||
else:
|
||||
stf = component.getAdapter(row.context, IStateful,
|
||||
stf = component.getAdapter(baseObject(row.context), IStateful,
|
||||
name=self.statesDefinition)
|
||||
stateObject = stf.getStateObject()
|
||||
icon = stateObject.icon or 'led%s.png' % stateObject.color
|
||||
return dict(title=util._(stateObject.title),
|
||||
return dict(title=self.translate(stateObject.title),
|
||||
icon='cybertools.icons/' + icon)
|
||||
|
||||
def translate(self, text):
|
||||
return util._(text)
|
||||
|
||||
|
||||
class VocabularyField(Field):
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue