Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions web_group_expand/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
- Mayank Patel \<<mayankpatel3555@gmail.com>\>
- [360ERP](https://www.360erp.com):
- Andrea Stirpe
- Arif Waram \<<arifwaram@gmail.com>\>
4 changes: 4 additions & 0 deletions web_group_expand/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ or collapse all the groups at once.
The buttons appear in the top right, in place of the pagination.

One level of groups is expanded or collapsed at a time.

The buttons are disabled when they would have no effect: the expand
button when all groups are already expanded, and the collapse button
when all groups are already collapsed.
16 changes: 16 additions & 0 deletions web_group_expand/static/src/js/list_controller.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ function flatten(arr) {
}

patch(ListController.prototype, {
get allGroupsExpanded() {
let layer = this.model.root.groups || [];
while (layer.length) {
if (layer.some((group) => group._config.isFolded)) {
return false;
}
layer = layer.flatMap((group) => group.list.groups || []);
}
return true;
},

get allGroupsCollapsed() {
const groups = this.model.root.groups || [];
return groups.every((group) => group._config.isFolded);
},

async expandAllGroups() {
// We expand layer by layer. So first we need to find the highest
// layer that's not already fully expanded.
Expand Down
2 changes: 2 additions & 0 deletions web_group_expand/static/src/xml/list_controller.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
class="btn btn-secondary fa fa-expand oe_group_by_expand"
data-tooltip="Expand"
aria-label="Expand"
t-att-disabled="allGroupsExpanded"
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-att-disabled="allGroupsCollapsed"
t-on-click="collapseAllGroups"
/>
</t>
Expand Down
Loading