[ADD] display inactive pager on group title rows in grouped lists

bzr revid: xmo@openerp.com-20110624111339-2jh8gm8r2l33iifb
This commit is contained in:
Xavier Morel 2011-06-24 13:13:39 +02:00
parent 3b6d9c7886
commit d567ba23ad
2 changed files with 37 additions and 9 deletions

View File

@ -613,6 +613,9 @@ background: linear-gradient(top, #ffffff 0%,#d8d8d8 11%,#afafaf 86%,#333333 91%,
vertical-align: middle; vertical-align: middle;
text-align: left; text-align: left;
} }
.openerp .oe-listview td.oe-record-delete {
text-align: right;
}
.openerp .oe-listview th.oe-sortable, .openerp .oe-listview th.oe-sortable,
.openerp .oe-listview th.oe-sortable .ui-icon { .openerp .oe-listview th.oe-sortable .ui-icon {
cursor: pointer; cursor: pointer;
@ -647,6 +650,14 @@ background: linear-gradient(top, #ffffff 0%,#d8d8d8 11%,#afafaf 86%,#333333 91%,
cursor: pointer; cursor: pointer;
} }
.openerp .oe-listview .oe-group-name {
padding-right: 1em;
}
.openerp .oe-listview .oe-group-name,
.openerp .oe-listview .oe-group-pagination {
white-space: nowrap;
}
.openerp .oe-listview tfoot td { .openerp .oe-listview tfoot td {
padding: 3px 3px 0; padding: 3px 3px 0;
} }

View File

@ -787,14 +787,9 @@ openerp.base.ListView.Groups = Class.extend( /** @lends openerp.base.ListView.Gr
this.columns = view.columns; this.columns = view.columns;
this.datagroup = null; this.datagroup = null;
this.sections = []; this.$row = null;
this.children = {}; this.children = {};
}, },
pad: function ($row) {
if (this.options.selectable) {
$row.append('<td>');
}
},
make_fragment: function () { make_fragment: function () {
return document.createDocumentFragment(); return document.createDocumentFragment();
}, },
@ -827,8 +822,13 @@ openerp.base.ListView.Groups = Class.extend( /** @lends openerp.base.ListView.Gr
}, },
open: function (point_insertion) { open: function (point_insertion) {
this.render().insertAfter(point_insertion); this.render().insertAfter(point_insertion);
this.$row.children().last()
.append('<button type="button" data-pager-action="previous">&lt;</button>')
.append('<span class="oe-pager-state"></span>')
.append('<button type="button" data-pager-action="next">&gt;</button>');
}, },
close: function () { close: function () {
this.$row.children().last().empty();
this.apoptosis(); this.apoptosis();
}, },
/** /**
@ -860,7 +860,7 @@ openerp.base.ListView.Groups = Class.extend( /** @lends openerp.base.ListView.Gr
self.bind_child_events(child); self.bind_child_events(child);
child.datagroup = group; child.datagroup = group;
var $row = $('<tr>'); var $row = child.$row = $('<tr>');
if (group.openable) { if (group.openable) {
$row.click(function (e) { $row.click(function (e) {
if (!$row.data('open')) { if (!$row.data('open')) {
@ -880,7 +880,7 @@ openerp.base.ListView.Groups = Class.extend( /** @lends openerp.base.ListView.Gr
} }
placeholder.appendChild($row[0]); placeholder.appendChild($row[0]);
var $group_column = $('<th>').appendTo($row); var $group_column = $('<th class="oe-group-name">').appendTo($row);
if (group.grouped_on) { if (group.grouped_on) {
// Don't fill this if group_by_no_leaf but no group_by // Don't fill this if group_by_no_leaf but no group_by
$group_column $group_column
@ -895,7 +895,9 @@ openerp.base.ListView.Groups = Class.extend( /** @lends openerp.base.ListView.Gr
// count column // count column
$('<td>').text(group.length).appendTo($row); $('<td>').text(group.length).appendTo($row);
self.pad($row); if (self.options.selectable) {
$row.append('<td>');
}
_(self.columns).chain() _(self.columns).chain()
.filter(function (column) {return !column.invisible;}) .filter(function (column) {return !column.invisible;})
.each(function (column) { .each(function (column) {
@ -916,6 +918,9 @@ openerp.base.ListView.Groups = Class.extend( /** @lends openerp.base.ListView.Gr
$row.append('<td>'); $row.append('<td>');
} }
}); });
if (self.options.deletable) {
$row.append('<td class="oe-group-pagination">');
}
}); });
return placeholder; return placeholder;
}, },
@ -957,6 +962,18 @@ openerp.base.ListView.Groups = Class.extend( /** @lends openerp.base.ListView.Gr
function (records) { function (records) {
if (!self.datagroup.openable) { if (!self.datagroup.openable) {
view.configure_pager(dataset); view.configure_pager(dataset);
} else {
var page = 1,
pages = Math.ceil(dataset.ids.length / limit);
self.$row
.find('.oe-pager-state')
.text(_.sprintf('%d/%d', page, pages))
.end()
.find('button[data-pager-action=previous]')
.attr('disabled', page === 1)
.end()
.find('button[data-pager-action=next]')
.attr('disabled', page === pages);
} }
var form_records = _(records).map( var form_records = _(records).map(