3
0
Fork 0

[MIG] web_group_expand: migrate to V17

17.0
andrea 2024-06-27 21:55:05 +02:00
parent 7d42f97f67
commit 9c230f4237
5 changed files with 25 additions and 12 deletions

View File

@ -73,6 +73,9 @@ Contributors
- Manuel Calero <manuelcalerosolis@gmail.com>
- Alvaro Estebanez (brain-tec AG) <alvaro.estebanez@bt-group.com>
- Mayank Patel <mayankpatel3555@gmail.com>
- `360ERP <https://www.360erp.com>`__:
- Andrea Stirpe
Maintainers
-----------

View File

@ -1,7 +1,7 @@
{
"name": "Group Expand Buttons",
"category": "Web",
"version": "16.0.1.0.0",
"version": "17.0.1.0.0",
"license": "AGPL-3",
"author": "OpenERP SA, "
"AvanzOSC, "

View File

@ -6,3 +6,5 @@
- Manuel Calero \<<manuelcalerosolis@gmail.com>\>
- Alvaro Estebanez (brain-tec AG) \<<alvaro.estebanez@bt-group.com>\>
- Mayank Patel \<<mayankpatel3555@gmail.com>\>
- [360ERP](https://www.360erp.com):
- Andrea Stirpe

View File

@ -416,6 +416,10 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
<li>Manuel Calero &lt;<a class="reference external" href="mailto:manuelcalerosolis&#64;gmail.com">manuelcalerosolis&#64;gmail.com</a>&gt;</li>
<li>Alvaro Estebanez (brain-tec AG) &lt;<a class="reference external" href="mailto:alvaro.estebanez&#64;bt-group.com">alvaro.estebanez&#64;bt-group.com</a>&gt;</li>
<li>Mayank Patel &lt;<a class="reference external" href="mailto:mayankpatel3555&#64;gmail.com">mayankpatel3555&#64;gmail.com</a>&gt;</li>
<li><a class="reference external" href="https://www.360erp.com">360ERP</a>:<ul>
<li>Andrea Stirpe</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">

View File

@ -3,28 +3,33 @@
import {patch} from "@web/core/utils/patch";
import {ListController} from "@web/views/list/list_controller";
patch(ListController.prototype, "web_group_expand.ListController", {
function flatten(arr) {
return arr.reduce((flat, toFlatten) => {
return flat.concat(Array.isArray(toFlatten) ? flatten(toFlatten) : toFlatten);
}, []);
}
patch(ListController.prototype, {
async expandAllGroups() {
// We expand layer by layer. So first we need to find the highest
// layer that's not already fully expanded.
let layer = this.model.root.groups;
while (layer.length) {
const closed = layer.filter(function (group) {
return group.isFolded;
return group._config.isFolded;
});
if (closed.length) {
// This layer is not completely expanded, expand it
await layer.forEach((group) => {
group.isFolded = false;
group._config.isFolded = false;
});
break;
}
// This layer is completely expanded, move to the next
layer = _.flatten(
layer = flatten(
layer.map(function (group) {
return group.list.groups || [];
}),
true
})
);
}
await this.model.root.load();
@ -36,18 +41,17 @@ patch(ListController.prototype, "web_group_expand.ListController", {
// layer that's not already fully collapsed.
let layer = this.model.root.groups;
while (layer.length) {
const next = _.flatten(
const next = flatten(
layer.map(function (group) {
return group.list.groups || [];
}),
true
})
).filter(function (group) {
return !group.isFolded;
return !group._config.isFolded;
});
if (!next.length) {
// Next layer is fully collapsed, so collapse this one
await layer.forEach((group) => {
group.isFolded = true;
group._config.isFolded = true;
});
break;
}