Aldo_Soares
7 years ago
committed by
Pedro M. Baeza
9 changed files with 117 additions and 80 deletions
-
10web_group_expand/README.rst
-
16web_group_expand/__manifest__.py
-
8web_group_expand/static/src/css/expand_buttons.css
-
8web_group_expand/static/src/css/web_group_expand.css
-
113web_group_expand/static/src/js/web_group_expand.js
-
11web_group_expand/static/src/xml/expand_buttons.xml
-
11web_group_expand/static/src/xml/web_group_expand.xml
-
9web_group_expand/templates/assets.xml
-
11web_group_expand/views/templates.xml
@ -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; |
|||
} |
@ -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> |
@ -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> |
@ -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> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue