mirror of https://github.com/OCA/web.git
[MIG] web_group_expand: Migration to 16.0
parent
c524d820a2
commit
d31ec94b40
|
@ -7,7 +7,7 @@ Group Expand Buttons
|
|||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:1e707b0c988c388ee8ae35b00354343f1e961eb524838d3fd56348df767e4ac8
|
||||
!! source digest: sha256:0fb42d09f0995520749d0cb55db14e5ed47e9e037598f2a9ac9e5534887e0666
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
|
||||
|
@ -72,6 +72,7 @@ Contributors
|
|||
* Jan Verbeek <jverbeek@therp.nl>
|
||||
* Manuel Calero <manuelcalerosolis@gmail.com>
|
||||
* Alvaro Estebanez (brain-tec AG) <alvaro.estebanez@bt-group.com>
|
||||
* Mayank Patel <mayankpatel3555@gmail.com>
|
||||
|
||||
Maintainers
|
||||
~~~~~~~~~~~
|
||||
|
|
|
@ -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, "
|
||||
|
@ -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",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
|
@ -5,3 +5,4 @@
|
|||
* Jan Verbeek <jverbeek@therp.nl>
|
||||
* Manuel Calero <manuelcalerosolis@gmail.com>
|
||||
* Alvaro Estebanez (brain-tec AG) <alvaro.estebanez@bt-group.com>
|
||||
* Mayank Patel <mayankpatel3555@gmail.com>
|
||||
|
|
|
@ -367,7 +367,7 @@ ul.auto-toc {
|
|||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
!! source digest: sha256:1e707b0c988c388ee8ae35b00354343f1e961eb524838d3fd56348df767e4ac8
|
||||
!! source digest: sha256:0fb42d09f0995520749d0cb55db14e5ed47e9e037598f2a9ac9e5534887e0666
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external image-reference" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external image-reference" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external image-reference" href="https://github.com/OCA/web/tree/16.0/web_group_expand"><img alt="OCA/web" src="https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github" /></a> <a class="reference external image-reference" href="https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_group_expand"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external image-reference" href="https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0"><img alt="Try me on Runboat" src="https://img.shields.io/badge/runboat-Try%20me-875A7B.png" /></a></p>
|
||||
<p>When grouping a list by a field, this module adds two buttons to expand or
|
||||
|
@ -416,6 +416,7 @@ If you spotted it first, help us to smash it by providing a detailed and welcome
|
|||
<li>Jan Verbeek <<a class="reference external" href="mailto:jverbeek@therp.nl">jverbeek@therp.nl</a>></li>
|
||||
<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>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="section" id="maintainers">
|
||||
|
|
|
@ -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();
|
||||
},
|
||||
});
|
|
@ -1,91 +0,0 @@
|
|||
/** @odoo-module */
|
||||
|
||||
import ListController from "web.ListController";
|
||||
import ListRenderer from "web.ListRenderer";
|
||||
import core from "web.core";
|
||||
|
||||
const qweb = core.qweb;
|
||||
|
||||
ListController.include({
|
||||
start: function () {
|
||||
this.$expandGroupButtons = $(qweb.render("web_group_expand.Buttons"));
|
||||
this.$expandGroupButtons
|
||||
.find("#oe_group_by_expand")
|
||||
.on("click", this.expandAllGroups.bind(this));
|
||||
this.$expandGroupButtons
|
||||
.find("#oe_group_by_collapse")
|
||||
.on("click", this.collapseAllGroups.bind(this));
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
renderButtons: function () {
|
||||
this._super.apply(this, arguments);
|
||||
this.$expandGroupButtons.toggleClass("o_hidden", !this.renderer.isGrouped);
|
||||
this.$buttons.append(this.$expandGroupButtons);
|
||||
},
|
||||
|
||||
expandAllGroups: function () {
|
||||
// We expand layer by layer. So first we need to find the highest
|
||||
// layer that's not already fully expanded.
|
||||
let layer = this.renderer.state.data;
|
||||
while (layer.length) {
|
||||
const closed = layer.filter(function (group) {
|
||||
return !group.isOpen;
|
||||
});
|
||||
if (closed.length) {
|
||||
// This layer is not completely expanded, expand it
|
||||
this._toggleGroups(closed);
|
||||
break;
|
||||
}
|
||||
// This layer is completely expanded, move to the next
|
||||
layer = _.flatten(
|
||||
layer.map(function (group) {
|
||||
return group.data;
|
||||
}),
|
||||
true
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
collapseAllGroups: function () {
|
||||
// We collapse layer by layer. So first we need to find the deepest
|
||||
// layer that's not already fully collapsed.
|
||||
let layer = this.renderer.state.data.filter(function (group) {
|
||||
return group.isOpen;
|
||||
});
|
||||
while (layer.length) {
|
||||
const next = _.flatten(
|
||||
layer.map(function (group) {
|
||||
return group.data;
|
||||
}),
|
||||
true
|
||||
).filter(function (group) {
|
||||
return group.isOpen;
|
||||
});
|
||||
if (!next.length) {
|
||||
// Next layer is fully collapsed, so collapse this one
|
||||
this._toggleGroups(layer);
|
||||
break;
|
||||
}
|
||||
layer = next;
|
||||
}
|
||||
},
|
||||
|
||||
_toggleGroups: function (groups) {
|
||||
const self = this;
|
||||
const defs = groups.map(function (group) {
|
||||
return self.model.toggleGroup(group.id);
|
||||
});
|
||||
$.when(...defs).then(
|
||||
this.update.bind(this, {}, {keepSelection: true, reload: false})
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
ListRenderer.include({
|
||||
updateState: function () {
|
||||
const res = this._super.apply(this, arguments);
|
||||
$("nav.oe_group_by_expand_buttons").toggleClass("o_hidden", !this.isGrouped);
|
||||
return res;
|
||||
},
|
||||
});
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<templates>
|
||||
<t t-name="web_group_expand.Buttons">
|
||||
<nav class="btn-group oe_group_by_expand_buttons o_hidden">
|
||||
<button
|
||||
class="btn btn-secondary fa fa-expand"
|
||||
id="oe_group_by_expand"
|
||||
title="Expand groups"
|
||||
type="button"
|
||||
/>
|
||||
<button
|
||||
class="btn btn-secondary fa fa-compress"
|
||||
id="oe_group_by_collapse"
|
||||
title="Collapse groups"
|
||||
type="button"
|
||||
/>
|
||||
</nav>
|
||||
</t>
|
||||
</templates>
|
|
@ -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>
|
Loading…
Reference in New Issue