dbm 1.4.13 → 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.
@@ -134,6 +134,7 @@ export default class ItemEditor extends Dbm.core.BaseObject {
134
134
  }
135
135
 
136
136
  addMultipleIncomingRelationsEditor(aType, aObjectType, aInitialValue, aUpdateEncoding = null) {
137
+ //console.log("addMultipleIncomingRelationsEditor");
137
138
  let name = "in_" + aType + "_" + aObjectType;
138
139
  return this._addMultipleRelationsEditor(name, aType, aObjectType, aInitialValue, Dbm.graphapi.webclient.admin.SaveFunctions.multipleIncomingRelations, aUpdateEncoding);
139
140
  }
@@ -144,6 +145,7 @@ export default class ItemEditor extends Dbm.core.BaseObject {
144
145
  }
145
146
 
146
147
  getAdminMultipleIncomingRelationsEditor(aType, aObjectType) {
148
+ //console.log("getAdminMultipleIncomingRelationsEditor");
147
149
  let name = "in_" + aType + "_" + aObjectType;
148
150
  let valueEditor = this.item["editor_multipleRelations_" + name];
149
151
  if(!valueEditor) {
@@ -39,7 +39,12 @@ export default class Relations extends Dbm.graphapi.webclient.decode.DecodeBaseO
39
39
  let relation = Dbm.getRepositoryItem(currentRelationData["relationId"]);
40
40
  if(typeItem.relations.indexOf(relation) === -1) {
41
41
  let linkedItem = Dbm.getRepositoryItem(currentRelationData["id"]);
42
- //METODO: add data to relation
42
+
43
+ relation.setValue("from", linkedItem);
44
+ relation.setValue("to", aItem);
45
+ relation.setValue("startAt", currentRelationData["startAt"]);
46
+ relation.setValue("endAt", currentRelationData["endAt"]);
47
+
43
48
  if(this._isRelationValid(currentRelationData["startAt"], currentRelationData["endAt"])) {
44
49
  typeItem.addToArray("objects", linkedItem);
45
50
  typeItem.addToArray("relations", relation);
@@ -72,7 +77,12 @@ export default class Relations extends Dbm.graphapi.webclient.decode.DecodeBaseO
72
77
  let relation = Dbm.getRepositoryItem(currentRelationData["relationId"]);
73
78
  if(typeItem.relations.indexOf(relation) === -1) {
74
79
  let linkedItem = Dbm.getRepositoryItem(currentRelationData["id"]);
75
- //METODO: add data to relation
80
+
81
+ relation.setValue("from", aItem);
82
+ relation.setValue("to", linkedItem);
83
+ relation.setValue("startAt", currentRelationData["startAt"]);
84
+ relation.setValue("endAt", currentRelationData["endAt"]);
85
+
76
86
  if(this._isRelationValid(currentRelationData["startAt"], currentRelationData["endAt"])) {
77
87
  typeItem.addToArray("objects", linkedItem);
78
88
  typeItem.addToArray("relations", relation);
@@ -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.13",
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
  {
@@ -0,0 +1,34 @@
1
+ import Dbm from "../../index.js";
2
+ import React from "react";
3
+
4
+ export default class GlobalFilters extends Dbm.core.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this._styleTag = null;
9
+
10
+ let colorFilters = Dbm.getRepositoryItem("globalSvg");
11
+ let filtersProperty = colorFilters.requireProperty("filters", []);
12
+
13
+ filtersProperty.addUpdate(this._getScopedCallFunctionCommand(this._updateStyles));
14
+ this._updateStyles();
15
+ }
16
+
17
+ _updateStyles() {
18
+ console.log("_updateStyles");
19
+
20
+ let colorFilters = Dbm.getRepositoryItem("globalSvg");
21
+ console.log(colorFilters.filters.length);
22
+
23
+ if(colorFilters.filters.length) {
24
+ if(!this._styleTag) {
25
+ this._styleTag = document.createElement("style");
26
+ document.head.appendChild(this._styleTag);
27
+ }
28
+
29
+ let declarations = Dbm.utils.ArrayFunctions.mapField(colorFilters.filters, "classDeclaration");
30
+ this._styleTag.innerHTML = declarations.join("\n");
31
+ console.log(declarations);
32
+ }
33
+ }
34
+ }
@@ -3,6 +3,7 @@ import React from "react";
3
3
 
4
4
  export {default as GlobalFilters} from "./GlobalFilters.js";
5
5
  export {default as MatrixFilter} from "./MatrixFilter.js";
6
+ export {default as AddGlobalFilterClasses} from "./AddGlobalFilterClasses.js";
6
7
 
7
8
  export const addGlobalRgbColorFilter = function(aName, aR, aG, aB) {
8
9
 
@@ -11,6 +12,7 @@ export const addGlobalRgbColorFilter = function(aName, aR, aG, aB) {
11
12
 
12
13
  let item = Dbm.getRepositoryItem("globalSvg/filters/" + aName);
13
14
  item.setValue("element", React.createElement(Dbm.react.svg.MatrixFilter, {"id": aName, "matrix": Dbm.utils.svg.ColorMatrixFunctions.floodColor(aR, aG, aB)}));
15
+ item.setValue("classDeclaration", "." + aName + "{filter:url(\"#" + aName + "\")}");
14
16
 
15
17
  let filters = [].concat(colorFilters.filters);
16
18
  filters.push(item);