dbm 1.2.1 → 1.2.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 (53) hide show
  1. package/flow/controllers/select/InArray.js +67 -0
  2. package/flow/controllers/select/index.js +2 -1
  3. package/flow/index.js +13 -3
  4. package/flow/updatefunctions/basic/MappedList.js +49 -0
  5. package/flow/updatefunctions/basic/PropertyOf.js +1 -1
  6. package/flow/updatefunctions/basic/PropertyOfWithDefault.js +28 -0
  7. package/flow/updatefunctions/basic/Translation.js +71 -0
  8. package/flow/updatefunctions/basic/index.js +77 -0
  9. package/flow/updatefunctions/thirdparty/google/maps/PlaceDetails.js +80 -0
  10. package/flow/updatefunctions/thirdparty/google/maps/index.js +1 -0
  11. package/graphapi/webclient/ApiConnection.js +1 -0
  12. package/graphapi/webclient/WebSocketConnection.js +1 -0
  13. package/graphapi/webclient/admin/EditorGroup.js +1 -1
  14. package/graphapi/webclient/admin/ItemEditor.js +39 -0
  15. package/graphapi/webclient/admin/ItemSaveData.js +6 -0
  16. package/graphapi/webclient/admin/SaveFunctions.js +4 -0
  17. package/graphapi/webclient/admin/ValueEditor.js +15 -0
  18. package/graphapi/webclient/decode/DecodeBaseObject.js +4 -0
  19. package/graphapi/webclient/decode/index.js +17 -2
  20. package/graphapi/webclient/index.js +41 -0
  21. package/package.json +1 -1
  22. package/react/admin/EditObject.js +52 -0
  23. package/react/admin/EditObjectById.js +2 -3
  24. package/react/admin/EditPage.js +16 -0
  25. package/react/admin/EditorGroup.js +23 -0
  26. package/react/admin/SaveAllButton.js +34 -0
  27. package/react/admin/editorsgroup/EditField.js +2 -2
  28. package/react/admin/editorsgroup/EditFieldTranslation.js +27 -0
  29. package/react/admin/editorsgroup/EditIdentifer.js +3 -3
  30. package/react/admin/editorsgroup/EditItem.js +1 -1
  31. package/react/admin/editorsgroup/EditRelation.js +2 -2
  32. package/react/admin/editorsgroup/EditVisibility.js +2 -2
  33. package/react/admin/editorsgroup/index.js +2 -1
  34. package/react/admin/index.js +3 -0
  35. package/react/admin/objects/EditObject.js +9 -7
  36. package/react/admin/objects/itemeditors/Name.js +31 -29
  37. package/react/blocks/admin/objects/RunObjectCommands.js +0 -14
  38. package/react/blocks/admin/objects/User.js +29 -1
  39. package/react/blocks/faq/AskAQuestion.js +1 -1
  40. package/react/blocks/index.js +12 -0
  41. package/react/text/TranslatedText.js +25 -0
  42. package/react/text/TranslationGroup.js +24 -0
  43. package/react/text/index.js +8 -2
  44. package/site/SiteDataLoader.js +8 -13
  45. package/site/index.js +2 -0
  46. package/site/translation/TranslationLoader.js +59 -0
  47. package/site/translation/index.js +27 -0
  48. package/utils/CompareFunctions.js +10 -0
  49. package/utils/StringFunctions.js +18 -3
  50. package/utils/index.js +3 -1
  51. package/utils/thirdparty/index.js +1 -0
  52. package/utils/thirdparty/wprrapi/WprrApiParser.js +31 -0
  53. package/utils/thirdparty/wprrapi/index.js +3 -0
@@ -0,0 +1,67 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class InArray extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+
7
+ let valuesUpdatedCommand = Dbm.commands.callFunction(this._valuesUpdated.bind(this));
8
+
9
+ this._selectionChangedBound = this._selectionChanged.bind(this);
10
+
11
+ Dbm.flow.addUpdateCommand(this.item.requireProperty("values", null), valuesUpdatedCommand);
12
+ this.item.requireProperty("selections", []);
13
+
14
+ }
15
+
16
+ getSelectionForValue(aValue) {
17
+ let selections = this.item.selections;
18
+ let currentSelection = Dbm.utils.ArrayFunctions.getItemBy(selections, "value", aValue);
19
+
20
+ if(!currentSelection) {
21
+ let selections = [].concat(this.item.selections);
22
+ let property = new Dbm.flow.FlowProperty();
23
+ property.setValue(false);
24
+ Dbm.flow.addUpdateCommand(property, Dbm.commands.callFunction(this._selectionChangedBound, [property, aValue]));
25
+
26
+ currentSelection = {"value": aValue, "property": property};
27
+ selections.push(currentSelection);
28
+ this.item.selections = selections;
29
+ }
30
+
31
+ return currentSelection.property;
32
+ }
33
+
34
+ _selectionChanged(aSelected, aValue) {
35
+ console.log("_selectionChanged");
36
+
37
+ let newValues = [].concat(this.item.values);
38
+ if(aSelected) {
39
+ newValues.push(aValue);
40
+ }
41
+ else {
42
+ let index = newValues.indexOf(aValue);
43
+ if(index >= 0) {
44
+ newValues.splice(index, 1);
45
+ }
46
+ }
47
+
48
+ this.item.properties.values.getMostUpstreamProperty().setValue(newValues);
49
+ }
50
+
51
+ _valuesUpdated() {
52
+ //console.log("_valuesUpdated");
53
+ let values = this.item.values;
54
+
55
+ let currentArray = this.item.selections;
56
+ let currentArrayLength = currentArray.length;
57
+ for(let i = 0; i < currentArrayLength; i++) {
58
+ let currentSelection = currentArray[i];
59
+ if(values.indexOf(currentSelection.value) !== -1) {
60
+ currentSelection.property.getMostUpstreamProperty().setValue(true);
61
+ }
62
+ else {
63
+ currentSelection.property.getMostUpstreamProperty().setValue(false);
64
+ }
65
+ }
66
+ }
67
+ }
@@ -1 +1,2 @@
1
- export {default as SingleSelection} from "./SingleSelection.js";
1
+ export {default as SingleSelection} from "./SingleSelection.js";
2
+ export {default as InArray} from "./InArray.js";
package/flow/index.js CHANGED
@@ -11,7 +11,7 @@ export {default as FlowPropertyWithExternalInput} from "./FlowPropertyWithExtern
11
11
  export * as updatefunctions from "./updatefunctions/index.js";
12
12
  export * as controllers from "./controllers/index.js";
13
13
 
14
- export let addUpdateCommand = function(aProperty, aCommand) {
14
+ export const addUpdateCommand = function(aProperty, aCommand) {
15
15
  let updateFunction = new Dbm.flow.updatefunctions.basic.RunCommand();
16
16
  updateFunction.input.properties.value.connectInput(aProperty);
17
17
  updateFunction.input.command = aCommand;
@@ -26,7 +26,7 @@ export let addUpdateCommand = function(aProperty, aCommand) {
26
26
  return {"updateFunction": updateFunction, "dirtyCommands": dirtyCommands};
27
27
  }
28
28
 
29
- export let addDirectUpdateCommand = function(aProperty, aCommand) {
29
+ export const addDirectUpdateCommand = function(aProperty, aCommand) {
30
30
  let updateFunction = new Dbm.flow.updatefunctions.basic.RunCommand();
31
31
  updateFunction.input.properties.value.connectInput(aProperty);
32
32
  updateFunction.input.command = aCommand;
@@ -41,7 +41,7 @@ export let addDirectUpdateCommand = function(aProperty, aCommand) {
41
41
  return {"updateFunction": updateFunction, "dirtyCommands": dirtyCommands};
42
42
  }
43
43
 
44
- export let addUpdateCommandWhenMatched = function(aProperty, aMatchValue, aCommand) {
44
+ export const addUpdateCommandWhenMatched = function(aProperty, aMatchValue, aCommand) {
45
45
  let whenMatched = Dbm.flow.updatefunctions.logic.whenMatched(aProperty, aMatchValue);
46
46
 
47
47
  let updateData = Dbm.flow.addUpdateCommand(whenMatched.output.properties.value, aCommand);
@@ -51,6 +51,16 @@ export let addUpdateCommandWhenMatched = function(aProperty, aMatchValue, aComma
51
51
  return whenMatched;
52
52
  }
53
53
 
54
+ export const runWhenMatched = function(aProperty, aMatchValue, aCommand) {
55
+ if(aProperty.value === aMatchValue) {
56
+ aCommand.perform(null, null);
57
+
58
+ return null;
59
+ }
60
+
61
+ return addUpdateCommandWhenMatched(aProperty, aMatchValue, aCommand);
62
+ }
63
+
54
64
  export const animateValue = function(aValue, aTime = 0.5, aEasing = null) {
55
65
 
56
66
  let returnObject = new Dbm.repository.Item();
@@ -0,0 +1,49 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class MappedList extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("items", []);
9
+ this.input.register("itemReferenceName", "forItem");
10
+ this.input.register("newItemCommands", []);
11
+
12
+ this.output.register("items", []);
13
+ }
14
+
15
+ _update() {
16
+ console.log("MappedList::_update");
17
+
18
+ let currentArray = this.input.items;
19
+ let currentArrayLength = currentArray.length;
20
+
21
+ let itemReferenceName = this.input.itemReferenceName;
22
+ let newItemCommands = this.input.newItemCommands;
23
+
24
+ let currentMappedList = this.output.properties.items.getValueWithoutFlow();
25
+
26
+ let returnArray = new Array(currentArrayLength);
27
+ for(let i = 0; i < currentArrayLength; i++) {
28
+ let currentItem = currentArray[i];
29
+
30
+ let index = Dbm.utils.ArrayFunctions.getItemIndexByIfExists(currentMappedList, itemReferenceName, currentItem);
31
+
32
+ if(index !== -1) {
33
+ returnArray[i] = currentMappedList[index];
34
+ currentMappedList.splice(index, 1);
35
+ }
36
+ else {
37
+ let newItem = new Dbm.repository.Item();
38
+ newItem.setId("mapped_" + Dbm.getInstance().getNextId());
39
+ newItem.setValue(itemReferenceName, currentItem);
40
+ Dbm.commands.performCommands(newItemCommands, this, {"mappedItem": newItem, "item": currentItem, "itemReferenceName": itemReferenceName});
41
+ returnArray[i] = newItem;
42
+ }
43
+
44
+ //METODO: clean up unused items
45
+ }
46
+
47
+ this.output.items = returnArray;
48
+ }
49
+ }
@@ -1,6 +1,6 @@
1
1
  import Dbm from "../../../index.js";
2
2
 
3
- export default class Length extends Dbm.flow.FlowUpdateFunction {
3
+ export default class PropertyOf extends Dbm.flow.FlowUpdateFunction {
4
4
 
5
5
  _construct() {
6
6
  super._construct();
@@ -0,0 +1,28 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class PropertyOfWithDefault extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("value", "");
9
+ this.input.register("propertyName", "");
10
+ this.input.register("defaultValue", null);
11
+
12
+ this.output.register("value", null);
13
+ }
14
+
15
+ _update() {
16
+ //console.log("_update");
17
+
18
+ let value = this.input.value;
19
+
20
+ let outputValue = Dbm.objectPath(value, this.input.propertyName);
21
+
22
+ if(!outputValue) {
23
+ outputValue = this.input.defaultValue;
24
+ }
25
+
26
+ this.output.value = outputValue
27
+ }
28
+ }
@@ -0,0 +1,71 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class Translation extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("translations", {});
9
+ this.input.register("path", null);
10
+ this.input.register("additionalPath", null);
11
+ this.input.register("id", "");
12
+ this.input.register("defaultValue", null);
13
+
14
+ this.output.register("value", null);
15
+ }
16
+
17
+ _update() {
18
+ //console.log("_update");
19
+
20
+ let translations = this.input.translations;
21
+
22
+ let path = this.input.path;
23
+ let additionalPath = this.input.additionalPath;
24
+ let id = this.input.id;
25
+
26
+ while(path) {
27
+
28
+ let currentAdditionalPath = additionalPath;
29
+ while(currentAdditionalPath) {
30
+
31
+ let currentValue = translations[path + "/" + currentAdditionalPath + "/" + id];
32
+ if(currentValue) {
33
+ this.output.value = currentValue;
34
+ return;
35
+ }
36
+
37
+ let nextIndex = currentAdditionalPath.lastIndexOf("/");
38
+ if(nextIndex >= 0) {
39
+ currentAdditionalPath = currentAdditionalPath.substring(0, nextIndex);
40
+ }
41
+ else {
42
+ currentAdditionalPath = null;
43
+ }
44
+ }
45
+
46
+ let currentValue = translations[path + "/" + id];
47
+ if(currentValue) {
48
+ this.output.value = currentValue;
49
+ return;
50
+ }
51
+
52
+ let nextIndex = path.lastIndexOf("/");
53
+ if(nextIndex >= 0) {
54
+ path = path.substring(0, nextIndex);
55
+ }
56
+ else {
57
+ path = null;
58
+ }
59
+ }
60
+
61
+ let currentValue = translations[id];
62
+ if(currentValue) {
63
+ this.output.value = currentValue;
64
+ return;
65
+ }
66
+
67
+ //METODO: report missing translation
68
+
69
+ this.output.value = this.input.defaultValue;
70
+ }
71
+ }
@@ -4,6 +4,9 @@ export {default as RunCommand} from "./RunCommand.js";
4
4
  export {default as CombineString} from "./CombineString.js";
5
5
  export {default as Length} from "./Length.js";
6
6
  export {default as PropertyOf} from "./PropertyOf.js";
7
+ export {default as PropertyOfWithDefault} from "./PropertyOfWithDefault.js";
8
+ export {default as MappedList} from "./MappedList.js";
9
+ export {default as Translation} from "./Translation.js";
7
10
 
8
11
  export const runCommand = function(aValue, aCommand) {
9
12
  let updateFunction = new Dbm.flow.updatefunctions.basic.RunCommand();
@@ -34,6 +37,15 @@ export const propertyOf = function(aValue, aPropertyName) {
34
37
  return updateFunction;
35
38
  }
36
39
 
40
+ export const propertyOfWithDefault = function(aValue, aPropertyName, aDefaultValue) {
41
+ let updateFunction = new Dbm.flow.updatefunctions.basic.PropertyOfWithDefault();
42
+ updateFunction.input.properties.value.setOrConnect(aValue);
43
+ updateFunction.input.properties.propertyName.setOrConnect(aPropertyName);
44
+ updateFunction.input.properties.defaultValue.setOrConnect(aDefaultValue);
45
+
46
+ return updateFunction;
47
+ }
48
+
37
49
  export const combine = function(...aValues) {
38
50
  let updateFunction = new Dbm.flow.updatefunctions.basic.CombineString();
39
51
 
@@ -46,4 +58,69 @@ export const combine = function(...aValues) {
46
58
 
47
59
 
48
60
  return updateFunction;
61
+ }
62
+
63
+ export const mappedList = function(aItems, aNewItemCommands = []) {
64
+ let updateFunction = new Dbm.flow.updatefunctions.basic.MappedList();
65
+ updateFunction.input.properties.items.setOrConnect(aItems);
66
+ updateFunction.input.properties.newItemCommands.setOrConnect(aNewItemCommands);
67
+
68
+ return updateFunction;
69
+ }
70
+
71
+ export const mappedListWithFunction = function(aItems, aNewItemFunction) {
72
+ let command = Dbm.commands.callFunction(aNewItemFunction, [Dbm.core.source.event("mappedItem"), Dbm.core.source.fromObject()]);
73
+
74
+ return mappedList(aItems, [command]);
75
+ }
76
+
77
+
78
+
79
+ export const activeMappedList = function(aItems, aActiveFromStart = false) {
80
+
81
+ let item = new Dbm.repository.Item();
82
+
83
+ item.requireProperty("items", []).setOrConnect(aItems);
84
+ item.requireProperty("activeItems", []);
85
+ item.requireProperty("selectionItems", []);
86
+
87
+ let activeItems = new Dbm.flow.controllers.select.InArray();
88
+
89
+ let createActiveField = function(aItem, aUpdateFunction) {
90
+ let activeProperty = aItem.requireProperty("active", aUpdateFunction.activeFromStart);
91
+ let inArrayProperty = activeItems.getSelectionForValue(aItem[aUpdateFunction.input.itemReferenceName]);
92
+ inArrayProperty.connectInput(activeProperty);
93
+ }
94
+
95
+ let updateFunction = mappedListWithFunction(item.properties.items, createActiveField);
96
+ updateFunction.activeFromStart = aActiveFromStart;
97
+ item.setValue("mappedList", updateFunction);
98
+ item.properties.selectionItems.connectInput(updateFunction.output.properties.items);
99
+
100
+ activeItems.item.properties.values.connectInput(item.properties.activeItems);
101
+ item.setValue("inArray", activeItems);
102
+
103
+ return item;
104
+ }
105
+
106
+ export const translation = function(aId, aDefaultValue = null, aPath = null, aAdditionalPath = null, aTranslations = null) {
107
+ let updateFunction = new Dbm.flow.updatefunctions.basic.Translation();
108
+
109
+ updateFunction.input.properties.id.setOrConnect(aId);
110
+ updateFunction.input.properties.defaultValue.setOrConnect(aDefaultValue);
111
+ updateFunction.input.properties.path.setOrConnect(aPath);
112
+ updateFunction.input.properties.additionalPath.setOrConnect(aAdditionalPath);
113
+
114
+ if(!aTranslations) {
115
+ aTranslations = Dbm.getRepositoryItem("site/translations").requireProperty("data");
116
+ }
117
+ updateFunction.input.properties.translations.setOrConnect(aTranslations);
118
+
119
+ return updateFunction;
120
+ }
121
+
122
+ export const translationProperty = function(aId, aDefaultValue = null, aPath = null, aAdditionalPath = null, aTranslations = null) {
123
+ let updateFunction = translation(aId, aDefaultValue, aPath, aAdditionalPath, aTranslations);
124
+
125
+ return updateFunction.output.properties.value;
49
126
  }
@@ -0,0 +1,80 @@
1
+ import Dbm from "../../../../../index.js";
2
+
3
+ export default class PlaceDetails extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("id", null);
9
+ this.input.register("fields", ["addressComponents", "location"]);
10
+
11
+ //reviews
12
+
13
+ this._loadedScript = false;
14
+ this._currentId = "";
15
+
16
+ this.output.register("updated", true);
17
+ this.output.register("data", null);
18
+ }
19
+
20
+ loadScript() {
21
+ console.log("loadScript");
22
+ let key = Dbm.getRepositoryItem("googleMapsApi").apiKey;
23
+ let scriptLoader = Dbm.loading.loadScript("https://maps.googleapis.com/maps/api/js?key=" + key + "&libraries=places");
24
+
25
+ console.log(scriptLoader.item.properties.status, scriptLoader);
26
+ if(scriptLoader.item.status === 1) {
27
+ this._scriptLoaded();
28
+ }
29
+ else {
30
+ Dbm.flow.addUpdateCommandWhenMatched(scriptLoader.item.properties.status, 1, Dbm.commands.callFunction(this._scriptLoaded.bind(this)));
31
+ }
32
+
33
+ return this;
34
+ }
35
+
36
+ _scriptLoaded() {
37
+ console.log("_scriptLoaded");
38
+ if(!this._loadedScript) {
39
+ this._loadedScript = true;
40
+ this._update();
41
+ }
42
+ }
43
+
44
+ _update() {
45
+ console.log("_update");
46
+
47
+
48
+ let id = this.input.id;
49
+ this._currentId = id;
50
+ this.output.updated = false;
51
+
52
+ if(id) {
53
+ this.output.properties.data.isDirty = false;
54
+ this.output.properties.updated.isDirty = false;
55
+
56
+ if(this._loadedScript) {
57
+
58
+ let place = new google.maps.places.Place({"id": this.input.id});
59
+ console.log(place);
60
+
61
+ let loadPromise = place.fetchFields({"fields": this.input.fields});
62
+
63
+ loadPromise.then((aResult) => {
64
+ console.log(id, place, aResult);
65
+ this.output.properties.data._internal_setValueInFlowOutsideOfUpdate(place);
66
+ })
67
+ }
68
+ else {
69
+ this.loadScript();
70
+ }
71
+ }
72
+ else {
73
+ this.output.data = null;
74
+ this.output.updated = true;
75
+ }
76
+ }
77
+ }
78
+
79
+
80
+
@@ -1,3 +1,4 @@
1
1
  import Dbm from "../../../../../index.js";
2
2
 
3
3
  export {default as AutoComplete} from "./AutoComplete.js";
4
+ export {default as PlaceDetails} from "./PlaceDetails.js";
@@ -77,6 +77,7 @@ export default class ApiConnection extends Dbm.core.BaseObject {
77
77
 
78
78
  requestData(aFunctionName, aData) {
79
79
  let item = this._getRequestItem();
80
+ item.requireProperty("data", null);
80
81
 
81
82
  let parametersArray = [];
82
83
 
@@ -94,6 +94,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
94
94
  requestData(aFunctionName, aData) {
95
95
  //console.log("requestData");
96
96
  let item = this._getRequestItem();
97
+ item.requireProperty("data", null);
97
98
  item.setValue("requestData", {"type": "data", "functionName": aFunctionName, "data": aData, "requestId": item.id});
98
99
  this._runRequest(item);
99
100
 
@@ -18,7 +18,7 @@ export default class EditorGroup extends Dbm.core.BaseObject {
18
18
  let itemEditor = this.item["editor_" + aId];
19
19
  if(!itemEditor) {
20
20
  itemEditor = new Dbm.graphapi.webclient.admin.ItemEditor();
21
- itemEditor.item.setValue("editedItem", Dbm.getInstance().repository.getItem(aId));
21
+ itemEditor.item.setValue("editedItem", Dbm.getRepositoryItem(aId));
22
22
  this.item.setValue("editor_" + aId, itemEditor);
23
23
  this.item.editors = [].concat(this.item.editors, itemEditor);
24
24
  this.item.anyChange.addCheck(itemEditor.item.properties.changed);
@@ -42,6 +42,18 @@ export default class ItemEditor extends Dbm.core.BaseObject {
42
42
  return this.addEditor(aField, aInitialValue, Dbm.graphapi.webclient.admin.SaveFunctions.setField, aUpdateEncoding);
43
43
  }
44
44
 
45
+ addFieldTranslationEditor(aField, aLanguage, aInitialValue, aUpdateEncoding = null) {
46
+ let name = "translation_" + aField + "_" + aLanguage;
47
+ let valueEditor = this.item["editor_" + name];
48
+ if(!valueEditor) {
49
+ valueEditor = this.addEditor(name, aInitialValue, Dbm.graphapi.webclient.admin.SaveFunctions.setFieldTranslation, aUpdateEncoding);
50
+ valueEditor.item.setValue("name", aField);
51
+ valueEditor.item.setValue("language", aLanguage);
52
+ }
53
+
54
+ return valueEditor;
55
+ }
56
+
45
57
  _addRelationEditor(aName, aType, aObjectType, aInitialValue, aSaveFunction, aUpdateEncoding = null) {
46
58
  let valueEditor = this.item["editor_relation_" + aName];
47
59
  if(!valueEditor) {
@@ -104,6 +116,33 @@ export default class ItemEditor extends Dbm.core.BaseObject {
104
116
  return this._addMultipleRelationsEditor(name, aType, aObjectType, aInitialValue, Dbm.graphapi.webclient.admin.SaveFunctions.multipleOutgoingRelations, aUpdateEncoding);
105
117
  }
106
118
 
119
+ getAdminMultipleIncomingRelationsEditor(aType, aObjectType) {
120
+ let name = "in_" + aType + "_" + aObjectType;
121
+ let valueEditor = this.item["editor_relation_" + name];
122
+ if(!valueEditor) {
123
+ let relations = Dbm.utils.ArrayFunctions.filterByField(Dbm.objectPath(this.item.editedItem, "relations/in." + aType + ".objects"), "objectTypes", aObjectType, "arrayContains");
124
+ let ids = Dbm.utils.ArrayFunctions.mapField(relations, "id");
125
+
126
+ valueEditor = this.addMultipleIncomingRelationsEditor(aType, aObjectType, ids, "relations");
127
+ }
128
+
129
+ return valueEditor;
130
+ }
131
+
132
+ getAdminMultipleOutgoingRelationsEditor(aType, aObjectType) {
133
+ let name = "out_" + aType + "_" + aObjectType;
134
+ let valueEditor = this.item["editor_relation_" + name];
135
+ if(!valueEditor) {
136
+ let relations = Dbm.utils.ArrayFunctions.filterByField(Dbm.objectPath(this.item.editedItem, "relations/in." + aType + ".objects"), "objectTypes", aObjectType, "arrayContains");
137
+ let ids = Dbm.utils.ArrayFunctions.mapField(relations, "id");
138
+
139
+ valueEditor = this.addMultipleOutgoingRelationsEditor(aType, aObjectType, ids, "relations");
140
+ }
141
+
142
+ return valueEditor;
143
+ }
144
+
145
+
107
146
  getVisibilityEditor(aInitialValue) {
108
147
  let name = "visibility";
109
148
  let valueEditor = this.item["visibility"];
@@ -28,6 +28,12 @@ export default class ItemSaveData extends Dbm.core.BaseObject {
28
28
 
29
29
  return this;
30
30
  }
31
+
32
+ setFieldTranslation(aField, aLanguage, aValue) {
33
+ this.createChange("setFieldTranslation", {"value": aValue, "language": aLanguage, "field": aField});
34
+
35
+ return this;
36
+ }
31
37
 
32
38
  addUpdateEncoding(aEncoding) {
33
39
  this._updateEncodings.push(aEncoding);
@@ -4,6 +4,10 @@ export const setField = function(aEditor, aItemSaveData) {
4
4
  aItemSaveData.setField(aEditor.item.name, aEditor.item.editValue.getValue());
5
5
  }
6
6
 
7
+ export const setFieldTranslation = function(aEditor, aItemSaveData) {
8
+ aItemSaveData.setFieldTranslation(aEditor.item.name, aEditor.item.language, aEditor.item.editValue.getValue());
9
+ }
10
+
7
11
  export const setUrl = function(aEditor, aItemSaveData) {
8
12
  aItemSaveData.createChange("setUrl", {"value": aEditor.item.editValue.getValue()});
9
13
  }
@@ -14,6 +14,21 @@ export default class ValueEditor extends Dbm.core.BaseObject {
14
14
  this.item.requireProperty("changed", false).connectInput(editValue.item.properties.changed);
15
15
  }
16
16
 
17
+ get value() {
18
+ return this.valueProperty.value;
19
+ }
20
+
21
+ set value(aValue) {
22
+
23
+ this.valueProperty.value = aValue;
24
+
25
+ return aValue;
26
+ }
27
+
28
+ get valueProperty() {
29
+ return this.item.editValue.value;
30
+ }
31
+
17
32
  addSaveCommand(aCommand) {
18
33
 
19
34
  this.item.saveCommands = [].concat(this.item.saveCommands, aCommand);
@@ -49,5 +49,9 @@ export default class DecodeBaseObject extends Dbm.core.BaseObject {
49
49
  }
50
50
  }
51
51
  }
52
+
53
+ if(this.item.setupCommands) {
54
+ Dbm.commands.performCommands(this.item.setupCommands, this, {"item": aItem});
55
+ }
52
56
  }
53
57
  }
@@ -3,13 +3,14 @@ import Dbm from "../../../index.js";
3
3
  export {default as DecodeBaseObject} from "./DecodeBaseObject.js";
4
4
  export {default as Relations} from "./Relations.js";
5
5
 
6
- export const setupDefaultDecoder = function(aName, aFields = [], aSingleLinks = [], aMultipleLinks = []) {
6
+ export const setupDefaultDecoder = function(aName, aFields = [], aSingleLinks = [], aMultipleLinks = [], aSetupCommands = []) {
7
7
  let decodePrefix = "graphApi/decode/";
8
8
 
9
9
  let decoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
10
10
  decoder.item.setValue("copyFields", aFields);
11
11
  decoder.item.setValue("copyLink", aSingleLinks);
12
12
  decoder.item.setValue("copyLinks", aMultipleLinks);
13
+ decoder.item.setValue("setupCommands", aSetupCommands);
13
14
  decoder.item.setValue("encodingType", aName);
14
15
  decoder.item.register(decodePrefix + aName);
15
16
 
@@ -73,7 +74,7 @@ export const fullSetup = function() {
73
74
  let name = "urlRequest";
74
75
  let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
75
76
  currentDecoder.item.setValue("copyFields", ["meta/description", "seo/noIndex", "seo/noFollow", "publishDate"]);
76
- currentDecoder.item.setValue("copyLink", ["category"]);
77
+ currentDecoder.item.setValue("copyLink", ["category", "translations"]);
77
78
  currentDecoder.item.setValue("copyLinks", ["categories"]);
78
79
  currentDecoder.item.setValue("encodingType", name);
79
80
  currentDecoder.item.register(decodePrefix + name);
@@ -201,4 +202,18 @@ export const fullSetup = function() {
201
202
 
202
203
  setupDefaultDecoder("linkPreview", ["title", "description", "link", "linkText"], ["page"]);
203
204
  setupDefaultDecoder("publishDate", ["publishDate"], []);
205
+ setupDefaultDecoder("language", [], ["language"]);
206
+ setupDefaultDecoder("admin_fieldTranslations", ["fields/translations"], []);
207
+ setupDefaultDecoder("translationGroup", [], [], ["pages"]);
208
+
209
+ let connectTranslations = function(aItem, aTranslationsName, aOutputName, aDefaultFieldName) {
210
+
211
+ let updateFunction = Dbm.flow.updatefunctions.basic.propertyOfWithDefault(aItem.getProperty(aTranslationsName), Dbm.getRepositoryItem("site").properties.currentLanguageCode, aItem.getProperty(aDefaultFieldName));
212
+ aItem.requireProperty(aOutputName, null).connectInput(updateFunction.output.properties.value);
213
+
214
+ aItem.requireProperty(aOutputName + "/update", updateFunction);
215
+ }
216
+
217
+ setupDefaultDecoder("name_translations", ["name/translations"], [], [], [Dbm.commands.callFunction(connectTranslations, [Dbm.core.source.event("item"), "name/translations", "name/translated", "name"])]);
218
+ setupDefaultDecoder("title_translations", ["title/translations"], [], [], [Dbm.commands.callFunction(connectTranslations, [Dbm.core.source.event("item"), "title/translations", "title/translated", "title"])]);
204
219
  }