summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/abstract_controller.js
diff options
context:
space:
mode:
authorHiral Bhavsar <hbh@odoo.com>2018-06-12 19:00:34 +0530
committerGéry Debongnie <ged@odoo.com>2018-07-25 12:48:38 +0200
commitda7b59045d246c159f93bc75e3f19c6b1221d31c (patch)
tree85a0e7811d5052f119e65bfb8621fc43061a9d12 /addons/web/static/src/js/views/abstract_controller.js
parent272bcadc92a077bb20e71a6797214379310b109e (diff)
[IMP] base_import, web: add view switcher and h 'Import' button in mobile
As there are a few chance that someone will import something on a mobile view. So, we hide the button 'Import' in a mobile view. For mobile view, we added a view switcher button and it'll display a list of views buttons. Also set active view's icon as its icon. Related to Task: 1857696 Co-authored-by: Mohammed Shekha <msh@openerp.com>
Diffstat (limited to 'addons/web/static/src/js/views/abstract_controller.js')
-rw-r--r--addons/web/static/src/js/views/abstract_controller.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js
index 155b1792dc6..ef95ea72696 100644
--- a/addons/web/static/src/js/views/abstract_controller.js
+++ b/addons/web/static/src/js/views/abstract_controller.js
@@ -14,6 +14,7 @@ odoo.define('web.AbstractController', function (require) {
var ajax = require('web.ajax');
var concurrency = require('web.concurrency');
+var config = require('web.config');
var ControlPanelMixin = require('web.ControlPanelMixin');
var core = require('web.core');
var AbstractAction = require('web.AbstractAction');
@@ -372,7 +373,8 @@ var AbstractController = AbstractAction.extend(ControlPanelMixin, {
return $();
}
- var $switchButtons = $(QWeb.render('ControlPanel.SwitchButtons', {
+ var template = config.device.isMobile ? 'ControlPanel.SwitchButtons.Mobile' : 'ControlPanel.SwitchButtons';
+ var $switchButtons = $(QWeb.render(template, {
views: views,
}));
// create bootstrap tooltips
@@ -380,11 +382,18 @@ var AbstractController = AbstractAction.extend(ControlPanelMixin, {
$switchButtons.filter('.o_cp_switch_' + view.type).tooltip();
});
// add onclick event listener
- $switchButtons.filter('button').click(_.debounce(function (event) {
+ var $switchButtonsFiltered = config.device.isMobile ? $switchButtons.find('button') : $switchButtons.filter('button');
+ $switchButtonsFiltered.click(_.debounce(function (event) {
var viewType = $(event.target).data('view-type');
self.trigger_up('switch_view', {view_type: viewType});
}, 200, true));
+ if (config.device.isMobile) {
+ // set active view's icon as view switcher button's icon
+ var activeView = _.findWhere(views, {type: this.viewType});
+ $switchButtons.find('.o_switch_view_button_icon').addClass('fa fa-lg ' + activeView.icon);
+ }
+
return $switchButtons;
},
/**