diff options
| author | Mohammed Shekha <msh@odoo.com> | 2020-04-20 09:36:05 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2020-05-08 11:38:59 +0000 |
| commit | 051a094838e4f27df91d66498ac03a3bd7b86358 (patch) | |
| tree | 00950e07df2e711b370157104b5b246e2ef381c6 /addons/web/static/src/js/views/basic/basic_controller.js | |
| parent | 8ca96078dbeb61678f8c0656f90b09ab8a82981a (diff) | |
[IMP] web: list and kanban: highlight create button
... when there is no data and user clicks anywhere in the no content
helper.
Task 2239617
Co-authored-by: Jinal Patel <jip@odoo.com>
Co-authored-by: Aaron Bohy <aab@odoo.com>
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 | 28 |
1 files changed, 28 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 bbfee26e51f..f652820e814 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -16,6 +16,9 @@ var TranslationDialog = require('web.TranslationDialog'); var _t = core._t; var BasicController = AbstractController.extend(FieldManagerMixin, { + events: Object.assign({}, AbstractController.prototype.events, { + 'click .o_content': '_onContentClicked', + }), custom_events: _.extend({}, AbstractController.prototype.custom_events, FieldManagerMixin.custom_events, { discard_changes: '_onDiscardChanges', pager_changed: '_onPagerChanged', @@ -602,6 +605,18 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { return Promise.resolve(); }, /** + * To override such that it returns true iff the primary action button must + * bounce when the user clicked on the given element, according to the + * current state of the view. + * + * @private + * @param {HTMLElement} element the node the user clicked on + * @returns {boolean} + */ + _shouldBounceOnClick: function (/* element */) { + return false; + }, + /** * Helper method, to get the current environment variables from the model * and notifies the component chain (by bubbling an event up) * @@ -623,6 +638,19 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { //-------------------------------------------------------------------------- /** + * Called when the user clicks on the 'content' part of the controller + * (typically the renderer area). Makes the first primary button in the + * control panel bounce, in some situations (see _shouldBounceOnClick). + * + * @private + * @param {MouseEvent} ev + */ + _onContentClicked(ev) { + if (this.$buttons && this._shouldBounceOnClick(ev.target)) { + this.$buttons.find('.btn-primary:visible:first').odooBounce(); + } + }, + /** * Called when a list element asks to discard the changes made to one of * its rows. It can happen with a x2many (if we are in a form view) or with * a list view. |
