[14.0][MIG] web_group_expand

This commit is contained in:
BT-aestebanez
2021-04-30 12:39:54 +02:00
committed by BT-aestebanez
parent 8c147aad9c
commit a1892f7d8c
9 changed files with 27 additions and 25 deletions

View File

@@ -1,10 +1,10 @@
odoo.define("web.web_group_expand", function(require) {
odoo.define("web.web_group_expand", function (require) {
"use strict";
var qweb = require("web.core").qweb;
require("web.ListController").include({
start: function() {
start: function () {
this.$expandGroupButtons = $(qweb.render("web_group_expand.Buttons"));
this.$expandGroupButtons
.find("#oe_group_by_expand")
@@ -15,18 +15,18 @@ odoo.define("web.web_group_expand", function(require) {
return this._super.apply(this, arguments);
},
renderPager: function($node) {
renderButtons: function () {
this._super.apply(this, arguments);
this.$expandGroupButtons.toggleClass("o_hidden", !this.renderer.isGrouped);
$node.append(this.$expandGroupButtons);
this.$buttons.append(this.$expandGroupButtons);
},
expandAllGroups: function() {
expandAllGroups: function () {
// We expand layer by layer. So first we need to find the highest
// layer that's not already fully expanded.
var layer = this.renderer.state.data;
while (layer.length) {
var closed = layer.filter(function(group) {
var closed = layer.filter(function (group) {
return !group.isOpen;
});
if (closed.length) {
@@ -36,7 +36,7 @@ odoo.define("web.web_group_expand", function(require) {
}
// This layer is completely expanded, move to the next
layer = _.flatten(
layer.map(function(group) {
layer.map(function (group) {
return group.data;
}),
true
@@ -44,19 +44,19 @@ odoo.define("web.web_group_expand", function(require) {
}
},
collapseAllGroups: function() {
collapseAllGroups: function () {
// We collapse layer by layer. So first we need to find the deepest
// layer that's not already fully collapsed.
var layer = this.renderer.state.data.filter(function(group) {
var layer = this.renderer.state.data.filter(function (group) {
return group.isOpen;
});
while (layer.length) {
var next = _.flatten(
layer.map(function(group) {
layer.map(function (group) {
return group.data;
}),
true
).filter(function(group) {
).filter(function (group) {
return group.isOpen;
});
if (!next.length) {
@@ -68,9 +68,9 @@ odoo.define("web.web_group_expand", function(require) {
}
},
_toggleGroups: function(groups) {
_toggleGroups: function (groups) {
var self = this;
var defs = groups.map(function(group) {
var defs = groups.map(function (group) {
return self.model.toggleGroup(group.id);
});
$.when(...defs).then(
@@ -80,7 +80,7 @@ odoo.define("web.web_group_expand", function(require) {
});
require("web.ListRenderer").include({
updateState: function() {
updateState: function () {
var res = this._super.apply(this, arguments);
$("nav.oe_group_by_expand_buttons").toggleClass(
"o_hidden",