-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIG] web_group_expand: Migration to 16.0
- Loading branch information
Christopher Rogos
committed
Sep 5, 2023
1 parent
ac78c85
commit 53ea89a
Showing
6 changed files
with
86 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
* Jan Verbeek <[email protected]> | ||
* Manuel Calero <[email protected]> | ||
* Alvaro Estebanez (brain-tec AG) <[email protected]> | ||
* Mayank Patel <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** @odoo-module */ | ||
|
||
import {patch} from "@web/core/utils/patch"; | ||
import {ListController} from "@web/views/list/list_controller"; | ||
|
||
patch(ListController.prototype, "web_group_expand.ListController", { | ||
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; | ||
}); | ||
if (closed.length) { | ||
// This layer is not completely expanded, expand it | ||
await layer.forEach((group) => { | ||
group.isFolded = false; | ||
}); | ||
break; | ||
} | ||
// This layer is completely expanded, move to the next | ||
layer = _.flatten( | ||
layer.map(function (group) { | ||
return group.list.groups || []; | ||
}), | ||
true | ||
); | ||
} | ||
await this.model.root.load(); | ||
this.model.notify(); | ||
}, | ||
|
||
async collapseAllGroups() { | ||
// We collapse layer by layer. So first we need to find the deepest | ||
// layer that's not already fully collapsed. | ||
let layer = this.model.root.groups; | ||
while (layer.length) { | ||
const next = _.flatten( | ||
layer.map(function (group) { | ||
return group.list.groups || []; | ||
}), | ||
true | ||
).filter(function (group) { | ||
return !group.isFolded; | ||
}); | ||
if (!next.length) { | ||
// Next layer is fully collapsed, so collapse this one | ||
await layer.forEach((group) => { | ||
group.isFolded = true; | ||
}); | ||
break; | ||
} | ||
layer = next; | ||
} | ||
await this.model.root.load(); | ||
this.model.notify(); | ||
}, | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
<t t-inherit="web.ListView.Buttons" t-inherit-mode="extension" owl="1"> | ||
<xpath expr="//div[hasclass('o_list_buttons')]" position="inside"> | ||
<t t-if="model.root.isGrouped"> | ||
<button | ||
type="button" | ||
class="btn btn-secondary fa fa-expand oe_group_by_expand" | ||
data-tooltip="Expand" | ||
aria-label="Expand" | ||
t-on-click="expandAllGroups" | ||
/> | ||
<button | ||
type="button" | ||
class="btn btn-secondary fa fa-compress oe_group_by_collapse" | ||
data-tooltip="Compress" | ||
aria-label="Compress" | ||
t-on-click="collapseAllGroups" | ||
/> | ||
</t> | ||
</xpath> | ||
</t> | ||
</templates> |