Reset changes method
This commit is contained in:
parent
27af51a0d9
commit
e72db08ad0
|
@ -394,15 +394,20 @@ AbstractClass.prototype.propertyChanged = function (attr) {
|
||||||
AbstractClass.prototype.reload = function (cb) {
|
AbstractClass.prototype.reload = function (cb) {
|
||||||
var obj = this.constructor.cache[this.id];
|
var obj = this.constructor.cache[this.id];
|
||||||
if (obj) {
|
if (obj) {
|
||||||
Object.keys(obj).forEach(function (k) {
|
obj.reset();
|
||||||
if (obj.propertyChanged(k)) {
|
|
||||||
obj[k] = obj[k + '_was'];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
this.constructor.find(this.id, cb);
|
this.constructor.find(this.id, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
AbstractClass.prototype.reset = function () {
|
||||||
|
var obj = this;
|
||||||
|
Object.keys(obj).forEach(function (k) {
|
||||||
|
if (obj.propertyChanged(k)) {
|
||||||
|
obj[k] = obj[k + '_was'];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// relations
|
// relations
|
||||||
AbstractClass.hasMany = function (anotherClass, params) {
|
AbstractClass.hasMany = function (anotherClass, params) {
|
||||||
var methodName = params.as; // or pluralize(anotherClass.modelName)
|
var methodName = params.as; // or pluralize(anotherClass.modelName)
|
||||||
|
|
Loading…
Reference in New Issue