[gen] Buttons can now be stretched to fit the size of the inner label.

This commit is contained in:
Gaetan Delannay 2014-04-20 19:22:40 +02:00
parent 2b1fc85512
commit 822e1a7c63
32 changed files with 91 additions and 61 deletions

View file

@ -28,20 +28,20 @@ class Action(Field):
# PX for viewing the Action button. # PX for viewing the Action button.
pxView = pxCell = Px(''' pxView = pxCell = Px('''
<form var="formId='%s_%s_form' % (zobj.id, name); <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'"> id=":formId" action=":ztool.absolute_url() + '/do'">
<input type="hidden" name="action" value="ExecuteAction"/> <input type="hidden" name="action" value="ExecuteAction"/>
<input type="hidden" name="objectUid" value=":zobj.id"/> <input type="hidden" name="objectUid" value=":zobj.id"/>
<input type="hidden" name="fieldName" value=":name"/> <input type="hidden" name="fieldName" value=":name"/>
<input if="field.confirm" type="button" class="button" <input if="field.confirm" type="button" class="button"
var="labelConfirm=_(field.labelId + '_confirm')" var="labelConfirm=_(field.labelId + '_confirm')" value=":label"
value=":ztool.truncateValue(label)" title=":label" style=":'%s; %s' % (url('action', bg=True), buttonWidth)"
style=":url('buttonAction', bg=True)"
onclick=":'askConfirm(%s,%s,%s)' % (q('form'), q(formId), \ onclick=":'askConfirm(%s,%s,%s)' % (q('form'), q(formId), \
q(labelConfirm))"/> q(labelConfirm))"/>
<input if="not field.confirm" type="submit" class="button" name="do" <input if="not field.confirm" type="submit" class="button" name="do"
value=":ztool.truncateValue(label)" title=":label" value=":label"
style=":url('buttonAction', bg=True)"/> style=":'%s; %s' % (url('action', bg=True), buttonWidth)"/>
</form>''') </form>''')
# It is not possible to edit an action, not to search it. # It is not possible to edit an action, not to search it.

View file

@ -56,23 +56,26 @@ class Ref(Field):
# objects (delete many, unlink many,...) # objects (delete many, unlink many,...)
pxGlobalActions = Px(''' pxGlobalActions = Px('''
<!-- Insert several objects (if in pick list) --> <!-- Insert several objects (if in pick list) -->
<input if="inPickList" var2="action='link'" type="button" class="button" <input if="inPickList" type="button" class="button"
value=":_('object_link_many')" var2="action='link'; label=_('object_link_many')" value=":label"
onclick=":'onLinkMany(%s,%s)' % (q(action), q(ajaxHookId))" 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 --> <!-- Unlink several objects -->
<input if="not isBack and field.unlink and canWrite and not inPickList" <input if="not isBack and field.unlink and canWrite and not inPickList"
var2="imgName=linkList and 'unlinkManyUp' or 'unlinkMany'; var2="imgName=linkList and 'unlinkManyUp' or 'unlinkMany';
action='unlink'" action='unlink'; label=_('object_unlink_many')"
type="button" class="button" value=":_('object_unlink_many')" type="button" class="button" value=":label"
onclick=":'onLinkMany(%s,%s)' % (q(action), q(ajaxHookId))" 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 --> <!-- Delete several objects -->
<input if="not isBack and field.delete and canWrite" <input if="not isBack and field.delete and canWrite"
var2="action='delete'" var2="action='delete'; label=_('object_delete_many')"
type="button" class="button" value=":_('object_delete_many')" type="button" class="button" value=":label"
onclick=":'onLinkMany(%s,%s)' % (q(action), q(ajaxHookId))" 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 # This PX displays icons for triggering actions on a given referenced object
@ -152,9 +155,10 @@ class Ref(Field):
'%d,%s' % (startNumber, q('CreateWithoutForm'))); '%d,%s' % (startNumber, q('CreateWithoutForm')));
noFormCall=not field.addConfirm and noFormCall or \ noFormCall=not field.addConfirm and noFormCall or \
'askConfirm(%s, %s, %s)' % (q('script'), q(noFormCall), \ 'askConfirm(%s, %s, %s)' % (q('script'), q(noFormCall), \
q(addConfirmMsg))" q(addConfirmMsg));
style=":url('buttonAdd', bg=True)" value=":_('add_ref')" label=_('add_ref')"
onclick=":field.noForm and noFormCall or formCall"/>''') 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 # 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. # ref field according to the field that corresponds to this column.
@ -215,7 +219,9 @@ class Ref(Field):
<x>:field.pxAdd</x> <x>:field.pxAdd</x>
<!-- The search button if field is queryable --> <!-- The search button if field is queryable -->
<input if="objects and field.queryable" type="button" class="button" <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)' % \ onclick=":'goto(%s)' % \
q('%s/search?className=%s&amp;ref=%s:%s' % \ q('%s/search?className=%s&amp;ref=%s:%s' % \
(ztool.absolute_url(), tiedClassName, zobj.id, field.name))"/> (ztool.absolute_url(), tiedClassName, zobj.id, field.name))"/>
@ -235,7 +241,7 @@ class Ref(Field):
<tr if="field.showHeaders"> <tr if="field.showHeaders">
<th if="not inPickList and numbered" width=":numbered"></th> <th if="not inPickList and numbered" width=":numbered"></th>
<th for="column in columns" width=":column.width" <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> <span>:_(refField.labelId)</span>
<x>:field.pxSortIcons</x> <x>:field.pxSortIcons</x>
<x var="className=tiedClassName; <x var="className=tiedClassName;

View file

@ -310,8 +310,8 @@ class Transition:
if user.has_role(condition, obj): if user.has_role(condition, obj):
hasRole = True hasRole = True
else: # It is a method else: # It is a method
if not condition(wf, obj.appy()): res = condition(wf, obj.appy())
return False if not res: return res # False or a No instance.
if hasRole != False: if hasRole != False:
return True return True
@ -387,18 +387,20 @@ class UiTransition:
pxView = Px('''<x> pxView = Px('''<x>
<!-- Real button --> <!-- Real button -->
<input if="transition.mayTrigger" <input if="transition.mayTrigger" type="button" class="button"
type="button" class="button" title=":transition.title" var2="label=transition.title"
style=":url('buttonTransition', bg=True)" style=":'%s; %s' % (url('transition', bg=True), \
value=":ztool.truncateValue(transition.title)" ztool.getButtonWidth(label))"
value=":label"
onclick=":'triggerTransition(%s,%s,%s)' % (q(formId), \ onclick=":'triggerTransition(%s,%s,%s)' % (q(formId), \
q(transition.name), q(transition.confirm))"/> q(transition.name), q(transition.confirm))"/>
<!-- Fake button, explaining why the transition can't be triggered --> <!-- Fake button, explaining why the transition can't be triggered -->
<input type="button" class="button" if="not transition.mayTrigger" <input if="not transition.mayTrigger" type="button"
style=":url('buttonFake', bg=True) + ';cursor: help'" class="fakeButton button" var2="label=transition.title"
value=":ztool.truncateValue(transition.title)" style=":'%s; %s' % (url('fake', bg=True),
title=":'%s: %s' % (transition.title, transition.reason)"/> ztool.getButtonWidth(label))"
value=":label" title=":'%s: %s' % (label, transition.reason)"/>
</x>''') </x>''')
def __init__(self, name, transition, obj, mayTrigger, ): def __init__(self, name, transition, obj, mayTrigger, ):

View file

@ -211,15 +211,10 @@ class Table:
# Some base layouts to use, for fields and pages ------------------------------- # Some base layouts to use, for fields and pages -------------------------------
# The default layouts for pages. # The default layouts for pages.
defaultPageLayouts = { defaultPageLayouts = {
'view': Table('w|-b|', align="center"), 'view': Table('w-b'), 'edit': Table('w-b', width=None)}
'edit': Table('w|-b|', width=None)}
# A layout for pages, containing the page summary. # A layout for pages, containing the page summary.
summaryPageLayouts = {'view': Table('s-w|-b|', align="center"), summaryPageLayouts = {'view': Table('s-w-b'), 'edit': Table('w-b', width=None)}
'edit': Table('w|-b|', width=None)} widePageLayouts = {'view': Table('w-b'), 'edit': Table('w-b')}
widePageLayouts = {
'view': Table('w|-b|', align="center"),
'edit': Table('w|-b|')
}
centeredPageLayouts = { centeredPageLayouts = {
'view': Table('w|-b|', align="center"), 'view': Table('w|-b|', align="center"),
'edit': Table('w|-b|', width=None, align='center') 'edit': Table('w|-b|', width=None, align='center')

View file

@ -1352,4 +1352,15 @@ class ToolMixin(BaseMixin):
"s.parentNode.insertBefore(ga, s);\n" \ "s.parentNode.insertBefore(ga, s);\n" \
"})();\n" % gaId "})();\n" % gaId
return code return code
def getButtonWidth(self, label):
'''Determine button width, in pixels, corresponding to the button
p_label.'''
l = len(label)
if l < 10:
width = '130px'
else:
# Consider 1 char = 6 pixels wide.
width = '%dpx' % (130 + ((l-10)*4))
return 'width:%s' % width
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------

View file

@ -855,7 +855,7 @@ class BaseMixin:
can't trigger, but for which he needs to know for what reason he can't trigger, but for which he needs to know for what reason he
can't trigger it; can't trigger it;
* if p_includeNotShowable is True, it includes transitions for which * if p_includeNotShowable is True, it includes transitions for which
show=False. Indeed, because "showability" is only a GUI concern, show=False. Indeed, because "showability" is only a UI concern,
and not a security concern, in some cases it has sense to set and not a security concern, in some cases it has sense to set
includeNotShowable=True, because those transitions are triggerable includeNotShowable=True, because those transitions are triggerable
from a security point of view. from a security point of view.

BIN
gen/ui/action.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

BIN
gen/ui/add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

View file

@ -66,9 +66,11 @@ img { border: 0; vertical-align: middle }
background-color: #dbdde1; font-weight: bold } background-color: #dbdde1; font-weight: bold }
.navigate td { padding: 4px 9px } .navigate td { padding: 4px 9px }
.login { margin: 3px; color: black } .login { margin: 3px; color: black }
input.button { border-width: 0 !important; color: #666666; height: 24px; input.button { color: #666666; height: 20px; width: 130px;
width: 150px; cursor:pointer; font-size: 90%; padding: 1px 0 0 10px; cursor:pointer; font-size: 90%; padding-left: 10px;
background-color: transparent !important } background-color: white; background-repeat: no-repeat;
background-position: 5% 25%; box-shadow: 2px 2px 2px #888888}
.fakeButton { background-color: #e6e6e6 !important ; cursor:help !important }
.buttons { margin-left: 4px } .buttons { margin-left: 4px }
.message { position: absolute; top: -40px; left: 50%; font-size: 90%; .message { position: absolute; top: -40px; left: 50%; font-size: 90%;
width: 600px; border: 1px #F0C36D solid; padding: 6px; width: 600px; border: 1px #F0C36D solid; padding: 6px;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 877 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 773 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 747 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 B

After

Width:  |  Height:  |  Size: 259 B

BIN
gen/ui/fake.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 657 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 288 B

BIN
gen/ui/next.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

BIN
gen/ui/previous.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

BIN
gen/ui/save.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 B

BIN
gen/ui/transition.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

After

Width:  |  Height:  |  Size: 243 B

View file

@ -192,7 +192,9 @@ class ToolWrapper(AbstractWrapper):
<!-- Create a new object from a web form. --> <!-- Create a new object from a web form. -->
<input type="button" class="button" <input type="button" class="button"
if="mayCreate and ('form' in createMeans)" if="mayCreate and ('form' in createMeans)"
style=":url('buttonAdd', bg=True)" value=":_('query_create')" var2="label=_('query_create')" value=":label"
style=":'%s; %s' % (url('add', bg=True), \
ztool.getButtonWidth(label))"
onclick=":'goto(%s)' % \ onclick=":'goto(%s)' % \
q('%s/do?action=Create&amp;className=%s' % \ q('%s/do?action=Create&amp;className=%s' % \
(toolUrl, className))"/> (toolUrl, className))"/>
@ -209,7 +211,7 @@ class ToolWrapper(AbstractWrapper):
<td><input type="text" size="14" name="w_SearchableText" <td><input type="text" size="14" name="w_SearchableText"
class="inputSearch"/></td> class="inputSearch"/></td>
<td> <td>
<input type="image" class="clickable" src=":url('search.gif')" <input type="image" class="clickable" src=":url('search')"
title=":_('search_button')"/></td> title=":_('search_button')"/></td>
</tr> </tr>
</table> </table>
@ -521,8 +523,10 @@ class ToolWrapper(AbstractWrapper):
<!-- Submit button --> <!-- Submit button -->
<p align=":dright"><br/> <p align=":dright"><br/>
<input type="submit" class="button" value=":_('search_button')" <input type="submit" class="button" var="label=_('search_button')"
style=":url('buttonSearch', bg=True)"/> value=":label"
style=":'%s; %s' % (url('search', bg=True), \
ztool.getButtonWidth(label))"/>
</p> </p>
</form> </form>
</x>''', template=AbstractWrapper.pxTemplate, hook='content') </x>''', template=AbstractWrapper.pxTemplate, hook='content')

View file

@ -370,7 +370,7 @@ class AbstractWrapper(object):
<!-- Input field for storing the comment coming from the popup --> <!-- Input field for storing the comment coming from the popup -->
<textarea id="comment" name="comment" cols="30" rows="3" <textarea id="comment" name="comment" cols="30" rows="3"
style="display:none"></textarea> style="display:none"></textarea>
<table> <table cellpadding="0" cellspacing="0">
<tr valign="middle"> <tr valign="middle">
<td align=":dright" for="transition in transitions"> <td align=":dright" for="transition in transitions">
<!-- Render a transition or a group of transitions. --> <!-- Render a transition or a group of transitions. -->
@ -448,31 +448,36 @@ class AbstractWrapper(object):
pageInfo=phaseObj.pagesInfo[page]"> pageInfo=phaseObj.pagesInfo[page]">
<tr valign="top"> <tr valign="top">
<!-- Previous --> <!-- Previous -->
<td if="previousPage and pageInfo.showPrevious"> <td if="previousPage and pageInfo.showPrevious"
var2="label=_('page_previous');
buttonWidth=ztool.getButtonWidth(label)">
<!-- Button on the edit page --> <!-- Button on the edit page -->
<x if="isEdit"> <x if="isEdit">
<input type="button" class="button" value=":_('page_previous')" <input type="button" class="button" value=":label"
onClick="submitAppyForm('previous')" onClick="submitAppyForm('previous')"
style=":url('buttonPrevious', bg=True)"/> style=":'%s; %s' % (url('previous', bg=True), buttonWidth)"/>
<input type="hidden" name="previousPage" value=":previousPage"/> <input type="hidden" name="previousPage" value=":previousPage"/>
</x> </x>
<!-- Button on the view page --> <!-- Button on the view page -->
<input if="not isEdit" type="button" class="button" <input if="not isEdit" type="button" class="button" value=":label"
value=":_('page_previous')" style=":'%s; %s' % (url('previous', bg=True), buttonWidth)"
style=":url('buttonPrevious', bg=True)"
onclick=":'goto(%s)' % q(zobj.getUrl(page=previousPage))"/> onclick=":'goto(%s)' % q(zobj.getUrl(page=previousPage))"/>
</td> </td>
<!-- Save --> <!-- Save -->
<td if="isEdit and pageInfo.showSave"> <td if="isEdit and pageInfo.showSave">
<input type="button" class="button" onClick="submitAppyForm('save')" <input type="button" class="button" onClick="submitAppyForm('save')"
style=":url('buttonSave', bg=True)" value=":_('object_save')"/> var="label=_('object_save')" value=":label"
style=":'%s; %s' % (url('save', bg=True), \
ztool.getButtonWidth(label))" />
</td> </td>
<!-- Cancel --> <!-- Cancel -->
<td if="isEdit and pageInfo.showCancel"> <td if="isEdit and pageInfo.showCancel">
<input type="button" class="button" onClick="submitAppyForm('cancel')" <input type="button" class="button" onClick="submitAppyForm('cancel')"
style=":url('buttonCancel', bg=True)" value=":_('object_cancel')"/> var="label=_('object_cancel')" value=":label"
style=":'%s; %s' % (url('cancel', bg=True), \
ztool.getButtonWidth(label))"/>
</td> </td>
<td if="not isEdit" <td if="not isEdit"
@ -482,7 +487,9 @@ class AbstractWrapper(object):
<!-- Edit --> <!-- Edit -->
<input type="button" class="button" if="editable and not locked" <input type="button" class="button" if="editable and not locked"
style=":url('buttonEdit', bg=True)" value=":_('object_edit')" var="label=_('object_edit')" value=":label"
style=":'%s; %s' % (url('edit', bg=True), \
ztool.getButtonWidth(label))"
onclick=":'goto(%s)' % q(zobj.getUrl(mode='edit', page=page))"/> onclick=":'goto(%s)' % q(zobj.getUrl(mode='edit', page=page))"/>
<!-- Locked --> <!-- Locked -->
@ -496,20 +503,23 @@ class AbstractWrapper(object):
<a if="editable and locked and user.has_role('Manager')"> <a if="editable and locked and user.has_role('Manager')">
<img class="clickable" title=":_('page_unlock')" <img class="clickable" title=":_('page_unlock')"
src=":url('unlockBig')" src=":url('unlockBig')"
onclick=":'onUnlockPage(%s,%s)' % (q(zobj.UID()), q(page))"/></a> onclick=":'onUnlockPage(%s,%s)' % (q(zobj.id), q(page))"/></a>
</td> </td>
<!-- Next --> <!-- Next -->
<td if="nextPage and pageInfo.showNext"> <td if="nextPage and pageInfo.showNext"
var2="label=_('page_next');
buttonWidth=ztool.getButtonWidth(label)">
<!-- Button on the edit page --> <!-- Button on the edit page -->
<x if="isEdit"> <x if="isEdit">
<input type="button" class="button" onClick="submitAppyForm('next')" <input type="button" class="button" onClick="submitAppyForm('next')"
style=":url('buttonNext', bg=True)" value=":_('page_next')"/> style=":'%s; %s' % (url('next', bg=True), buttonWidth)"
value=":label"/>
<input type="hidden" name="nextPage" value=":nextPage"/> <input type="hidden" name="nextPage" value=":nextPage"/>
</x> </x>
<!-- Button on the view page --> <!-- Button on the view page -->
<input if="not isEdit" type="button" class="button" <input if="not isEdit" type="button" class="button" value=":label"
style=":url('buttonNext', bg=True)" value=":_('page_next')" style=":'%s; %s' % (url('next', bg=True), buttonWidth)"
onclick=":'goto(%s)' % q(zobj.getUrl(page=nextPage))"/> onclick=":'goto(%s)' % q(zobj.getUrl(page=nextPage))"/>
</td> </td>