Skip to content

Commit

Permalink
[MIG] web_group_expand: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Rogos committed Sep 5, 2023
1 parent ac78c85 commit 53ea89a
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 115 deletions.
8 changes: 3 additions & 5 deletions web_group_expand/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Group Expand Buttons",
"category": "Web",
"version": "15.0.1.0.0",
"version": "16.0.1.0.0",
"license": "AGPL-3",
"author": "OpenERP SA, "
"AvanzOSC, "
Expand All @@ -13,10 +13,8 @@
"depends": ["web"],
"assets": {
"web.assets_backend": [
"/web_group_expand/static/src/js/web_group_expand.esm.js",
],
"web.assets_qweb": [
"/web_group_expand/static/src/xml/expand_buttons.xml",
"/web_group_expand/static/src/xml/list_controller.xml",
"/web_group_expand/static/src/js/list_controller.esm.js",
],
},
}
1 change: 1 addition & 0 deletions web_group_expand/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
* Jan Verbeek <[email protected]>
* Manuel Calero <[email protected]>
* Alvaro Estebanez (brain-tec AG) <[email protected]>
* Mayank Patel <[email protected]>
59 changes: 59 additions & 0 deletions web_group_expand/static/src/js/list_controller.esm.js
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();
},
});
91 changes: 0 additions & 91 deletions web_group_expand/static/src/js/web_group_expand.esm.js

This file was deleted.

19 changes: 0 additions & 19 deletions web_group_expand/static/src/xml/expand_buttons.xml

This file was deleted.

23 changes: 23 additions & 0 deletions web_group_expand/static/src/xml/list_controller.xml
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>

0 comments on commit 53ea89a

Please sign in to comment.