diff options
| author | fwi-odoo <fwi@odoo.com> | 2017-04-25 13:55:38 +0200 |
|---|---|---|
| committer | fwi-odoo <fwi@odoo.com> | 2017-05-03 13:41:07 +0200 |
| commit | a53335fdb2fe6e9232bde66f06e9499bece452d4 (patch) | |
| tree | 662cb9a587ed2b076f0ffe4896d2e75ce120ae34 /addons/web/static/src/js/views/basic/basic_controller.js | |
| parent | 30384249e11d1d74b19bf2b63d4fd9fe6a99bad1 (diff) | |
[FIX] web, document: adapt toolbar to the new views
- Fix the toolbar behaviour since there is no more dataset in the widget.
- Improve the communication beetwen the controller and the toolbar.
- Move the code linked to the document upload in the right file.
- Adapt the tests to mock the search_read done by ´document´ addon
- Adapt the mock server to be able to give a custom toolbar action
Diffstat (limited to 'addons/web/static/src/js/views/basic/basic_controller.js')
| -rw-r--r-- | addons/web/static/src/js/views/basic/basic_controller.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index 33f6727987e..87e8d1a6664 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -19,6 +19,7 @@ var _t = core._t; var BasicController = AbstractController.extend(FieldManagerMixin, { custom_events: _.extend({}, AbstractController.prototype.custom_events, FieldManagerMixin.custom_events, { reload: '_onReload', + sidebar_data_asked: '_onSidebarDataAsked' }), /** * @override @@ -127,6 +128,14 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { }); }, /** + * Method that will be overriden by the views with the ability to have selected ids + * + * @returns [] + */ + getSelectedIds: function () { + return []; + }, + /** * @override */ renderPager: function ($node, options) { @@ -288,6 +297,19 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { } }, /** + * Returns the new sidebar env + * + * @private + * @return {Object} the new sidebar env + */ + _getSidebarEnv: function () { + return { + context: this.model.get(this.handle).getContext(), + activeIds: this.getSelectedIds(), + model: this.modelName, + }; + }, + /** * Used by list and kanban views to determine whether or not to display * the no content helper (if there is no data in the state to display) * @@ -389,9 +411,15 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { /** * Helper method, to get the current environment variables from the model * and notifies the component chain (by bubbling an event up) + * + * @private */ _updateEnv: function () { var env = this.model.get(this.handle, {env: true}); + if (this.sidebar) { + var sidebarEnv = this._getSidebarEnv(); + this.sidebar.updateEnv(sidebarEnv); + } this.trigger_up('env_updated', env); }, /** @@ -457,6 +485,17 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { this.reload({fieldNames: data.fieldNames}); } }, + /** + * Handler used to get all the data necessary when a custom action is + * performed through the sidebar. + * + * @private + * @param {OdooEvent} event + */ + _onSidebarDataAsked: function (event) { + var sidebarEnv = this._getSidebarEnv(); + event.data.callback(sidebarEnv); + }, }); return BasicController; |
