dbm 1.1.23 → 1.2.1

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 (43) hide show
  1. package/core/source/FirstSource.js +36 -0
  2. package/core/source/index.js +21 -0
  3. package/dbm.js +16 -5
  4. package/flow/controllers/index.js +2 -1
  5. package/flow/controllers/timing/IntervalStep.js +60 -0
  6. package/flow/controllers/timing/index.js +1 -0
  7. package/flow/updatefunctions/animation/AnimateValue.js +39 -0
  8. package/flow/updatefunctions/animation/index.js +13 -0
  9. package/flow/updatefunctions/dom/ElementPosition.js +2 -4
  10. package/flow/updatefunctions/index.js +1 -0
  11. package/flow/updatefunctions/logic/FloatMod.js +26 -0
  12. package/flow/updatefunctions/logic/PositionedItems.js +1 -1
  13. package/flow/updatefunctions/logic/index.js +18 -0
  14. package/flow/updatefunctions/thirdparty/google/index.js +3 -0
  15. package/flow/updatefunctions/thirdparty/google/maps/AutoComplete.js +132 -0
  16. package/flow/updatefunctions/thirdparty/google/maps/index.js +3 -0
  17. package/flow/updatefunctions/thirdparty/index.js +2 -1
  18. package/graphapi/webclient/ApiConnection.js +1 -0
  19. package/graphapi/webclient/decode/index.js +16 -0
  20. package/package.json +1 -1
  21. package/react/admin/EditPage.js +2 -0
  22. package/react/admin/objects/EditObject.js +3 -0
  23. package/react/admin/pageeditors/LinkPreviews.js +98 -0
  24. package/react/admin/pageeditors/index.js +1 -0
  25. package/react/area/FixedWidthInfiniteSlideshow.js +50 -0
  26. package/react/area/List.js +4 -0
  27. package/react/area/index.js +1 -0
  28. package/react/blocks/content/LinkList.js +67 -0
  29. package/react/blocks/content/LinkListCard.js +83 -0
  30. package/react/blocks/content/index.js +3 -1
  31. package/react/blocks/index.js +22 -0
  32. package/react/form/Form.js +49 -0
  33. package/react/form/Option.js +18 -0
  34. package/react/form/index.js +3 -1
  35. package/react/image/CoverScaledImage.js +20 -1
  36. package/react/interaction/CommandButton.js +16 -3
  37. package/react/text/HtmlText.js +6 -1
  38. package/react/text/NumberDisplay.js +30 -0
  39. package/react/text/OptionalLink.js +21 -0
  40. package/react/text/index.js +2 -0
  41. package/utils/ArrayFunctions.js +16 -0
  42. package/utils/CompareFunctions.js +14 -0
  43. package/utils/UrlFunctions.js +22 -5
@@ -0,0 +1,36 @@
1
+ import Dbm from "../../index.js";
2
+
3
+ export default class FirstSource extends Dbm.core.source.SourceBaseObject {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.item.setValue("defaultValue", null);
9
+ this.item.setValue("sources", []);
10
+ }
11
+
12
+ getSource(aFromObject, aEventData = null) {
13
+ //console.log("getSource");
14
+
15
+ let currentArray = this.item.sources;
16
+ let currentArrayLength = currentArray.length;
17
+ for(let i = 0; i < currentArrayLength; i++) {
18
+ let currentSource = currentArray[i];
19
+
20
+ let value = currentSource.getSource(aFromObject, aEventData);
21
+ if(this._log) {
22
+ console.log("Source first>>>>>", i, currentSource, value);
23
+ }
24
+
25
+ if(value) {
26
+ return value;
27
+ }
28
+ }
29
+
30
+ if(this._log) {
31
+ console.log("Source first>>>>> default", this.item.defaultValue);
32
+ }
33
+
34
+ return this.item.defaultValue;
35
+ }
36
+ }
@@ -4,6 +4,7 @@ export {default as SourceBaseObject} from "./SourceBaseObject.js";
4
4
  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
+ export {default as FirstSource} from "./FirstSource.js";
7
8
 
8
9
  export const event = function(aPath = null) {
9
10
  let newSource = new Dbm.core.source.EventSource();
@@ -29,3 +30,23 @@ export const staticObject = function(aObject, aPath = null) {
29
30
 
30
31
  return newSource;
31
32
  }
33
+
34
+ export const first = function(...aSources) {
35
+ let newSource = new Dbm.core.source.FirstSource();
36
+
37
+ newSource.item.sources = [].concat(aSources);
38
+
39
+ return newSource;
40
+ }
41
+
42
+ export const firstWithDefault = function(...aSourcesAndDefault) {
43
+ let newSource = new Dbm.core.source.FirstSource();
44
+
45
+ let sources = [].concat(aSourcesAndDefault);
46
+ let defaultValue = sources.pop();
47
+
48
+ newSource.item.sources = sources;
49
+ newSource.item.properties.defaultValue.setOrConnect(defaultValue);
50
+
51
+ return newSource;
52
+ }
package/dbm.js CHANGED
@@ -1,16 +1,19 @@
1
1
  import {GlobalObject} from "./core/index.js";
2
2
 
3
- if(!globalThis.dbm) {
4
- globalThis.dbm = new GlobalObject();
3
+ export const setupGlobalInstance = function(aObject, aPath) {
4
+ if(!globalThis.dbm) {
5
+ globalThis.dbm = new GlobalObject();
6
+ }
5
7
  }
6
8
 
7
- export let getInstance = function() {
9
+
10
+ export const getInstance = function() {
8
11
  return globalThis.dbm;
9
12
  }
10
13
 
11
14
  //export {getInstance};
12
15
 
13
- export let objectPath = function(aObject, aPath) {
16
+ export const objectPath = function(aObject, aPath) {
14
17
  //console.log("objectPath");
15
18
 
16
19
  let currentObject = aObject;
@@ -57,7 +60,7 @@ export let objectPath = function(aObject, aPath) {
57
60
  return currentObject;
58
61
  }
59
62
 
60
- export let setAtObjectPath = function(aObject, aPath, aValue) {
63
+ export const setAtObjectPath = function(aObject, aPath, aValue) {
61
64
  aPath += "";
62
65
  if(aPath.length === 0) {
63
66
  return 0;
@@ -82,6 +85,14 @@ export let setAtObjectPath = function(aObject, aPath, aValue) {
82
85
  }
83
86
  }
84
87
 
88
+ export const getRepositoryItem = function(aName) {
89
+ return getInstance().repository.getItem(aName);
90
+ }
91
+
92
+ export const getGraphApi = function() {
93
+ return getRepositoryItem("graphApi").controller;
94
+ }
95
+
85
96
  export * as utils from "./utils/index.js";
86
97
  export * as core from "./core/index.js";
87
98
  export * as loading from "./loading/index.js";
@@ -1,4 +1,5 @@
1
1
  export * as select from "./select/index.js";
2
2
  export * as edit from "./edit/index.js";
3
3
  export * as transform from "./transform/index.js";
4
- export * as interaction from "./interaction/index.js";
4
+ export * as interaction from "./interaction/index.js";
5
+ export * as timing from "./timing/index.js";
@@ -0,0 +1,60 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class IntervalStep extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+
7
+ this.item.requireProperty("value", 0);
8
+ this.item.requireProperty("step", 1);
9
+ Dbm.flow.addUpdateCommand(this.item.requireProperty("interval", 1), Dbm.commands.callFunction(this.resetInterval.bind(this)));
10
+
11
+ this._started = false;
12
+ this._intervalId = -1;
13
+ this._callback_nextStepBound = this._callback_nextStep.bind(this);
14
+ }
15
+
16
+ start() {
17
+ this._started = true;
18
+ this._startInterval();
19
+
20
+ return this;
21
+ }
22
+
23
+ stop() {
24
+ this._started = false;
25
+ this._stopInterval();
26
+
27
+ return this;
28
+ }
29
+
30
+ setValue(aValue) {
31
+ this.item.properties.value.getMostUpstreamProperty().value = aValue;
32
+ this.resetInterval();
33
+
34
+ return this;
35
+ }
36
+
37
+ _callback_nextStep() {
38
+ this.item.properties.value.getMostUpstreamProperty().value += this.item.step;
39
+ }
40
+
41
+ _startInterval() {
42
+ if(this._intervalId === -1) {
43
+ this._intervalId = setInterval(this._callback_nextStepBound, this.item.interval*1000);
44
+ }
45
+ }
46
+
47
+ _stopInterval() {
48
+ if(this._intervalId !== -1) {
49
+ clearInterval(this._intervalId);
50
+ this._intervalId = -1;
51
+ }
52
+ }
53
+
54
+ resetInterval() {
55
+ if(this._started) {
56
+ this._stopInterval();
57
+ this._startInterval();
58
+ }
59
+ }
60
+ }
@@ -0,0 +1 @@
1
+ export {default as IntervalStep} from "./IntervalStep.js";
@@ -0,0 +1,39 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class AnimateValue extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this._animationInputValue = new Dbm.flow.FlowProperty();
9
+ this._animationInputValue.value = 0;
10
+ Dbm.flow.addUpdateCommand(this._animationInputValue, Dbm.commands.callFunction(this._updateAnimation.bind(this)));
11
+
12
+ this._animatedValue = new Dbm.flow.FlowProperty();
13
+ this._animatedValue.value = 0;
14
+ Dbm.flow.addUpdateCommand(this._animatedValue, Dbm.commands.callFunction(this._animationUpdated.bind(this)));
15
+
16
+ this.input.register("value", 0);
17
+ this._animationInputValue.connectInput(this.input.properties.value);
18
+ this.input.register("time", 0.5);
19
+ this.input.register("easing", null);
20
+ this.input.register("delay", 0);
21
+ this.output.register("value", 0);
22
+ }
23
+
24
+ _update() {
25
+ //console.log("_update");
26
+
27
+ //this._animationInputValue.value = this.input.value;
28
+ }
29
+
30
+ _updateAnimation() {
31
+ //console.log("_updateAnimation");
32
+ this._animatedValue.animateValue(this._animationInputValue.value, this.input.time, this.input.delay, this.input.easing);
33
+ }
34
+
35
+ _animationUpdated() {
36
+ //console.log("_animationUpdated");
37
+ this.output.properties.value._internal_setValueInFlowOutsideOfUpdate(this._animatedValue.value);
38
+ }
39
+ }
@@ -0,0 +1,13 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export {default as AnimateValue} from "./AnimateValue.js";
4
+
5
+ export let animateValue = function(aValue = 0, aTime = 0.5, aDelay = 0, aEasing = null) {
6
+ let updateFunction = new Dbm.flow.updatefunctions.animation.AnimateValue();
7
+ updateFunction.input.properties.value.setOrConnect(aValue);
8
+ updateFunction.input.properties.time.setOrConnect(aTime);
9
+ updateFunction.input.properties.delay.setOrConnect(aDelay);
10
+ updateFunction.input.properties.easing.setOrConnect(aEasing);
11
+
12
+ return updateFunction;
13
+ }
@@ -30,12 +30,10 @@ export default class ElementPosition extends Dbm.flow.FlowUpdateFunction {
30
30
  }
31
31
 
32
32
  _update() {
33
- console.log("_update");
33
+ //console.log("_update");
34
34
 
35
35
  let element = this.input.element;
36
36
 
37
- console.log(element, this.input.prepareX, this.input.prepareY);
38
-
39
37
  if(element) {
40
38
 
41
39
  //this.output.width = element.clientWidth;
@@ -85,7 +83,7 @@ export default class ElementPosition extends Dbm.flow.FlowUpdateFunction {
85
83
  }
86
84
 
87
85
  _callback_scroll(aEvent) {
88
- console.log("_callback_scroll");
86
+ //console.log("_callback_scroll");
89
87
 
90
88
  let element = this.input.element;
91
89
 
@@ -3,4 +3,5 @@ export * as debug from "./debug/index.js";
3
3
  export * as react from "./react/index.js";
4
4
  export * as basic from "./basic/index.js";
5
5
  export * as dom from "./dom/index.js";
6
+ export * as animation from "./animation/index.js";
6
7
  export * as thirdparty from "./thirdparty/index.js";
@@ -0,0 +1,26 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class FloatMod extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("input", 0);
9
+ this.input.register("min", 0);
10
+ this.input.register("max", 1);
11
+
12
+ this.output.register("result", 0);
13
+ }
14
+
15
+ _update() {
16
+ //console.log("_update");
17
+
18
+ let relativeValue = this.input.input-this.input.min;
19
+ let length = this.input.max-this.input.min;
20
+
21
+ let times = Math.floor(relativeValue/length);
22
+ let clampledValue = relativeValue-(length*times);
23
+
24
+ this.output.result = this.input.min+clampledValue;
25
+ }
26
+ }
@@ -1,6 +1,6 @@
1
1
  import Dbm from "../../../index.js";
2
2
 
3
- export default class PoisitonedItems extends Dbm.flow.FlowUpdateFunction {
3
+ export default class PositionedItems extends Dbm.flow.FlowUpdateFunction {
4
4
 
5
5
  _construct() {
6
6
  super._construct();
@@ -12,6 +12,7 @@ export {default as AllAtValue} from "./AllAtValue.js";
12
12
  export {default as WhenMatched} from "./WhenMatched.js";
13
13
  export {default as Invert} from "./Invert.js";
14
14
  export {default as PositionedItems} from "./PositionedItems.js";
15
+ export {default as FloatMod} from "./FloatMod.js";
15
16
 
16
17
  export let subtract = function(aInput1 = 0, aInput2 = 0) {
17
18
  let updateFunction = new Dbm.flow.updatefunctions.logic.Subtraction();
@@ -111,5 +112,22 @@ export let switchValue = function(aValue = null) {
111
112
  let updateFunction = new Dbm.flow.updatefunctions.logic.Switch();
112
113
  updateFunction.input.properties.value.setOrConnect(aValue);
113
114
 
115
+ return updateFunction;
116
+ }
117
+
118
+ export let floatMod = function(aValue = null, aMax = 1) {
119
+ let updateFunction = new Dbm.flow.updatefunctions.logic.FloatMod();
120
+ updateFunction.input.properties.input.setOrConnect(aValue);
121
+ updateFunction.input.properties.max.setOrConnect(aMax);
122
+
123
+ return updateFunction;
124
+ }
125
+
126
+ export let floatModRange = function(aValue = null, aMin = 0, aMax = 1) {
127
+ let updateFunction = new Dbm.flow.updatefunctions.logic.FloatMod();
128
+ updateFunction.input.properties.input.setOrConnect(aValue);
129
+ updateFunction.input.properties.min.setOrConnect(aMin);
130
+ updateFunction.input.properties.max.setOrConnect(aMax);
131
+
114
132
  return updateFunction;
115
133
  }
@@ -0,0 +1,3 @@
1
+ import Dbm from "../../../../index.js";
2
+
3
+ export * as maps from "./maps/index.js";
@@ -0,0 +1,132 @@
1
+ import Dbm from "../../../../../index.js";
2
+
3
+ export default class AutoComplete extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("text", "");
9
+ this.input.register("countries", []);
10
+ this.input.register("types", ["geocode"]);
11
+ this.input.register("language", "en");
12
+
13
+ this._loadedScript = false;
14
+ this._currentText = "";
15
+
16
+ this.output.register("updated", true);
17
+ this.output.register("results", []);
18
+ }
19
+
20
+ loadScript() {
21
+ let key = Dbm.getRepositoryItem("googleMapsApi").apiKey;
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
+ }
30
+
31
+ return this;
32
+ }
33
+
34
+ _scriptLoaded() {
35
+ console.log("_scriptLoaded");
36
+ if(!this._loadedScript) {
37
+ this._loadedScript = true;
38
+ this._update();
39
+ }
40
+ }
41
+
42
+ setLanguage(aLanguageCode) {
43
+ this.input.language = aLanguageCode;
44
+
45
+ return this;
46
+ }
47
+
48
+ setCountryRestrictions(aCountryCode) {
49
+ this.input.countries = Dbm.utils.ArrayFunctions.arrayOrSeparatedString(aCountryCode);
50
+
51
+ return this;
52
+ }
53
+
54
+ _update() {
55
+ console.log("_update");
56
+
57
+
58
+ let text = this.input.text;
59
+ this._currentText = text;
60
+ this.output.updated = false;
61
+
62
+ if(text) {
63
+ this.output.properties.results.isDirty = false;
64
+ this.output.properties.updated.isDirty = false;
65
+
66
+ if(this._loadedScript) {
67
+
68
+ let requestData = {
69
+ input: text,
70
+ language: this.input.language,
71
+ };
72
+
73
+ if(this.input.countries) {
74
+ requestData["includedRegionCodes"] = this.input.countries;
75
+ }
76
+ if(this.input.types) {
77
+ requestData["includedPrimaryTypes"] = this.input.types;
78
+ }
79
+
80
+ let request = google.maps.places.AutocompleteSuggestion.fetchAutocompleteSuggestions(requestData);
81
+
82
+ request.then((aResult) => {
83
+ let suggestions = aResult.suggestions;
84
+ this._resultsLoaded(text, Dbm.utils.ArrayFunctions.mapField(suggestions, "placePrediction"));
85
+ });
86
+ }
87
+ else {
88
+ this.loadScript();
89
+ }
90
+ }
91
+ else {
92
+ this.output.results = [];
93
+ this.output.updated = true;
94
+ }
95
+
96
+
97
+ }
98
+
99
+ _getResultDetails(aPlaceId) {
100
+
101
+ let place = new google.maps.places.Place({"id": aPlaceId});
102
+
103
+ let loadPromise = place.fetchFields({"fields": ["addressComponents"]});
104
+
105
+ loadPromise.then((aResult) => {
106
+ //console.log(place);
107
+ })
108
+ }
109
+
110
+ _resultsLoaded(aText, aPredictions) {
111
+ console.log("_resultsLoaded");
112
+ /*
113
+ for(let i = 0; i < aPredictions.length; i++) {
114
+ let currentPredition = aPredictions[i];
115
+
116
+ //console.log(currentPredition.text.text, currentPredition.mainText.text, currentPredition.secondaryText.text, currentPredition.placeId);
117
+ this._getResultDetails(currentPredition.placeId);
118
+ break;
119
+ }
120
+ */
121
+
122
+ //console.log(this.isDirty, this.output.properties.results.isDirty, this._currentText, aText);
123
+
124
+ if(this._currentText === aText) {
125
+ this.output.properties.results._internal_setValueInFlowOutsideOfUpdate(aPredictions);
126
+ this.output.properties.updated._internal_setValueInFlowOutsideOfUpdate(true);
127
+ }
128
+ }
129
+ }
130
+
131
+
132
+
@@ -0,0 +1,3 @@
1
+ import Dbm from "../../../../../index.js";
2
+
3
+ export {default as AutoComplete} from "./AutoComplete.js";
@@ -1 +1,2 @@
1
- export * as threejs from "./threejs/index.js";
1
+ export * as threejs from "./threejs/index.js";
2
+ export * as google from "./google/index.js";
@@ -28,6 +28,7 @@ export default class ApiConnection extends Dbm.core.BaseObject {
28
28
 
29
29
  requestRange(aSelect, aEncode) {
30
30
  let item = this._getRequestItem();
31
+ item.requireProperty("items", []);
31
32
 
32
33
  let selectArray = [];
33
34
  let encodeString = aEncode.join(",");
@@ -3,6 +3,19 @@ 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 = []) {
7
+ let decodePrefix = "graphApi/decode/";
8
+
9
+ let decoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
10
+ decoder.item.setValue("copyFields", aFields);
11
+ decoder.item.setValue("copyLink", aSingleLinks);
12
+ decoder.item.setValue("copyLinks", aMultipleLinks);
13
+ decoder.item.setValue("encodingType", aName);
14
+ decoder.item.register(decodePrefix + aName);
15
+
16
+ return decoder;
17
+ }
18
+
6
19
  export const fullSetup = function() {
7
20
  let decodePrefix = "graphApi/decode/";
8
21
 
@@ -185,4 +198,7 @@ export const fullSetup = function() {
185
198
  currentDecoder.item.setValue("encodingType", name);
186
199
  currentDecoder.item.register(decodePrefix + name);
187
200
  }
201
+
202
+ setupDefaultDecoder("linkPreview", ["title", "description", "link", "linkText"], ["page"]);
203
+ setupDefaultDecoder("publishDate", ["publishDate"], []);
188
204
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbm",
3
- "version": "1.1.23",
3
+ "version": "1.2.1",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {},
@@ -55,6 +55,8 @@ export default class EditPage extends Dbm.react.BaseObject {
55
55
  itemSaveData.setField("contentPreloadTags", preloadImages);
56
56
  itemSaveData.setField("lastModified", (new Date()).toISOString());
57
57
  itemSaveData.createChange("clearCache", {});
58
+ itemSaveData.createChange("addAction", {"type": "pageUpdates/updateCategoryListing"});
59
+
58
60
 
59
61
  saveData.save();
60
62
  }
@@ -39,6 +39,9 @@ export default class EditObject extends Dbm.react.BaseObject {
39
39
 
40
40
  React.createElement(Dbm.react.area.HasData, {check: this.item.properties.loaded},
41
41
  React.createElement(Dbm.react.context.AddContextVariables, {"values": {"item": item, "itemEditor": itemEditor}},
42
+ React.createElement(Dbm.react.area.List, {items: Dbm.react.source.contextVariable("item.objectTypes"), "as": "objectType", "keyField": "(root)"},
43
+ Dbm.react.text.text(Dbm.react.source.contextVariable("objectType"))
44
+ ),
42
45
  React.createElement(Dbm.react.area.List, {items: Dbm.react.source.contextVariable("item.objectTypes"), "as": "objectType", "keyField": "(root)"},
43
46
  React.createElement(Dbm.react.admin.objects.InjectObjectTypeEditor, {type: Dbm.react.source.contextVariable("objectType")})
44
47
  )
@@ -0,0 +1,98 @@
1
+ import React from "react";
2
+ import Dbm from "../../../index.js";
3
+
4
+ export default class LinkPreview extends Dbm.react.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+
8
+ let item = this.context.item;
9
+ let itemEditor = this.context.itemEditor;
10
+
11
+ {
12
+ let direction = "in";
13
+ let relationType = "for";
14
+ let objectType = "linkPreview";
15
+ let relations = Dbm.utils.ArrayFunctions.filterByField(Dbm.objectPath(item, "relations/" + direction + "." + relationType + ".objects"), "objectTypes", objectType, "arrayContains");
16
+ let editor = itemEditor.addMultipleIncomingRelationsEditor(relationType, objectType, Dbm.utils.ArrayFunctions.mapField(relations, "id"), ["relations"]);
17
+ console.log(relations, editor);
18
+ }
19
+ }
20
+
21
+ _addArrayRow(aArrayEditor) {
22
+ console.log("_addArrayRow");
23
+
24
+ let changes = [
25
+ {"type": "addOutgoingRelation", "data": {"value": this.context.item.id, "type": "for"}}
26
+ ];
27
+
28
+ //METODO: set update date
29
+
30
+ let request = Dbm.getInstance().repository.getItem("graphApi").controller.createItem(["linkPreview"], "public", changes, ["id"]);
31
+
32
+ Dbm.flow.addUpdateCommandWhenMatched(request.properties.status, 1, Dbm.commands.callFunction(this._created.bind(this), [request, aArrayEditor]));
33
+ }
34
+
35
+ _created(aRequest, aArrayEditor) {
36
+ console.log("_created");
37
+ console.log(aRequest);
38
+
39
+ aArrayEditor.push(aRequest.item.id);
40
+ }
41
+
42
+ _removeArrayRow(aArrayEditor, aItem) {
43
+ aArrayEditor.removeItem(aItem);
44
+ }
45
+
46
+ _renderMainElement() {
47
+
48
+ let direction = "in";
49
+ let relationType = "for";
50
+ let objectType = "linkPreview";
51
+
52
+ return React.createElement("div", {},
53
+ React.createElement("h2", {}, "Preview in list"),
54
+
55
+ React.createElement(Dbm.react.form.EditArray, {"value": Dbm.react.source.contextVariable("itemEditor.item.editor_multipleRelations_" + direction + "_" + relationType + "_" + objectType + ".item.editValue.item.properties.value")},
56
+ React.createElement("div", {},
57
+ React.createElement(Dbm.react.admin.EditObjectById, {id: Dbm.react.source.contextVariable("item.value")},
58
+ React.createElement("div", {},
59
+ React.createElement(Dbm.react.form.LabelledArea, {label: "Image (if different from page main image)"}),
60
+ React.createElement(Dbm.react.admin.editorsgroup.EditRelation, {"direction": "in", "relationType": "isMainImageFor", "objectType": "image"},
61
+ React.createElement(Dbm.react.form.GraphApiImage, {value: Dbm.react.source.contextVariable("valueEditor.editValue.value"), "encoding": "title", nameField: "title", className: "standard-field standard-field-padding full-width"})
62
+ ),
63
+ React.createElement("div", {className: "spacing small"}),
64
+ React.createElement(Dbm.react.form.LabelledArea, {label: "Title (if different from page title)"}),
65
+ React.createElement(Dbm.react.admin.editorsgroup.EditField, {"fieldName": "title"},
66
+ React.createElement(Dbm.react.form.FormField, {value: Dbm.react.source.contextVariable("valueEditor.editValue.value"), className: "standard-field standard-field-padding full-width", placeholder: "Same as page title"})
67
+ ),
68
+ React.createElement("div", {className: "spacing small"}),
69
+ React.createElement(Dbm.react.form.LabelledArea, {label: "Excerpt"}),
70
+ React.createElement(Dbm.react.admin.editorsgroup.EditField, {"fieldName": "description"},
71
+ React.createElement(Dbm.react.form.TextArea, {value: Dbm.react.source.contextVariable("valueEditor.editValue.value"), className: "standard-field standard-field-padding full-width"})
72
+ ),
73
+ React.createElement("div", {className: "spacing small"}),
74
+ React.createElement(Dbm.react.form.LabelledArea, {label: "Link text (optional)"}),
75
+ React.createElement(Dbm.react.admin.editorsgroup.EditField, {"fieldName": "linkText"},
76
+ React.createElement(Dbm.react.form.FormField, {value: Dbm.react.source.contextVariable("valueEditor.editValue.value"), className: "standard-field standard-field-padding full-width", placeholder: "Read more"})
77
+ )
78
+ ),
79
+ ),
80
+ ),
81
+ /*
82
+ React.createElement("div", {"data-slot": "after"},
83
+ React.createElement("div", {"className": "spacing standard"}),
84
+ React.createElement(Dbm.react.interaction.CommandButton, {command: Dbm.commands.callFunction(this._addArrayRow.bind(this), [Dbm.react.source.contextVariable("arrayEditor")])},
85
+ React.createElement("div", {"className": "flex-row"},
86
+ React.createElement("div", {"className": "flex-row-item"},
87
+ React.createElement("div", {"className": "action-button action-button-padding"}, "Add")
88
+ )
89
+ ),
90
+
91
+ )
92
+ )
93
+ */
94
+ ),
95
+ );
96
+ }
97
+ }
98
+
@@ -1 +1,2 @@
1
1
  export {default as HelpSections} from "./HelpSections.js";
2
+ export {default as LinkPreviews} from "./LinkPreviews.js";