-
-
- {props.onSave &&
}
+
+
+
+
+
+
+ {!props.hideAddValue && (
+
+ )}
+
+ {props.onSave &&
}
+
+
-
+
-
-
+
);
});
diff --git a/src/components/shared/JsObject/Editor/models/JsRoot.ts b/src/components/shared/JsObject/Editor/models/JsRoot.ts
index bc5dde70e..8ffdd0fb5 100644
--- a/src/components/shared/JsObject/Editor/models/JsRoot.ts
+++ b/src/components/shared/JsObject/Editor/models/JsRoot.ts
@@ -1,14 +1,24 @@
-import { action, computed } from 'mobx';
+import { action, computed, observable } from 'mobx';
import iJs, { JsModelType } from './iJs';
import { JsTypes, JsRoot as JsRootType, toJsSchema, EditLevel } from '../../toJsSchema';
import iParentable from './iParentable';
import { toModel } from './toModel';
+export interface EditorConfig {
+ numberStep: number;
+}
+
class JsRoot extends iParentable
{
readonly type = 'root';
+ @observable accessor _pristineSize: number = 0;
+ readonly editorConfig: EditorConfig;
- constructor(editLevel?: EditLevel) {
+ constructor(editLevel?: EditLevel, config?: Partial) {
super({ type: 'root', value: [], editLevel: editLevel }, null as any);
+ this.editorConfig = {
+ numberStep: 0.01,
+ ...(config || {})
+ };
}
@action
@@ -21,6 +31,7 @@ class JsRoot extends iParentable {
}
const models = jsSchema.map((js) => toModel(js, this));
this.setValues(models);
+ this._pristineSize = this._value.length;
}
@action
@@ -35,7 +46,7 @@ class JsRoot extends iParentable {
@computed
get isDirty(): boolean {
- return this._value.some((value) => value.isDirty);
+ return this._value.length < this._pristineSize || this._value.some((value) => value.isDirty);
}
@computed