diff --git a/web_group_expand/README.rst b/web_group_expand/README.rst index a88dcba57..be83c94bd 100644 --- a/web_group_expand/README.rst +++ b/web_group_expand/README.rst @@ -1,60 +1,85 @@ -.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg - :alt: License: AGPL-3 - ==================== Group Expand Buttons ==================== -A group by list can be expanded and collapased with buttons +.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + !! This file is generated by oca-gen-addon-readme !! + !! changes will be overwritten. !! + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -You'll see two buttons appear on top right corner of the list when you perform -a group by with which you can expand and collapse grouped records by level. +.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png + :target: https://odoo-community.org/page/development-status + :alt: Beta +.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png + :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/12.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-12-0/web-12-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/12.0 + :alt: Try me on Runbot +|badge1| |badge2| |badge3| |badge4| |badge5| -Usage -===== +When grouping a list by a field, this module adds two buttons to expand or +collapse all the groups at once. -.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas - :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/162/8.0 +The buttons appear in the top right, in place of the pagination. -For further information, please visit: +One level of groups is expanded or collapsed at a time. -* https://www.odoo.com/forum/help-1 +**Table of contents** +.. contents:: + :local: Bug Tracker =========== Bugs are tracked on `GitHub 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 -`here `_. +If you spotted it first, help us smashing it by providing a detailed and welcomed +`feedback `_. +Do not contact contributors directly about support or help with technical issues. Credits ======= +Authors +~~~~~~~ + +* OpenERP SA +* AvanzOSC +* Serv. Tecnol. Avanzados - Pedro M. Baeza +* Therp BV + Contributors ------------- +~~~~~~~~~~~~ * Mantavya Gajjar * Oihane Crucelaegui * Pedro M. Baeza * Jay Vora (SerpentCS) for their alternative implementation +* Jan Verbeek -Maintainer ----------- +Maintainers +~~~~~~~~~~~ + +This module is maintained by the OCA. .. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association :target: https://odoo-community.org -This module is maintained by the OCA. - 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. -To contribute to this module, please visit http://odoo-community.org. +This module is part of the `OCA/web `_ project on GitHub. +You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_group_expand/__openerp__.py b/web_group_expand/__manifest__.py similarity index 79% rename from web_group_expand/__openerp__.py rename to web_group_expand/__manifest__.py index 36acdc497..c98849280 100644 --- a/web_group_expand/__openerp__.py +++ b/web_group_expand/__manifest__.py @@ -1,13 +1,15 @@ { "name": "Group Expand Buttons", "category": "Web", - "version": "8.0.1.0.0", + "version": "12.0.1.0.0", + "license": "AGPL-3", "author": "OpenERP SA, " "AvanzOSC, " "Serv. Tecnol. Avanzados - Pedro M. Baeza, " + "Therp BV, " "Odoo Community Association (OCA)", "depends": [ - "web" + "web", ], "qweb": [ "static/src/xml/expand_buttons.xml", @@ -15,5 +17,4 @@ "data": [ "views/templates.xml", ], - "installable": True, } diff --git a/web_group_expand/i18n/nl.po b/web_group_expand/i18n/nl.po new file mode 100644 index 000000000..6ed84a394 --- /dev/null +++ b/web_group_expand/i18n/nl.po @@ -0,0 +1,31 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * web_group_expand +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 12.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2020-04-20 10:58+0000\n" +"PO-Revision-Date: 2020-04-20 12:59+0200\n" +"Last-Translator: <>\n" +"Language-Team: \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + +#. module: web_group_expand +#. openerp-web +#: code:addons/web_group_expand/static/src/xml/expand_buttons.xml:12 +#, python-format +msgid "Collapse groups" +msgstr "Groepen inklappen" + +#. module: web_group_expand +#. openerp-web +#: code:addons/web_group_expand/static/src/xml/expand_buttons.xml:8 +#, python-format +msgid "Expand groups" +msgstr "Groepen uitvouwen" diff --git a/web_group_expand/i18n/web_group_expand.pot b/web_group_expand/i18n/web_group_expand.pot index 386b25585..b482f9624 100644 --- a/web_group_expand/i18n/web_group_expand.pot +++ b/web_group_expand/i18n/web_group_expand.pot @@ -1,9 +1,10 @@ # Translation of Odoo Server. # This file contains the translation of the following modules: +# * web_group_expand # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 8.0\n" +"Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: <>\n" "Language-Team: \n" @@ -12,3 +13,17 @@ msgstr "" "Content-Transfer-Encoding: \n" "Plural-Forms: \n" +#. module: web_group_expand +#. openerp-web +#: code:addons/web_group_expand/static/src/xml/expand_buttons.xml:12 +#, python-format +msgid "Collapse groups" +msgstr "" + +#. module: web_group_expand +#. openerp-web +#: code:addons/web_group_expand/static/src/xml/expand_buttons.xml:8 +#, python-format +msgid "Expand groups" +msgstr "" + diff --git a/web_group_expand/readme/CONTRIBUTORS.rst b/web_group_expand/readme/CONTRIBUTORS.rst new file mode 100644 index 000000000..9c037f882 --- /dev/null +++ b/web_group_expand/readme/CONTRIBUTORS.rst @@ -0,0 +1,5 @@ +* Mantavya Gajjar +* Oihane Crucelaegui +* Pedro M. Baeza +* Jay Vora (SerpentCS) for their alternative implementation +* Jan Verbeek diff --git a/web_group_expand/readme/DESCRIPTION.rst b/web_group_expand/readme/DESCRIPTION.rst new file mode 100644 index 000000000..993a16b87 --- /dev/null +++ b/web_group_expand/readme/DESCRIPTION.rst @@ -0,0 +1,6 @@ +When grouping a list by a field, this module adds two buttons to expand 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. diff --git a/web_group_expand/static/description/icon.png b/web_group_expand/static/description/icon.png index 9eb607c3d..775a59353 100644 Binary files a/web_group_expand/static/description/icon.png and b/web_group_expand/static/description/icon.png differ diff --git a/web_group_expand/static/description/index.html b/web_group_expand/static/description/index.html new file mode 100644 index 000000000..7e1774e9c --- /dev/null +++ b/web_group_expand/static/description/index.html @@ -0,0 +1,429 @@ + + + + + + +Group Expand Buttons + + + +
+

Group Expand Buttons

+ + +

Beta License: AGPL-3 OCA/web Translate me on Weblate Try me on Runbot

+

When grouping a list by a field, this module adds two buttons to expand 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.

+

Table of contents

+ +
+

Bug Tracker

+

Bugs are tracked on GitHub 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.

+

Do not contact contributors directly about support or help with technical issues.

+
+
+

Credits

+
+

Authors

+
    +
  • OpenERP SA
  • +
  • AvanzOSC
  • +
  • Serv. Tecnol. Avanzados - Pedro M. Baeza
  • +
  • Therp BV
  • +
+
+
+

Contributors

+ +
+
+

Maintainers

+

This module is maintained by the OCA.

+Odoo Community Association +

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 project on GitHub.

+

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

+
+
+
+ + diff --git a/web_group_expand/static/src/css/expand_buttons.css b/web_group_expand/static/src/css/expand_buttons.css deleted file mode 100644 index e02cfec57..000000000 --- a/web_group_expand/static/src/css/expand_buttons.css +++ /dev/null @@ -1,8 +0,0 @@ - -.openerp ul#oe_group_by li.oe_group_expand{ - line-height: 25px; -} -.openerp .fa-expand, .openerp .fa-compress { - font-size:15px; - font-weight:bold; -} diff --git a/web_group_expand/static/src/js/web_group_expand.js b/web_group_expand/static/src/js/web_group_expand.js index c724abc53..290d0645e 100644 --- a/web_group_expand/static/src/js/web_group_expand.js +++ b/web_group_expand/static/src/js/web_group_expand.js @@ -1,45 +1,73 @@ -"use strict"; -openerp.web_group_expand = function(openerp) { - var QWeb = openerp.web.qweb; - openerp.web.ViewManager.include({ - switch_mode: function(view_type, no_store, view_options) { - if (view_type != 'list' && view_type != 'tree' ) { - this.$el.find("ul#oe_group_by").remove(); - } - if(view_type == 'tree'){ - this.load_expand_buttons(); - this.$ExpandButtons.find("a#oe_group_by_reset").click(function(){ - $('.oe_open .treeview-tr.oe-treeview-first').filter(function(){return ($(this).parents('tr').attr('data-level') == 1)}).click() - }); - this.$ExpandButtons.find("a#oe_group_by_expand").click(function(){ - $('.treeview-tr.oe-treeview-first').filter(function(){return (!$(this).parents().is('.oe_open')) & ($(this).parents().css( "display" ) != 'none')}).click(); - }); - } +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); }, - expand: function(domains, contexts, groupbys) { - this.$el.find("ul#oe_group_by").remove(); - if(groupbys.length && this.active_view == 'list') { - this.load_expand_buttons(); - this.$el.find("a#oe_group_by_reset").click(function(){ - $('span.ui-icon-triangle-1-s').click() - }); - this.$el.find("a#oe_group_by_expand").click(function(){ - $('span.ui-icon-triangle-1-e').click() - }); + + renderPager: function ($node) { + this._super.apply(this, arguments); + this.$expandGroupButtons.toggleClass("o_hidden", !this.renderer.isGrouped); + $node.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); } }, - load_expand_buttons:function() { - var self = this; - this.$el.find("ul#oe_group_by").remove(); - this.$ExpandButtons = $(QWeb.render("GroupExpand.Buttons", {'widget':self})); - this.$el.find("ul.oe_view_manager_switch.oe_button_group.oe_right").before(this.$ExpandButtons); + + 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; + } }, - setup_search_view: function(view_id, search_defaults) { + + _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); - this.searchview.on('search_data', self, this.expand); - return res + $("nav.oe_group_by_expand_buttons").toggleClass("o_hidden", !this.isGrouped); + return res; }, - }) -} + }); +}); diff --git a/web_group_expand/static/src/xml/expand_buttons.xml b/web_group_expand/static/src/xml/expand_buttons.xml index 27d3a50a1..3f3b55ff7 100644 --- a/web_group_expand/static/src/xml/expand_buttons.xml +++ b/web_group_expand/static/src/xml/expand_buttons.xml @@ -1,11 +1,15 @@ - - -
-
    -
  • -
  • -
-
-
+ + + + diff --git a/web_group_expand/views/templates.xml b/web_group_expand/views/templates.xml index e53261531..0864cf845 100644 --- a/web_group_expand/views/templates.xml +++ b/web_group_expand/views/templates.xml @@ -1,11 +1,8 @@ - - - - - + + +