[FIX] events handling from inner lists
Move handling of opening a group to its own method, to reduce nesting bzr revid: xmo@openerp.com-20110518130009-8mlgpg2f3i1hod4t
This commit is contained in:
parent
abd7b1898b
commit
277aaa7d57
|
@ -534,12 +534,12 @@ body.openerp {
|
||||||
-moz-border-radius-topright: 7px;
|
-moz-border-radius-topright: 7px;
|
||||||
border-top-right-radius: 7px;
|
border-top-right-radius: 7px;
|
||||||
}
|
}
|
||||||
.openerp .oe-listview table tbody tr:last-child th:first-child {
|
.openerp .oe-listview table tbody:last-child tr:last-child th:first-child {
|
||||||
-webkit-border-bottom-left-radius: 7px;
|
-webkit-border-bottom-left-radius: 7px;
|
||||||
-moz-border-radius-bottomleft: 7px;
|
-moz-border-radius-bottomleft: 7px;
|
||||||
border-bottom-left-radius: 7px;
|
border-bottom-left-radius: 7px;
|
||||||
}
|
}
|
||||||
.openerp .oe-listview table tbody tr:last-child td:last-child {
|
.openerp .oe-listview table tbody:last-child tr:last-child td:last-child {
|
||||||
-webkit-border-bottom-right-radius: 7px;
|
-webkit-border-bottom-right-radius: 7px;
|
||||||
-moz-border-radius-bottomright: 7px;
|
-moz-border-radius-bottomright: 7px;
|
||||||
border-bottom-right-radius: 7px;
|
border-bottom-right-radius: 7px;
|
||||||
|
|
|
@ -469,33 +469,38 @@ openerp.base.ListView.Groups = Class.extend( /** @lends openerp.base.ListView.Gr
|
||||||
make_fragment: function () {
|
make_fragment: function () {
|
||||||
return this.$element[0].ownerDocument.createDocumentFragment();
|
return this.$element[0].ownerDocument.createDocumentFragment();
|
||||||
},
|
},
|
||||||
|
open_group: function (e, group) {
|
||||||
|
var self = this,
|
||||||
|
$row = $(e.currentTarget);
|
||||||
|
group.list(function (groups) {
|
||||||
|
$row.parent()[0].insertBefore(
|
||||||
|
self.render_groups(groups),
|
||||||
|
$row[0].nextSibling);
|
||||||
|
}, function (dataset) {
|
||||||
|
// Now we need to split the current tbody in order to
|
||||||
|
// insert the list's
|
||||||
|
|
||||||
|
// Create new tbody after current one
|
||||||
|
var $current_body = $row.closest('tbody');
|
||||||
|
|
||||||
|
var $next_siblings = $row.nextAll();
|
||||||
|
if ($next_siblings.length) {
|
||||||
|
var $split = $('<tbody>').insertAfter($current_body);
|
||||||
|
// Move all following siblings of current row to split
|
||||||
|
$split.append($row.nextAll());
|
||||||
|
}
|
||||||
|
// Insert list rendering after current tbody
|
||||||
|
self.render_dataset(dataset).then(function (list) {
|
||||||
|
$current_body.after(list.$current);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
render_groups: function (datagroups) {
|
render_groups: function (datagroups) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var placeholder = this.make_fragment();
|
var placeholder = this.make_fragment();
|
||||||
_(datagroups).each(function (group) {
|
_(datagroups).each(function (group) {
|
||||||
var $row = $('<tr>').click(function () {
|
var $row = $('<tr>').click(function (e) {
|
||||||
group.list(function (groups) {
|
self.open_group(e, group);
|
||||||
$row.parent()[0].insertBefore(
|
|
||||||
self.render_groups(groups),
|
|
||||||
$row[0].nextSibling);
|
|
||||||
}, function (dataset) {
|
|
||||||
// Now we need to split the current tbody in order to
|
|
||||||
// insert the list's
|
|
||||||
|
|
||||||
// Create new tbody after current one
|
|
||||||
var $current_body = $row.closest('tbody');
|
|
||||||
|
|
||||||
var $next_siblings = $row.nextAll();
|
|
||||||
if ($next_siblings.length) {
|
|
||||||
var $split = $('<tbody>').insertAfter($current_body);
|
|
||||||
// Move all following siblings of current row to split
|
|
||||||
$split.append($row.nextAll());
|
|
||||||
}
|
|
||||||
// Insert list rendering after current tbody
|
|
||||||
self.render_dataset(dataset).then(function (list) {
|
|
||||||
$current_body.after(list.$current);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
placeholder.appendChild($row[0]);
|
placeholder.appendChild($row[0]);
|
||||||
self.pad($row);
|
self.pad($row);
|
||||||
|
@ -516,13 +521,24 @@ openerp.base.ListView.Groups = Class.extend( /** @lends openerp.base.ListView.Gr
|
||||||
return placeholder;
|
return placeholder;
|
||||||
},
|
},
|
||||||
render_dataset: function (dataset) {
|
render_dataset: function (dataset) {
|
||||||
var self = this;
|
var self = this,
|
||||||
var rows = [];
|
$self = $(self),
|
||||||
var list = new openerp.base.ListView.List({
|
rows = [],
|
||||||
|
list = new openerp.base.ListView.List({
|
||||||
options: this.options,
|
options: this.options,
|
||||||
columns: this.columns,
|
columns: this.columns,
|
||||||
rows: rows
|
rows: rows
|
||||||
});
|
});
|
||||||
|
$(list).bind('selected deleted action row_link', function (e) {
|
||||||
|
// additional positional parameters are provided to trigger as an
|
||||||
|
// Array, following the event type or event object, but are
|
||||||
|
// provided to the .bind event handler as *args.
|
||||||
|
// Convert our *args back into an Array in order to trigger them
|
||||||
|
// on the group itself, so it can ultimately be forwarded wherever
|
||||||
|
// it's supposed to go.
|
||||||
|
var args = Array.prototype.slice.call(arguments, 1);
|
||||||
|
$self.trigger.call($self, e, args);
|
||||||
|
});
|
||||||
|
|
||||||
var d = new $.Deferred();
|
var d = new $.Deferred();
|
||||||
this.view.rpc('/base/listview/fill', {
|
this.view.rpc('/base/listview/fill', {
|
||||||
|
|
Loading…
Reference in New Issue