diff options
| author | Aaron Bohy <aab@odoo.com> | 2015-03-16 15:11:19 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2015-03-20 16:34:42 +0100 |
| commit | c6b1d0158e1de705bc22623df212aa9fb78ef806 (patch) | |
| tree | e54db6a4062db96905aac3906d6fe3c246e52220 /addons/web/static/src/js/control_panel.js | |
| parent | 4b0a8d4096be411b1516f8f89ea3d9950b167cf0 (diff) | |
[ADD] Web: ControlPanelMixin
Creation of the ControlPanelMixin that should be used by widgets
needing a ControlPanel. It facilitates the way those widgets communicate
with the ControlPanel to update it according to their status.
From now on, client action widgets can easily use the main ControlPanel.
Diffstat (limited to 'addons/web/static/src/js/control_panel.js')
| -rw-r--r-- | addons/web/static/src/js/control_panel.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/addons/web/static/src/js/control_panel.js b/addons/web/static/src/js/control_panel.js index 2064ada44b9..43f4e8bd8e9 100644 --- a/addons/web/static/src/js/control_panel.js +++ b/addons/web/static/src/js/control_panel.js @@ -1,3 +1,32 @@ +odoo.define('web.ControlPanelMixin', function (require) { +"use strict"; + +/** + * Mixin allowing widgets to communicate with the ControlPanel. Widgets needing a + * ControlPanel should use this mixin and call update_control_panel(cp_status) where + * cp_status contains information for the ControlPanel to update itself. + */ +var ControlPanelMixin = { + need_control_panel: true, + /** + * @param {web.Bus} [cp_bus] Bus to communicate with the ControlPanel + */ + set_cp_bus: function(cp_bus) { + this.cp_bus = cp_bus; + }, + /** + * Triggers 'update' on the cp_bus to update the ControlPanel according to cp_status + * @param {Object} [cp_status] see web.ControlPanel.update() for a description + */ + update_control_panel: function(cp_status) { + this.cp_bus.trigger("update", cp_status || {}); + }, +}; + +return ControlPanelMixin; + +}); + odoo.define('web.ControlPanel', function (require) { "use strict"; |
