summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/chrome/view_manager.js
diff options
context:
space:
mode:
authorDharmraj Jhala <dja@openerp.com>2017-05-11 17:15:15 +0530
committerGéry Debongnie <ged@odoo.com>2017-07-12 13:43:08 +0200
commit4330ea02676a4afd88707bb463a007e7de3c8686 (patch)
treef547124a18fd30e09433a65cd9aa7b5a6645131a /addons/web/static/src/js/chrome/view_manager.js
parent578edf73b9f637b0d27708c511b542a27bd7a3b8 (diff)
[ADD] web, *: add rainbowification
This commit introduces the 'rainbowification' feature to the web client (and to some affected addons). This feature is essentially a way to display a nice friendly message when some business event happens. For example, a encouraging message is displayed when the user clear her/his inbox, or when a salesman closes a deal. The mechanism currently only displays a 'rainbowman', but could be extended later to add other kind of animation. There are a few different ways to display a 'rainbowman': - any JS code can simply trigger_up an event ('show_effect') with some options: for example this.trigger_up('show_effect', { type: 'rainbow_man', fadeout: 'no', message: $done, click_close: false, }); - an action returned by the server can have an 'effect' key, with some options - the do_execute_action method accepts a 'effect' option. This is useful when one wants to specify a rainbow on an action button in a form view Joint work with: dbh <dbh@odoo.com>, ged <ged@odoo.com>
Diffstat (limited to 'addons/web/static/src/js/chrome/view_manager.js')
-rw-r--r--addons/web/static/src/js/chrome/view_manager.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/addons/web/static/src/js/chrome/view_manager.js b/addons/web/static/src/js/chrome/view_manager.js
index 11be6fa4e6e..14ed4bdebc7 100644
--- a/addons/web/static/src/js/chrome/view_manager.js
+++ b/addons/web/static/src/js/chrome/view_manager.js
@@ -550,6 +550,9 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
* @param {String} [action_data.special=null] special action handlers, closes the dialog if set
* @param {String} [action_data.type='workflow'] the action type, if present, one of ``'object'``, ``'action'`` or ``'workflow'``
* @param {Object} [action_data.context=null] additional action context, to add to the current context
+ * @param {string} [action_data.effect] if given, a visual effect (a
+ * rainbowman by default) will be displayed when the action is complete,
+ * with the string (evaluated) given as options.
* @param {DataSet} dataset a dataset object used to communicate with the server
* @param {integer[]} [res_ids] the res_ids of the objects on which the action is to be applied (fallback on env.ids if not set)
* @param {Function} on_closed callback to execute when dialog is closed or when the action does not generate any result (no new action)
@@ -562,6 +565,14 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
// response handler
var handler = function (action) {
+ // show effect if button have effect attribute
+ // Rainbowman can be displayed from two places : from attribute on a button, or from python.
+ // Code below handles the first case i.e 'effect' attribute on button.
+ var effect = false;
+ if (action_data.effect) {
+ effect = pyeval.py_eval(action_data.effect);
+ };
+
if (action && action.constructor === Object) {
// filter out context keys that are specific to the current action.
// Wrong default_* and search_default_* values will no give the expected result
@@ -580,11 +591,16 @@ var ViewManager = Widget.extend(ControlPanelMixin, {
}
ncontext.add(action.context || {});
action.context = ncontext;
+ // In case effect data is returned from python and also there is rainbow
+ // attribute on button, priority is given to button attribute
+ action.effect = effect || action.effect;
return self.do_action(action, {
on_close: result_handler,
});
} else {
- self.do_action({"type":"ir.actions.act_window_close"});
+ // If action doesn't return anything, but have effect
+ // attribute on button, display rainbowman
+ self.do_action({"type":"ir.actions.act_window_close", 'effect': effect});
return result_handler();
}
};