[gen] Ref field: added a confirmation popup when the user wants to sort the ref. Indeed, most users think it is like sorting query results: they are not conscious it is a permanent change in the database, with effect for all users.

This commit is contained in:
Gaetan Delannay 2014-10-07 15:03:07 +02:00
parent c2676c9cf8
commit a16871f4b5
11 changed files with 57 additions and 17 deletions

View file

@ -328,8 +328,9 @@ class Field:
return self.indexed and not self.isMultiValued() and not \ return self.indexed and not self.isMultiValued() and not \
((self.type == 'String') and self.isSelection()) ((self.type == 'String') and self.isSelection())
elif usage == 'ref': elif usage == 'ref':
return self.type in ('Integer', 'Float', 'Boolean', 'Date') or \ if self.type in ('Integer', 'Float', 'Boolean', 'Date'): return True
((self.type == 'String') and (self.format == 0)) elif self.type == 'String':
return (self.format == 0) and not self.isMultilingual(None,True)
def isShowable(self, obj, layoutType): def isShowable(self, obj, layoutType):
'''When displaying p_obj on a given p_layoutType, must we show this '''When displaying p_obj on a given p_layoutType, must we show this

View file

@ -189,9 +189,13 @@ class Ref(Field):
(q(startNumber), q('sort'), q('sortKey'), q(refField.name), \ (q(startNumber), q('sort'), q('sortKey'), q(refField.name), \
q('reverse'), q('**v**')))"> q('reverse'), q('**v**')))">
<img class="clickable" src=":url('sortAsc')" <img class="clickable" src=":url('sortAsc')"
onclick=":ajaxBaseCall.replace('**v**', 'False')"/> var="js=ajaxBaseCall.replace('**v**', 'False')"
onclick=":'askConfirm(%s,%s,%s)' % (q('script'), q(js,False), \
q(sortConfirm))"/>
<img class="clickable" src=":url('sortDesc')" <img class="clickable" src=":url('sortDesc')"
onclick=":ajaxBaseCall.replace('**v**', 'True')"/> var="js=ajaxBaseCall.replace('**v**', 'True')"
onclick=":'askConfirm(%s,%s,%s)' % (q('script'), q(js,False), \
q(sortConfirm))"/>
</x>''') </x>''')
# Shows the object number in a numbered list of tied objects. # Shows the object number in a numbered list of tied objects.
@ -430,6 +434,7 @@ class Ref(Field):
navBaseCall='askRefField(%s,%s,%s,**v**)' % \ navBaseCall='askRefField(%s,%s,%s,**v**)' % \
(q(ajaxHookId), q(zobj.absolute_url()), q(innerRef)); (q(ajaxHookId), q(zobj.absolute_url()), q(innerRef));
changeOrder=mayEdit and field.getAttribute(zobj, 'changeOrder'); changeOrder=mayEdit and field.getAttribute(zobj, 'changeOrder');
sortConfirm=changeOrder and _('sort_confirm');
numbered=field.isNumbered(zobj); numbered=field.isNumbered(zobj);
changeNumber=not inPickList and numbered and changeOrder and \ changeNumber=not inPickList and numbered and changeOrder and \
(totalNumber &gt; 3); (totalNumber &gt; 3);

View file

@ -476,10 +476,12 @@ class String(Field):
res = False res = False
return res return res
def isMultilingual(self, obj): def isMultilingual(self, obj, dontKnow=False):
'''Is this field multilingual ?.''' '''Is this field multilingual ? If we don't know, say p_dontKnow.'''
# In the following case, impossible to know: we say no. # In the following case, impossible to know: we say no.
if not obj and callable(self.languages): return if not obj:
if callable(self.languages): return dontKnow
else: return len(self.languages) > 1
return len(self.getAttribute(obj, 'languages')) > 1 return len(self.getAttribute(obj, 'languages')) > 1
def getDefaultLayouts(self): def getDefaultLayouts(self):

View file

@ -83,7 +83,7 @@ msgstr ""
msgid "no_ref" msgid "no_ref"
msgstr "" msgstr ""
#. Default: "Add a new one" #. Default: "Add"
msgid "add_ref" msgid "add_ref"
msgstr "" msgstr ""
@ -251,6 +251,10 @@ msgstr ""
msgid "save_confirm" msgid "save_confirm"
msgstr "" msgstr ""
#. Default: "Are you sure? You are going to permanently change the order of these elements, for all users."
msgid "sort_confirm"
msgstr ""
#. Default: "Go to top" #. Default: "Go to top"
msgid "goto_first" msgid "goto_first"
msgstr "" msgstr ""

View file

@ -83,7 +83,7 @@ msgstr ""
msgid "no_ref" msgid "no_ref"
msgstr "" msgstr ""
#. Default: "Add a new one" #. Default: "Add"
msgid "add_ref" msgid "add_ref"
msgstr "" msgstr ""
@ -251,6 +251,10 @@ msgstr ""
msgid "save_confirm" msgid "save_confirm"
msgstr "" msgstr ""
#. Default: "Are you sure? You are going to permanently change the order of these elements, for all users."
msgid "sort_confirm"
msgstr ""
#. Default: "Go to top" #. Default: "Go to top"
msgid "goto_first" msgid "goto_first"
msgstr "" msgstr ""

View file

@ -83,7 +83,7 @@ msgstr "Sie haben zuviele Elemente ausgewählt."
msgid "no_ref" msgid "no_ref"
msgstr "Kein Element" msgstr "Kein Element"
#. Default: "Add a new one" #. Default: "Add"
msgid "add_ref" msgid "add_ref"
msgstr "Hinzufügen" msgstr "Hinzufügen"
@ -251,6 +251,10 @@ msgstr ""
msgid "save_confirm" msgid "save_confirm"
msgstr "" msgstr ""
#. Default: "Are you sure? You are going to permanently change the order of these elements, for all users."
msgid "sort_confirm"
msgstr ""
#. Default: "Go to top" #. Default: "Go to top"
msgid "goto_first" msgid "goto_first"
msgstr "Zurück zum Anfang" msgstr "Zurück zum Anfang"

View file

@ -84,9 +84,9 @@ msgstr "Too much elements are selected here."
msgid "no_ref" msgid "no_ref"
msgstr "No object." msgstr "No object."
#. Default: "Add a new one" #. Default: "Add"
msgid "add_ref" msgid "add_ref"
msgstr "Add a new one" msgstr "Add"
#. Default: "Available elements" #. Default: "Available elements"
msgid "selectable_objects" msgid "selectable_objects"
@ -252,6 +252,10 @@ msgstr "Action had no effect."
msgid "save_confirm" msgid "save_confirm"
msgstr "Are you sure you want to apply this change?" msgstr "Are you sure you want to apply this change?"
#. Default: "Are you sure? You are going to permanently change the order of these elements, for all users."
msgid "sort_confirm"
msgstr "Are you sure? You are going to permanently change the order of these elements, for all users."
#. Default: "Go to top" #. Default: "Go to top"
msgid "goto_first" msgid "goto_first"
msgstr "Go to top" msgstr "Go to top"

View file

@ -83,7 +83,7 @@ msgstr "Demasiados elementos son seleccionados aquí."
msgid "no_ref" msgid "no_ref"
msgstr "Ningún elemento." msgstr "Ningún elemento."
#. Default: "Add a new one" #. Default: "Add"
msgid "add_ref" msgid "add_ref"
msgstr "Añadir" msgstr "Añadir"
@ -251,6 +251,10 @@ msgstr ""
msgid "save_confirm" msgid "save_confirm"
msgstr "" msgstr ""
#. Default: "Are you sure? You are going to permanently change the order of these elements, for all users."
msgid "sort_confirm"
msgstr ""
#. Default: "Go to top" #. Default: "Go to top"
msgid "goto_first" msgid "goto_first"
msgstr "Ir al inicio" msgstr "Ir al inicio"

View file

@ -84,7 +84,7 @@ msgstr "Trop d'éléments sont sélectionnés ici."
msgid "no_ref" msgid "no_ref"
msgstr "-" msgstr "-"
#. Default: "Add a new one" #. Default: "Add"
msgid "add_ref" msgid "add_ref"
msgstr "Ajouter" msgstr "Ajouter"
@ -252,6 +252,10 @@ msgstr "L'action n'a eu aucun effet."
msgid "save_confirm" msgid "save_confirm"
msgstr "Êtes-vous sûr de vouloir appliquer ce changement?" msgstr "Êtes-vous sûr de vouloir appliquer ce changement?"
#. Default: "Are you sure? You are going to permanently change the order of these elements, for all users."
msgid "sort_confirm"
msgstr "Êtes-vous sûr? Vous allez changer l'ordre de ces éléments de manière permanente, pour tous les utilisateurs."
#. Default: "Go to top" #. Default: "Go to top"
msgid "goto_first" msgid "goto_first"
msgstr "Aller au début" msgstr "Aller au début"

View file

@ -83,9 +83,9 @@ msgstr "Un numero eccessivo di elementi sono scelti"
msgid "no_ref" msgid "no_ref"
msgstr "-" msgstr "-"
#. Default: "Add a new one" #. Default: "Add"
msgid "add_ref" msgid "add_ref"
msgstr "Aggiungi un nuovo" msgstr "Aggiungi"
#. Default: "Available elements" #. Default: "Available elements"
msgid "selectable_objects" msgid "selectable_objects"
@ -251,6 +251,10 @@ msgstr ""
msgid "save_confirm" msgid "save_confirm"
msgstr "" msgstr ""
#. Default: "Are you sure? You are going to permanently change the order of these elements, for all users."
msgid "sort_confirm"
msgstr ""
#. Default: "Go to top" #. Default: "Go to top"
msgid "goto_first" msgid "goto_first"
msgstr "Andare all'inizio" msgstr "Andare all'inizio"

View file

@ -83,7 +83,7 @@ msgstr "U hebt teveel elementen geselecteerd."
msgid "no_ref" msgid "no_ref"
msgstr "-" msgstr "-"
#. Default: "Add a new one" #. Default: "Add"
msgid "add_ref" msgid "add_ref"
msgstr "Toevoegen" msgstr "Toevoegen"
@ -251,6 +251,10 @@ msgstr "De actie heeft geen effect gehad."
msgid "save_confirm" msgid "save_confirm"
msgstr "Bent u zeker om deze wijziging door te voeren?" msgstr "Bent u zeker om deze wijziging door te voeren?"
#. Default: "Are you sure? You are going to permanently change the order of these elements, for all users."
msgid "sort_confirm"
msgstr ""
#. Default: "Go to top" #. Default: "Go to top"
msgid "goto_first" msgid "goto_first"
msgstr "Ga naar het begin" msgstr "Ga naar het begin"