dbm 1.1.11 → 1.1.13

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 (45) hide show
  1. package/core/source/SourceBaseObject.js +8 -0
  2. package/flow/controllers/transform/SingleArrayValues.js +125 -0
  3. package/flow/controllers/transform/index.js +2 -1
  4. package/graphapi/webclient/CachedRequests.js +2 -4
  5. package/graphapi/webclient/GraphApi.js +2 -2
  6. package/graphapi/webclient/admin/ImageUploader.js +81 -0
  7. package/graphapi/webclient/admin/ItemEditor.js +62 -0
  8. package/graphapi/webclient/admin/SaveFunctions.js +34 -0
  9. package/graphapi/webclient/admin/index.js +2 -0
  10. package/graphapi/webclient/decode/Relations.js +77 -0
  11. package/graphapi/webclient/decode/index.js +38 -6
  12. package/package.json +1 -1
  13. package/react/BaseObject.js +1 -1
  14. package/react/admin/EditPage.js +25 -1
  15. package/react/admin/SelectedImage.js +48 -0
  16. package/react/admin/editor/fields/SelectObjectsField.js +80 -0
  17. package/react/admin/editor/fields/index.js +1 -0
  18. package/react/admin/editorsgroup/EditField.js +1 -3
  19. package/react/admin/editorsgroup/EditItem.js +43 -0
  20. package/react/admin/editorsgroup/index.js +2 -1
  21. package/react/admin/index.js +1 -0
  22. package/react/admin/objects/RunObjectCommands.js +55 -0
  23. package/react/admin/objects/index.js +1 -0
  24. package/react/admin/objects/itemeditors/Name.js +1 -1
  25. package/react/admin/objects/itemeditors/Title.js +1 -1
  26. package/react/admin/website/EditLocalBusiness.js +87 -86
  27. package/react/admin/website/EditWebsite.js +64 -10
  28. package/react/area/HasData.js +23 -4
  29. package/react/area/index.js +14 -1
  30. package/react/blocks/admin/objects/RunObjectCommands.js +32 -0
  31. package/react/blocks/admin/objects/index.js +2 -1
  32. package/react/blocks/content/ContentBlock.js +3 -4
  33. package/react/blocks/faq/AskAQuestion.js +25 -36
  34. package/react/blocks/index.js +1 -0
  35. package/react/context/AddItemByIdToContext.js +24 -0
  36. package/react/context/index.js +2 -1
  37. package/react/form/EditArray.js +43 -0
  38. package/react/form/GraphApiImage.js +92 -0
  39. package/react/form/GraphApiObjectSelection.js +1 -1
  40. package/react/form/GraphApiSelectOrCreateObject.js +71 -0
  41. package/react/form/TextArea.js +31 -0
  42. package/react/form/index.js +5 -1
  43. package/utils/ArrayFunctions.js +24 -2
  44. package/utils/CompareFunctions.js +45 -0
  45. package/utils/index.js +2 -1
@@ -24,6 +24,14 @@ export default class SourceBaseObject extends Dbm.core.BaseObject {
24
24
 
25
25
  if(this._log) {
26
26
  console.log("Source>>>>>", baseObject, path);
27
+ let currentPath = "";
28
+ let currentArray = path.split(".");
29
+ let currentArrayLength = currentArray.length;
30
+ for(let i = 0; i < currentArrayLength; i++) {
31
+ currentPath += currentArray[i];
32
+ console.log(currentPath, Dbm.objectPath(baseObject, currentPath));
33
+ currentPath += ".";
34
+ }
27
35
  }
28
36
 
29
37
  if(!path) {
@@ -0,0 +1,125 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class SingleArrayValues extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+
7
+ this.item.requireProperty("array", []);
8
+ this.item.requireProperty("items", []);
9
+
10
+ let arrayUpdatedCommand = Dbm.commands.callFunction(this._arrayUpdated.bind(this));
11
+ Dbm.flow.addUpdateCommand(this.item.properties.array, arrayUpdatedCommand);
12
+
13
+ this._valueUpdatedCommand = Dbm.commands.callFunction(this._valueUpdated.bind(this));
14
+
15
+ }
16
+
17
+ _createItem(aInitialValue = null) {
18
+ let newItem = new Dbm.repository.Item();
19
+ newItem.setId("_dbmInternal/" + Dbm.getInstance().getNextId());
20
+ Dbm.flow.addUpdateCommand(newItem.requireProperty("value", aInitialValue), this._valueUpdatedCommand);
21
+
22
+ return newItem;
23
+ }
24
+
25
+ push(aValue = null) {
26
+ let item = this._createItem(aValue);
27
+
28
+ let dataArray = [].concat(this.item.array);
29
+ let itemsArray = [].concat(this.item.items);
30
+
31
+ itemsArray.push(item);
32
+ dataArray.push(aValue);
33
+
34
+ this.item.items = itemsArray;
35
+ this.item.properties.array.getMostUpstreamProperty().value = dataArray;
36
+ }
37
+
38
+ removeItem(aItem) {
39
+ //console.log("removeItem");
40
+ //console.log(aItem);
41
+
42
+ let dataArray = [].concat(this.item.array);
43
+ let itemsArray = [].concat(this.item.items);
44
+
45
+ let index = itemsArray.indexOf(aItem);
46
+ if(index >= 0) {
47
+ itemsArray.splice(index, 1);
48
+ dataArray.splice(index, 1);
49
+
50
+ this.item.items = itemsArray;
51
+ this.item.properties.array.getMostUpstreamProperty().value = dataArray;
52
+ }
53
+ }
54
+
55
+ _movePosition(aFromIndex, aToIndex) {
56
+ //METODO
57
+ }
58
+
59
+ moveItem(aItem, aPosition) {
60
+ let index = this.item.items.indexOf(aItem);
61
+ if(index >= 0) {
62
+ this._movePosition(index, aPosition);
63
+ }
64
+ }
65
+
66
+ moveUpItem(aItem, aPosition) {
67
+
68
+ let index = this.item.items.indexOf(aItem);
69
+ if(index >= 0) {
70
+ if(index > 0) {
71
+ this._movePosition(index, index-1);
72
+ }
73
+ }
74
+ }
75
+
76
+ moveDownItem(aItem, aPosition) {
77
+ let index = this.item.items.indexOf(aItem);
78
+ if(index >= 0) {
79
+ if(index < this.item.items.length-1) {
80
+ this._movePosition(index, index+1);
81
+ }
82
+ }
83
+ }
84
+
85
+ _arrayUpdated() {
86
+ console.log("_arrayUpdated");
87
+
88
+ let dataArray = this.item.array;
89
+ let itemsArray = this.item.items;
90
+
91
+ let dataLength = dataArray.length;
92
+ let itemsLength = itemsArray.length;
93
+ let itemChange = dataLength-itemsLength;
94
+ if(itemChange !== 0) {
95
+ itemsArray = [].concat(itemsArray);
96
+ if(itemChange < 0) {
97
+ itemsArray.splice(itemsArray.length, Math.abs(itemChange));
98
+ }
99
+ else if(itemChange > 0) {
100
+ for(let i = 0; i < itemChange; i++) {
101
+ itemsArray.push(this._createItem(dataArray[itemsLength+i]));
102
+ }
103
+ }
104
+ }
105
+
106
+ let currentArray = dataArray;
107
+ let currentArrayLength = currentArray.length;
108
+ for(let i = 0; i < currentArrayLength; i++) {
109
+ itemsArray[i].value = currentArray[i];
110
+ }
111
+
112
+ if(itemChange !== 0) {
113
+ this.item.items = itemsArray;
114
+ }
115
+
116
+ }
117
+
118
+ _valueUpdated() {
119
+ console.log("_valueUpdated");
120
+
121
+ let values = Dbm.utils.ArrayFunctions.mapField(this.item.items, "value");
122
+ console.log(values);
123
+ this.item.properties.array.getMostUpstreamProperty().value = values;
124
+ }
125
+ }
@@ -1 +1,2 @@
1
- export {default as PartOfObject} from "./PartOfObject.js";
1
+ export {default as PartOfObject} from "./PartOfObject.js";
2
+ export {default as SingleArrayValues} from "./SingleArrayValues.js";
@@ -42,10 +42,9 @@ export default class CachedRequests extends Dbm.core.BaseObject {
42
42
  }
43
43
 
44
44
  requestRange(aSelect, aEncode) {
45
- console.log("requestRange");
45
+ //console.log("requestRange");
46
46
 
47
47
  let id = this._getRangeIdentifier(aSelect, aEncode);
48
- console.log(id);
49
48
 
50
49
  if(this._ranges[id]) {
51
50
  return this._ranges[id];
@@ -59,10 +58,9 @@ export default class CachedRequests extends Dbm.core.BaseObject {
59
58
  }
60
59
 
61
60
  requestItem(aId, aEncode) {
62
- console.log("requestItem");
61
+ //console.log("requestItem");
63
62
 
64
63
  let id = aId + "/" + this._getEncodeIdentifier(aEncode);
65
- console.log(id);
66
64
 
67
65
  if(this._items[id]) {
68
66
  return this._items[id];
@@ -21,7 +21,7 @@ export default class GraphApi extends Dbm.core.BaseObject {
21
21
  }
22
22
 
23
23
  requestRange(aSelect, aEncode) {
24
- console.log("requestRange");
24
+ //console.log("requestRange");
25
25
 
26
26
  if(this._websocketConnection && this._websocketConnection.item.status === 1) {
27
27
  return this._websocketConnection.requestRange(aSelect, aEncode);
@@ -31,7 +31,7 @@ export default class GraphApi extends Dbm.core.BaseObject {
31
31
  }
32
32
 
33
33
  requestItem(aId, aEncode) {
34
- console.log("requestItem");
34
+ //console.log("requestItem");
35
35
 
36
36
  if(this._websocketConnection && this._websocketConnection.item.status === 1) {
37
37
  return this._websocketConnection.requestItem(aId, aEncode);
@@ -0,0 +1,81 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class ImageUploader extends Dbm.core.BaseObject {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.item.requireProperty("file", null);
9
+ this.item.requireProperty("status", 0);
10
+ this.item.requireProperty("item", null);
11
+
12
+ this._fileUploadedBound = this._fileUploaded.bind(this);
13
+ }
14
+
15
+ setFile(aFile) {
16
+ this.item.file = aFile;
17
+ return this;
18
+ }
19
+
20
+ uploadImage() {
21
+ console.log("uploadImage");
22
+ if(this.item.status !== 0) {
23
+ console.warn("Image is already uploading", this);
24
+ return this;
25
+ }
26
+
27
+ let file = this.item.file;
28
+ if(!file) {
29
+ console.warn("No file set", this);
30
+ return this;
31
+ }
32
+
33
+ this.item.status = 2;
34
+
35
+ let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
36
+
37
+ let preSign = graphApi.requestData("fileUpload", {"fileName": file.name, "mimeType": file.type});
38
+
39
+ Dbm.flow.addDirectUpdateCommand(preSign.getProperty("status"), Dbm.commands.callFunction(this._statusChanged.bind(this), [preSign, file]));
40
+
41
+ return this;
42
+ }
43
+
44
+ _statusChanged(aPreSign, aFile) {
45
+ console.log("_statusChanged");
46
+ console.log(aPreSign, aFile);
47
+
48
+ let item = Dbm.getInstance().repository.getItem(aPreSign.data.id);
49
+ item.setValue("name", aPreSign.data.name);
50
+ item.setValue("url", aPreSign.data.publicUrl);
51
+ item.setValue("resizeUrl", aPreSign.data.publicResizeUrl);
52
+ item.setValue("identifier", aPreSign.data.identifier);
53
+ this.item.item = item;
54
+
55
+ if(aPreSign.status === 1) {
56
+ let url = aPreSign.data.url;
57
+ console.log(url, aPreSign.data);
58
+
59
+ let headers = {
60
+ 'Content-Type': aFile.type,
61
+ 'Cache-Control': 'no-cache',
62
+ };
63
+
64
+ let additionalHeaders = aPreSign.data.additionalHeaders;
65
+ for(let objectName in additionalHeaders) {
66
+ headers[objectName] = additionalHeaders[objectName];
67
+ }
68
+
69
+ fetch(url, {method: 'PUT', headers: new Headers(headers), body: aFile}).then(this._fileUploadedBound)
70
+
71
+ }
72
+ }
73
+
74
+ _fileUploaded() {
75
+ console.log("_fileUploaded");
76
+
77
+ this.item.status = 1;
78
+
79
+ console.log("Uploaded", this.item.item);
80
+ }
81
+ }
@@ -42,6 +42,68 @@ 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
+ _addRelationEditor(aName, aType, aObjectType, aInitialValue, aSaveFunction, aUpdateEncoding = null) {
46
+ let valueEditor = this.item["editor_relation_" + aName];
47
+ if(!valueEditor) {
48
+ valueEditor = new Dbm.graphapi.webclient.admin.ValueEditor();
49
+ valueEditor.item.editValue.setInitialValue(aInitialValue);
50
+
51
+ valueEditor.item.setValue("itemEditor", this.item);
52
+ valueEditor.item.setValue("type", aType);
53
+ valueEditor.item.setValue("objectType", aObjectType);
54
+ valueEditor.item.setValue("updateEncoding", aUpdateEncoding);
55
+
56
+ this.item.anyChange.addCheck(valueEditor.item.properties.changed);
57
+ this.item.setValue("editor_relation_" + aName, valueEditor);
58
+ this.item.editors = [].concat(this.item.editors, valueEditor);
59
+
60
+ valueEditor.addSaveFunction(aSaveFunction);
61
+ }
62
+
63
+ return valueEditor;
64
+ }
65
+
66
+ addIncomingRelationEditor(aType, aObjectType, aInitialValue, aUpdateEncoding = null) {
67
+ let name = "in_" + aType + "_" + aObjectType;
68
+ return this._addRelationEditor(name, aType, aObjectType, aInitialValue, Dbm.graphapi.webclient.admin.SaveFunctions.incomingRelation, aUpdateEncoding);
69
+ }
70
+
71
+ addOutgoingRelationEditor(aType, aObjectType, aInitialValue, aUpdateEncoding = null) {
72
+ let name = "out_" + aType + "_" + aObjectType;
73
+ return this._addRelationEditor(name, aType, aObjectType, aInitialValue, Dbm.graphapi.webclient.admin.SaveFunctions.outgoingRelation, aUpdateEncoding);
74
+ }
75
+
76
+ _addMultipleRelationsEditor(aName, aType, aObjectType, aInitialValue, aSaveFunction, aUpdateEncoding = null) {
77
+ let valueEditor = this.item["editor_relation_" + aName];
78
+ if(!valueEditor) {
79
+ valueEditor = new Dbm.graphapi.webclient.admin.ValueEditor();
80
+ valueEditor.item.editValue.setInitialValue(aInitialValue);
81
+
82
+ valueEditor.item.setValue("itemEditor", this.item);
83
+ valueEditor.item.setValue("type", aType);
84
+ valueEditor.item.setValue("objectType", aObjectType);
85
+ valueEditor.item.setValue("updateEncoding", aUpdateEncoding);
86
+
87
+ this.item.anyChange.addCheck(valueEditor.item.properties.changed);
88
+ this.item.setValue("editor_multipleRelations_" + aName, valueEditor);
89
+ this.item.editors = [].concat(this.item.editors, valueEditor);
90
+
91
+ valueEditor.addSaveFunction(aSaveFunction);
92
+ }
93
+
94
+ return valueEditor;
95
+ }
96
+
97
+ addMultipleIncomingRelationsEditor(aType, aObjectType, aInitialValue, aUpdateEncoding = null) {
98
+ let name = "in_" + aType + "_" + aObjectType;
99
+ return this._addMultipleRelationsEditor(name, aType, aObjectType, aInitialValue, Dbm.graphapi.webclient.admin.SaveFunctions.multipleIncomingRelations, aUpdateEncoding);
100
+ }
101
+
102
+ addMultipleOutgoingRelationsEditor(aType, aObjectType, aInitialValue, aUpdateEncoding = null) {
103
+ let name = "out_" + aType + "_" + aObjectType;
104
+ return this._addMultipleRelationsEditor(name, aType, aObjectType, aInitialValue, Dbm.graphapi.webclient.admin.SaveFunctions.multipleOutgoingRelations, aUpdateEncoding);
105
+ }
106
+
45
107
  addCommandsToSaveData(aSaveData) {
46
108
 
47
109
  let editedItemId = Dbm.objectPath(this.item, "editedItem.id");
@@ -1,7 +1,41 @@
1
+ import Dbm from "../../../index.js";
2
+
1
3
  export const setField = function(aEditor, aItemSaveData) {
2
4
  aItemSaveData.setField(aEditor.item.name, aEditor.item.editValue.getValue());
3
5
  }
4
6
 
5
7
  export const setUrl = function(aEditor, aItemSaveData) {
6
8
  aItemSaveData.createChange("setUrl", {"value": aEditor.item.editValue.getValue()});
9
+ }
10
+
11
+ export const setIdentifier = function(aEditor, aItemSaveData) {
12
+ aItemSaveData.createChange("setIdentifier", {"value": aEditor.item.editValue.getValue()});
13
+ }
14
+
15
+ export const setVisibility = function(aEditor, aItemSaveData) {
16
+ aItemSaveData.createChange("setVisibility", {"value": aEditor.item.editValue.getValue()});
17
+ }
18
+
19
+ export const incomingRelation = function(aEditor, aItemSaveData) {
20
+ let id = aEditor.item.editValue.getValue();
21
+
22
+ aItemSaveData.createChange("replaceIncomingRelation", {"value": id, "type": aEditor.item.type, "objectType": aEditor.item.objectType});
23
+ }
24
+
25
+ export const outgoingRelation = function(aEditor, aItemSaveData) {
26
+ let id = aEditor.item.editValue.getValue();
27
+
28
+ aItemSaveData.createChange("replaceOutgoingRelation", {"value": id, "type": aEditor.item.type, "objectType": aEditor.item.objectType});
29
+ }
30
+
31
+ export const multipleIncomingRelations = function(aEditor, aItemSaveData) {
32
+ let ids = Dbm.utils.ArrayFunctions.removeValues(aEditor.item.editValue.getValue(), [0, null, undefined]);
33
+
34
+ aItemSaveData.createChange("replaceMultipleIncomingRelations", {"value": ids, "type": aEditor.item.type, "objectType": aEditor.item.objectType});
35
+ }
36
+
37
+ export const multipleOutgoingRelations = function(aEditor, aItemSaveData) {
38
+ let ids = Dbm.utils.ArrayFunctions.removeValues(aEditor.item.editValue.getValue(), [0, null, undefined]);
39
+
40
+ aItemSaveData.createChange("replaceMultipleOutgoingRelations", {"value": ids, "type": aEditor.item.type, "objectType": aEditor.item.objectType});
7
41
  }
@@ -5,4 +5,6 @@ export {default as EditorGroup} from "./EditorGroup.js";
5
5
  export {default as ItemEditor} from "./ItemEditor.js";
6
6
  export {default as ValueEditor} from "./ValueEditor.js";
7
7
 
8
+ export {default as ImageUploader} from "./ImageUploader.js";
9
+
8
10
  export * as SaveFunctions from "./SaveFunctions.js";
@@ -0,0 +1,77 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class Relations extends Dbm.graphapi.webclient.decode.DecodeBaseObject {
4
+ _construct() {
5
+ super._construct();
6
+ }
7
+
8
+ _isRelationValid(aStartTime, aEndTime) {
9
+ let now = (new Date()).toISOString().split("T").join(" ").substring(0, 19);
10
+
11
+ return ((aStartTime === null || aStartTime <= now) && (aEndTime === null || aEndTime > now));
12
+ }
13
+
14
+ updateItem(aItem, aData) {
15
+ super.updateItem(aItem, aData);
16
+
17
+ let relations = aData["relations"];
18
+ {
19
+ let currentRelations = relations["in"];
20
+ let currentRelationsItem = aItem["relations/in"];
21
+ if(!currentRelationsItem) {
22
+ currentRelationsItem = new Dbm.repository.Item();
23
+ aItem.setValue("relations/in", currentRelationsItem);
24
+ }
25
+
26
+ let currentArray = currentRelations;
27
+ let currentArrayLength = currentArray.length;
28
+ for(let i = 0; i < currentArrayLength; i++) {
29
+ let currentRelationData = currentArray[i];
30
+ let currentType = currentRelationData["type"];
31
+ let typeItem = currentRelationsItem[currentType];
32
+ if(!typeItem) {
33
+ typeItem = new Dbm.repository.Item();
34
+ typeItem.setValue("objects", []);
35
+ currentRelationsItem.setValue(currentType, typeItem);
36
+ }
37
+
38
+ if(this._isRelationValid(currentRelationData["startAt"], currentRelationData["endAt"])) {
39
+ let newArray = [].concat(typeItem["objects"]);
40
+ newArray.push(Dbm.getInstance().repository.getItem(currentRelationData["id"]));
41
+ typeItem["objects"] = newArray;
42
+ //METODO: set up relations
43
+ }
44
+
45
+ }
46
+ }
47
+
48
+ {
49
+ let currentRelations = relations["out"];
50
+ let currentRelationsItem = aItem["relations/out"];
51
+ if(!currentRelationsItem) {
52
+ currentRelationsItem = new Dbm.repository.Item();
53
+ aItem.setValue("relations/out", currentRelationsItem);
54
+ }
55
+
56
+ let currentArray = currentRelations;
57
+ let currentArrayLength = currentArray.length;
58
+ for(let i = 0; i < currentArrayLength; i++) {
59
+ let currentRelationData = currentArray[i];
60
+ let currentType = currentRelationData["type"];
61
+ let typeItem = currentRelationsItem[currentType];
62
+ if(!typeItem) {
63
+ typeItem = new Dbm.repository.Item();
64
+ typeItem.setValue("objects", []);
65
+ currentRelationsItem.setValue(currentType, typeItem);
66
+ }
67
+
68
+ if(this._isRelationValid(currentRelationData["startAt"], currentRelationData["endAt"])) {
69
+ let newArray = [].concat(typeItem["objects"]);
70
+ newArray.push(Dbm.getInstance().repository.getItem(currentRelationData["id"]));
71
+ typeItem["objects"] = newArray;
72
+ //METODO: set up relations
73
+ }
74
+ }
75
+ }
76
+ }
77
+ }
@@ -1,6 +1,7 @@
1
1
  import Dbm from "../../../index.js";
2
2
 
3
3
  export {default as DecodeBaseObject} from "./DecodeBaseObject.js";
4
+ export {default as Relations} from "./Relations.js";
4
5
 
5
6
  export const fullSetup = function() {
6
7
  let decodePrefix = "graphApi/decode/";
@@ -135,10 +136,41 @@ export const fullSetup = function() {
135
136
  }
136
137
 
137
138
  {
138
- let name = "helpSection";
139
- let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
140
- currentDecoder.item.setValue("copyFields", ["title", "link"]);
141
- currentDecoder.item.setValue("encodingType", name);
142
- currentDecoder.item.register(decodePrefix + name);
143
- }
139
+ let name = "helpSection";
140
+ let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
141
+ currentDecoder.item.setValue("copyFields", ["title", "link"]);
142
+ currentDecoder.item.setValue("encodingType", name);
143
+ currentDecoder.item.register(decodePrefix + name);
144
+ }
145
+
146
+ {
147
+ let name = "relations";
148
+ let currentDecoder = new Dbm.graphapi.webclient.decode.Relations();
149
+ currentDecoder.item.setValue("encodingType", name);
150
+ currentDecoder.item.register(decodePrefix + name);
151
+ }
152
+
153
+ {
154
+ let name = "atLocation";
155
+ let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
156
+ currentDecoder.item.setValue("copyLink", ["location"]);
157
+ currentDecoder.item.setValue("encodingType", name);
158
+ currentDecoder.item.register(decodePrefix + name);
159
+ }
160
+
161
+ {
162
+ let name = "mainImage";
163
+ let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
164
+ currentDecoder.item.setValue("copyLink", ["image"]);
165
+ currentDecoder.item.setValue("encodingType", name);
166
+ currentDecoder.item.register(decodePrefix + name);
167
+ }
168
+
169
+ {
170
+ let name = "location";
171
+ let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
172
+ currentDecoder.item.setValue("copyFields", ["street", "postCode", "city", "country", "coordinates"]);
173
+ currentDecoder.item.setValue("encodingType", name);
174
+ currentDecoder.item.register(decodePrefix + name);
175
+ }
144
176
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbm",
3
- "version": "1.1.11",
3
+ "version": "1.1.13",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {},
@@ -32,7 +32,7 @@ export default class BaseObject extends Component {
32
32
  currentDynamicProperty.connectInput(currentProp);
33
33
  }
34
34
  else if(this._dynamicProps[objectName]) {
35
- let currentDynamicProperty = this.getDynamicProp(objectName);
35
+ let currentDynamicProperty = this._dynamicProps[objectName];
36
36
  currentDynamicProperty.value = currentProp;
37
37
  }
38
38
  }
@@ -114,6 +114,20 @@ export default class EditPage extends Dbm.react.BaseObject {
114
114
 
115
115
  }
116
116
 
117
+ _generateHelpSectionSuggestions() {
118
+
119
+ let page = this.context.page;
120
+
121
+ let editorGroup = this.item.editorGroup;
122
+ let itemEditor = editorGroup.getItemEditor(page.id);
123
+
124
+ let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
125
+
126
+ let request = graphApi.requestData("admin/helpSectionSuggestions", {"value": {"title": itemEditor.getEditor("title").item.editValue.getValue(), "content": itemEditor.getEditor("content").item.editValue.getValue()}});
127
+ Dbm.flow.addUpdateCommandWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._helpSectionSuggestionsLoaded.bind(this), [request]));
128
+
129
+ }
130
+
117
131
  _dataLoaded(aRequest) {
118
132
  let summary = Dbm.objectPath(aRequest, "data.seoSummary");
119
133
 
@@ -125,6 +139,13 @@ export default class EditPage extends Dbm.react.BaseObject {
125
139
  itemEditor.getEditor("meta/description").item.editValue.item.value = summary;
126
140
  }
127
141
 
142
+ _helpSectionSuggestionsLoaded(aRequest) {
143
+ console.log("_helpSectionSuggestionsLoaded");
144
+ let titles = Dbm.objectPath(aRequest, "data.titles");
145
+
146
+ console.log(aRequest, titles);
147
+ }
148
+
128
149
  _renderMainElement() {
129
150
 
130
151
  let page = this.context.page;
@@ -200,7 +221,10 @@ export default class EditPage extends Dbm.react.BaseObject {
200
221
  React.createElement(Dbm.react.form.FormField, {value: this.item.properties.importText}),
201
222
  React.createElement("div", {"className": "standard-button standard-button-padding", "onClick": () => {this._import()}},
202
223
  "Import"
203
- )
224
+ ),
225
+ React.createElement("div", {className: "flex-row-item"},
226
+ React.createElement("div", {onClick: () => {this._generateHelpSectionSuggestions()}, className: "action-button action-button-padding"}, "Dev: Help sections"),
227
+ ),
204
228
  ),
205
229
  React.createElement("div", {className: "spacing standard"}),
206
230
  React.createElement("div", {className: "save-all-position"},
@@ -0,0 +1,48 @@
1
+ import React from "react";
2
+ import Dbm from "../../index.js";
3
+
4
+ export default class SelectedImage extends Dbm.react.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+
8
+ let id = this.getPropValue("id");
9
+ this.item.requireProperty("item", null);
10
+ this.item.requireProperty("loaded", false);
11
+
12
+ let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
13
+ let request = graphApi.requestRange(
14
+ [
15
+ {"type": "idSelection", "ids": [id]}
16
+ ],
17
+ ["name", "image"]
18
+ );
19
+
20
+ Dbm.flow.addUpdateCommandWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._dataLoaded.bind(this), [request]));
21
+ }
22
+
23
+ _dataLoaded(aRequest) {
24
+ console.log("_dataLoaded");
25
+ console.log(aRequest);
26
+
27
+ this.item.item = aRequest.items[0];
28
+
29
+ this.item.loaded = true;
30
+ }
31
+
32
+ _renderMainElement() {
33
+ return React.createElement("div", {},
34
+ React.createElement(Dbm.react.area.HasData, {check: this.item.properties.item},
35
+ React.createElement(Dbm.react.context.AddItemToContext, {item: this.item.properties.item},
36
+ React.createElement("div", {className: "flex-row small-item-spacing"},
37
+ React.createElement("div", {className: "flex-row-item flex-no-resize"},
38
+ React.createElement(Dbm.react.image.WidthScaledImage, {"image": Dbm.react.source.contextVariable("item"), targetWidth: 120, className: "editor-preview background-contain"}),
39
+ ),
40
+ React.createElement("div", {className: "flex-row-item flex-resize", style: {wordBreak: "break-word", overflowWrap: "break-word"}},
41
+ Dbm.react.text.text(Dbm.react.source.contextVariable("item.url"))
42
+ )
43
+ )
44
+ )
45
+ )
46
+ );
47
+ }
48
+ }