dbm 1.2.1 → 1.2.3

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 (75) hide show
  1. package/commands/CommandBaseObject.js +2 -2
  2. package/commands/SetProperty.js +1 -1
  3. package/core/source/SourceCommand.js +17 -0
  4. package/core/source/index.js +15 -0
  5. package/flow/controllers/select/InArray.js +67 -0
  6. package/flow/controllers/select/index.js +2 -1
  7. package/flow/index.js +13 -3
  8. package/flow/updatefunctions/basic/MappedList.js +49 -0
  9. package/flow/updatefunctions/basic/PropertyOf.js +1 -1
  10. package/flow/updatefunctions/basic/PropertyOfWithDefault.js +28 -0
  11. package/flow/updatefunctions/basic/Translation.js +71 -0
  12. package/flow/updatefunctions/basic/index.js +77 -0
  13. package/flow/updatefunctions/thirdparty/google/maps/AutoComplete.js +1 -8
  14. package/flow/updatefunctions/thirdparty/google/maps/PlaceDetails.js +73 -0
  15. package/flow/updatefunctions/thirdparty/google/maps/PlaceDetailsFromQuery.js +71 -0
  16. package/flow/updatefunctions/thirdparty/google/maps/index.js +2 -0
  17. package/graphapi/webclient/ApiConnection.js +1 -0
  18. package/graphapi/webclient/WebSocketConnection.js +1 -0
  19. package/graphapi/webclient/admin/EditorGroup.js +1 -1
  20. package/graphapi/webclient/admin/ItemEditor.js +39 -0
  21. package/graphapi/webclient/admin/ItemSaveData.js +6 -0
  22. package/graphapi/webclient/admin/SaveFunctions.js +4 -0
  23. package/graphapi/webclient/admin/ValueEditor.js +15 -0
  24. package/graphapi/webclient/decode/DecodeBaseObject.js +4 -0
  25. package/graphapi/webclient/decode/index.js +17 -2
  26. package/graphapi/webclient/index.js +41 -0
  27. package/package.json +1 -1
  28. package/react/BaseObject.js +12 -1
  29. package/react/admin/EditObject.js +52 -0
  30. package/react/admin/EditObjectById.js +2 -3
  31. package/react/admin/EditPage.js +16 -0
  32. package/react/admin/EditorGroup.js +23 -0
  33. package/react/admin/SaveAllButton.js +34 -0
  34. package/react/admin/editorsgroup/EditField.js +2 -2
  35. package/react/admin/editorsgroup/EditFieldTranslation.js +27 -0
  36. package/react/admin/editorsgroup/EditIdentifer.js +3 -3
  37. package/react/admin/editorsgroup/EditItem.js +1 -1
  38. package/react/admin/editorsgroup/EditRelation.js +2 -2
  39. package/react/admin/editorsgroup/EditVisibility.js +2 -2
  40. package/react/admin/editorsgroup/index.js +2 -1
  41. package/react/admin/index.js +3 -0
  42. package/react/admin/objects/EditObject.js +9 -7
  43. package/react/admin/objects/itemeditors/Field.js +26 -0
  44. package/react/admin/objects/itemeditors/FieldWithTranslations.js +38 -0
  45. package/react/admin/objects/itemeditors/Name.js +20 -28
  46. package/react/admin/objects/itemeditors/PageRepresentation.js +1 -1
  47. package/react/admin/objects/itemeditors/Title.js +20 -28
  48. package/react/admin/objects/itemeditors/index.js +2 -1
  49. package/react/area/SwitchableArea.js +39 -0
  50. package/react/area/index.js +1 -0
  51. package/react/blocks/admin/objects/RunObjectCommands.js +0 -14
  52. package/react/blocks/admin/objects/User.js +29 -1
  53. package/react/blocks/faq/AskAQuestion.js +1 -1
  54. package/react/blocks/index.js +24 -0
  55. package/react/interaction/ClickOutsideTrigger.js +53 -0
  56. package/react/interaction/CommandButton.js +7 -1
  57. package/react/interaction/ConfirmButton.js +56 -0
  58. package/react/interaction/index.js +3 -1
  59. package/react/text/TranslatedText.js +25 -0
  60. package/react/text/TranslationGroup.js +24 -0
  61. package/react/text/index.js +8 -2
  62. package/site/SiteDataLoader.js +8 -13
  63. package/site/index.js +2 -0
  64. package/site/translation/TranslationLoader.js +59 -0
  65. package/site/translation/index.js +27 -0
  66. package/utils/ArrayFunctions.js +47 -1
  67. package/utils/CompareFunctions.js +32 -0
  68. package/utils/StringFunctions.js +18 -3
  69. package/utils/index.js +3 -1
  70. package/utils/thirdparty/google/index.js +1 -0
  71. package/utils/thirdparty/google/maps/PlaceFunctions.js +53 -0
  72. package/utils/thirdparty/google/maps/index.js +1 -0
  73. package/utils/thirdparty/index.js +2 -0
  74. package/utils/thirdparty/wprrapi/WprrApiParser.js +31 -0
  75. package/utils/thirdparty/wprrapi/index.js +3 -0
@@ -9,7 +9,7 @@ export default class CommandBaseObject extends Dbm.core.BaseObject {
9
9
  //MENOTE: should be overridden
10
10
  }
11
11
 
12
- _resolveSource(aValueOrSource) {
12
+ _resolveSource(aValueOrSource, aFromObject = null, aData = null) {
13
13
  if(aValueOrSource) {
14
14
  if(aValueOrSource.isFlowProperty) {
15
15
  return aValueOrSource.value;
@@ -22,7 +22,7 @@ export default class CommandBaseObject extends Dbm.core.BaseObject {
22
22
  return aValueOrSource;
23
23
  }
24
24
 
25
- _resolveSourceWithoutFlow(aValueOrSource) {
25
+ _resolveSourceWithoutFlow(aValueOrSource, aFromObject = null, aData = null) {
26
26
  if(aValueOrSource && aValueOrSource.isSource) {
27
27
  return aValueOrSource.getSource(aFromObject, aData);
28
28
  }
@@ -13,6 +13,6 @@ export default class SetProperty extends CommandBaseObject {
13
13
 
14
14
  let value = this.getInput("value");
15
15
 
16
- this._resolveSourceWithoutFlow(this.item.property).value = value;
16
+ this._resolveSourceWithoutFlow(this.item.property, aFromObject, aData).value = value;
17
17
  }
18
18
  }
@@ -0,0 +1,17 @@
1
+ import Dbm from "../../index.js";
2
+
3
+ export default class SourceCommand extends Dbm.core.source.SourceBaseObject {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.item.setValue("object", null);
9
+ }
10
+
11
+ getBaseObject(aFromObject, aEventData) {
12
+
13
+ let command = this.item.object;
14
+
15
+ return command.perform(aFromObject, aEventData);
16
+ }
17
+ }
@@ -5,6 +5,7 @@ export {default as EventSource} from "./EventSource.js";
5
5
  export {default as FromObject} from "./FromObject.js";
6
6
  export {default as StaticSource} from "./StaticSource.js";
7
7
  export {default as FirstSource} from "./FirstSource.js";
8
+ export {default as SourceCommand} from "./SourceCommand.js";
8
9
 
9
10
  export const event = function(aPath = null) {
10
11
  let newSource = new Dbm.core.source.EventSource();
@@ -50,3 +51,17 @@ export const firstWithDefault = function(...aSourcesAndDefault) {
50
51
 
51
52
  return newSource;
52
53
  }
54
+
55
+ export const command = function(aCommand) {
56
+ let newSource = new Dbm.core.source.SourceCommand();
57
+
58
+ newSource.item.object = aCommand;
59
+
60
+ return newSource;
61
+ }
62
+
63
+ export const callFunction = function(aFunction, aArguments = []) {
64
+ let functionCommand = Dbm.commands.callFunction(aFunction, aArguments);
65
+
66
+ return command(functionCommand);
67
+ }
@@ -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
  }
@@ -20,13 +20,7 @@ export default class AutoComplete extends Dbm.flow.FlowUpdateFunction {
20
20
  loadScript() {
21
21
  let key = Dbm.getRepositoryItem("googleMapsApi").apiKey;
22
22
  let scriptLoader = Dbm.loading.loadScript("https://maps.googleapis.com/maps/api/js?key=" + key + "&libraries=places");
23
-
24
- if(scriptLoader.item.properties.status === 1) {
25
- this._scriptLoaded();
26
- }
27
- else {
28
- Dbm.flow.addUpdateCommandWhenMatched(scriptLoader.item.properties.status, 1, Dbm.commands.callFunction(this._scriptLoaded.bind(this)));
29
- }
23
+ Dbm.flow.runWhenMatched(scriptLoader.item.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._scriptLoaded.bind(this)));
30
24
 
31
25
  return this;
32
26
  }
@@ -54,7 +48,6 @@ export default class AutoComplete extends Dbm.flow.FlowUpdateFunction {
54
48
  _update() {
55
49
  console.log("_update");
56
50
 
57
-
58
51
  let text = this.input.text;
59
52
  this._currentText = text;
60
53
  this.output.updated = false;
@@ -0,0 +1,73 @@
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
+ Dbm.flow.runWhenMatched(scriptLoader.item.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._scriptLoaded.bind(this)));
25
+
26
+ return this;
27
+ }
28
+
29
+ _scriptLoaded() {
30
+ console.log("_scriptLoaded");
31
+ if(!this._loadedScript) {
32
+ this._loadedScript = true;
33
+ this._update();
34
+ }
35
+ }
36
+
37
+ _update() {
38
+ console.log("_update");
39
+
40
+
41
+ let id = this.input.id;
42
+ this._currentId = id;
43
+ this.output.updated = false;
44
+
45
+ if(id) {
46
+ this.output.properties.data.isDirty = false;
47
+ this.output.properties.updated.isDirty = false;
48
+
49
+ if(this._loadedScript) {
50
+
51
+ let place = new google.maps.places.Place({"id": this.input.id});
52
+ console.log(place);
53
+
54
+ let loadPromise = place.fetchFields({"fields": this.input.fields});
55
+
56
+ loadPromise.then((aResult) => {
57
+ console.log(id, place, aResult);
58
+ this.output.properties.data._internal_setValueInFlowOutsideOfUpdate(place);
59
+ })
60
+ }
61
+ else {
62
+ this.loadScript();
63
+ }
64
+ }
65
+ else {
66
+ this.output.data = null;
67
+ this.output.updated = true;
68
+ }
69
+ }
70
+ }
71
+
72
+
73
+
@@ -0,0 +1,71 @@
1
+ import Dbm from "../../../../../index.js";
2
+
3
+ export default class PlaceDetailsDetailsFromQuery extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("query", null);
9
+ this.input.register("fields", ["addressComponents", "location"]);
10
+
11
+ this._loadedScript = false;
12
+ this._currentId = "";
13
+
14
+ this.output.register("updated", true);
15
+ this.output.register("data", null);
16
+ }
17
+
18
+ loadScript() {
19
+ console.log("loadScript");
20
+ let key = Dbm.getRepositoryItem("googleMapsApi").apiKey;
21
+ let scriptLoader = Dbm.loading.loadScript("https://maps.googleapis.com/maps/api/js?key=" + key + "&libraries=places");
22
+ Dbm.flow.runWhenMatched(scriptLoader.item.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._scriptLoaded.bind(this)));
23
+
24
+ return this;
25
+ }
26
+
27
+ _scriptLoaded() {
28
+ console.log("_scriptLoaded");
29
+ if(!this._loadedScript) {
30
+ this._loadedScript = true;
31
+ this._update();
32
+ }
33
+ }
34
+
35
+ _update() {
36
+ console.log("_update");
37
+
38
+
39
+ let query = this.input.query;
40
+ this._currentQuery = query;
41
+ this.output.updated = false;
42
+
43
+ if(query) {
44
+ this.output.properties.data.isDirty = false;
45
+ this.output.properties.updated.isDirty = false;
46
+
47
+ if(this._loadedScript) {
48
+
49
+ let loadPromise = google.maps.places.Place.searchByText({
50
+ textQuery: query,
51
+ fields: this.input.fields,
52
+ });
53
+
54
+ loadPromise.then((aResponse) => {
55
+ let place = aResponse.places[0];
56
+ this.output.properties.data._internal_setValueInFlowOutsideOfUpdate(place);
57
+ })
58
+ }
59
+ else {
60
+ this.loadScript();
61
+ }
62
+ }
63
+ else {
64
+ this.output.data = null;
65
+ this.output.updated = true;
66
+ }
67
+ }
68
+ }
69
+
70
+
71
+
@@ -1,3 +1,5 @@
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";
5
+ export {default as PlaceDetailsFromQuery} from "./PlaceDetailsFromQuery.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);