[IMP]Add parent-id attribute to get childrens of that parentid and show selected parent's childrens rather than else.

lp bug: https://launchpad.net/bugs/1183156 fixed

bzr revid: bth@tinyerp.com-20130705121036-0pn454ts3z9wkwxr
This commit is contained in:
bth-openerp
2013-07-05 17:40:36 +05:30
parent 7e4776f2f2
commit 19ae69201c
2 changed files with 13 additions and 12 deletions
+11 -11
View File
@@ -163,12 +163,13 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
var is_loaded = 0,
$this = $(this),
record_id = $this.data('id'),
parent_id = $this.data('parent-id'),
record = self.records[record_id],
children_ids = record[self.children_field];
_(children_ids).each(function(childid) {
if (self.$el.find('#treerow_' + childid).length) {
if (self.$el.find('#treerow_' + childid).is(':hidden')) {
if (self.$el.find('[id=treerow_' + childid + '][data-parent-id='+ record_id +']').length ) {
if (self.$el.find('[id=treerow_' + childid + '][data-parent-id='+ record_id +']').is(':hidden')) {
is_loaded = -1;
} else {
is_loaded++;
@@ -180,7 +181,7 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
self.getdata(record_id, children_ids);
}
} else {
self.showcontent(record_id, is_loaded < 0);
self.showcontent($this, record_id, is_loaded < 0);
}
});
},
@@ -201,9 +202,9 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
'fields': self.fields,
'level': $curr_node.data('level') || 0,
'render': instance.web.format_value,
'color_for': self.color_for
'color_for': self.color_for,
'parent_id': id
});
if ($curr_node.length) {
$curr_node.addClass('oe_open');
$curr_node.after(children_rows);
@@ -243,14 +244,13 @@ instance.web.TreeView = instance.web.View.extend(/** @lends instance.web.TreeVie
},
// show & hide the contents
showcontent: function (record_id, show) {
this.$el.find('#treerow_' + record_id)
.toggleClass('oe_open', show);
showcontent: function (curnode,record_id, show) {
curnode.parent('tr').toggleClass('oe_open', show);
_(this.records[record_id][this.children_field]).each(function (child_id) {
var $child_row = this.$el.find('#treerow_' + child_id);
var $child_row = this.$el.find('[id=treerow_' + child_id + '][data-parent-id='+ curnode.data('id') +']');
if ($child_row.hasClass('oe_open')) {
this.showcontent(child_id, false);
$child_row.toggleClass('oe_open',show);
this.showcontent($child_row, child_id, false);
}
$child_row.toggle(show);
}, this);
+2 -1
View File
@@ -684,7 +684,8 @@
<tr t-name="TreeView.rows"
t-foreach="records" t-as="record"
t-att-id="'treerow_' + record.id"
t-att-data-id="record.id" t-att-data-level="level + 1">
t-att-data-id="record.id" t-att-data-level="level + 1"
t-att-data-parent-id="parent_id">
<t t-set="children" t-value="record[children_field]"/>
<t t-set="class" t-value="children and children.length ? 'treeview-tr' : 'treeview-td'"/>
<t t-set="rank" t-value="'oe-treeview-first'"/>