[gen] Buttons can now be stretched to fit the size of the inner label.
This commit is contained in:
parent
2b1fc85512
commit
822e1a7c63
32 changed files with 91 additions and 61 deletions
|
@ -28,20 +28,20 @@ class Action(Field):
|
|||
# PX for viewing the Action button.
|
||||
pxView = pxCell = Px('''
|
||||
<form var="formId='%s_%s_form' % (zobj.id, name);
|
||||
label=_(field.labelId)"
|
||||
label=_(field.labelId);
|
||||
buttonWidth=ztool.getButtonWidth(label)"
|
||||
id=":formId" action=":ztool.absolute_url() + '/do'">
|
||||
<input type="hidden" name="action" value="ExecuteAction"/>
|
||||
<input type="hidden" name="objectUid" value=":zobj.id"/>
|
||||
<input type="hidden" name="fieldName" value=":name"/>
|
||||
<input if="field.confirm" type="button" class="button"
|
||||
var="labelConfirm=_(field.labelId + '_confirm')"
|
||||
value=":ztool.truncateValue(label)" title=":label"
|
||||
style=":url('buttonAction', bg=True)"
|
||||
var="labelConfirm=_(field.labelId + '_confirm')" value=":label"
|
||||
style=":'%s; %s' % (url('action', bg=True), buttonWidth)"
|
||||
onclick=":'askConfirm(%s,%s,%s)' % (q('form'), q(formId), \
|
||||
q(labelConfirm))"/>
|
||||
<input if="not field.confirm" type="submit" class="button" name="do"
|
||||
value=":ztool.truncateValue(label)" title=":label"
|
||||
style=":url('buttonAction', bg=True)"/>
|
||||
value=":label"
|
||||
style=":'%s; %s' % (url('action', bg=True), buttonWidth)"/>
|
||||
</form>''')
|
||||
|
||||
# It is not possible to edit an action, not to search it.
|
||||
|
|
|
@ -56,23 +56,26 @@ class Ref(Field):
|
|||
# objects (delete many, unlink many,...)
|
||||
pxGlobalActions = Px('''
|
||||
<!-- Insert several objects (if in pick list) -->
|
||||
<input if="inPickList" var2="action='link'" type="button" class="button"
|
||||
value=":_('object_link_many')"
|
||||
<input if="inPickList" type="button" class="button"
|
||||
var2="action='link'; label=_('object_link_many')" value=":label"
|
||||
onclick=":'onLinkMany(%s,%s)' % (q(action), q(ajaxHookId))"
|
||||
style=":url('linkMany', bg=True)"/>
|
||||
style=":'%s; %s' % (url('linkMany', bg=True), \
|
||||
ztool.getButtonWidth(label))"/>
|
||||
<!-- Unlink several objects -->
|
||||
<input if="not isBack and field.unlink and canWrite and not inPickList"
|
||||
var2="imgName=linkList and 'unlinkManyUp' or 'unlinkMany';
|
||||
action='unlink'"
|
||||
type="button" class="button" value=":_('object_unlink_many')"
|
||||
action='unlink'; label=_('object_unlink_many')"
|
||||
type="button" class="button" value=":label"
|
||||
onclick=":'onLinkMany(%s,%s)' % (q(action), q(ajaxHookId))"
|
||||
style=":url(imgName, bg=True)"/>
|
||||
style=":'%s; %s' % (url(imgName, bg=True), \
|
||||
ztool.getButtonWidth(label))"/>
|
||||
<!-- Delete several objects -->
|
||||
<input if="not isBack and field.delete and canWrite"
|
||||
var2="action='delete'"
|
||||
type="button" class="button" value=":_('object_delete_many')"
|
||||
var2="action='delete'; label=_('object_delete_many')"
|
||||
type="button" class="button" value=":label"
|
||||
onclick=":'onLinkMany(%s,%s)' % (q(action), q(ajaxHookId))"
|
||||
style=":url('deleteMany', bg=True)"/>
|
||||
style=":'%s; %s' % (url('deleteMany', bg=True), \
|
||||
ztool.getButtonWidth(label))"/>
|
||||
''')
|
||||
|
||||
# This PX displays icons for triggering actions on a given referenced object
|
||||
|
@ -152,9 +155,10 @@ class Ref(Field):
|
|||
'%d,%s' % (startNumber, q('CreateWithoutForm')));
|
||||
noFormCall=not field.addConfirm and noFormCall or \
|
||||
'askConfirm(%s, %s, %s)' % (q('script'), q(noFormCall), \
|
||||
q(addConfirmMsg))"
|
||||
style=":url('buttonAdd', bg=True)" value=":_('add_ref')"
|
||||
onclick=":field.noForm and noFormCall or formCall"/>''')
|
||||
q(addConfirmMsg));
|
||||
label=_('add_ref')"
|
||||
style=":'%s; %s' % (url('add', bg=True), ztool.getButtonWidth(label))"
|
||||
value=":label" onclick=":field.noForm and noFormCall or formCall"/>''')
|
||||
|
||||
# This PX displays, in a cell header from a ref table, icons for sorting the
|
||||
# ref field according to the field that corresponds to this column.
|
||||
|
@ -215,7 +219,9 @@ class Ref(Field):
|
|||
<x>:field.pxAdd</x>
|
||||
<!-- The search button if field is queryable -->
|
||||
<input if="objects and field.queryable" type="button" class="button"
|
||||
style=":url('buttonSearch', bg=True)" value=":_('search_title')"
|
||||
var2="label=_('search_title')" value=":label"
|
||||
style=":'%s; %s' % (url('search', bg=True), \
|
||||
ztool.getButtonWidth(label))"
|
||||
onclick=":'goto(%s)' % \
|
||||
q('%s/search?className=%s&ref=%s:%s' % \
|
||||
(ztool.absolute_url(), tiedClassName, zobj.id, field.name))"/>
|
||||
|
@ -235,7 +241,7 @@ class Ref(Field):
|
|||
<tr if="field.showHeaders">
|
||||
<th if="not inPickList and numbered" width=":numbered"></th>
|
||||
<th for="column in columns" width=":column.width"
|
||||
align="column.align" var2="refField=column.field">
|
||||
align=":column.align" var2="refField=column.field">
|
||||
<span>:_(refField.labelId)</span>
|
||||
<x>:field.pxSortIcons</x>
|
||||
<x var="className=tiedClassName;
|
||||
|
|
|
@ -310,8 +310,8 @@ class Transition:
|
|||
if user.has_role(condition, obj):
|
||||
hasRole = True
|
||||
else: # It is a method
|
||||
if not condition(wf, obj.appy()):
|
||||
return False
|
||||
res = condition(wf, obj.appy())
|
||||
if not res: return res # False or a No instance.
|
||||
if hasRole != False:
|
||||
return True
|
||||
|
||||
|
@ -387,18 +387,20 @@ class UiTransition:
|
|||
|
||||
pxView = Px('''<x>
|
||||
<!-- Real button -->
|
||||
<input if="transition.mayTrigger"
|
||||
type="button" class="button" title=":transition.title"
|
||||
style=":url('buttonTransition', bg=True)"
|
||||
value=":ztool.truncateValue(transition.title)"
|
||||
<input if="transition.mayTrigger" type="button" class="button"
|
||||
var2="label=transition.title"
|
||||
style=":'%s; %s' % (url('transition', bg=True), \
|
||||
ztool.getButtonWidth(label))"
|
||||
value=":label"
|
||||
onclick=":'triggerTransition(%s,%s,%s)' % (q(formId), \
|
||||
q(transition.name), q(transition.confirm))"/>
|
||||
|
||||
<!-- Fake button, explaining why the transition can't be triggered -->
|
||||
<input type="button" class="button" if="not transition.mayTrigger"
|
||||
style=":url('buttonFake', bg=True) + ';cursor: help'"
|
||||
value=":ztool.truncateValue(transition.title)"
|
||||
title=":'%s: %s' % (transition.title, transition.reason)"/>
|
||||
<input if="not transition.mayTrigger" type="button"
|
||||
class="fakeButton button" var2="label=transition.title"
|
||||
style=":'%s; %s' % (url('fake', bg=True),
|
||||
ztool.getButtonWidth(label))"
|
||||
value=":label" title=":'%s: %s' % (label, transition.reason)"/>
|
||||
</x>''')
|
||||
|
||||
def __init__(self, name, transition, obj, mayTrigger, ):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue