diff options
| author | Mohammed Shekha <msh@odoo.com> | 2019-08-07 05:59:27 +0000 |
|---|---|---|
| committer | Adrien Dieudonne <adr@odoo.com> | 2019-08-09 09:01:19 +0000 |
| commit | 597142d12c35e2cfe40323f76b3d6c7645d7638f (patch) | |
| tree | a5e56ad103cfe5f55ffe733e4956afa6314afb13 /addons/web/static/src/js | |
| parent | 80a8b66246762598c901b380cb113a988d579ff9 (diff) | |
[REF] web: move some logic in _prepareButtons method
This function was too long and it's now easier to override it
in enterprise
Task ID : 1924779
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/views/view_dialogs.js | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/addons/web/static/src/js/views/view_dialogs.js b/addons/web/static/src/js/views/view_dialogs.js index 4634bf1b1fa..beead650622 100644 --- a/addons/web/static/src/js/views/view_dialogs.js +++ b/addons/web/static/src/js/views/view_dialogs.js @@ -377,36 +377,7 @@ var SelectCreateDialog = ViewDialog.extend({ return view.getController(this).then(function (controller) { self.viewController = controller; // render the footer buttons - self.__buttons = [{ - text: _t("Cancel"), - classes: 'btn-secondary o_form_button_cancel', - close: true, - }]; - if (!self.options.no_create) { - self.__buttons.unshift({ - text: _t("Create"), - classes: 'btn-primary', - click: self.create_edit_record.bind(self) - }); - } - if (!self.options.disable_multiple_selection) { - self.__buttons.unshift({ - text: _t("Select"), - classes: 'btn-primary o_select_button', - disabled: true, - close: true, - click: function () { - var records = self.viewController.getSelectedRecords(); - var values = _.map(records, function (record) { - return { - id: record.res_id, - display_name: record.data.display_name, - }; - }); - self.on_selected(values); - }, - }); - } + self._prepareButtons(); return self.viewController.appendTo(fragment); }).then(function () { return fragment; @@ -438,6 +409,43 @@ var SelectCreateDialog = ViewDialog.extend({ }); return isFocusSet; }, + /** + * prepare buttons for dialog footer based on options + * + * @private + */ + _prepareButtons: function () { + this.__buttons = [{ + text: _t("Cancel"), + classes: 'btn-secondary o_form_button_cancel', + close: true, + }]; + if (!this.options.no_create) { + this.__buttons.unshift({ + text: _t("Create"), + classes: 'btn-primary', + click: this.create_edit_record.bind(this) + }); + } + if (!this.options.disable_multiple_selection) { + this.__buttons.unshift({ + text: _t("Select"), + classes: 'btn-primary o_select_button', + disabled: true, + close: true, + click: function () { + var records = this.viewController.getSelectedRecords(); + var values = _.map(records, function (record) { + return { + id: record.res_id, + display_name: record.data.display_name, + }; + }); + this.on_selected(values); + }, + }); + } + }, }); return { |
