Does not allow functions in loops anymore

bzr revid: nicolas.vanhoren@openerp.com-20130725113041-n6u9gyo1vbv1blw5
This commit is contained in:
niv-openerp 2013-07-25 13:30:41 +02:00
parent 17ba69eb52
commit ec9ae7ec81
3 changed files with 12 additions and 12 deletions

View File

@ -7,7 +7,6 @@ module.exports = function(grunt) {
sub: true, //[] instead of .
evil: true, //eval
laxbreak: true, //unsafe line breaks
loopfunc: true, // functions in loops
},
}
});

View File

@ -96,7 +96,7 @@ openerp.web.corelib = function(instance) {
initializing = false;
// Copy the properties over onto the new prototype
for (var name in prop) {
_.each(prop, function(val, name) {
// Check if we're overwriting an existing function
prototype[name] = typeof prop[name] == "function" &&
fnTest.test(prop[name]) ?
@ -117,7 +117,7 @@ openerp.web.corelib = function(instance) {
};
})(name, prop[name]) :
prop[name];
}
});
// The dummy class constructor
function Class() {
@ -132,7 +132,7 @@ openerp.web.corelib = function(instance) {
return this;
}
Class.include = function (properties) {
for (var name in properties) {
_.each(properties, function(val, name) {
if (typeof properties[name] !== 'function'
|| !fnTest.test(properties[name])) {
prototype[name] = properties[name];
@ -158,7 +158,7 @@ openerp.web.corelib = function(instance) {
};
})(name, properties[name]);
}
}
});
};
// Populate our constructed prototype object

View File

@ -1519,6 +1519,13 @@ 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;
var fct = function (dataset, id, seq) {
$.async_when().done(function () {
var attrs = {};
attrs[seqname] = seq;
dataset.write(id, attrs);
});
};
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
@ -1526,13 +1533,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
// FIXME: breaks on o2ms (e.g. Accounting > Financial
// Accounting > Taxes > Taxes, child tax accounts)
// when synchronous (without setTimeout)
(function (dataset, id, seq) {
$.async_when().done(function () {
var attrs = {};
attrs[seqname] = seq;
dataset.write(id, attrs);
});
}(dataset, record.get('id'), seq));
fct(dataset, record.get('id'), seq);
record.set(seqname, seq);
}
}