~neobis/openerp-web/7.0

« back to all changes in this revision

Viewing changes to addons/web/static/src/js/view_tree.js

  • Committer: Elias Hermoso Illera
  • Date: 2014-05-16 11:47:10 UTC
  • mfrom: (3745.2.354 staging)
  • Revision ID: elias@neobis.nl-20140516114710-22cjtfp6voqw410j
[MRG] - Merged from OCB branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
163
163
            var is_loaded = 0,
164
164
                $this = $(this),
165
165
                record_id = $this.data('id'),
 
166
                row_parent_id = $this.data('row-parent-id'),
166
167
                record = self.records[record_id],
167
168
                children_ids = record[self.children_field];
168
169
 
169
170
            _(children_ids).each(function(childid) {
170
 
                if (self.$el.find('#treerow_' + childid).length) {
171
 
                    if (self.$el.find('#treerow_' + childid).is(':hidden')) {
 
171
                if (self.$el.find('[id=treerow_' + childid + '][data-row-parent-id='+ record_id +']').length ) {
 
172
                    if (self.$el.find('[id=treerow_' + childid + '][data-row-parent-id='+ record_id +']').is(':hidden')) {
172
173
                        is_loaded = -1;
173
174
                    } else {
174
175
                        is_loaded++;
180
181
                    self.getdata(record_id, children_ids);
181
182
                }
182
183
            } else {
183
 
                self.showcontent(record_id, is_loaded < 0);
 
184
                self.showcontent($this, record_id, is_loaded < 0);
184
185
            }
185
186
        });
186
187
    },
192
193
            _(records).each(function (record) {
193
194
                self.records[record.id] = record;
194
195
            });
195
 
 
196
196
            var $curr_node = self.$el.find('#treerow_' + id);
197
197
            var children_rows = QWeb.render('TreeView.rows', {
198
198
                'records': records,
201
201
                'fields': self.fields,
202
202
                'level': $curr_node.data('level') || 0,
203
203
                'render': instance.web.format_value,
204
 
                'color_for': self.color_for
 
204
                'color_for': self.color_for,
 
205
                'row_parent_id': id
205
206
            });
206
 
 
207
207
            if ($curr_node.length) {
208
208
                $curr_node.addClass('oe_open');
209
209
                $curr_node.after(children_rows);
243
243
    },
244
244
 
245
245
    // show & hide the contents
246
 
    showcontent: function (record_id, show) {
247
 
        this.$el.find('#treerow_' + record_id)
248
 
                .toggleClass('oe_open', show);
249
 
 
 
246
    showcontent: function (curnode,record_id, show) {
 
247
        curnode.parent('tr').toggleClass('oe_open', show);
250
248
        _(this.records[record_id][this.children_field]).each(function (child_id) {
251
 
            var $child_row = this.$el.find('#treerow_' + child_id);
 
249
            var $child_row = this.$el.find('[id=treerow_' + child_id + '][data-row-parent-id='+ curnode.data('id') +']');
252
250
            if ($child_row.hasClass('oe_open')) {
253
 
                this.showcontent(child_id, false);
 
251
                $child_row.toggleClass('oe_open',show);
 
252
                this.showcontent($child_row, child_id, false);
254
253
            }
255
254
            $child_row.toggle(show);
256
255
        }, this);