Browse Source

[MIG] web_group_expand: Migration to 11.0

pull/928/head
Aldo_Soares 6 years ago
committed by Pedro M. Baeza
parent
commit
6f261ee58d
  1. 10
      web_group_expand/README.rst
  2. 16
      web_group_expand/__manifest__.py
  3. 8
      web_group_expand/static/src/css/expand_buttons.css
  4. 8
      web_group_expand/static/src/css/web_group_expand.css
  5. 113
      web_group_expand/static/src/js/web_group_expand.js
  6. 11
      web_group_expand/static/src/xml/expand_buttons.xml
  7. 11
      web_group_expand/static/src/xml/web_group_expand.xml
  8. 9
      web_group_expand/templates/assets.xml
  9. 11
      web_group_expand/views/templates.xml

10
web_group_expand/README.rst

@ -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 Group Expand Buttons
@ -16,7 +17,7 @@ Usage
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot :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: For further information, please visit:
@ -29,7 +30,7 @@ Bug Tracker
Bugs are tracked on `GitHub Issues <https://github.com/OCA/web/issues>`_. 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. 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 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 Credits
@ -42,6 +43,7 @@ Contributors
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es> * Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com> * Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Jay Vora (SerpentCS) for their alternative implementation * Jay Vora (SerpentCS) for their alternative implementation
* Aldo Soares <soares_aldo@hotmail.com>
Maintainer Maintainer
---------- ----------

16
web_group_expand/__openerp__.py → web_group_expand/__manifest__.py

@ -1,19 +1,25 @@
{ {
"name": "Group Expand Buttons", "name": "Group Expand Buttons",
'summary': """
Enables expanding/reset all groups in list view
""",
"version": "11.0.1.0.0",
"category": "Web", "category": "Web",
"version": "8.0.1.0.0",
"author": "OpenERP SA, " "author": "OpenERP SA, "
"AvanzOSC, " "AvanzOSC, "
"Serv. Tecnol. Avanzados - Pedro M. Baeza, " "Serv. Tecnol. Avanzados - Pedro M. Baeza, "
"Odoo Community Association (OCA)", "Odoo Community Association (OCA)",
"website": "https://github.com/oca/web",
'license': 'AGPL-3',
"depends": [ "depends": [
"web" "web"
], ],
"qweb": [
"static/src/xml/expand_buttons.xml",
],
"data": [ "data": [
"views/templates.xml",
"templates/assets.xml",
],
"qweb": [
"static/src/xml/web_group_expand.xml",
], ],
"installable": True, "installable": True,
'application': False,
} }

8
web_group_expand/static/src/css/expand_buttons.css

@ -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

@ -0,0 +1,8 @@
.o_favorites_menu + .toggle_buttons{
float: left;
padding-left: 5px;
}
.o_favorites_menu + .toggle_buttons button{
display: inline;
}

113
web_group_expand/static/src/js/web_group_expand.js

@ -1,44 +1,75 @@
odoo.define('web_groupby_expand.web_groupby_expand', function (require) {
"use strict"; "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)
},
});
});

11
web_group_expand/static/src/xml/expand_buttons.xml

@ -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

@ -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

@ -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>

11
web_group_expand/views/templates.xml

@ -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>
Loading…
Cancel
Save