diff options
Diffstat (limited to 'addons/web/static/src/js/view_list.js')
| -rw-r--r-- | addons/web/static/src/js/view_list.js | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/addons/web/static/src/js/view_list.js b/addons/web/static/src/js/view_list.js index 4f58b002328..991f4db6852 100644 --- a/addons/web/static/src/js/view_list.js +++ b/addons/web/static/src/js/view_list.js @@ -171,11 +171,13 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi current_date: new Date().toString('yyyy-MM-dd') // TODO: time, datetime, relativedelta }); - + var i; + var pair; + var expression; if (this.fonts) { - for(var i=0, len=this.fonts.length; i<len; ++i) { - var pair = this.fonts[i], - font = pair[0], + for(i=0, len=this.fonts.length; i<len; ++i) { + pair = this.fonts[i]; + var font = pair[0]; expression = pair[1]; if (py.evaluate(expression, context).toJSON()) { switch(font) { @@ -194,10 +196,10 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi } if (!this.colors) { return style; } - for(var i=0, len=this.colors.length; i<len; ++i) { - var pair = this.colors[i], - color = pair[0], - expression = pair[1]; + for(i=0, len=this.colors.length; i<len; ++i) { + pair = this.colors[i]; + var color = pair[0]; + expression = pair[1]; if (py.evaluate(expression, context).toJSON()) { return style += 'color: ' + color + ';'; } @@ -394,7 +396,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi var total = dataset.size(); var limit = this.limit() || total; - if (total == 0) + if (total === 0) this.$pager.hide(); else this.$pager.css("display", ""); @@ -454,7 +456,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi * @param {String} [view="page"] the view type to switch to */ select_record:function (index, view) { - view = view || index == null ? 'form' : 'form'; + view = view || index === null || index === undefined ? 'form' : 'form'; this.dataset.index = index; _.delay(_.bind(function () { this.do_switch_view(view); @@ -503,7 +505,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi var reloaded = $.Deferred(); this.$el.find('.oe_list_content').append( this.groups.render(function () { - if (self.dataset.index == null && self.records.length || + if ((self.dataset.index === null || self.dataset.index === undefined) && self.records.length || self.dataset.index >= self.records.length) { self.dataset.index = 0; } @@ -1517,7 +1519,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we // if drag to 1st row (to = 0), start sequencing from 0 // (exclusive lower bound) seq = to ? list.records.at(to - 1).get(seqname) : 0; - while (++seq, record = list.records.at(index++)) { + while (++seq, (record = list.records.at(index++))) { // write are independent from one another, so we can just // launch them all at the same time and we don't really // give a fig about when they're done @@ -1825,7 +1827,7 @@ var Collection = instance.web.Class.extend(/** @lends Collection# */{ var instance_ = (records[i] instanceof Record) ? records[i] : new Record(records[i]); instance_.bind(null, this._onRecordEvent); this._byId[instance_.get('id')] = instance_; - if (options.at == undefined) { + if (options.at === undefined || options.at === null) { this.records.push(instance_); if (!options.silent) { this.trigger('add', this, instance_, this.records.length-1); @@ -1867,7 +1869,8 @@ var Collection = instance.web.Class.extend(/** @lends Collection# */{ if (!_(this._proxies).isEmpty()) { var record = null; _(this._proxies).detect(function (proxy) { - return record = proxy.get(id); + record = proxy.get(id); + return record; }); return record; } @@ -1881,10 +1884,11 @@ var Collection = instance.web.Class.extend(/** @lends Collection# */{ * @returns {Collection} */ proxy: function (section) { - return this._proxies[section] = new Collection(null, { + this._proxies[section] = new Collection(null, { parent: this, key: section }).bind(null, this._onRecordEvent); + return this._proxies[section]; }, /** * @param {Array} [records] |
