mirror of https://github.com/OCA/web.git
Merge pull request #928 from multidadosti-erp/11.0-mig-web_group_expand
11.0 mig web_group_expandpull/946/head
commit
a9361d26e9
|
@ -0,0 +1,62 @@
|
|||
.. image:: https://img.shields.io/badge/license-AGPL--3-blue.png
|
||||
:target: https://www.gnu.org/licenses/agpl
|
||||
:alt: License: AGPL-3
|
||||
|
||||
====================
|
||||
Group Expand Buttons
|
||||
====================
|
||||
|
||||
A group by list can be expanded and collapased with buttons
|
||||
|
||||
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.
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
.. 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/11.0
|
||||
|
||||
For further information, please visit:
|
||||
|
||||
* https://www.odoo.com/forum/help-1
|
||||
|
||||
|
||||
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
|
||||
`here <https://github.com/OCA/web/issues/new?body=module:%20web_group_expand%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Contributors
|
||||
------------
|
||||
|
||||
* Mantavya Gajjar <mga@openerp.com>
|
||||
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
|
||||
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
|
||||
* Jay Vora (SerpentCS) for their alternative implementation
|
||||
* Aldo Soares <soares_aldo@hotmail.com>
|
||||
|
||||
Maintainer
|
||||
----------
|
||||
|
||||
.. 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.
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"name": "Group Expand Buttons",
|
||||
'summary': """
|
||||
Enables expanding/reset all groups in list view
|
||||
""",
|
||||
"version": "11.0.1.0.0",
|
||||
"category": "Web",
|
||||
"author": "OpenERP SA, "
|
||||
"AvanzOSC, "
|
||||
"Serv. Tecnol. Avanzados - Pedro M. Baeza, "
|
||||
"Odoo Community Association (OCA)",
|
||||
"website": "https://github.com/oca/web",
|
||||
'license': 'AGPL-3',
|
||||
"depends": [
|
||||
"web"
|
||||
],
|
||||
"data": [
|
||||
"templates/assets.xml",
|
||||
],
|
||||
"qweb": [
|
||||
"static/src/xml/web_group_expand.xml",
|
||||
],
|
||||
"installable": True,
|
||||
'application': False,
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
|
@ -0,0 +1,8 @@
|
|||
.o_favorites_menu + .toggle_buttons{
|
||||
float: left;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.o_favorites_menu + .toggle_buttons button{
|
||||
display: inline;
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
odoo.define('web_groupby_expand.web_groupby_expand', function (require) {
|
||||
"use strict";
|
||||
|
||||
var ViewManager = require('web.ViewManager');
|
||||
|
||||
ViewManager.include({
|
||||
render_view_control_elements: function (){
|
||||
var res = this._super.apply(this, arguments);
|
||||
if (this.searchview_elements) {
|
||||
var searchview = this.searchview_elements.$searchview_buttons
|
||||
var expand_button = searchview.find('#oe_group_by_expand');
|
||||
var reset_button = searchview.find('#oe_group_by_reset');
|
||||
expand_button.on('click', this.proxy('expand_records'));
|
||||
reset_button.on('click', this.proxy('reset_records'));
|
||||
this.do_toggle_visibility(false)
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
||||
_process_search_data: function () {
|
||||
var res = this._super.apply(this, arguments);
|
||||
if (this.active_view && this.active_view.type == 'list' && this.searchview_elements) {
|
||||
var searchview = this.searchview_elements.$searchview_buttons
|
||||
var has_groups = res.groupBy.length > 0
|
||||
this.do_toggle_visibility(has_groups)
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
||||
get_search_groups: function (groups) {
|
||||
var current_search_group = {};
|
||||
for (var group in groups) {
|
||||
if (groups[group].count > 0 && groups[group].data.length > 0) {
|
||||
current_search_group[groups[group].id] = groups[group].data;
|
||||
}
|
||||
}
|
||||
return current_search_group;
|
||||
},
|
||||
|
||||
do_toggle_visibility: function (show) {
|
||||
var searchview = this.searchview_elements.$searchview_buttons
|
||||
var buttons = searchview.find('.toggle_buttons');
|
||||
if (show) {
|
||||
buttons.show()
|
||||
}
|
||||
else {
|
||||
buttons.hide()
|
||||
}
|
||||
},
|
||||
|
||||
toggle_group_records: function (op, controller) {
|
||||
var current_search_group = this.get_search_groups(controller.model.localData);
|
||||
if (current_search_group) {
|
||||
for (var group in current_search_group) {
|
||||
for (var gp in current_search_group[group]) {
|
||||
var cur_group = controller.model.localData[current_search_group[group][gp]]
|
||||
if ((op && !cur_group.isOpen) || (!op && cur_group.isOpen)) {
|
||||
controller.trigger_up('toggle_group', { group: cur_group })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
reset_records: function () {
|
||||
var controller = this.active_view.controller;
|
||||
this.toggle_group_records(false, controller)
|
||||
},
|
||||
|
||||
expand_records: function () {
|
||||
var controller = this.active_view.controller;
|
||||
this.toggle_group_records(true, controller)
|
||||
},
|
||||
});
|
||||
});
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<template xml:space="preserve">
|
||||
<t t-extend="SearchView.FavoriteMenu">
|
||||
<t t-jquery=".o_favorites_menu" t-operation="after">
|
||||
<div class="toggle_buttons">
|
||||
<button id="oe_group_by_expand" class="fa fa-expand btn btn-icon"/>
|
||||
<button id="oe_group_by_reset" class="fa fa-compress btn btn-icon"/>
|
||||
</div>
|
||||
</t>
|
||||
</t>
|
||||
</template>
|
|
@ -0,0 +1,9 @@
|
|||
<?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">
|
||||
<link rel="stylesheet" href="/web_group_expand/static/src/css/web_group_expand.css"/>
|
||||
<script type="text/javascript" src="/web_group_expand/static/src/js/web_group_expand.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
Loading…
Reference in New Issue