[gen] Buttons for workfow conditions are now smaller when shown in lists of objects; added the possibility to define a specific icon for every workflow transition.
This commit is contained in:
parent
f0c1f69573
commit
e1b6b1b951
5 changed files with 27 additions and 19 deletions
|
@ -106,9 +106,6 @@ class Ref(Field):
|
|||
src=":url('arrowDown')" title=":_('move_down')"
|
||||
onclick=":ajaxBaseCall.replace('**v**', 'down')"/>
|
||||
</td>
|
||||
<!-- Workflow transitions -->
|
||||
<td if="tied.o.showTransitions('result')"
|
||||
var2="targetObj=tied.o">:tied.pxTransitions</td>
|
||||
<!-- Edit -->
|
||||
<td if="not field.noForm and tied.o.mayEdit()">
|
||||
<a var="navInfo='ref.%s.%s:%s.%d.%d' % (zobj.id, field.name, \
|
||||
|
@ -136,6 +133,9 @@ class Ref(Field):
|
|||
onclick=":'onLink(%s,%s,%s,%s)' % (q(action), q(zobj.id), \
|
||||
q(field.name), q(tiedUid))"/>
|
||||
</td>
|
||||
<!-- Workflow transitions -->
|
||||
<td if="tied.o.showTransitions('result')"
|
||||
var2="targetObj=tied.o; buttonsMode='small'">:tied.pxTransitions</td>
|
||||
</tr>
|
||||
</table>''')
|
||||
|
||||
|
|
|
@ -166,7 +166,7 @@ class State:
|
|||
class Transition:
|
||||
'''Represents a workflow transition.'''
|
||||
def __init__(self, states, condition=True, action=None, notify=None,
|
||||
show=True, confirm=False, group=None):
|
||||
show=True, confirm=False, group=None, icon=None):
|
||||
# In its simpler form, "states" is a list of 2 states:
|
||||
# (fromState, toState). But it can also be a list of several
|
||||
# (fromState, toState) sub-lists. This way, you may define only 1
|
||||
|
@ -184,6 +184,8 @@ class Transition:
|
|||
# the transition. It will only be possible by code.
|
||||
self.confirm = confirm # If True, a confirm popup will show up.
|
||||
self.group = Group.get(group)
|
||||
# The user may specify a specific icon to show for this transition.
|
||||
self.icon = icon or 'transition'
|
||||
|
||||
def standardiseStates(self, states):
|
||||
'''Get p_states as a list or a list of lists. Indeed, the user may also
|
||||
|
@ -331,7 +333,8 @@ class Transition:
|
|||
return msg
|
||||
|
||||
def trigger(self, transitionName, obj, wf, comment, doAction=True,
|
||||
doNotify=True, doHistory=True, doSay=True, reindex=True):
|
||||
doNotify=True, doHistory=True, doSay=True, reindex=True,
|
||||
noSecurity=False):
|
||||
'''This method triggers this transition on p_obj. The transition is
|
||||
supposed to be triggerable (call to self.isTriggerable must have been
|
||||
performed before calling this method). If p_doAction is False, the
|
||||
|
@ -344,6 +347,9 @@ class Transition:
|
|||
trigger programmatically, and no message is returned to the user.
|
||||
If p_reindex is False, object reindexing will be performed by the
|
||||
calling method.'''
|
||||
# Security check
|
||||
if not noSecurity and not self.isTriggerable(obj, wf):
|
||||
raise Exception('Transition "%s" can\'t be triggered.' % name)
|
||||
# Create the workflow_history dict if it does not exist.
|
||||
if not hasattr(obj.aq_base, 'workflow_history'):
|
||||
from persistent.mapping import PersistentMapping
|
||||
|
@ -387,9 +393,6 @@ class Transition:
|
|||
def onUiRequest(self, obj, wf, name, rq):
|
||||
'''Executed when a user wants to trigger this transition from the UI.'''
|
||||
tool = obj.getTool()
|
||||
# Is this transition triggerable?
|
||||
if not self.isTriggerable(obj, wf):
|
||||
raise Exception('Transition "%s" can\'t be triggered.' % name)
|
||||
# Trigger the transition
|
||||
self.trigger(name, obj, wf, rq.get('comment', ''), reindex=False)
|
||||
# Reindex obj if required.
|
||||
|
@ -398,11 +401,12 @@ class Transition:
|
|||
|
||||
class UiTransition:
|
||||
'''Represents a widget that displays a transition.'''
|
||||
pxView = Px('''
|
||||
pxView = Px('''<x var="buttonCss = (buttonsMode == 'small') and \
|
||||
'buttonSmall button' or 'button'">
|
||||
<!-- Real button -->
|
||||
<input if="transition.mayTrigger" type="button" class="button"
|
||||
<input if="transition.mayTrigger" type="button" class=":buttonCss"
|
||||
var2="label=transition.title"
|
||||
style=":'%s; %s' % (url('transition', bg=True), \
|
||||
style=":'%s; %s' % (url(transition.icon, bg=True), \
|
||||
ztool.getButtonWidth(label))"
|
||||
value=":label"
|
||||
onclick=":'triggerTransition(%s,%s,%s)' % (q(formId), \
|
||||
|
@ -410,15 +414,16 @@ class UiTransition:
|
|||
|
||||
<!-- Fake button, explaining why the transition can't be triggered -->
|
||||
<input if="not transition.mayTrigger" type="button"
|
||||
class="fake button" var2="label=transition.title"
|
||||
class=":'fake ' + buttonCss" var2="label=transition.title"
|
||||
style=":'%s; %s' % (url('fake', bg=True),
|
||||
ztool.getButtonWidth(label))"
|
||||
value=":label" title=":transition.reason"/>''')
|
||||
value=":label" title=":transition.reason"/></x>''')
|
||||
|
||||
def __init__(self, name, transition, obj, mayTrigger, ):
|
||||
self.name = name
|
||||
self.transition = transition
|
||||
self.type = 'transition'
|
||||
self.icon = transition.icon
|
||||
label = obj.getWorkflowLabel(name)
|
||||
self.title = obj.translate(label)
|
||||
if transition.confirm:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue