Serpent Consulting Services Pvt. Ltd
9 years ago
committed by
Jay Vora(SerpentCS)
6 changed files with 53 additions and 37 deletions
-
10web_group_expand/README.rst
-
3web_group_expand/__init__.py
-
9web_group_expand/__openerp__.py
-
1web_group_expand/static/src/css/expand_buttons.css
-
57web_group_expand/static/src/js/web_group_expand.js
-
10web_group_expand/static/src/xml/expand_buttons.xml
@ -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). |
@ -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; |
||||
}, |
}, |
||||
}) |
|
||||
} |
|
||||
|
}); |
||||
|
}); |
@ -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> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue