Browse Source

Migrated web_group_expand module to v9

pull/373/head
Serpent Consulting Services Pvt. Ltd 8 years ago
committed by Jay Vora(SerpentCS)
parent
commit
205abee601
  1. 10
      web_group_expand/README.rst
  2. 3
      web_group_expand/__init__.py
  3. 9
      web_group_expand/__openerp__.py
  4. 1
      web_group_expand/static/src/css/expand_buttons.css
  5. 57
      web_group_expand/static/src/js/web_group_expand.js
  6. 10
      web_group_expand/static/src/xml/expand_buttons.xml

10
web_group_expand/README.rst

@ -5,7 +5,7 @@
Group Expand Buttons Group Expand Buttons
==================== ====================
A group by list can be expanded and collapased with buttons
A group by list can be expanded and collapsed with buttons.
You'll see two buttons appear on top right corner of the list when you perform 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. a group by with which you can expand and collapse grouped records by level.
@ -16,7 +16,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/9.0
For further information, please visit: For further information, please visit:
@ -28,8 +28,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
`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**>`_.
If you spotted it first, help us smashing it by providing a detailed and welcomed feedback.
Credits Credits
@ -41,6 +40,7 @@ Contributors
* Mantavya Gajjar <mga@openerp.com> * Mantavya Gajjar <mga@openerp.com>
* Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es> * Oihane Crucelaegui <oihanecrucelaegi@avanzosc.es>
* Pedro M. Baeza <pedro.baeza@serviciosbaeza.com> * Pedro M. Baeza <pedro.baeza@serviciosbaeza.com>
* Meet Dholakia <vora.jay@serpentcs.com>
* Jay Vora (SerpentCS) for their alternative implementation * Jay Vora (SerpentCS) for their alternative implementation
Maintainer Maintainer
@ -56,5 +56,5 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and mission is to support the collaborative development of Odoo features and
promote its widespread use. promote its widespread use.
To contribute to this module, please visit http://odoo-community.org.
To contribute to this module, please visit https://odoo-community.org.

3
web_group_expand/__init__.py

@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Serpent Consulting Services Pvt. Ltd. (http://www.serpentcs.com)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

9
web_group_expand/__openerp__.py

@ -1,7 +1,12 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Serpent Consulting Services Pvt. Ltd.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
"name": "Group Expand Buttons", "name": "Group Expand Buttons",
"category": "Web", "category": "Web",
"version": "8.0.1.0.0",
"version": "9.0.1.0.0",
"license": "AGPL-3",
"author": "OpenERP SA, " "author": "OpenERP SA, "
"AvanzOSC, " "AvanzOSC, "
"Serv. Tecnol. Avanzados - Pedro M. Baeza, " "Serv. Tecnol. Avanzados - Pedro M. Baeza, "
@ -15,5 +20,5 @@
"data": [ "data": [
"views/templates.xml", "views/templates.xml",
], ],
'installable': False,
'installable': True,
} }

1
web_group_expand/static/src/css/expand_buttons.css

@ -3,6 +3,5 @@
line-height: 25px; line-height: 25px;
} }
.openerp .fa-expand, .openerp .fa-compress { .openerp .fa-expand, .openerp .fa-compress {
font-size:15px;
font-weight:bold; font-weight:bold;
} }

57
web_group_expand/static/src/js/web_group_expand.js

@ -1,44 +1,53 @@
"use strict";
openerp.web_group_expand = function(openerp) {
var QWeb = openerp.web.qweb;
openerp.web.ViewManager.include({
odoo.define('web_group_expand.web_group_expand',function(require){
"use strict";
var core = require('web.core');
var ViewManager = require('web.ViewManager');
var _t = core._t;
var QWeb = core.qweb;
ViewManager.include({
switch_mode: function(view_type, no_store, view_options) { 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 !== 'list' && view_type !== 'tree' ) {
$("div#oe_group_by").remove();
} }
if(view_type == 'tree'){
if(view_type === 'tree'){
$("div#oe_group_by").remove();
this.load_expand_buttons(); 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("li#oe_group_by_reset").click(function(){
$('.oe_open .treeview-tr.oe-treeview-first').filter(function(){
return parseInt($(this).parents('tr').attr('data-level'),10) === 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();
this.$ExpandButtons.find("li#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 this._super.apply(this, arguments);
return this._super(view_type, no_store, view_options);
}, },
expand: function(domains, contexts, groupbys) { expand: function(domains, contexts, groupbys) {
this.$el.find("ul#oe_group_by").remove();
if(groupbys.length && this.active_view == 'list') {
$("div#oe_group_by").remove();
if(groupbys.length && this.active_view.type === 'list') {
this.load_expand_buttons(); this.load_expand_buttons();
this.$el.find("a#oe_group_by_reset").click(function(){
$('span.ui-icon-triangle-1-s').click()
$("li#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()
$("li#oe_group_by_expand").click(function(){
$('span.ui-icon-triangle-1-e').click();
}); });
} }
}, },
load_expand_buttons:function() { load_expand_buttons:function() {
var self = this; var self = this;
this.$ExpandButtons = $(QWeb.render("GroupExpand.Buttons", {'widget':self})); this.$ExpandButtons = $(QWeb.render("GroupExpand.Buttons", {'widget':self}));
this.$el.find("ul.oe_view_manager_switch.oe_button_group.oe_right").before(this.$ExpandButtons);
$(".oe-cp-switch-buttons.btn-group.btn-group-sm").before(this.$ExpandButtons);
}, },
setup_search_view: function(view_id, search_defaults) {
setup_search_view: function() {
var self = this; var self = this;
var res = this._super.apply(this, arguments);
var res = this._super();
this.searchview.on('search_data', self, this.expand); this.searchview.on('search_data', self, this.expand);
return res
return res;
}, },
})
}
});
});

10
web_group_expand/static/src/xml/expand_buttons.xml

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve"> <templates id="template" xml:space="preserve">
<t t-name="GroupExpand.Buttons"> <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>
<div id="oe_group_by" class="oe-cp-switch-buttons btn-group btn-group-sm">
<li id="oe_group_by_expand" type="button" class="btn btn-default fa fa-expand oe_group_expand" title="Expand"/>
<li id="oe_group_by_reset" type="button" class="btn btn-default fa fa-compress oe_group_expand" title="Expand"/>
</div>
</div> </div>
</t> </t>
</templates> </templates>
Loading…
Cancel
Save