From d01787c19d4631a1de56f9873586e44ae06318f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Fri, 18 May 2018 10:02:04 +0200 Subject: [PATCH] [IMP] web,mail: improve search view for mobile devices With this commit, we introduce a better screen to manipulate the search view in a mobile device. Note: most of this work was initially done by suh-odoo, then was adapted and moved to community by myself. task 31464 --- addons/mail/static/src/js/discuss_mobile.js | 24 ---- addons/mail/static/src/scss/discuss.scss | 29 ---- addons/mail/static/src/xml/discuss.xml | 1 - .../mail/static/tests/discuss_mobile_tests.js | 6 +- .../web/static/src/js/chrome/search_menus.js | 6 + .../web/static/src/js/chrome/search_view.js | 34 +++-- .../src/js/chrome/search_view_mobile.js | 96 +++++++++++++ addons/web/static/src/scss/control_panel.scss | 2 +- addons/web/static/src/scss/search_view.scss | 134 +++++++++--------- .../static/src/scss/search_view_mobile.scss | 88 ++++++++++++ addons/web/static/src/xml/base.xml | 27 +++- .../tests/chrome/search_view_mobile_tests.js | 83 +++++++++++ addons/web/static/tests/helpers/test_utils.js | 3 + addons/web/views/webclient_templates.xml | 3 + .../static/src/xml/website.backend.xml | 3 +- 15 files changed, 403 insertions(+), 136 deletions(-) create mode 100644 addons/web/static/src/js/chrome/search_view_mobile.js create mode 100644 addons/web/static/src/scss/search_view_mobile.scss create mode 100644 addons/web/static/tests/chrome/search_view_mobile_tests.js diff --git a/addons/mail/static/src/js/discuss_mobile.js b/addons/mail/static/src/js/discuss_mobile.js index 556651ec67e..531553e6804 100644 --- a/addons/mail/static/src/js/discuss_mobile.js +++ b/addons/mail/static/src/js/discuss_mobile.js @@ -14,7 +14,6 @@ if (!config.device.isMobile) { Discuss.include({ template: 'mail.discuss_mobile', - need_control_panel: false, // in mobile, we use a custom control panel events: _.extend(Discuss.prototype.events, { 'click .o_mail_mobile_tab': '_onMobileTabClicked', 'click .o_channel_inbox_item': '_onMobileInboxButtonClicked', @@ -122,14 +121,6 @@ Discuss.include({ this._super.apply(this, arguments); } }, - /** - * @private - */ - _toggleSearchView: function () { - this.searchviewDisplayed = !this.searchviewDisplayed; - this.searchview.$el.toggleClass('o_hidden', !this.searchviewDisplayed); - this.$buttons.toggleClass('o_hidden', this.searchviewDisplayed); - }, /** * Overrides to toggle the visibility of the tabs when a message is unselected * @@ -198,10 +189,6 @@ Discuss.include({ self.$buttons.find('.o_mail_chat_button_' + type).removeClass('o_hidden'); self.$buttons.find('.o_mail_chat_button_mark_read').toggleClass('o_hidden', type !== 'channel_inbox'); self.$buttons.find('.o_mail_chat_button_unstar_all').toggleClass('o_hidden', type !== 'channel_starred'); - self.$('.o_enable_searchview').toggleClass('o_hidden', !inInbox); - if (!inInbox && self.searchviewDisplayed) { - self._toggleSearchView(); // close the searchview when leaving Inbox - } // update Inbox page buttons if (inInbox) { @@ -219,17 +206,6 @@ Discuss.include({ self.$('.o_mail_mobile_tab[data-type=' + type + ']').addClass('active'); }); }, - /** - * @override - */ - _updateControlPanel: function () { - this.$buttons.appendTo(this.$('.o_mail_chat_mobile_control_panel')); - this.searchview.$el.appendTo(this.$('.o_mail_chat_mobile_control_panel')); - var $enable_searchview = $('