[gen] Within Ref fields, added 2 icons for moving tied objects to top or bottom + bugfixes.

This commit is contained in:
Gaetan Delannay 2014-04-15 13:01:39 +02:00
parent ac08d2d795
commit 036856f07e
23 changed files with 113 additions and 29 deletions

View file

@ -45,7 +45,7 @@ class Calendar(Field):
goForward=not endDate or (endDate.strftime(fmt) > \ goForward=not endDate or (endDate.strftime(fmt) > \
grid[-1][-1].strftime(fmt))"> grid[-1][-1].strftime(fmt))">
<!-- Go to the previous month --> <!-- Go to the previous month -->
<img class="clickable" if="goBack" src=":url('arrowLeftSimple')" <img class="clickable" if="goBack" src=":url('arrowLeft')"
onclick=":'askMonthView(%s,%s,%s,%s)' % \ onclick=":'askMonthView(%s,%s,%s,%s)' % \
(q(ajaxHookId),q(objUrl),q(field.name),q(previousMonth))"/> (q(ajaxHookId),q(objUrl),q(field.name),q(previousMonth))"/>
<!-- Go back to the default date --> <!-- Go back to the default date -->
@ -58,7 +58,7 @@ class Calendar(Field):
q(objUrl), q(field.name), q(defaultDateMonth))" q(objUrl), q(field.name), q(defaultDateMonth))"
disabled=":defaultDate.strftime(fmt)==monthDayOne.strftime(fmt)"/> disabled=":defaultDate.strftime(fmt)==monthDayOne.strftime(fmt)"/>
<!-- Go to the next month --> <!-- Go to the next month -->
<img class="clickable" if="goForward" src=":url('arrowRightSimple')" <img class="clickable" if="goForward" src=":url('arrowRight')"
onclick=":'askMonthView(%s, %s, %s, %s)' % (q(ajaxHookId), \ onclick=":'askMonthView(%s, %s, %s, %s)' % (q(ajaxHookId), \
q(objUrl), q(field.name), q(nextMonth))"/> q(objUrl), q(field.name), q(nextMonth))"/>
<span>:_('month_%s' % monthDayOne.aMonth())</span> <span>:_('month_%s' % monthDayOne.aMonth())</span>

View file

@ -78,18 +78,28 @@ class Ref(Field):
# This PX displays icons for triggering actions on a given referenced object # This PX displays icons for triggering actions on a given referenced object
# (edit, delete, etc). # (edit, delete, etc).
pxObjectActions = Px(''' pxObjectActions = Px('''
<table class="noStyle"> <table class="noStyle" var="tiedUid=tied.o.id">
<tr> <tr>
<!-- Arrows for moving objects up or down --> <!-- Arrows for moving objects up or down -->
<td if="not isBack and (len(objects)&gt;1) and changeOrder and canWrite \ <td if="not isBack and (totalNumber &gt;1) and changeOrder and canWrite \
and not inPickList" and not inPickList"
var2="objectIndex=field.getIndexOf(zobj, tied); var2="objectIndex=field.getIndexOf(zobj, tiedUid);
ajaxBaseCall=navBaseCall.replace('**v**','%s,%s,{%s:%s,%s:%s}'%\ ajaxBaseCall=navBaseCall.replace('**v**','%s,%s,{%s:%s,%s:%s}'%\
(q(startNumber), q('doChangeOrder'), q('refObjectUid'), (q(startNumber), q('doChangeOrder'), q('refObjectUid'),
q(tied.o.id), q('move'), q('**v**')))"> q(tiedUid), q('move'), q('**v**')))">
<!-- Move to top -->
<img if="objectIndex &gt; 1" class="clickable"
src=":url('arrowsUp')" title=":_('move_top')"
onclick=":ajaxBaseCall.replace('**v**', 'top')"/>
<!-- Move to bottom -->
<img if="objectIndex &lt; (totalNumber-2)" class="clickable"
src=":url('arrowsDown')" title=":_('move_bottom')"
onclick=":ajaxBaseCall.replace('**v**', 'bottom')"/>
<!-- Move up -->
<img if="objectIndex &gt; 0" class="clickable" src=":url('arrowUp')" <img if="objectIndex &gt; 0" class="clickable" src=":url('arrowUp')"
title=":_('move_up')" title=":_('move_up')"
onclick=":ajaxBaseCall.replace('**v**', 'up')"/> onclick=":ajaxBaseCall.replace('**v**', 'up')"/>
<!-- Move down -->
<img if="objectIndex &lt; (totalNumber-1)" class="clickable" <img if="objectIndex &lt; (totalNumber-1)" class="clickable"
src=":url('arrowDown')" title=":_('move_down')" src=":url('arrowDown')" title=":_('move_down')"
onclick=":ajaxBaseCall.replace('**v**', 'down')"/> onclick=":ajaxBaseCall.replace('**v**', 'down')"/>
@ -107,7 +117,7 @@ class Ref(Field):
<!-- Delete --> <!-- Delete -->
<td if="not isBack and field.delete and canWrite and tied.o.mayDelete()"> <td if="not isBack and field.delete and canWrite and tied.o.mayDelete()">
<img class="clickable" title=":_('object_delete')" src=":url('delete')" <img class="clickable" title=":_('object_delete')" src=":url('delete')"
onclick=":'onDeleteObject(%s)' % q(tied.o.id)"/> onclick=":'onDeleteObject(%s)' % q(tiedUid)"/>
</td> </td>
<!-- Unlink --> <!-- Unlink -->
<td if="not isBack and field.unlink and canWrite and not inPickList"> <td if="not isBack and field.unlink and canWrite and not inPickList">
@ -115,14 +125,14 @@ class Ref(Field):
action='unlink'" action='unlink'"
class="clickable" title=":_('object_unlink')" src=":url(imgName)" class="clickable" title=":_('object_unlink')" src=":url(imgName)"
onclick=":'onLink(%s,%s,%s,%s)' % (q(action), q(zobj.id), \ onclick=":'onLink(%s,%s,%s,%s)' % (q(action), q(zobj.id), \
q(field.name), q(tied.o.id))"/> q(field.name), q(tiedUid))"/>
</td> </td>
<!-- Insert (if in pick list) --> <!-- Insert (if in pick list) -->
<td if="inPickList"> <td if="inPickList">
<img var="action='link'" class="clickable" title=":_('object_link')" <img var="action='link'" class="clickable" title=":_('object_link')"
src=":url(action)" src=":url(action)"
onclick=":'onLink(%s,%s,%s,%s)' % (q(action), q(zobj.id), \ onclick=":'onLink(%s,%s,%s,%s)' % (q(action), q(zobj.id), \
q(field.name), q(tied.o.id))"/> q(field.name), q(tiedUid))"/>
</td> </td>
</tr> </tr>
</table>''') </table>''')
@ -923,16 +933,25 @@ class Ref(Field):
(obj.id, self.name, code % ('objs', 'objs'), poss) (obj.id, self.name, code % ('objs', 'objs'), poss)
def doChangeOrder(self, obj): def doChangeOrder(self, obj):
'''Moves a referred object up or down.''' '''Moves a referred object up/down/top/bottom.'''
rq = obj.REQUEST rq = obj.REQUEST
# Move the item up (-1), down (+1) ? # How to move the item?
move = (rq['move'] == 'down') and 1 or -1 move = rq['move']
# The UID of the referred object to move # Get the UID of the tied object to move
uid = rq['refObjectUid'] uid = rq['refObjectUid']
uids = getattr(obj.aq_base, self.name) uids = getattr(obj.aq_base, self.name)
oldIndex = uids.index(uid) oldIndex = uids.index(uid)
# Remove the object from its previous position.
uids.remove(uid) uids.remove(uid)
newIndex = oldIndex + move # Re-insert the object at its new position.
if move == 'up':
newIndex = oldIndex - 1
elif move == 'down':
newIndex = oldIndex + 1
elif move == 'top':
newIndex = 0
elif move == 'bottom':
newIndex = len(uids)
uids.insert(newIndex, uid) uids.insert(newIndex, uid)
xhtmlToText = re.compile('<.*?>', re.S) xhtmlToText = re.compile('<.*?>', re.S)
@ -959,11 +978,12 @@ class Ref(Field):
res = refObject.tool.o.truncateValue(res, maxWidth) res = refObject.tool.o.truncateValue(res, maxWidth)
return res return res
def getIndexOf(self, obj, refObj): def getIndexOf(self, obj, tiedUid):
'''Gets the position of p_refObj within this field on p_obj.''' '''Gets the position of tied object identified by p_tiedUid within this
field on p_obj.'''
uids = getattr(obj.aq_base, self.name, None) uids = getattr(obj.aq_base, self.name, None)
if not uids: raise IndexError() if not uids: raise IndexError()
return uids.index(refObj.o.id) return uids.index(tiedUid)
def sort(self, obj): def sort(self, obj):
'''Called when the user wants to sort the content of this field.''' '''Called when the user wants to sort the content of this field.'''

View file

@ -103,6 +103,14 @@ msgstr ""
msgid "move_down" msgid "move_down"
msgstr "" msgstr ""
#. Default: "Move to top"
msgid "move_top"
msgstr ""
#. Default: "Move to bottom"
msgid "move_bottom"
msgstr ""
#. Default: "create" #. Default: "create"
msgid "query_create" msgid "query_create"
msgstr "" msgstr ""

View file

@ -103,6 +103,14 @@ msgstr ""
msgid "move_down" msgid "move_down"
msgstr "" msgstr ""
#. Default: "Move to top"
msgid "move_top"
msgstr ""
#. Default: "Move to bottom"
msgid "move_bottom"
msgstr ""
#. Default: "create" #. Default: "create"
msgid "query_create" msgid "query_create"
msgstr "" msgstr ""

View file

@ -103,6 +103,14 @@ msgstr "Nach oben verschieben"
msgid "move_down" msgid "move_down"
msgstr "Nach unten verschieben" msgstr "Nach unten verschieben"
#. Default: "Move to top"
msgid "move_top"
msgstr ""
#. Default: "Move to bottom"
msgid "move_bottom"
msgstr ""
#. Default: "create" #. Default: "create"
msgid "query_create" msgid "query_create"
msgstr "Anfertigen" msgstr "Anfertigen"

View file

@ -104,6 +104,14 @@ msgstr "Move up"
msgid "move_down" msgid "move_down"
msgstr "Move down" msgstr "Move down"
#. Default: "Move to top"
msgid "move_top"
msgstr "Move to top"
#. Default: "Move to bottom"
msgid "move_bottom"
msgstr "Move to bottom"
#. Default: "create" #. Default: "create"
msgid "query_create" msgid "query_create"
msgstr "create" msgstr "create"

View file

@ -103,6 +103,14 @@ msgstr "Mueva hacia arriba"
msgid "move_down" msgid "move_down"
msgstr "Mueva hacia abajo" msgstr "Mueva hacia abajo"
#. Default: "Move to top"
msgid "move_top"
msgstr ""
#. Default: "Move to bottom"
msgid "move_bottom"
msgstr ""
#. Default: "create" #. Default: "create"
msgid "query_create" msgid "query_create"
msgstr "Crear" msgstr "Crear"

View file

@ -104,6 +104,14 @@ msgstr "Déplacer vers le haut"
msgid "move_down" msgid "move_down"
msgstr "Déplacer vers le bas" msgstr "Déplacer vers le bas"
#. Default: "Move to top"
msgid "move_top"
msgstr "Déplacer en première position"
#. Default: "Move to bottom"
msgid "move_bottom"
msgstr "Déplacer en dernière position"
#. Default: "create" #. Default: "create"
msgid "query_create" msgid "query_create"
msgstr "Créer" msgstr "Créer"

View file

@ -103,6 +103,14 @@ msgstr "Su"
msgid "move_down" msgid "move_down"
msgstr "Giù" msgstr "Giù"
#. Default: "Move to top"
msgid "move_top"
msgstr ""
#. Default: "Move to bottom"
msgid "move_bottom"
msgstr ""
#. Default: "create" #. Default: "create"
msgid "query_create" msgid "query_create"
msgstr "Creazione in corso" msgstr "Creazione in corso"

View file

@ -103,6 +103,14 @@ msgstr "Verplaats naar boven"
msgid "move_down" msgid "move_down"
msgstr "Verplaats naar beneden" msgstr "Verplaats naar beneden"
#. Default: "Move to top"
msgid "move_top"
msgstr ""
#. Default: "Move to bottom"
msgid "move_bottom"
msgstr ""
#. Default: "create" #. Default: "create"
msgid "query_create" msgid "query_create"
msgstr "Aanmaken" msgstr "Aanmaken"

View file

@ -48,9 +48,9 @@ function len(dict) {
return res; return res;
} }
function switchLanguage(selectWidget) { function switchLanguage(selectWidget, siteUrl) {
var language = selectWidget.options[selectWidget.selectedIndex].value; var language = selectWidget.options[selectWidget.selectedIndex].value;
goto("/config/changeLanguage?language=" + language); goto(siteUrl + '/config/changeLanguage?language=' + language);
} }
var isIe = (navigator.appName == "Microsoft Internet Explorer"); var isIe = (navigator.appName == "Microsoft Internet Explorer");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

After

Width:  |  Height:  |  Size: 234 B

View file

Before

Width:  |  Height:  |  Size: 218 B

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 B

BIN
gen/ui/arrowRight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 216 B

BIN
gen/ui/arrowsDown.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

BIN
gen/ui/arrowsLeft.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 236 B

BIN
gen/ui/arrowsRight.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

BIN
gen/ui/arrowsUp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

View file

@ -50,13 +50,13 @@ class ToolWrapper(AbstractWrapper):
<tr valign="bottom"> <tr valign="bottom">
<!-- Go to the first page --> <!-- Go to the first page -->
<td if="(startNumber != 0) and (startNumber != batchSize)"><img <td if="(startNumber != 0) and (startNumber != batchSize)"><img
class="clickable" src=":url('arrowLeftDouble')" class="clickable" src=":url('arrowsLeft')"
title=":_('goto_first')" title=":_('goto_first')"
onClick=":navBaseCall.replace('**v**', '0'+sortAndFilter)"/></td> onClick=":navBaseCall.replace('**v**', '0'+sortAndFilter)"/></td>
<!-- Go to the previous page --> <!-- Go to the previous page -->
<td var="sNumber=startNumber - batchSize" if="startNumber != 0"><img <td var="sNumber=startNumber - batchSize" if="startNumber != 0"><img
class="clickable" src=":url('arrowLeftSimple')" class="clickable" src=":url('arrowLeft')"
title=":_('goto_previous')" title=":_('goto_previous')"
onClick=":navBaseCall.replace('**v**', \ onClick=":navBaseCall.replace('**v**', \
str(sNumber)+sortAndFilter)"/></td> str(sNumber)+sortAndFilter)"/></td>
@ -70,7 +70,7 @@ class ToolWrapper(AbstractWrapper):
<!-- Go to the next page --> <!-- Go to the next page -->
<td var="sNumber=startNumber + batchSize" <td var="sNumber=startNumber + batchSize"
if="sNumber &lt; totalNumber"><img class="clickable" if="sNumber &lt; totalNumber"><img class="clickable"
src=":url('arrowRightSimple')" title=":_('goto_next')" src=":url('arrowRight')" title=":_('goto_next')"
onClick=":navBaseCall.replace('**v**', \ onClick=":navBaseCall.replace('**v**', \
str(sNumber)+sortAndFilter)"/></td> str(sNumber)+sortAndFilter)"/></td>
@ -82,7 +82,7 @@ class ToolWrapper(AbstractWrapper):
sNumber= nbOfCountedPages * batchSize" sNumber= nbOfCountedPages * batchSize"
if="(startNumber != sNumber) and \ if="(startNumber != sNumber) and \
(startNumber != sNumber-batchSize)"><img class="clickable" (startNumber != sNumber-batchSize)"><img class="clickable"
src=":url('arrowRightDouble')" title=":_('goto_last')" src=":url('arrowsRight')" title=":_('goto_last')"
onClick=":navBaseCall.replace('**v**', \ onClick=":navBaseCall.replace('**v**', \
str(sNumber)+sortAndFilter)"/></td> str(sNumber)+sortAndFilter)"/></td>
</tr> </tr>

View file

@ -31,9 +31,9 @@ class AbstractWrapper(object):
<!-- Go to the first or previous page --> <!-- Go to the first or previous page -->
<a if="ni.firstUrl" href=":ni.firstUrl"><img title=":_('goto_first')" <a if="ni.firstUrl" href=":ni.firstUrl"><img title=":_('goto_first')"
src=":url('arrowLeftDouble')"/></a><a src=":url('arrowsLeft')"/></a><a
if="ni.previousUrl" href=":ni.previousUrl"><img if="ni.previousUrl" href=":ni.previousUrl"><img
title=":_('goto_previous')" src=":url('arrowLeftSimple')"/></a> title=":_('goto_previous')" src=":url('arrowLeft')"/></a>
<!-- Explain which element is currently shown --> <!-- Explain which element is currently shown -->
<span class="discreet"> <span class="discreet">
@ -42,9 +42,9 @@ class AbstractWrapper(object):
<!-- Go to the next or last page --> <!-- Go to the next or last page -->
<a if="ni.nextUrl" href=":ni.nextUrl"><img title=":_('goto_next')" <a if="ni.nextUrl" href=":ni.nextUrl"><img title=":_('goto_next')"
src=":url('arrowRightSimple')"/></a><a src=":url('arrowRight')"/></a><a
if="ni.lastUrl" href=":ni.lastUrl"><img title=":_('goto_last')" if="ni.lastUrl" href=":ni.lastUrl"><img title=":_('goto_last')"
src=":url('arrowRightDouble')"/></a> src=":url('arrowsRight')"/></a>
</div>''') </div>''')
pxNavigationStrip = Px(''' pxNavigationStrip = Px('''
@ -188,10 +188,10 @@ class AbstractWrapper(object):
class="pageLink clickable">:_('app_connect')</a> class="pageLink clickable">:_('app_connect')</a>
<!-- Language selector --> <!-- Language selector -->
<select if="ztool.showLanguageSelector()" <select if="ztool.showLanguageSelector()" class="pageLink"
var2="languages=ztool.getLanguages(); var2="languages=ztool.getLanguages();
defaultLanguage=languages[0]" defaultLanguage=languages[0]"
class="pageLink" onchange="switchLanguage(this)"> onchange=":'switchLanguage(this,%s)' % q(ztool.getSiteUrl())">
<option for="lg in languages" value=":lg" <option for="lg in languages" value=":lg"
selected=":lang == lg">:ztool.getLanguageName(lg)</option> selected=":lang == lg">:ztool.getLanguageName(lg)</option>
</select> </select>