dbm 1.4.14 → 1.4.15

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.
@@ -225,4 +225,7 @@ export const fullSetup = function() {
225
225
  setupDefaultDecoder("menuLocation", ["identifier"], ["menu"], []);
226
226
  setupDefaultDecoder("menu", ["order"], [], ["menuItems"], [Dbm.commands.callFunction(linkUpMenu, [Dbm.core.source.event("item")])]);
227
227
  setupDefaultDecoder("menuItem", ["label", "link"], [], []);
228
+
229
+ setupDefaultDecoder("review", ["rating", "from", "description", "date"], ["source"], []);
230
+ setupDefaultDecoder("reviewSource", ["imageUrl", "link"], ["type"], []);
228
231
  }
@@ -0,0 +1,53 @@
1
+ import Dbm from "../../index.js";
2
+
3
+ export const findPlace = async function(aName) {
4
+ let response = await fetch("https://places.googleapis.com/v1/places:searchText", {
5
+ method: "POST",
6
+ headers: {
7
+ "Content-Type": "application/json",
8
+ "X-Goog-Api-Key": Dbm.getRepositoryItem("googleMapsApi").apiKey,
9
+ "X-Goog-FieldMask": "*"
10
+ },
11
+ body: JSON.stringify({
12
+ textQuery: aName,
13
+ maxResultCount: 1
14
+ })
15
+ });
16
+
17
+ let repsonseText = await response.text();
18
+
19
+ let place = null;
20
+ try {
21
+ let responseData = JSON.parse(repsonseText);
22
+ place = Dbm.objectPath(responseData, "places.0");
23
+ }
24
+ catch(theError) {
25
+
26
+ }
27
+
28
+ return place;
29
+ }
30
+
31
+ export const getReviews = async function(aPlaceId) {
32
+ let response = await fetch("https://places.googleapis.com/v1/places/" + aPlaceId, {
33
+ headers: {
34
+ "X-Goog-Api-Key": Dbm.getRepositoryItem("googleMapsApi").apiKey,
35
+ "X-Goog-FieldMask": "*"
36
+ }
37
+ });
38
+
39
+ let repsonseText = await response.text();
40
+ let reviews = [];
41
+
42
+ try {
43
+ let responseData = JSON.parse(repsonseText);
44
+ console.log(responseData);
45
+ reviews = Dbm.objectPath(responseData, "reviews");
46
+ }
47
+ catch(theError) {
48
+
49
+ }
50
+
51
+ return reviews;
52
+ }
53
+
package/node/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import Dbm from "../index.js";
2
2
  export * as communication from "./communication/index.js";
3
+ export * as googlemaps from "./googlemaps/index.js";
3
4
 
4
5
  export const getDatabase = function() {
5
6
  return Dbm.getRepositoryItem("graphDatabase").controller;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbm",
3
- "version": "1.4.14",
3
+ "version": "1.4.15",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -111,6 +111,16 @@ export default class BaseObject extends Component {
111
111
  return value;
112
112
  }
113
113
 
114
+ getPropValueWithoutNull(aName, aDefaultValue) {
115
+ let value = this.getPropValue(aName);
116
+
117
+ if(value === null || value === undefined) {
118
+ value = aDefaultValue;
119
+ }
120
+
121
+ return value;
122
+ }
123
+
114
124
  createRef(aName) {
115
125
  let refToProperty = this.item["ref/" + aName];
116
126
 
@@ -18,6 +18,12 @@ export default class DraggableHierarchyDisplay extends Dbm.react.BaseObject {
18
18
  _renderMainElement() {
19
19
 
20
20
  let children = this.getPropValue("children");
21
+ let depthLimit = this.getPropValueWithoutNull("depthLimit", -1);
22
+ let newDepthLimit = depthLimit;
23
+ if(depthLimit > 0) {
24
+ newDepthLimit = depthLimit-1;
25
+ }
26
+ let canAddChilds = (depthLimit !== 0);
21
27
 
22
28
  return React.createElement("div", {},
23
29
  React.createElement(Dbm.react.context.AddItemToContext, {"item": Dbm.react.source.contextVariable("hierarchyItem.linkedItem")},
@@ -50,14 +56,16 @@ export default class DraggableHierarchyDisplay extends Dbm.react.BaseObject {
50
56
  React.createElement("div", {className: "spacing small"}),
51
57
  React.createElement(Dbm.react.area.HasData, {check: Dbm.react.source.contextVariable("hierarchyItem.properties.children"), checkType: "notEmpty"},
52
58
  React.createElement(Dbm.react.area.List, {items: Dbm.react.source.contextVariable("hierarchyItem.properties.children"), as: "hierarchyItem"},
53
- React.createElement(Dbm.react.admin.objects.itemeditors.DraggableHierarchyDisplay, {}, children),
59
+ React.createElement(Dbm.react.admin.objects.itemeditors.DraggableHierarchyDisplay, {depthLimit: newDepthLimit}, children),
54
60
  React.createElement("div", {"data-slot": "spacing", className: "spacing small"}),
55
61
  ),
56
62
  React.createElement("div", {className: "spacing small"})
57
63
  ),
58
- React.createElement(Dbm.react.interaction.drag.DraggableItem, {skipDraggable: true, moveMode: "appendChild"},
59
- React.createElement("div", {className: "append-drop-position centered-cell-holder"},
60
- React.createElement("div", {})
64
+ React.createElement(Dbm.react.area.HasData, {check: canAddChilds},
65
+ React.createElement(Dbm.react.interaction.drag.DraggableItem, {skipDraggable: true, moveMode: "appendChild"},
66
+ React.createElement("div", {className: "append-drop-position centered-cell-holder"},
67
+ React.createElement("div", {})
68
+ )
61
69
  )
62
70
  )
63
71
  )
@@ -348,6 +348,7 @@ export default class HierarchyOrderedRelationsList extends Dbm.react.BaseObject
348
348
 
349
349
  let label = this.getPropValue("label");
350
350
  let children = this.getPropValue("children");
351
+ let depthLimit = this.getPropValueWithoutNull("depthLimit", -1);
351
352
 
352
353
  return React.createElement("div", {},
353
354
  React.createElement(Dbm.react.context.AddContextVariables, {"values": {"dragController": this, "hierarchyController": this}},
@@ -355,7 +356,7 @@ export default class HierarchyOrderedRelationsList extends Dbm.react.BaseObject
355
356
  React.createElement("div", {"className": ""},
356
357
  React.createElement(Dbm.react.area.List, {items: this.item.hierarchy.properties.children, as: "hierarchyItem"},
357
358
  React.createElement(Dbm.react.context.AddItemToContext, {"item": Dbm.react.source.contextVariable("hierarchyItem.linkedItem")},
358
- React.createElement(Dbm.react.admin.objects.itemeditors.DraggableHierarchyDisplay, {},
359
+ React.createElement(Dbm.react.admin.objects.itemeditors.DraggableHierarchyDisplay, {depthLimit: depthLimit},
359
360
  children
360
361
  )
361
362
  ),
@@ -591,7 +591,7 @@ export let registerAllBlocks = function() {
591
591
  pageEditors.push(newEditor);
592
592
  }
593
593
 
594
- {
594
+ {
595
595
  let objectTypeEditor = Dbm.getInstance().repository.getItem("admin/objectTypeEditors/emailTemplate");
596
596
  if(!objectTypeEditor.editors) {
597
597
  objectTypeEditor.setValue("editors", []);
@@ -611,6 +611,47 @@ export let registerAllBlocks = function() {
611
611
  objectTypeEditor.editors = newArray;
612
612
  }
613
613
 
614
+ {
615
+ let objectTypeEditor = Dbm.getInstance().repository.getItem("admin/objectTypeEditors/group/reviewGroup");
616
+ if(!objectTypeEditor.editors) {
617
+ objectTypeEditor.setValue("editors", []);
618
+ }
619
+
620
+ let newArray = [].concat(objectTypeEditor.editors);
621
+
622
+ {
623
+ let itemEditor = new Dbm.repository.Item();
624
+ itemEditor.setValue("element", createElement(Dbm.react.admin.objects.itemeditors.HierarchyOrderedRelationsList, {
625
+ "label": "Reviews",
626
+ "direction": "in",
627
+ "relationType": "in",
628
+ "objectType": "groupItem",
629
+ "orderFieldName": "order",
630
+ "depthLimit": 0
631
+ },
632
+ createElement("div", {"className": ""},
633
+ createElement(Dbm.react.admin.EditObject, {"item": Dbm.react.source.item()},
634
+ createElement("div", {"className": "flex-row small-item-spacing"},
635
+ createElement("div", {"className": "flex-row-item flex-resize"},
636
+ createElement(Dbm.react.admin.objects.itemeditors.SingleRelation, {
637
+ "direction": "out",
638
+ "relationType": "for",
639
+ "objectType": "review",
640
+ encoding: "name",
641
+ nameField: "name"
642
+ })
643
+ )
644
+ )
645
+
646
+ )
647
+ )
648
+ ));
649
+ newArray.push(itemEditor);
650
+ }
651
+
652
+ objectTypeEditor.editors = newArray;
653
+ }
654
+
614
655
  admin.pageEditors = pageEditors;
615
656
 
616
657
  {