[FIX] handling of groups with length 0 in ContainerDataGroup's group descriptor munger
For a group with a ${field}_count of 0, code would fallback on __count which does not exist -> would try to set group.length to `undefined` which leads to the property being removed from the result, blowing up the call to `$('<td>').text(group.length)` in the listview (jQuery's .text() apparently does not like getting `undefined` as its parameter... who knew?) Also make `openable` clearer, and improve style of listview in case of an empty group (openable but length 0): remove the arrow on the left (but leave the indent, otherwise it's ugly). lp bug: https://launchpad.net/bugs/889807 fixed bzr revid: xmo@openerp.com-20111115112906-e87sf40tgr8goqps
This commit is contained in:
parent
f6b0482130
commit
e536b4ace8
|
@ -119,17 +119,18 @@ openerp.web.ContainerDataGroup = openerp.web.DataGroup.extend( /** @lends opener
|
|||
aggregates[key] = value || 0;
|
||||
});
|
||||
|
||||
var group_size = fixed_group[field_name + '_count'] || fixed_group.__count || 0;
|
||||
var leaf_group = fixed_group.__context.group_by.length === 0;
|
||||
return {
|
||||
__context: fixed_group.__context,
|
||||
__domain: fixed_group.__domain,
|
||||
|
||||
grouped_on: field_name,
|
||||
// if terminal group (or no group) and group_by_no_leaf => use group.__count
|
||||
length: fixed_group[field_name + '_count'] || fixed_group.__count,
|
||||
length: group_size,
|
||||
value: fixed_group[field_name],
|
||||
|
||||
openable: !(this.context['group_by_no_leaf']
|
||||
&& fixed_group.__context.group_by.length === 0),
|
||||
// A group is openable if it's not a leaf in group_by_no_leaf mode
|
||||
openable: !(leaf_group && this.context['group_by_no_leaf']),
|
||||
|
||||
aggregates: aggregates
|
||||
};
|
||||
|
|
|
@ -1127,7 +1127,7 @@ openerp.web.ListView.Groups = openerp.web.Class.extend( /** @lends openerp.web.L
|
|||
child.datagroup = group;
|
||||
|
||||
var $row = child.$row = $('<tr>');
|
||||
if (group.openable) {
|
||||
if (group.openable && group.length) {
|
||||
$row.click(function (e) {
|
||||
if (!$row.data('open')) {
|
||||
$row.data('open', true)
|
||||
|
@ -1159,7 +1159,13 @@ openerp.web.ListView.Groups = openerp.web.Class.extend( /** @lends openerp.web.L
|
|||
} catch (e) {
|
||||
$group_column.html(row_data[group_column.id].value);
|
||||
}
|
||||
if (group.openable) {
|
||||
if (!group.length) {
|
||||
// Kinda-ugly hack: jquery-ui has no "empty" icon, so set
|
||||
// wonky background position to ensure nothing is displayed
|
||||
// there but the rest of the behavior is ui-icon's
|
||||
$group_column.prepend(
|
||||
'<span class="ui-icon" style="float: left; background-position: 150px 150px">');
|
||||
} else if (group.openable) {
|
||||
// Make openable if not terminal group & group_by_no_leaf
|
||||
$group_column
|
||||
.prepend('<span class="ui-icon ui-icon-triangle-1-e" style="float: left;">');
|
||||
|
|
Loading…
Reference in New Issue