From f44bb4e06b4659c2babf0c47310fafe619fdb4a6 Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Wed, 4 Feb 2015 12:23:56 +0100 Subject: [PATCH] [gen] appy.js: closing the confirm popup via button 'no' cleans field 'comment'. --- gen/mixins/ToolMixin.py | 2 +- gen/ui/appy.js | 22 ++++++++++++++-------- gen/wrappers/__init__.py | 4 ++-- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/gen/mixins/ToolMixin.py b/gen/mixins/ToolMixin.py index d423ebe..fdff595 100644 --- a/gen/mixins/ToolMixin.py +++ b/gen/mixins/ToolMixin.py @@ -1285,7 +1285,7 @@ class ToolMixin(BaseMixin): request, a server action can be executed before rendering the XHTML chunk. This method executes this action.''' if action.startswith(':'): - # The action corresponds to a method on Appy p_obj. + # The action corresponds to a method on Appy p_obj msg = getattr(obj, action[1:])() else: # The action must be executed on p_field if present, on obj.o else. diff --git a/gen/ui/appy.js b/gen/ui/appy.js index 5dcc3dd..95330c3 100644 --- a/gen/ui/appy.js +++ b/gen/ui/appy.js @@ -242,10 +242,9 @@ function AjaxData(hook, px, params, parentHook, url, mode, beforeSend, onGet) { this.parentHook = parentHook; } - -function askAjax(hook, form) { - /* Call askAjaxChunk by getting an AjaxData instance from p_hook and a - potential action from p_form). */ +function askAjax(hook, form, params) { + /* Call askAjaxChunk by getting an AjaxData instance from p_hook, a + potential action from p_form and additional parameters from p_param. */ var d = document.getElementById(hook)['ajax']; // Complete data with a parent data if present if (d['parentHook']) { @@ -277,6 +276,8 @@ function askAjax(hook, form) { } } else var mode = d.mode; + // Get p_params if given. Note that they override anything else. + if (params) { for (var key in params) d.params[key] = params[key]; } askAjaxChunk(d.hook,mode,d.url,d.px,d.params,d.beforeSend,d.onGet) } /* The functions below wrap askAjaxChunk for getting specific content through @@ -859,7 +860,7 @@ function openPopup(popupId, msg, width, height) { popup.style.display = 'block'; } -function closePopup(popupId) { +function closePopup(popupId, clean) { // Get the popup var container = null; if (popupId == 'iframePopup') container = window.parent.document; @@ -868,8 +869,13 @@ function closePopup(popupId) { // Close the popup popup.style.display = 'none'; popup.style.width = null; + // Clean field "clean" if specified + if (clean) { + var f = popup.getElementsByTagName('form')[0]; + f.elements[clean].value = ''; + } if (popupId == 'iframePopup') { - // Reinitialise the enclosing iframe. + // Reinitialise the enclosing iframe var iframe = container.getElementById('appyIFrame'); iframe.style.width = null; iframe.innerHTML = ''; @@ -920,14 +926,14 @@ function transferComment(confirmForm, targetForm) { // Function triggered when an action confirmed by the user must be performed function doConfirm() { - // The user confirmed: perform the required action. + // The user confirmed: perform the required action closePopup('confirmActionPopup'); var confirmForm = document.getElementById('confirmActionForm'); var actionType = confirmForm.actionType.value; var action = confirmForm.action.value; if (actionType == 'form') { /* Submit the form whose id is in "action", and transmit him the comment - from the popup when relevant */ + from the popup when relevant. */ var f = document.getElementById(action); transferComment(confirmForm, f); f.submit(); diff --git a/gen/wrappers/__init__.py b/gen/wrappers/__init__.py index ccf7c34..f8cba60 100644 --- a/gen/wrappers/__init__.py +++ b/gen/wrappers/__init__.py @@ -109,8 +109,8 @@ class AbstractWrapper(object):

- +