mirror of https://github.com/OCA/web.git
[MIG] web_group_expand: Migration to 15.0
parent
b0b71c4199
commit
fbf46d45ca
|
@ -14,13 +14,13 @@ Group Expand Buttons
|
|||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/web/tree/14.0/web_group_expand
|
||||
:target: https://github.com/OCA/web/tree/15.0/web_group_expand
|
||||
:alt: OCA/web
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/web-14-0/web-14-0-web_group_expand
|
||||
:target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_group_expand
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/162/14.0
|
||||
:target: https://runbot.odoo-community.org/runbot/162/15.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
|
@ -43,7 +43,7 @@ Bug Tracker
|
|||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_group_expand%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/web/issues/new?body=module:%20web_group_expand%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
|
@ -83,6 +83,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
|||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
This module is part of the `OCA/web <https://github.com/OCA/web/tree/14.0/web_group_expand>`_ project on GitHub.
|
||||
This module is part of the `OCA/web <https://github.com/OCA/web/tree/15.0/web_group_expand>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "Group Expand Buttons",
|
||||
"category": "Web",
|
||||
"version": "14.0.1.0.0",
|
||||
"version": "15.0.1.0.0",
|
||||
"license": "AGPL-3",
|
||||
"author": "OpenERP SA, "
|
||||
"AvanzOSC, "
|
||||
|
@ -11,6 +11,12 @@
|
|||
"Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/OCA/web",
|
||||
"depends": ["web"],
|
||||
"qweb": ["static/src/xml/expand_buttons.xml"],
|
||||
"data": ["views/templates.xml"],
|
||||
"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",
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 14.0\n"
|
||||
"Project-Id-Version: Odoo Server 15.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
|
|
|
@ -367,7 +367,7 @@ ul.auto-toc {
|
|||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" 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" 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" href="https://github.com/OCA/web/tree/14.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" href="https://translation.odoo-community.org/projects/web-14-0/web-14-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" href="https://runbot.odoo-community.org/runbot/162/14.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external" 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" 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" href="https://github.com/OCA/web/tree/15.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" href="https://translation.odoo-community.org/projects/web-15-0/web-15-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" href="https://runbot.odoo-community.org/runbot/162/15.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>When grouping a list by a field, this module adds two buttons to expand or
|
||||
collapse all the groups at once.</p>
|
||||
<p>The buttons appear in the top right, in place of the pagination.</p>
|
||||
|
@ -389,7 +389,7 @@ collapse all the groups at once.</p>
|
|||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/web/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_group_expand%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/OCA/web/issues/new?body=module:%20web_group_expand%0Aversion:%2015.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
|
@ -423,7 +423,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
|||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/14.0/web_group_expand">OCA/web</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/web/tree/15.0/web_group_expand">OCA/web</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/** @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,92 +0,0 @@
|
|||
odoo.define("web.web_group_expand", function (require) {
|
||||
"use strict";
|
||||
|
||||
var qweb = require("web.core").qweb;
|
||||
|
||||
require("web.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.
|
||||
var layer = this.renderer.state.data;
|
||||
while (layer.length) {
|
||||
var 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.
|
||||
var layer = this.renderer.state.data.filter(function (group) {
|
||||
return group.isOpen;
|
||||
});
|
||||
while (layer.length) {
|
||||
var 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) {
|
||||
var self = this;
|
||||
var defs = groups.map(function (group) {
|
||||
return self.model.toggleGroup(group.id);
|
||||
});
|
||||
$.when(...defs).then(
|
||||
this.update.bind(this, {}, {keepSelection: true, reload: false})
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
require("web.ListRenderer").include({
|
||||
updateState: function () {
|
||||
var res = this._super.apply(this, arguments);
|
||||
$("nav.oe_group_by_expand_buttons").toggleClass(
|
||||
"o_hidden",
|
||||
!this.isGrouped
|
||||
);
|
||||
return res;
|
||||
},
|
||||
});
|
||||
});
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<odoo>
|
||||
<template
|
||||
id="assets_backend"
|
||||
name="web_groupby_expand assets"
|
||||
inherit_id="web.assets_backend"
|
||||
>
|
||||
<xpath expr="." position="inside">
|
||||
<script
|
||||
type="text/javascript"
|
||||
src="/web_group_expand/static/src/js/web_group_expand.js"
|
||||
/>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
Loading…
Reference in New Issue