[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
|
@ -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:
|
||||
|
|
|
@ -67,9 +67,11 @@ img { border: 0; vertical-align: middle }
|
|||
.navigate td { padding: 4px 9px }
|
||||
.login { margin: 3px; color: black }
|
||||
input.button { color: #666666; height: 20px; width: 130px;
|
||||
cursor:pointer; font-size: 90%; padding-left: 10px;
|
||||
cursor:pointer; font-size: 90%; padding: 1px 0 0 10px;
|
||||
background-color: white; background-repeat: no-repeat;
|
||||
background-position: 5% 25%; box-shadow: 2px 2px 2px #888888}
|
||||
input.buttonSmall { width: 100px !important; font-size: 85%; height: 18px;
|
||||
margin-bottom: 3px}
|
||||
.fake { background-color: #e6e6e6 !important ; cursor:help !important }
|
||||
.buttons { margin-left: 4px }
|
||||
.message { position: absolute; top: -40px; left: 50%; font-size: 90%;
|
||||
|
|
|
@ -190,7 +190,7 @@ class ToolWrapper(AbstractWrapper):
|
|||
<x var="mayCreate=ztool.userMayCreate(rootClass);
|
||||
createMeans=ztool.getCreateMeans(rootClass)">
|
||||
<!-- Create a new object from a web form. -->
|
||||
<input type="button" class="button"
|
||||
<input type="button" class="buttonSmall button"
|
||||
if="mayCreate and ('form' in createMeans)"
|
||||
var2="label=_('query_create')" value=":label"
|
||||
style=":'%s; %s' % (url('add', bg=True), \
|
||||
|
@ -323,7 +323,7 @@ class ToolWrapper(AbstractWrapper):
|
|||
|
||||
<!-- Actions -->
|
||||
<table class="noStyle" if="zobj.mayAct()">
|
||||
<tr valign="top">
|
||||
<tr>
|
||||
<!-- Edit -->
|
||||
<td if="zobj.mayEdit()">
|
||||
<a var="navInfo='search.%s.%s.%d.%d' % \
|
||||
|
@ -340,7 +340,8 @@ class ToolWrapper(AbstractWrapper):
|
|||
</td>
|
||||
<!-- Workflow transitions -->
|
||||
<td if="zobj.showTransitions('result')"
|
||||
var2="targetObj=zobj">:targetObj.appy().pxTransitions</td>
|
||||
var2="targetObj=zobj;
|
||||
buttonsMode='small'">:targetObj.appy().pxTransitions</td>
|
||||
</tr>
|
||||
</table>
|
||||
</x>
|
||||
|
|
|
@ -363,7 +363,7 @@ class AbstractWrapper(object):
|
|||
|
||||
pxTransitions = Px('''
|
||||
<form var="transitions=targetObj.getTransitions()" if="transitions"
|
||||
var2="formId='trigger_%s' % targetObj.UID()" method="post"
|
||||
var2="formId='trigger_%s' % targetObj.id" method="post"
|
||||
id=":formId" action=":targetObj.absolute_url() + '/do'">
|
||||
<input type="hidden" name="action" value="Trigger"/>
|
||||
<input type="hidden" name="transition"/>
|
||||
|
@ -524,7 +524,7 @@ class AbstractWrapper(object):
|
|||
</td>
|
||||
|
||||
<!-- Workflow transitions -->
|
||||
<td var="targetObj=zobj"
|
||||
<td var="targetObj=zobj; buttonsMode='normal'"
|
||||
if="targetObj.showTransitions(layoutType)">:obj.pxTransitions</td>
|
||||
|
||||
<!-- Refresh -->
|
||||
|
|
Loading…
Reference in a new issue