diff options
| author | Géry Debongnie <ged@odoo.com> | 2017-10-01 11:35:46 +0200 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2017-10-01 11:35:46 +0200 |
| commit | 962fa7325d6c9405890aa2d66385044099b0b1da (patch) | |
| tree | 28a3741039661a8b2aa26de9bcb9bc740f2e1064 /addons | |
| parent | 1d34e269dac2e0cafd85ad91a6240569b5b7282c (diff) | |
[DOC] web: add some doc in control panel mixin
This should make it easier for developers to use the control panel mixin
properly.
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/web/static/src/js/chrome/control_panel.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/addons/web/static/src/js/chrome/control_panel.js b/addons/web/static/src/js/chrome/control_panel.js index 173d91aea25..8be394205d5 100644 --- a/addons/web/static/src/js/chrome/control_panel.js +++ b/addons/web/static/src/js/chrome/control_panel.js @@ -5,6 +5,37 @@ odoo.define('web.ControlPanelMixin', function (require) { * 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. + * + * Note that the API is slightly awkward. Hopefully we will improve this when + * we get the time to refactor the control panel. + * + * For example, here is what a typical client action would need to do to add + * support for a control panel with some buttons: + * + * var ControlPanelMixin = require('web.ControlPanelMixin'); + * + * var SomeClientAction = Widget.extend(ControlPanelMixin, { + * ... + * start: function () { + * this._renderButtons(); + * this._updateControlPanel(); + * ... + * }, + * do_show: function () { + * ... + * this._updateControlPanel(); + * }, + * _renderButtons: function () { + * this.$buttons = $(QWeb.render('SomeTemplate.Buttons')); + * this.$buttons.on('click', ...); + * }, + * _updateControlPanel: function () { + * this.update_control_panel({ + * breadcrumbs: this.action_manager.get_breadcrumbs(), + * cp_content: { + * $buttons: this.$buttons, + * }, + * }); */ var ControlPanelMixin = { need_control_panel: true, |
