From f9193fa417005b57fdeb745ec449956cb8e7e7cb Mon Sep 17 00:00:00 2001 From: Romain Estievenart Date: Mon, 13 Jul 2020 07:11:45 +0000 Subject: [PATCH] [IMP] web: enable action menu on mobile This commit creates the required hooks to implement this feature. Task ID: 1879566 --- .../web/static/src/js/views/list/list_controller.js | 2 ++ addons/web/static/src/js/views/list/list_renderer.js | 11 ++++++++++- addons/web/static/src/xml/base.xml | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/views/list/list_controller.js b/addons/web/static/src/js/views/list/list_controller.js index 97053682df3..b6ea1d5c95a 100644 --- a/addons/web/static/src/js/views/list/list_controller.js +++ b/addons/web/static/src/js/views/list/list_controller.js @@ -7,6 +7,7 @@ odoo.define('web.ListController', function (require) { * and bind all extra buttons/pager in the control panel. */ +var config = require('web.config'); var core = require('web.core'); var BasicController = require('web.BasicController'); var DataExport = require('web.DataExport'); @@ -636,6 +637,7 @@ var ListController = BasicController.extend({ const state = this.model.get(this.handle, {raw: true}); this.$selectionBox = $(qweb.render('ListView.selection', { isDomainSelected: this.isDomainSelected, + isMobile: config.device.isMobile, isPageSelected: this.isPageSelected, nbSelected: this.selectedRecords.length, nbTotal: state.count, diff --git a/addons/web/static/src/js/views/list/list_renderer.js b/addons/web/static/src/js/views/list/list_renderer.js index dc53bd16108..87493239c88 100644 --- a/addons/web/static/src/js/views/list/list_renderer.js +++ b/addons/web/static/src/js/views/list/list_renderer.js @@ -293,6 +293,15 @@ var ListRenderer = BasicRenderer.extend({ }), }; }, + /** + * Returns the jQuery node used to update the selection + * + * @private + * @return {jQuery} + */ + _getSelectableRecordCheckboxes: function () { + return this.$('tbody .o_list_record_selector input:visible:not(:disabled)'); + }, /** * Adjacent buttons (in the arch) are displayed in a single column. This * function iterates over the arch's nodes and replaces "button" nodes by @@ -1174,7 +1183,7 @@ var ListRenderer = BasicRenderer.extend({ _updateSelection: function () { this.selection = []; var self = this; - var $inputs = this.$('tbody .o_list_record_selector input:visible:not(:disabled)'); + var $inputs = this._getSelectableRecordCheckboxes(); var allChecked = $inputs.length > 0; $inputs.each(function (index, input) { if (input.checked) { diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 3e02425ef80..01d4942710e 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -162,7 +162,7 @@ - +