[gen] Ref field improved.

This commit is contained in:
Gaetan Delannay 2014-04-05 10:54:40 +02:00
parent b9bfee9615
commit 977cd0a225
13 changed files with 141 additions and 90 deletions

View file

@ -31,7 +31,7 @@ class Action(Field):
label=_(field.labelId)"
id=":formId" action=":ztool.absolute_url() + '/do'">
<input type="hidden" name="action" value="ExecuteAppyAction"/>
<input type="hidden" name="objectUid" value=":zobj.UID()"/>
<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')"

View file

@ -978,6 +978,7 @@ class Ref(Field):
unlink_many, delete_many).'''
action = rq['linkAction']
tool = obj.getTool()
msg = None
if not action.endswith('_many'):
# "link" or "unlink"
tied = tool.getObject(rq['targetUid'])
@ -1012,10 +1013,13 @@ class Ref(Field):
# Collect this object
target = not isObj and tool.getObject(value) or value.o
targets.append(target)
if not targets:
msg = obj.translate('action_null')
else:
# Perform the action on every target. Count the number of failed
# operations.
mustDelete = action == 'delete_many'
failed = 0
mustDelete = action == 'delete_many'
for target in targets:
if mustDelete:
# Delete
@ -1024,11 +1028,10 @@ class Ref(Field):
else:
# Link or unlink
exec 'self.%sObject(obj, target)' % action.split('_')[0]
urlBack = obj.getUrl(rq['HTTP_REFERER'])
if not failed:
msg = obj.translate('action_done')
else:
if failed:
msg = obj.translate('action_partial', mapping={'nb':failed})
urlBack = obj.getUrl(rq['HTTP_REFERER'])
if not msg: msg = obj.translate('action_done')
obj.say(msg)
tool.goto(urlBack)

View file

@ -1175,7 +1175,7 @@ class BaseMixin:
if not msg:
# Use the default i18n messages
suffix = 'ko'
if successfull: suffix = 'ok'
if successfull: suffix = 'done'
msg = self.translate('action_%s' % suffix)
if (resultType == 'computation') or not successfull:
self.say(msg)

View file

@ -43,6 +43,10 @@ msgstr ""
msgid "appy_title"
msgstr ""
#. Default: "Ok"
msgid "appy_ok"
msgstr ""
#. Default: "Data change"
msgid "data_change"
msgstr ""
@ -91,14 +95,6 @@ msgstr ""
msgid "selected_objects"
msgstr ""
#. Default: "The action has been successfully executed."
msgid "action_ok"
msgstr ""
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr ""
#. Default: "Move up"
msgid "move_up"
msgstr ""
@ -227,10 +223,18 @@ msgstr ""
msgid "action_done"
msgstr ""
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr ""
#. Default: "Action could not be performed on ${nb} element(s)."
msgid "action_partial"
msgstr ""
#. Default: "Action had no effect."
msgid "action_null"
msgstr ""
#. Default: "Go to top"
msgid "goto_first"
msgstr ""

View file

@ -43,6 +43,10 @@ msgstr ""
msgid "appy_title"
msgstr ""
#. Default: "Ok"
msgid "appy_ok"
msgstr ""
#. Default: "Data change"
msgid "data_change"
msgstr ""
@ -91,14 +95,6 @@ msgstr ""
msgid "selected_objects"
msgstr ""
#. Default: "The action has been successfully executed."
msgid "action_ok"
msgstr ""
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr ""
#. Default: "Move up"
msgid "move_up"
msgstr ""
@ -227,10 +223,18 @@ msgstr ""
msgid "action_done"
msgstr ""
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr ""
#. Default: "Action could not be performed on ${nb} element(s)."
msgid "action_partial"
msgstr ""
#. Default: "Action had no effect."
msgid "action_null"
msgstr ""
#. Default: "Go to top"
msgid "goto_first"
msgstr ""

View file

@ -43,6 +43,10 @@ msgstr ""
msgid "appy_title"
msgstr "Titel"
#. Default: "Ok"
msgid "appy_ok"
msgstr ""
#. Default: "Data change"
msgid "data_change"
msgstr "Änderung der Angaben"
@ -91,14 +95,6 @@ msgstr ""
msgid "selected_objects"
msgstr ""
#. Default: "The action has been successfully executed."
msgid "action_ok"
msgstr "Der Auftrag wird ausgeführt."
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr "Ein Problem ist aufgetreten."
#. Default: "Move up"
msgid "move_up"
msgstr "Nach oben verschieben"
@ -225,12 +221,20 @@ msgstr ""
#. Default: "The action has been performed."
msgid "action_done"
msgstr ""
msgstr "Der Auftrag wird ausgeführt."
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr "Ein Problem ist aufgetreten."
#. Default: "Action could not be performed on ${nb} element(s)."
msgid "action_partial"
msgstr ""
#. Default: "Action had no effect."
msgid "action_null"
msgstr ""
#. Default: "Go to top"
msgid "goto_first"
msgstr "Zurück zum Anfang"

View file

@ -44,6 +44,10 @@ msgstr "Owner"
msgid "appy_title"
msgstr "Title"
#. Default: "Ok"
msgid "appy_ok"
msgstr "Ok"
#. Default: "Data change"
msgid "data_change"
msgstr "Data change"
@ -92,14 +96,6 @@ msgstr "Selectable elements"
msgid "selected_objects"
msgstr "Inserted elements"
#. Default: "The action has been successfully executed."
msgid "action_ok"
msgstr "The action has been successfully executed."
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr "A problem occurred while executing the action."
#. Default: "Move up"
msgid "move_up"
msgstr "Move up"
@ -202,7 +198,7 @@ msgstr "Unlink"
#. Default: "Remove selection"
msgid "object_unlink_many"
msgstr ""
msgstr "Remove selection"
#. Default: "Insert"
msgid "object_link"
@ -222,16 +218,24 @@ msgstr "Unlock"
#. Default: "Are you sure?"
msgid "action_confirm"
msgstr ""
msgstr "Are you sure?"
#. Default: "The action has been performed."
msgid "action_done"
msgstr ""
msgstr "The action has been performed."
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr "A problem occurred while executing the action."
#. Default: "Action could not be performed on ${nb} element(s)."
msgid "action_partial"
msgstr "Action could not be performed on ${nb} element(s)."
#. Default: "Action had no effect."
msgid "action_null"
msgstr "Action had no effect."
#. Default: "Go to top"
msgid "goto_first"
msgstr "Go to top"

View file

@ -43,6 +43,10 @@ msgstr ""
msgid "appy_title"
msgstr "Título"
#. Default: "Ok"
msgid "appy_ok"
msgstr ""
#. Default: "Data change"
msgid "data_change"
msgstr "Cambio de datos"
@ -91,14 +95,6 @@ msgstr ""
msgid "selected_objects"
msgstr ""
#. Default: "The action has been successfully executed."
msgid "action_ok"
msgstr "La acción ha sido efectuada."
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr "Ha surgido un problema."
#. Default: "Move up"
msgid "move_up"
msgstr "Mueva hacia arriba"
@ -225,12 +221,20 @@ msgstr "¿Está seguro?"
#. Default: "The action has been performed."
msgid "action_done"
msgstr ""
msgstr "La acción ha sido efectuada."
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr "Ha surgido un problema."
#. Default: "Action could not be performed on ${nb} element(s)."
msgid "action_partial"
msgstr ""
#. Default: "Action had no effect."
msgid "action_null"
msgstr ""
#. Default: "Go to top"
msgid "goto_first"
msgstr "Ir al inicio"

View file

@ -44,6 +44,10 @@ msgstr "Propriétaire"
msgid "appy_title"
msgstr "Titre"
#. Default: "Ok"
msgid "appy_ok"
msgstr "Ok"
#. Default: "Data change"
msgid "data_change"
msgstr "Changement de données"
@ -92,14 +96,6 @@ msgstr "Éléments sélectionnables"
msgid "selected_objects"
msgstr "Éléments insérés"
#. Default: "The action has been successfully executed."
msgid "action_ok"
msgstr "L'action a été effectuée."
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr "Un problème est survenu."
#. Default: "Move up"
msgid "move_up"
msgstr "Déplacer vers le haut"
@ -228,10 +224,18 @@ msgstr "Êtes-vous sûr?"
msgid "action_done"
msgstr "L'action a été réalisée."
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr "Un problème est survenu."
#. Default: "Action could not be performed on ${nb} element(s)."
msgid "action_partial"
msgstr "L'action n'a pu être réalisée pour ${nb} élément(s)."
#. Default: "Action had no effect."
msgid "action_null"
msgstr "L'action n'a eu aucun effet."
#. Default: "Go to top"
msgid "goto_first"
msgstr "Aller au début"

View file

@ -43,6 +43,10 @@ msgstr ""
msgid "appy_title"
msgstr "Qualifica"
#. Default: "Ok"
msgid "appy_ok"
msgstr ""
#. Default: "Data change"
msgid "data_change"
msgstr "Revisione dati"
@ -91,14 +95,6 @@ msgstr ""
msgid "selected_objects"
msgstr ""
#. Default: "The action has been successfully executed."
msgid "action_ok"
msgstr "L'operazione è stata eseguita con successo"
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr "Si è manifestato un problema"
#. Default: "Move up"
msgid "move_up"
msgstr "Su"
@ -225,12 +221,20 @@ msgstr "È sicuro?"
#. Default: "The action has been performed."
msgid "action_done"
msgstr ""
msgstr "L'operazione è stata eseguita con successo"
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr "Si è manifestato un problema"
#. Default: "Action could not be performed on ${nb} element(s)."
msgid "action_partial"
msgstr ""
#. Default: "Action had no effect."
msgid "action_null"
msgstr ""
#. Default: "Go to top"
msgid "goto_first"
msgstr "Andare all'inizio"

View file

@ -43,6 +43,10 @@ msgstr "Eigenaar"
msgid "appy_title"
msgstr "Titel"
#. Default: "Ok"
msgid "appy_ok"
msgstr ""
#. Default: "Data change"
msgid "data_change"
msgstr "Wijziging van de gegevens"
@ -91,14 +95,6 @@ msgstr ""
msgid "selected_objects"
msgstr ""
#. Default: "The action has been successfully executed."
msgid "action_ok"
msgstr "De opdracht werd uitgevoerd."
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr "Er heeft zich een probleem voorgedaan."
#. Default: "Move up"
msgid "move_up"
msgstr "Verplaats naar boven"
@ -225,12 +221,20 @@ msgstr ""
#. Default: "The action has been performed."
msgid "action_done"
msgstr ""
msgstr "De opdracht werd uitgevoerd."
#. Default: "A problem occurred while executing the action."
msgid "action_ko"
msgstr "Er heeft zich een probleem voorgedaan."
#. Default: "Action could not be performed on ${nb} element(s)."
msgid "action_partial"
msgstr ""
#. Default: "Action had no effect."
msgid "action_null"
msgstr ""
#. Default: "Go to top"
msgid "goto_first"
msgstr "Ga naar het begin"

View file

@ -549,6 +549,11 @@ function onLinkMany(action, id) {
for (var uid in statuses) uids += uid + ',';
// Get the array semantics
var semantics = node['_appy_' + elems[2] + '_sem'];
// Show an error messagge if non element is selected.
if ((semantics == 'checked') && (Object.keys(statuses).length == 0)) {
openPopup('alertPopup', no_elem_selected);
return;
}
// Fill the form and ask for a confirmation
f = document.getElementById('linkForm');
f.linkAction.value = action + '_many';
@ -666,7 +671,8 @@ function protectAppyForm() {
function openPopup(popupId, msg) {
// Put the message into the popup
if (msg) {
var confirmElem = document.getElementById('appyConfirmText');
var msgHook = (popupId == 'alertPopup')? 'appyAlertText': 'appyConfirmText';
var confirmElem = document.getElementById(msgHook);
confirmElem.innerHTML = msg;
}
// Open the popup

View file

@ -156,6 +156,16 @@ class AbstractWrapper(object):
</form>
</div>
<!-- Popup for displaying an error message (~JS alert()) -->
<div id="alertPopup" class="popup">
<img src=":url('warningBig')" align=":dleft" style="margin-right: 10px"/>
<p id="appyAlertText" style="margin-bottom: 15px"></p>
<div align="center">
<input type="button" onclick="closePopup('alertPopup')"
value=":_('appy_ok')"/>
</div>
</div>
<table class="main" align="center" cellpadding="0">
<tr class="top">
<!-- Top banner -->