Comparing version 1.0.0-pre-64 to 1.0.0-pre-65
@@ -99,6 +99,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
set value(value) { | ||
var _a; | ||
const oldValue = this.model; | ||
this.updateArray(value); | ||
if (this.parent && this.field) { | ||
this.parent.model[this.field] = this.model; | ||
const parent = this.parent; | ||
if ((parent === null || parent === void 0 ? void 0 : parent.setModelValue) && this.field) { | ||
parent.setModelValue(this.field, this.model); | ||
} | ||
let dirty = (value === null || value === void 0 ? void 0 : value.length) !== (oldValue === null || oldValue === void 0 ? void 0 : oldValue.length); | ||
if (!dirty) { | ||
for (let i = 0; i < value.length; i++) { | ||
dirty = dirty || value[i] !== oldValue[i]; | ||
} | ||
} | ||
this.isDirty = dirty; | ||
(_a = this.parent) === null || _a === void 0 ? void 0 : _a.refreshDirty(); | ||
} | ||
@@ -105,0 +116,0 @@ get childValidators() { |
@@ -12,4 +12,6 @@ import { ChildValidators, DryvValidationObject, DryvValidationResult, DryvValidationSession, Refs } from './'; | ||
}; | ||
private _ignoreModelChanges; | ||
constructor(model: TModel, session: DryvValidationSession<TModel>, parent: DryvComplexValidator | undefined, options: DryvOptions, field?: keyof TModel); | ||
private updateModel; | ||
setModelValue(field: keyof TModel, value: any): void; | ||
get value(): TModel; | ||
@@ -16,0 +18,0 @@ set value(value: TModel); |
@@ -19,2 +19,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
this.fields = {}; | ||
this._ignoreModelChanges = false; | ||
this.editingProxy = dryvEditingObject(this); | ||
@@ -35,2 +36,5 @@ this.validationProxy = dryvValidationObject(this); | ||
const eventId = register((event) => { | ||
if (this._ignoreModelChanges) { | ||
return; | ||
} | ||
let validator = this.fields[event.field]; | ||
@@ -59,2 +63,12 @@ if (this.isReverting || validator === null) { | ||
} | ||
setModelValue(field, value) { | ||
this._ignoreModelChanges = true; | ||
try { | ||
this.model[field] = value; | ||
this.refreshDirty(); | ||
} | ||
finally { | ||
this._ignoreModelChanges = false; | ||
} | ||
} | ||
get value() { | ||
@@ -65,4 +79,5 @@ return this.model; | ||
this.updateModel(value); | ||
if (this.parent && this.field) { | ||
this.parent.model[this.field] = this.model; | ||
const parent = this.parent; | ||
if ((parent === null || parent === void 0 ? void 0 : parent.setModelValue) && this.field) { | ||
parent.setModelValue(this.field, this.model); | ||
} | ||
@@ -69,0 +84,0 @@ } |
{ | ||
"name": "dryvjs", | ||
"version": "1.0.0-pre-64", | ||
"version": "1.0.0-pre-65", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
124288
1828