dbm 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/commands/CommandBaseObject.js +25 -0
  2. package/commands/SetProperty.js +18 -0
  3. package/commands/index.js +20 -8
  4. package/core/source/FromObject.js +8 -0
  5. package/core/source/index.js +9 -0
  6. package/flow/controllers/edit/EditMultipleValues.js +57 -0
  7. package/flow/controllers/edit/EditValue.js +52 -0
  8. package/flow/controllers/edit/index.js +2 -0
  9. package/flow/controllers/index.js +2 -0
  10. package/flow/controllers/select/SingleSelection.js +65 -0
  11. package/flow/controllers/select/index.js +1 -0
  12. package/flow/index.js +1 -0
  13. package/flow/updatefunctions/basic/Length.js +20 -0
  14. package/flow/updatefunctions/basic/PropertyOf.js +21 -0
  15. package/flow/updatefunctions/basic/index.js +17 -0
  16. package/flow/updatefunctions/logic/Condition.js +12 -1
  17. package/flow/updatefunctions/logic/Invert.js +18 -0
  18. package/flow/updatefunctions/logic/index.js +8 -0
  19. package/graphapi/webclient/GraphApi.js +4 -0
  20. package/graphapi/webclient/WebSocketConnection.js +10 -0
  21. package/graphapi/webclient/admin/EditorGroup.js +59 -0
  22. package/graphapi/webclient/admin/ItemEditor.js +74 -0
  23. package/graphapi/webclient/admin/ItemSaveData.js +63 -0
  24. package/graphapi/webclient/admin/SaveData.js +60 -0
  25. package/graphapi/webclient/admin/SaveFunctions.js +7 -0
  26. package/graphapi/webclient/admin/ValueEditor.js +61 -0
  27. package/graphapi/webclient/admin/index.js +8 -0
  28. package/graphapi/webclient/decode/index.js +16 -3
  29. package/graphapi/webclient/index.js +17 -1
  30. package/package.json +1 -1
  31. package/react/admin/EditPage.js +101 -51
  32. package/react/admin/SelectImageFromLibrary.js +56 -0
  33. package/react/admin/editor/Editor.js +2 -0
  34. package/react/admin/editor/fields/ImageField.js +143 -5
  35. package/react/admin/index.js +1 -0
  36. package/react/area/OpenCloseExpandableArea.js +11 -4
  37. package/react/form/FileDropArea.js +92 -0
  38. package/react/form/index.js +2 -1
  39. package/react/image/LocalImage.js +42 -0
  40. package/react/image/index.js +2 -1
  41. package/react/index.js +1 -1
  42. package/react/interaction/CommandButton.js +97 -0
  43. package/react/interaction/index.js +3 -0
  44. package/react/modules/index.js +11 -1
  45. package/react/text/index.js +2 -2
  46. package/site/BrowserUpdater.js +46 -0
  47. package/site/SiteDataLoader.js +9 -13
  48. package/site/SiteNavigation.js +0 -15
  49. package/site/index.js +20 -1
  50. package/utils/ArrayFunctions.js +71 -0
  51. package/utils/UrlFunctions.js +15 -11
@@ -8,4 +8,29 @@ export default class CommandBaseObject extends Dbm.core.BaseObject {
8
8
  perform(aFromObject, aData) {
9
9
  //MENOTE: should be overridden
10
10
  }
11
+
12
+ _resolveSource(aValueOrSource) {
13
+ if(aValueOrSource) {
14
+ if(aValueOrSource.isFlowProperty) {
15
+ return aValueOrSource.value;
16
+ }
17
+ else if(aValueOrSource.isSource) {
18
+ return aValueOrSource.getSource(aFromObject, aData);
19
+ }
20
+ }
21
+
22
+ return aValueOrSource;
23
+ }
24
+
25
+ _resolveSourceWithoutFlow(aValueOrSource) {
26
+ if(aValueOrSource && aValueOrSource.isSource) {
27
+ return aValueOrSource.getSource(aFromObject, aData);
28
+ }
29
+
30
+ return aValueOrSource;
31
+ }
32
+
33
+ getInput(aName) {
34
+ return this._resolveSource(this.item[aName]);
35
+ }
11
36
  }
@@ -0,0 +1,18 @@
1
+ import Dbm from "../index.js";
2
+ import CommandBaseObject from "./CommandBaseObject.js"
3
+
4
+ export default class SetProperty extends CommandBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.item.setValue("property", null);
9
+ this.item.setValue("value", null);
10
+ }
11
+
12
+ perform(aFromObject, aData) {
13
+
14
+ let value = this.getInput("value");
15
+
16
+ this._resolveSourceWithoutFlow(this.item.property).value = value;
17
+ }
18
+ }
package/commands/index.js CHANGED
@@ -2,10 +2,11 @@ import Dbm from "../index.js";
2
2
 
3
3
  export {default as CommandBaseObject} from "./CommandBaseObject.js";
4
4
  export {default as CallFunction} from "./CallFunction.js";
5
+ export {default as SetProperty} from "./SetProperty.js";
5
6
  export {default as ResolvePromise} from "./ResolvePromise.js";
6
7
 
7
8
 
8
- let callScopedFunction = function(aScopeObject, aFunction, aArguments = []) {
9
+ export const callScopedFunction = function(aScopeObject, aFunction, aArguments = []) {
9
10
  let newCommand = new Dbm.commands.CallFunction();
10
11
  newCommand.item.setValue("scopeObject", aScopeObject);
11
12
  newCommand.item.setValue("callFunction", aFunction);
@@ -14,9 +15,7 @@ let callScopedFunction = function(aScopeObject, aFunction, aArguments = []) {
14
15
  return newCommand;
15
16
  }
16
17
 
17
- export {callScopedFunction};
18
-
19
- let callFunction = function(aFunction, aArguments = []) {
18
+ export const callFunction = function(aFunction, aArguments = []) {
20
19
  let newCommand = new Dbm.commands.CallFunction();
21
20
  newCommand.item.setValue("callFunction", aFunction);
22
21
  newCommand.item.setValue("callArguments", aArguments);
@@ -24,13 +23,26 @@ let callFunction = function(aFunction, aArguments = []) {
24
23
  return newCommand;
25
24
  }
26
25
 
27
- export {callFunction};
28
-
29
- let resolvePromise = function(aValue = null) {
26
+ export const resolvePromise = function(aValue = null) {
30
27
  let newCommand = new Dbm.commands.ResolvePromise();
31
28
  newCommand.item.setValue("value", aValue);
32
29
 
33
30
  return newCommand;
34
31
  }
35
32
 
36
- export {resolvePromise};
33
+ export const setProperty = function(aProperty, aValue) {
34
+ let newCommand = new Dbm.commands.SetProperty();
35
+ newCommand.item.setValue("property", aProperty);
36
+ newCommand.item.setValue("value", aValue);
37
+
38
+ return newCommand;
39
+ }
40
+
41
+ export const performCommands = function(aCommands, aFromObject = null, aEventData = null) {
42
+ let currentArray = aCommands;
43
+ let currentArrayLength = currentArray.length;
44
+ for(let i = 0; i < currentArrayLength; i++) {
45
+ let currentCommand = currentArray[i];
46
+ currentCommand.perform(aFromObject, aEventData);
47
+ }
48
+ }
@@ -0,0 +1,8 @@
1
+ import Dbm from "../../index.js";
2
+
3
+ export default class FromObject extends Dbm.core.source.SourceBaseObject {
4
+
5
+ getBaseObject(aFromObject, aEventData) {
6
+ return aFromObject;
7
+ }
8
+ }
@@ -2,6 +2,7 @@ import Dbm from "../../index.js";
2
2
 
3
3
  export {default as SourceBaseObject} from "./SourceBaseObject.js";
4
4
  export {default as EventSource} from "./EventSource.js";
5
+ export {default as FromObject} from "./FromObject.js";
5
6
  export {default as StaticSource} from "./StaticSource.js";
6
7
 
7
8
  export const event = function(aPath = null) {
@@ -12,6 +13,14 @@ export const event = function(aPath = null) {
12
13
  return newSource;
13
14
  }
14
15
 
16
+ export const fromObject = function(aPath = null) {
17
+ let newSource = new Dbm.core.source.FromObject();
18
+
19
+ newSource.item.properties.path.setOrConnect(aPath);
20
+
21
+ return newSource;
22
+ }
23
+
15
24
  export const staticObject = function(aObject, aPath = null) {
16
25
  let newSource = new Dbm.core.source.StaticSource();
17
26
 
@@ -0,0 +1,57 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class EditMultipleValues extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+
7
+ this.item.requireProperty("editValues", {});
8
+
9
+ let anyChange = Dbm.flow.updatefunctions.logic.any();
10
+
11
+ this.item.requireProperty("anyChange", anyChange);
12
+ this.item.requireProperty("changed", false).connectInput(anyChange.output.properties.value);
13
+
14
+ }
15
+
16
+ get editors() {
17
+ return this.item.editValues;
18
+ }
19
+
20
+ _createEditValue(aName) {
21
+
22
+ let editValue = new Dbm.flow.controllers.edit.EditValue();
23
+
24
+ this.addEditor(aName, editValue);
25
+
26
+ return editValue;
27
+ }
28
+
29
+ addEditor(aName, aEditor) {
30
+ let editValues = {...this.item.editValues};
31
+ editValues[aName] = aEditor;
32
+
33
+ this.item.anyChange.addCheck(aEditor.item.properties.changed);
34
+
35
+ this.item.editValues = editValues;
36
+
37
+ return this;
38
+ }
39
+
40
+ getEditorIfExists(aName) {
41
+ let editValues = this.item.editValues;
42
+ if(editValues[aName]) {
43
+ return editValues[aName];
44
+ }
45
+
46
+ return null;
47
+ }
48
+
49
+ getEditor(aName) {
50
+ let editValue = this.getEditorIfExists(aName);
51
+ if(!editValue) {
52
+ editValue = this._createEditValue(aName);
53
+ }
54
+
55
+ return editValue;
56
+ }
57
+ }
@@ -0,0 +1,52 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class EditValue extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+
7
+ this.item.requireProperty("storedValue", null);
8
+ this.item.requireProperty("value", null);
9
+
10
+ let condition = Dbm.flow.updatefunctions.logic.condition(this.item.properties.storedValue, "!==", this.item.properties.value);
11
+
12
+ this.item.requireProperty("changed", false).connectInput(condition.output.properties.result);
13
+ this._setStoredValueBound = this._setStoredValue.bind(this);
14
+ }
15
+
16
+ get value() {
17
+ return this.item.properties.value;
18
+ }
19
+
20
+ getValue() {
21
+ return this.item.value;
22
+ }
23
+
24
+ setInitialValue(aValue) {
25
+ this.item.storedValue = aValue;
26
+ this.item.value = aValue;
27
+
28
+ return this;
29
+ }
30
+
31
+ _setStoredValue(aValue) {
32
+ this.item.storedValue = aValue;
33
+
34
+ return this;
35
+ }
36
+
37
+ store() {
38
+ this.item.properties.storedValue.getMostUpstreamProperty().storedValue = this.item.value;
39
+
40
+ return this;
41
+ }
42
+
43
+ undo() {
44
+ this.item.value = this.item.storedValue;
45
+
46
+ return this;
47
+ }
48
+
49
+ getStoreCommand() {
50
+ return Dbm.commands.callFunction(this._setStoredValueBound, [this.item.value]);
51
+ }
52
+ }
@@ -0,0 +1,2 @@
1
+ export {default as EditValue} from "./EditValue.js";
2
+ export {default as EditMultipleValues} from "./EditMultipleValues.js";
@@ -0,0 +1,2 @@
1
+ export * as select from "./select/index.js";
2
+ export * as edit from "./edit/index.js";
@@ -0,0 +1,65 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class SingleSelection extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+
7
+ let valueUpdatedCommand = Dbm.commands.callFunction(this._valueUpdated.bind(this));
8
+
9
+ this._selectionChangedBound = this._selectionChanged.bind(this);
10
+
11
+ Dbm.flow.addUpdateCommand(this.item.requireProperty("value", null), valueUpdatedCommand);
12
+ Dbm.flow.addUpdateCommand(this.item.requireProperty("selections", []), valueUpdatedCommand);
13
+
14
+ this.item.requireProperty("matched", false);
15
+ }
16
+
17
+ addSelectionValue(aValue) {
18
+ let selections = [].concat(this.item.selections);
19
+
20
+ let property = new Dbm.flow.FlowProperty();
21
+ property.setValue(false);
22
+ Dbm.flow.addUpdateCommand(property, Dbm.commands.callFunction(this._selectionChangedBound, [property, aValue]));
23
+
24
+ selections.push({"value": aValue, "property": property});
25
+ this.item.selections = selections;
26
+
27
+ return property;
28
+ }
29
+
30
+ _selectionChanged(aSelected, aValue) {
31
+ //console.log("_selectionChanged");
32
+ //console.log(aSelected, aValue);
33
+
34
+ if(aSelected) {
35
+ this.item.properties.value.getMostUpstreamProperty().setValue(aValue);
36
+ }
37
+ else {
38
+ if(this.item.properties.value === aValue) {
39
+ this.item.properties.value.getMostUpstreamProperty().setValue(null);
40
+ }
41
+ }
42
+ }
43
+
44
+ _valueUpdated() {
45
+ //console.log("_valueUpdated");
46
+ let value = this.item.value;
47
+
48
+ let matched = false;
49
+
50
+ let currentArray = this.item.selections;
51
+ let currentArrayLength = currentArray.length;
52
+ for(let i = 0; i < currentArrayLength; i++) {
53
+ let currentSelection = currentArray[i];
54
+ if(currentSelection.value === value) {
55
+ currentSelection.property.value = true;
56
+ matched = true;
57
+ }
58
+ else {
59
+ currentSelection.property.value = false;
60
+ }
61
+ }
62
+
63
+ this.item.matched = matched;
64
+ }
65
+ }
@@ -0,0 +1 @@
1
+ export {default as SingleSelection} from "./SingleSelection.js";
package/flow/index.js CHANGED
@@ -9,6 +9,7 @@ export {default as DirtyCommands} from "./DirtyCommands.js";
9
9
  export {default as FlowPropertyWithExternalInput} from "./FlowPropertyWithExternalInput.js";
10
10
 
11
11
  export * as updatefunctions from "./updatefunctions/index.js";
12
+ export * as controllers from "./controllers/index.js";
12
13
 
13
14
  export let addUpdateCommand = function(aProperty, aCommand) {
14
15
  let updateFunction = new Dbm.flow.updatefunctions.basic.RunCommand();
@@ -0,0 +1,20 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class Length extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("value", "");
9
+
10
+ this.output.register("length", 0);
11
+ }
12
+
13
+ _update() {
14
+ //console.log("_update");
15
+
16
+ let value = this.input.value;
17
+
18
+ this.output.length = value ? value.length : 0;
19
+ }
20
+ }
@@ -0,0 +1,21 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class Length extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("value", "");
9
+ this.input.register("propertyName", "");
10
+
11
+ this.output.register("value", null);
12
+ }
13
+
14
+ _update() {
15
+ //console.log("_update");
16
+
17
+ let value = this.input.value;
18
+
19
+ this.output.value = Dbm.objectPath(value, this.input.propertyName);
20
+ }
21
+ }
@@ -2,6 +2,8 @@ import Dbm from "../../../index.js";
2
2
 
3
3
  export {default as RunCommand} from "./RunCommand.js";
4
4
  export {default as CombineString} from "./CombineString.js";
5
+ export {default as Length} from "./Length.js";
6
+ export {default as PropertyOf} from "./PropertyOf.js";
5
7
 
6
8
  export const runCommand = function(aValue, aCommand) {
7
9
  let updateFunction = new Dbm.flow.updatefunctions.basic.RunCommand();
@@ -15,4 +17,19 @@ export const transformValue = function(aValue, aFunction) {
15
17
  let command = Dbm.commands.callFunction(aFunction, [Dbm.core.source.event()]);
16
18
 
17
19
  return Dbm.flow.updatefunctions.basic.runCommand(aValue, command);
20
+ }
21
+
22
+ export const length = function(aValue) {
23
+ let updateFunction = new Dbm.flow.updatefunctions.basic.Length();
24
+ updateFunction.input.properties.value.setOrConnect(aValue);
25
+
26
+ return updateFunction;
27
+ }
28
+
29
+ export const propertyOf = function(aValue, aPropertyName) {
30
+ let updateFunction = new Dbm.flow.updatefunctions.basic.PropertyOf();
31
+ updateFunction.input.properties.value.setOrConnect(aValue);
32
+ updateFunction.input.properties.propertyName.setOrConnect(aPropertyName);
33
+
34
+ return updateFunction;
18
35
  }
@@ -15,6 +15,17 @@ export default class Condition extends Dbm.flow.FlowUpdateFunction {
15
15
  _update() {
16
16
  //console.log("_update");
17
17
 
18
- this.output.result = this.input.operation.call(this, this.input.input1, this.input.input2);
18
+ let operation = this.input.operation;
19
+ if(typeof(operation) === "string") {
20
+ if(operation === "!==") {
21
+ operation = function(aA, aB) {return aA !== aB;}
22
+ }
23
+ else {
24
+ //METODO: add more operations
25
+ operation = function(aA, aB) {return aA === aB;}
26
+ }
27
+ }
28
+
29
+ this.output.result = operation.call(this, this.input.input1, this.input.input2);
19
30
  }
20
31
  }
@@ -0,0 +1,18 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class Invert extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("input", false);
9
+
10
+ this.output.register("result", true);
11
+ }
12
+
13
+ _update() {
14
+ //console.log("_update");
15
+
16
+ this.output.result = !this.input.input;
17
+ }
18
+ }
@@ -10,6 +10,7 @@ export {default as All} from "./All.js";
10
10
  export {default as Any} from "./Any.js";
11
11
  export {default as AllAtValue} from "./AllAtValue.js";
12
12
  export {default as WhenMatched} from "./WhenMatched.js";
13
+ export {default as Invert} from "./Invert.js";
13
14
 
14
15
  export let subtract = function(aInput1 = 0, aInput2 = 0) {
15
16
  let updateFunction = new Dbm.flow.updatefunctions.logic.Subtraction();
@@ -19,6 +20,13 @@ export let subtract = function(aInput1 = 0, aInput2 = 0) {
19
20
  return updateFunction;
20
21
  }
21
22
 
23
+ export let invert = function(aValue = false) {
24
+ let updateFunction = new Dbm.flow.updatefunctions.logic.Invert();
25
+ updateFunction.input.properties.input.setValue(aValue);
26
+
27
+ return updateFunction;
28
+ }
29
+
22
30
  export let invertP = function(aP = 0) {
23
31
  let updateFunction = new Dbm.flow.updatefunctions.logic.Subtraction();
24
32
  updateFunction.input.properties.input1.setValue(1);
@@ -32,6 +32,10 @@ export default class GraphApi extends Dbm.core.BaseObject {
32
32
  return this._websocketConnection.requestData(aFunctionName, aData);
33
33
  }
34
34
 
35
+ performAction(aFunctionName, aData) {
36
+ return this._websocketConnection.performAction(aFunctionName, aData);
37
+ }
38
+
35
39
  createItem(aTypes, aVisibility = "draft", aChanges = [], aEncode = []) {
36
40
  return this._websocketConnection.createItem(aTypes, aVisibility, aChanges, aEncode);
37
41
  }
@@ -87,6 +87,15 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
87
87
  return item;
88
88
  }
89
89
 
90
+ performAction(aFunctionName, aData) {
91
+ //console.log("performAction");
92
+ let item = this._getRequestItem();
93
+ item.setValue("requestData", {"type": "action", "functionName": aFunctionName, "data": aData, "requestId": item.id});
94
+ this._runRequest(item);
95
+
96
+ return item;
97
+ }
98
+
90
99
  createItem(aTypes, aVisibility = "draft", aChanges = [], aEncode = []) {
91
100
  let item = this._getRequestItem();
92
101
  item.setValue("requestData", {"type": "admin/createObject", "types": aTypes, "visibility": aVisibility, "changes": aChanges, "encode": aEncode, "requestId": item.id});
@@ -212,6 +221,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
212
221
  }
213
222
  break;
214
223
  case "data/response":
224
+ case "action/response":
215
225
  {
216
226
  let item = repository.getItem(data["requestId"]);
217
227
  item.setValue("data", data["data"]);
@@ -0,0 +1,59 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class EditorGroup extends Dbm.core.BaseObject {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.item.requireProperty("status", "none");
9
+ this.item.requireProperty("editors", []);
10
+
11
+ let anyChange = Dbm.flow.updatefunctions.logic.any();
12
+
13
+ this.item.requireProperty("anyChange", anyChange);
14
+ this.item.requireProperty("changed", false).connectInput(anyChange.output.properties.value);
15
+ }
16
+
17
+ getItemEditor(aId) {
18
+ let itemEditor = this.item["editor_" + aId];
19
+ if(!itemEditor) {
20
+ itemEditor = new Dbm.graphapi.webclient.admin.ItemEditor();
21
+ itemEditor.item.setValue("editedItem", Dbm.getInstance().repository.getItem(aId));
22
+ this.item.setValue("editor_" + aId, itemEditor);
23
+ this.item.editors = [].concat(this.item.editors, itemEditor);
24
+ this.item.anyChange.addCheck(itemEditor.item.properties.changed);
25
+ }
26
+
27
+ return itemEditor;
28
+ }
29
+
30
+ addCommandsToSaveData(aSaveData) {
31
+
32
+ aSaveData.addStartCommand(Dbm.commands.setProperty(this.item.properties.status, "loading"));
33
+
34
+ let currentArray = this.item.editors;
35
+ let currentArrayLength = currentArray.length;
36
+ for(let i = 0; i < currentArrayLength; i++) {
37
+ let currentEditor = currentArray[i];
38
+
39
+ if(currentEditor.item.changed) {
40
+ currentEditor.addCommandsToSaveData(aSaveData);
41
+ }
42
+
43
+ }
44
+
45
+ aSaveData.addSavedCommand(Dbm.commands.setProperty(this.item.properties.status, "none"));
46
+ }
47
+
48
+ getSaveData() {
49
+ let saveData = new Dbm.graphapi.webclient.admin.SaveData();
50
+ this.addCommandsToSaveData(saveData);
51
+ return saveData;
52
+ }
53
+
54
+ save() {
55
+ let saveData = this.getSaveData();
56
+ console.log(saveData);
57
+ saveData.save();
58
+ }
59
+ }
@@ -0,0 +1,74 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class ItemEditor extends Dbm.core.BaseObject {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.item.requireProperty("status", "none");
9
+ this.item.requireProperty("editors", []);
10
+
11
+ let anyChange = Dbm.flow.updatefunctions.logic.any();
12
+
13
+ this.item.requireProperty("anyChange", anyChange);
14
+ this.item.requireProperty("changed", false).connectInput(anyChange.output.properties.value);
15
+ }
16
+
17
+ getEditor(aField) {
18
+ return this.item["editor_" + aField];
19
+ }
20
+
21
+ addEditor(aName, aInitialValue, aSaveFunction, aUpdateEncoding = null) {
22
+ let valueEditor = this.item["editor_" + aName];
23
+ if(!valueEditor) {
24
+ valueEditor = new Dbm.graphapi.webclient.admin.ValueEditor();
25
+ valueEditor.item.editValue.setInitialValue(aInitialValue);
26
+
27
+ valueEditor.item.setValue("itemEditor", this.item);
28
+ valueEditor.item.setValue("name", aName);
29
+ valueEditor.item.setValue("updateEncoding", aUpdateEncoding);
30
+
31
+ this.item.anyChange.addCheck(valueEditor.item.properties.changed);
32
+ this.item.setValue("editor_" + aName, valueEditor);
33
+ this.item.editors = [].concat(this.item.editors, valueEditor);
34
+
35
+ valueEditor.addSaveFunction(aSaveFunction);
36
+ }
37
+
38
+ return valueEditor;
39
+ }
40
+
41
+ addFieldEditor(aField, aInitialValue, aUpdateEncoding = null) {
42
+ return this.addEditor(aField, aInitialValue, Dbm.graphapi.webclient.admin.SaveFunctions.setField, aUpdateEncoding);
43
+ }
44
+
45
+ addCommandsToSaveData(aSaveData) {
46
+
47
+ let editedItemId = Dbm.objectPath(this.item, "editedItem.id");
48
+ let itemSaveData = aSaveData.getItemSaveData(editedItemId);
49
+
50
+ let currentArray = this.item.editors;
51
+ let currentArrayLength = currentArray.length;
52
+ for(let i = 0; i < currentArrayLength; i++) {
53
+ let currentEditor = currentArray[i];
54
+
55
+ if(currentEditor.item.changed) {
56
+ currentEditor.addCommandsToSaveData(aSaveData);
57
+ }
58
+ }
59
+
60
+ itemSaveData.addStartCommand(Dbm.commands.setProperty(this.item.properties.status, "loading"));
61
+ itemSaveData.addSavedCommand(Dbm.commands.setProperty(this.item.properties.status, "none"));
62
+ }
63
+
64
+ getSaveData() {
65
+ let saveData = new Dbm.graphapi.webclient.admin.SaveData();
66
+ this.addCommandsToSaveData(saveData);
67
+ return saveData;
68
+ }
69
+
70
+ save() {
71
+ let saveData = this.getSaveData();
72
+ saveData.save();
73
+ }
74
+ }