diff --git a/web_group_expand/readme/CONTRIBUTORS.rst b/web_group_expand/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..f8c448d7 --- /dev/null +++ b/web_group_expand/readme/CONTRIBUTORS.rst @@ -0,0 +1,7 @@ +* Mantavya Gajjar +* Oihane Crucelaegui +* Pedro M. Baeza +* Jay Vora (SerpentCS) for their alternative implementation +* Aldo Soares +* Meet Dholakia +* Alexandre Díaz diff --git a/web_group_expand/readme/DESCRIPTION.rst b/web_group_expand/readme/DESCRIPTION.rst new file mode 100644 index 00000000..b771e3b6 --- /dev/null +++ b/web_group_expand/readme/DESCRIPTION.rst @@ -0,0 +1,4 @@ +A group by list can be expanded and collapased with buttons + +You'll see two buttons appear on top right corner of the list when you perform +a group by with which you can expand and collapse grouped records by level. diff --git a/web_group_expand/static/src/css/web_group_expand.css b/web_group_expand/static/src/css/web_group_expand.css deleted file mode 100644 index 63604211..00000000 --- a/web_group_expand/static/src/css/web_group_expand.css +++ /dev/null @@ -1,8 +0,0 @@ -.o_favorites_menu + .toggle_buttons{ - float: left; - padding-left: 5px; -} - -.o_favorites_menu + .toggle_buttons button{ - display: inline; -} \ No newline at end of file diff --git a/web_group_expand/static/src/js/web_group_expand.js b/web_group_expand/static/src/js/web_group_expand.js index e222a0bd..aa8fc420 100644 --- a/web_group_expand/static/src/js/web_group_expand.js +++ b/web_group_expand/static/src/js/web_group_expand.js @@ -23,21 +23,28 @@ odoo.define('web_group_expand.web_group_expand', function (require) { } }) }, - }) + }); ViewManager.include({ - + init: function(parent, dataset, views, flags, options) { + this._super.apply(this, arguments); + this._has_groupby_search = false; + }, _process_search_data: function () { var res = this._super.apply(this, arguments); - if (this.active_view && this.active_view.type == 'list' && this.searchview) { - if(this.searchview.groupby_expand_menu){ - var has_groups = res.groupBy.length > 0 - this.searchview.groupby_expand_menu.do_toggle_visibility(has_groups) - } - }else{ - this.searchview.groupby_expand_menu.do_toggle_visibility(false) - } + this._has_groupby_search = (res.groupBy.length > 0); + this._set_groupby_expand_menu_visible(this._has_groupby_search && this.active_view && this.active_view.type === 'list'); return res; }, + switch_mode: function(view_type, view_options) { + return this._super.apply(this, arguments).then(function() { + this._set_groupby_expand_menu_visible(this._has_groupby_search && view_type === 'list'); + }.bind(this)); + }, + _set_groupby_expand_menu_visible: function(is_visible) { + if (this.searchview && this.searchview.groupby_expand_menu) { + this.searchview.groupby_expand_menu.do_toggle_visibility(is_visible); + } + }, }); }); diff --git a/web_group_expand/static/src/less/web_group_expand.less b/web_group_expand/static/src/less/web_group_expand.less new file mode 100644 index 00000000..c3fd446e --- /dev/null +++ b/web_group_expand/static/src/less/web_group_expand.less @@ -0,0 +1,10 @@ +.o_favorites_menu { + +.toggle_buttons { + float: left; + padding-left: 5px; + + button { + display: inline; + } + } +} diff --git a/web_group_expand/templates/assets.xml b/web_group_expand/templates/assets.xml index ec62493c..0ba586be 100644 --- a/web_group_expand/templates/assets.xml +++ b/web_group_expand/templates/assets.xml @@ -2,7 +2,7 @@