[11.0][FIX][web_group_expand] Fix issue #987 & Improvements (#993)

* Fixes issue #987
* Follow new readme structure
* Use Less
* Hide expand/collapse buttons if select a view type that isn't a 'list'
This commit is contained in:
QS5ELkMu
2018-07-17 21:24:50 +02:00
committed by Pedro M. Baeza
parent f0504cc235
commit 9decd5988d
6 changed files with 39 additions and 19 deletions

View File

@@ -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);
}
},
});
});