mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[MIG] web_group_expand: Migration to 11.0
This commit is contained in:
committed by
Pedro M. Baeza
parent
f9c58fff79
commit
6f261ee58d
@@ -1,5 +1,6 @@
|
||||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
|
||||
:alt: License: AGPL-3
|
||||
.. 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
|
||||
@@ -16,7 +17,7 @@ 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/8.0
|
||||
:target: https://runbot.odoo-community.org/runbot/162/11.0
|
||||
|
||||
For further information, please visit:
|
||||
|
||||
@@ -29,7 +30,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
|
||||
`here <https://github.com/OCA/web/issues/new?body=module:%20web_group_expand%0Aversion:%208.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`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
|
||||
@@ -42,6 +43,7 @@ Contributors
|
||||
* 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
|
||||
----------
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
{
|
||||
"name": "Group Expand Buttons",
|
||||
'summary': """
|
||||
Enables expanding/reset all groups in list view
|
||||
""",
|
||||
"version": "11.0.1.0.0",
|
||||
"category": "Web",
|
||||
"version": "8.0.1.0.0",
|
||||
"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"
|
||||
],
|
||||
"qweb": [
|
||||
"static/src/xml/expand_buttons.xml",
|
||||
],
|
||||
"data": [
|
||||
"views/templates.xml",
|
||||
"templates/assets.xml",
|
||||
],
|
||||
"qweb": [
|
||||
"static/src/xml/web_group_expand.xml",
|
||||
],
|
||||
"installable": True,
|
||||
'application': False,
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
8
web_group_expand/static/src/css/web_group_expand.css
Normal file
8
web_group_expand/static/src/css/web_group_expand.css
Normal file
@@ -0,0 +1,8 @@
|
||||
.o_favorites_menu + .toggle_buttons{
|
||||
float: left;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
.o_favorites_menu + .toggle_buttons button{
|
||||
display: inline;
|
||||
}
|
||||
@@ -1,44 +1,75 @@
|
||||
odoo.define('web_groupby_expand.web_groupby_expand', function (require) {
|
||||
"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();
|
||||
|
||||
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;
|
||||
}
|
||||
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();
|
||||
});
|
||||
}
|
||||
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 })
|
||||
}
|
||||
}
|
||||
}
|
||||
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()
|
||||
});
|
||||
}
|
||||
},
|
||||
load_expand_buttons:function() {
|
||||
var self = this;
|
||||
this.$ExpandButtons = $(QWeb.render("GroupExpand.Buttons", {'widget':self}));
|
||||
this.$el.find("ul.oe_view_manager_switch.oe_button_group.oe_right").before(this.$ExpandButtons);
|
||||
},
|
||||
setup_search_view: function(view_id, search_defaults) {
|
||||
var self = this;
|
||||
var res = this._super.apply(this, arguments);
|
||||
this.searchview.on('search_data', self, this.expand);
|
||||
return res
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
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)
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates id="template" xml:space="preserve">
|
||||
<t t-name="GroupExpand.Buttons">
|
||||
<div class="oe_list_buttons">
|
||||
<ul id="oe_group_by" class="oe_view_manager_switch oe_button_group oe_right">
|
||||
<li class="oe_group_expand"><a id="oe_group_by_expand"><i class="fa fa-expand" id="expand_icon" /></a></li>
|
||||
<li class="oe_group_expand"><a id="oe_group_by_reset"><i class="fa fa-compress" id="compress_icon" /></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</t>
|
||||
</templates>
|
||||
11
web_group_expand/static/src/xml/web_group_expand.xml
Normal file
11
web_group_expand/static/src/xml/web_group_expand.xml
Normal file
@@ -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>
|
||||
9
web_group_expand/templates/assets.xml
Normal file
9
web_group_expand/templates/assets.xml
Normal file
@@ -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>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<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"></script>
|
||||
<link rel="stylesheet" href="/web_group_expand/static/src/css/expand_buttons.css"/>
|
||||
</xpath>
|
||||
</template>
|
||||
</data>
|
||||
</openerp>
|
||||
Reference in New Issue
Block a user