forked from Techsystech/web
[MIG] web_group_expand: migrate to V17
parent
7d42f97f67
commit
9c230f4237
|
@ -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
|
||||
-----------
|
||||
|
|
|
@ -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, "
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -416,6 +416,10 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|||
<li>Manuel Calero <<a class="reference external" href="mailto:manuelcalerosolis@gmail.com">manuelcalerosolis@gmail.com</a>></li>
|
||||
<li>Alvaro Estebanez (brain-tec AG) <<a class="reference external" href="mailto:alvaro.estebanez@bt-group.com">alvaro.estebanez@bt-group.com</a>></li>
|
||||
<li>Mayank Patel <<a class="reference external" href="mailto:mayankpatel3555@gmail.com">mayankpatel3555@gmail.com</a>></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">
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue