dbm 1.0.6 → 1.1.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 (67) hide show
  1. package/flow/controllers/index.js +1 -0
  2. package/flow/controllers/select/SingleSelection.js +65 -0
  3. package/flow/controllers/select/index.js +1 -0
  4. package/flow/index.js +1 -0
  5. package/flow/updatefunctions/basic/Length.js +20 -0
  6. package/flow/updatefunctions/basic/PropertyOf.js +21 -0
  7. package/flow/updatefunctions/basic/index.js +17 -0
  8. package/flow/updatefunctions/dom/ElementPosition.js +1 -1
  9. package/flow/updatefunctions/dom/HorizontalFlip.js +5 -6
  10. package/flow/updatefunctions/dom/StyleObject.js +1 -1
  11. package/flow/updatefunctions/logic/Condition.js +12 -1
  12. package/flow/updatefunctions/logic/Invert.js +18 -0
  13. package/flow/updatefunctions/logic/Switch.js +6 -0
  14. package/flow/updatefunctions/logic/index.js +8 -0
  15. package/graphapi/webclient/GraphApi.js +4 -0
  16. package/graphapi/webclient/WebSocketConnection.js +23 -8
  17. package/graphapi/webclient/decode/index.js +16 -0
  18. package/package.json +1 -1
  19. package/react/BaseObject.js +18 -7
  20. package/react/ChildFunctions.js +27 -0
  21. package/react/admin/EditPage.js +41 -1
  22. package/react/admin/{Editor.js → editor/Editor.js} +27 -11
  23. package/react/admin/{EditorBlock.js → editor/EditorBlock.js} +15 -4
  24. package/react/admin/editor/EditorBlockFields.js +23 -0
  25. package/react/admin/editor/EditorBlockName.js +28 -0
  26. package/react/admin/editor/fields/CheckboxField.js +54 -0
  27. package/react/admin/editor/fields/ImageField.js +137 -0
  28. package/react/admin/editor/fields/RichTextField.js +75 -0
  29. package/react/admin/editor/fields/TextField.js +53 -0
  30. package/react/admin/editor/fields/index.js +4 -0
  31. package/react/admin/editor/index.js +6 -0
  32. package/react/admin/index.js +3 -4
  33. package/react/animation/AnimatedElement.js +22 -0
  34. package/react/animation/AnimationController.js +53 -0
  35. package/react/animation/index.js +22 -0
  36. package/react/area/HasData.js +5 -0
  37. package/react/area/InsertElement.js +1 -1
  38. package/react/area/List.js +46 -0
  39. package/react/area/OpenCloseExpandableArea.js +14 -5
  40. package/react/area/ResponsiveLayout.js +48 -0
  41. package/react/area/index.js +12 -1
  42. package/react/blocks/Image.js +17 -0
  43. package/react/blocks/index.js +69 -55
  44. package/react/cookies/CookieSettings.js +1 -1
  45. package/react/form/Checkbox.js +2 -1
  46. package/react/form/FileDropArea.js +92 -0
  47. package/react/form/FormField.js +1 -0
  48. package/react/form/LabelledArea.js +22 -0
  49. package/react/form/index.js +3 -1
  50. package/react/image/CoverScaledImage.js +32 -0
  51. package/react/image/Image.js +37 -0
  52. package/react/image/LocalImage.js +42 -0
  53. package/react/image/WidthScaledImage.js +30 -0
  54. package/react/image/index.js +4 -0
  55. package/react/index.js +6 -1
  56. package/react/interaction/CommandButton.js +97 -0
  57. package/react/interaction/index.js +3 -0
  58. package/react/login/LoginForm.js +1 -1
  59. package/react/source/index.js +15 -1
  60. package/react/text/Link.js +18 -0
  61. package/react/text/index.js +1 -0
  62. package/site/SiteDataLoader.js +1 -1
  63. package/tracking/Controller.js +1 -1
  64. package/utils/ArrayFunctions.js +128 -2
  65. package/utils/UrlFunctions.js +77 -0
  66. package/utils/index.js +2 -1
  67. package/react/admin/EditorBlockName.js +0 -19
@@ -0,0 +1 @@
1
+ export * as select from "./select/index.js";
@@ -0,0 +1,65 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class SingleSelection extends Dbm.core.BaseObject {
4
+ _construct() {
5
+ super._construct();
6
+
7
+ let valueUpdatedCommand = Dbm.commands.callFunction(this._valueUpdated.bind(this));
8
+
9
+ this._selectionChangedBound = this._selectionChanged.bind(this);
10
+
11
+ Dbm.flow.addUpdateCommand(this.item.requireProperty("value", null), valueUpdatedCommand);
12
+ Dbm.flow.addUpdateCommand(this.item.requireProperty("selections", []), valueUpdatedCommand);
13
+
14
+ this.item.requireProperty("matched", false);
15
+ }
16
+
17
+ addSelectionValue(aValue) {
18
+ let selections = [].concat(this.item.selections);
19
+
20
+ let property = new Dbm.flow.FlowProperty();
21
+ property.setValue(false);
22
+ Dbm.flow.addUpdateCommand(property, Dbm.commands.callFunction(this._selectionChangedBound, [property, aValue]));
23
+
24
+ selections.push({"value": aValue, "property": property});
25
+ this.item.selections = selections;
26
+
27
+ return property;
28
+ }
29
+
30
+ _selectionChanged(aSelected, aValue) {
31
+ //console.log("_selectionChanged");
32
+ //console.log(aSelected, aValue);
33
+
34
+ if(aSelected) {
35
+ this.item.properties.value.getMostUpstreamProperty().setValue(aValue);
36
+ }
37
+ else {
38
+ if(this.item.properties.value === aValue) {
39
+ this.item.properties.value.getMostUpstreamProperty().setValue(null);
40
+ }
41
+ }
42
+ }
43
+
44
+ _valueUpdated() {
45
+ //console.log("_valueUpdated");
46
+ let value = this.item.value;
47
+
48
+ let matched = false;
49
+
50
+ let currentArray = this.item.selections;
51
+ let currentArrayLength = currentArray.length;
52
+ for(let i = 0; i < currentArrayLength; i++) {
53
+ let currentSelection = currentArray[i];
54
+ if(currentSelection.value === value) {
55
+ currentSelection.property.value = true;
56
+ matched = true;
57
+ }
58
+ else {
59
+ currentSelection.property.value = false;
60
+ }
61
+ }
62
+
63
+ this.item.matched = matched;
64
+ }
65
+ }
@@ -0,0 +1 @@
1
+ export {default as SingleSelection} from "./SingleSelection.js";
package/flow/index.js CHANGED
@@ -9,6 +9,7 @@ export {default as DirtyCommands} from "./DirtyCommands.js";
9
9
  export {default as FlowPropertyWithExternalInput} from "./FlowPropertyWithExternalInput.js";
10
10
 
11
11
  export * as updatefunctions from "./updatefunctions/index.js";
12
+ export * as controllers from "./controllers/index.js";
12
13
 
13
14
  export let addUpdateCommand = function(aProperty, aCommand) {
14
15
  let updateFunction = new Dbm.flow.updatefunctions.basic.RunCommand();
@@ -0,0 +1,20 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class Length extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("value", "");
9
+
10
+ this.output.register("length", 0);
11
+ }
12
+
13
+ _update() {
14
+ //console.log("_update");
15
+
16
+ let value = this.input.value;
17
+
18
+ this.output.length = value ? value.length : 0;
19
+ }
20
+ }
@@ -0,0 +1,21 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class Length extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("value", "");
9
+ this.input.register("propertyName", "");
10
+
11
+ this.output.register("value", null);
12
+ }
13
+
14
+ _update() {
15
+ //console.log("_update");
16
+
17
+ let value = this.input.value;
18
+
19
+ this.output.value = Dbm.objectPath(value, this.input.propertyName);
20
+ }
21
+ }
@@ -2,6 +2,8 @@ import Dbm from "../../../index.js";
2
2
 
3
3
  export {default as RunCommand} from "./RunCommand.js";
4
4
  export {default as CombineString} from "./CombineString.js";
5
+ export {default as Length} from "./Length.js";
6
+ export {default as PropertyOf} from "./PropertyOf.js";
5
7
 
6
8
  export const runCommand = function(aValue, aCommand) {
7
9
  let updateFunction = new Dbm.flow.updatefunctions.basic.RunCommand();
@@ -15,4 +17,19 @@ export const transformValue = function(aValue, aFunction) {
15
17
  let command = Dbm.commands.callFunction(aFunction, [Dbm.core.source.event()]);
16
18
 
17
19
  return Dbm.flow.updatefunctions.basic.runCommand(aValue, command);
20
+ }
21
+
22
+ export const length = function(aValue) {
23
+ let updateFunction = new Dbm.flow.updatefunctions.basic.Length();
24
+ updateFunction.input.properties.value.setOrConnect(aValue);
25
+
26
+ return updateFunction;
27
+ }
28
+
29
+ export const propertyOf = function(aValue, aPropertyName) {
30
+ let updateFunction = new Dbm.flow.updatefunctions.basic.PropertyOf();
31
+ updateFunction.input.properties.value.setOrConnect(aValue);
32
+ updateFunction.input.properties.propertyName.setOrConnect(aPropertyName);
33
+
34
+ return updateFunction;
18
35
  }
@@ -49,7 +49,7 @@ export default class ElementPosition extends Dbm.flow.FlowUpdateFunction {
49
49
  }
50
50
 
51
51
  _callback_scroll(aEvent) {
52
- console.log("_callback_scroll");
52
+ //console.log("_callback_scroll");
53
53
 
54
54
  let element = this.input.element;
55
55
 
@@ -6,11 +6,10 @@ export default class HorizontalFlip extends Dbm.flow.FlowUpdateFunction {
6
6
  super._construct();
7
7
 
8
8
  this.input.register("envelope", 0);
9
- console.log(this.input.properties.envelope);
10
9
  this.input.register("perspective", "3000px");
11
10
 
12
11
  this.output.register("style1", {});
13
- this.output.register("style2", {"opacity": 0, "position": "absolute", "top": 0, "left": 0, "width": "100%", "dispaly": "none"});
12
+ this.output.register("style2", {"opacity": 0, "position": "absolute", "top": 0, "left": 0, "width": "100%", "display": "none"});
14
13
  this.output.register("inDom1", true);
15
14
  this.output.register("inDom2", false);
16
15
  }
@@ -28,12 +27,12 @@ export default class HorizontalFlip extends Dbm.flow.FlowUpdateFunction {
28
27
  this.output.inDom2 = inDom2;
29
28
 
30
29
  if(!inDom1) {
31
- this.output.style1 = {"opacity": 0, "position": "absolute", "top": 0, "left": 0, "width": "100%", "dispaly": "none"};
30
+ this.output.style1 = {"opacity": 0, "position": "absolute", "top": 0, "left": 0, "width": "100%", "display": "none"};
32
31
  this.output.style2 = {};
33
32
  }
34
33
  else if(!inDom2) {
35
34
  this.output.style1 = {};
36
- this.output.style2 = {"opacity": 0, "position": "absolute", "top": 0, "left": 0, "width": "100%", "dispaly": "none"};
35
+ this.output.style2 = {"opacity": 0, "position": "absolute", "top": 0, "left": 0, "width": "100%", "display": "none"};
37
36
  }
38
37
  else {
39
38
  let angle1 = 180*envelope;
@@ -49,7 +48,7 @@ export default class HorizontalFlip extends Dbm.flow.FlowUpdateFunction {
49
48
  styleObject2["position"] = "absolute";
50
49
  styleObject2["top"] = 0;
51
50
  styleObject2["left"] = 0;
52
- styleObject2["width"] = 0;
51
+ styleObject2["width"] = "100%";
53
52
  }
54
53
  else {
55
54
  styleObject1["opacity"] = 0;
@@ -57,7 +56,7 @@ export default class HorizontalFlip extends Dbm.flow.FlowUpdateFunction {
57
56
  styleObject1["position"] = "absolute";
58
57
  styleObject1["top"] = 0;
59
58
  styleObject1["left"] = 0;
60
- styleObject1["width"] = 0;
59
+ styleObject1["width"] = "100%";
61
60
  }
62
61
 
63
62
  this.output.style1 = styleObject1;
@@ -33,7 +33,7 @@ export default class StyleObject extends Dbm.flow.FlowUpdateFunction {
33
33
  let unit = this.input.units[objectName].value;
34
34
 
35
35
  if(unit) {
36
- value += " " + unit;
36
+ value += "" + unit;
37
37
  }
38
38
  styleObject[objectName] = value;
39
39
  }
@@ -15,6 +15,17 @@ export default class Condition extends Dbm.flow.FlowUpdateFunction {
15
15
  _update() {
16
16
  //console.log("_update");
17
17
 
18
- this.output.result = this.input.operation.call(this, this.input.input1, this.input.input2);
18
+ let operation = this.input.operation;
19
+ if(typeof(operation) === "string") {
20
+ if(operation === "!==") {
21
+ operation = function(aA, aB) {return aA !== aB;}
22
+ }
23
+ else {
24
+ //METODO: add more operations
25
+ operation = function(aA, aB) {return aA === aB;}
26
+ }
27
+ }
28
+
29
+ this.output.result = operation.call(this, this.input.input1, this.input.input2);
19
30
  }
20
31
  }
@@ -0,0 +1,18 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class Invert extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("input", false);
9
+
10
+ this.output.register("result", true);
11
+ }
12
+
13
+ _update() {
14
+ //console.log("_update");
15
+
16
+ this.output.result = !this.input.input;
17
+ }
18
+ }
@@ -12,6 +12,12 @@ export default class Switch extends Dbm.flow.FlowUpdateFunction {
12
12
  this.output.register("value", null);
13
13
  }
14
14
 
15
+ setDefaultValue(aValue) {
16
+ this.input.properties.defaultValue.setOrConnect(aValue);
17
+
18
+ return this;
19
+ }
20
+
15
21
  addCase(aKey, aOutputValue) {
16
22
 
17
23
  let newCase = {key: aKey, value: aOutputValue};
@@ -10,6 +10,7 @@ export {default as All} from "./All.js";
10
10
  export {default as Any} from "./Any.js";
11
11
  export {default as AllAtValue} from "./AllAtValue.js";
12
12
  export {default as WhenMatched} from "./WhenMatched.js";
13
+ export {default as Invert} from "./Invert.js";
13
14
 
14
15
  export let subtract = function(aInput1 = 0, aInput2 = 0) {
15
16
  let updateFunction = new Dbm.flow.updatefunctions.logic.Subtraction();
@@ -19,6 +20,13 @@ export let subtract = function(aInput1 = 0, aInput2 = 0) {
19
20
  return updateFunction;
20
21
  }
21
22
 
23
+ export let invert = function(aValue = false) {
24
+ let updateFunction = new Dbm.flow.updatefunctions.logic.Invert();
25
+ updateFunction.input.properties.input.setValue(aValue);
26
+
27
+ return updateFunction;
28
+ }
29
+
22
30
  export let invertP = function(aP = 0) {
23
31
  let updateFunction = new Dbm.flow.updatefunctions.logic.Subtraction();
24
32
  updateFunction.input.properties.input1.setValue(1);
@@ -32,6 +32,10 @@ export default class GraphApi extends Dbm.core.BaseObject {
32
32
  return this._websocketConnection.requestData(aFunctionName, aData);
33
33
  }
34
34
 
35
+ performAction(aFunctionName, aData) {
36
+ return this._websocketConnection.performAction(aFunctionName, aData);
37
+ }
38
+
35
39
  createItem(aTypes, aVisibility = "draft", aChanges = [], aEncode = []) {
36
40
  return this._websocketConnection.createItem(aTypes, aVisibility, aChanges, aEncode);
37
41
  }
@@ -50,14 +50,16 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
50
50
  }
51
51
 
52
52
  _runRequest(aRequestItem) {
53
- let newRequests = [].concat(this.item.requests);
54
- newRequests.push(aRequestItem);
55
- this.item.setValue("requests", newRequests);
56
-
53
+
57
54
  if(this.item.status === 1) {
58
55
  aRequestItem.setValue("status", Dbm.loading.LoadingStatus.LOADING);
59
56
  this._webSocket.send(JSON.stringify(aRequestItem.requestData));
60
57
  }
58
+ else {
59
+ let newRequests = [].concat(this.item.requests);
60
+ newRequests.push(aRequestItem);
61
+ this.item.setValue("requests", newRequests);
62
+ }
61
63
  }
62
64
 
63
65
  requestRange(aSelect, aEncode) {
@@ -85,6 +87,15 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
85
87
  return item;
86
88
  }
87
89
 
90
+ performAction(aFunctionName, aData) {
91
+ //console.log("performAction");
92
+ let item = this._getRequestItem();
93
+ item.setValue("requestData", {"type": "action", "functionName": aFunctionName, "data": aData, "requestId": item.id});
94
+ this._runRequest(item);
95
+
96
+ return item;
97
+ }
98
+
88
99
  createItem(aTypes, aVisibility = "draft", aChanges = [], aEncode = []) {
89
100
  let item = this._getRequestItem();
90
101
  item.setValue("requestData", {"type": "admin/createObject", "types": aTypes, "visibility": aVisibility, "changes": aChanges, "encode": aEncode, "requestId": item.id});
@@ -111,7 +122,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
111
122
  }
112
123
 
113
124
  _callback_onOpen(aEvent) {
114
- console.log("_callback_onOpen");
125
+ //console.log("_callback_onOpen");
115
126
 
116
127
  if(this._intervalId === -1) {
117
128
  this._intervalId = setInterval(this._callback_sendHeartbeatBound, 20*1000);
@@ -119,8 +130,8 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
119
130
  }
120
131
 
121
132
  _callback_onClose(aEvent) {
122
- console.log("_callback_onClose");
123
- console.log(aEvent);
133
+ //console.log("_callback_onClose");
134
+ //console.log(aEvent);
124
135
 
125
136
  if(this._intervalId !== -1) {
126
137
  clearInterval(this._intervalId);
@@ -148,13 +159,14 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
148
159
  }
149
160
 
150
161
  _callback_sendHeartbeat() {
151
- console.log("_callback_sendHeartbeat");
162
+ //console.log("_callback_sendHeartbeat");
152
163
 
153
164
  this._webSocket.send(JSON.stringify({"type": "heartbeat"}));
154
165
  }
155
166
 
156
167
  _connectionReady() {
157
168
  this.item.setValue("status", 1);
169
+
158
170
  let currentArray = this.item.requests;
159
171
  let currentArrayLength = currentArray.length;
160
172
  for(let i = 0; i < currentArrayLength; i++) {
@@ -162,6 +174,8 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
162
174
  currentItem.setValue("status", Dbm.loading.LoadingStatus.LOADING);
163
175
  this._webSocket.send(JSON.stringify(currentItem.requestData));
164
176
  }
177
+
178
+ this.item.requests = [];
165
179
  }
166
180
 
167
181
  _callback_onMessage(aEvent) {
@@ -207,6 +221,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
207
221
  }
208
222
  break;
209
223
  case "data/response":
224
+ case "action/response":
210
225
  {
211
226
  let item = repository.getItem(data["requestId"]);
212
227
  item.setValue("data", data["data"]);
@@ -62,6 +62,22 @@ let fullSetup = function() {
62
62
  currentDecoder.item.setValue("encodingType", name);
63
63
  currentDecoder.item.register(decodePrefix + name);
64
64
  }
65
+
66
+ {
67
+ let name = "navigationName";
68
+ let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
69
+ currentDecoder.item.setValue("copyFields", ["navigationName"]);
70
+ currentDecoder.item.setValue("encodingType", name);
71
+ currentDecoder.item.register(decodePrefix + name);
72
+ }
73
+
74
+ {
75
+ let name = "breadcrumb";
76
+ let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
77
+ currentDecoder.item.setValue("copyLinks", ["breadcrumbs"]);
78
+ currentDecoder.item.setValue("encodingType", name);
79
+ currentDecoder.item.register(decodePrefix + name);
80
+ }
65
81
  }
66
82
 
67
83
  export {fullSetup};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbm",
3
- "version": "1.0.6",
3
+ "version": "1.1.1",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {},
@@ -25,7 +25,7 @@ export default class BaseObject extends Component {
25
25
  if(currentProp && currentProp.isSource) {
26
26
  currentProp = currentProp.getSource(this);
27
27
  let currentDynamicProperty = this.getDynamicProp(objectName);
28
- currentDynamicProperty.setValue(currentProp);
28
+ currentDynamicProperty.setOrConnect(currentProp);
29
29
  }
30
30
  else if(currentProp && currentProp.isFlowProperty) {
31
31
  let currentDynamicProperty = this.getDynamicProp(objectName);
@@ -129,15 +129,13 @@ export default class BaseObject extends Component {
129
129
  return this._performCreateMainElement(aType, aProps, children);
130
130
  }
131
131
 
132
- _performCreateMainElement(aType, aProps, children) {
132
+ _removedUsedProps(aProps) {
133
+
134
+ }
133
135
 
136
+ _copyProps(aProps) {
134
137
  let newProps = {...aProps};
135
138
 
136
- let elementType = this.getProp("elementType");
137
- if(elementType) {
138
- aType = elementType;
139
- }
140
-
141
139
  for(let objectName in this.props) {
142
140
  let currentValue = this.getPropValue(objectName);
143
141
  switch(objectName) {
@@ -178,6 +176,19 @@ export default class BaseObject extends Component {
178
176
  }
179
177
  }
180
178
 
179
+ this._removedUsedProps(newProps);
180
+ return newProps;
181
+ }
182
+
183
+ _performCreateMainElement(aType, aProps, children) {
184
+
185
+ let newProps = this._copyProps(aProps);
186
+
187
+ let elementType = this.getProp("elementType");
188
+ if(elementType) {
189
+ aType = elementType;
190
+ }
191
+
181
192
  if(!children || !children.length) {
182
193
  return createElement(aType, newProps);
183
194
  }
@@ -0,0 +1,27 @@
1
+ import Dbm from "../index.js";
2
+
3
+ export const splitIntoSlots = function(aChildren) {
4
+ let returnObject = {};
5
+
6
+ aChildren = Dbm.utils.ArrayFunctions.singleOrArray(aChildren);
7
+
8
+ if(aChildren) {
9
+ let currentArray = aChildren;
10
+ let currentArrayLength = currentArray.length;
11
+ for(let i = 0; i < currentArrayLength; i++) {
12
+ let currentElement = currentArray[i];
13
+ let currentSlot = Dbm.objectPath(currentElement, "props.data-slot");
14
+ if(!currentSlot) {
15
+ currentSlot = "main";
16
+ }
17
+ let currentArea = returnObject[currentSlot];
18
+ if(!currentArea) {
19
+ returnObject[currentSlot] = currentArea = [];
20
+ }
21
+ currentArea.push(currentElement);
22
+ }
23
+ }
24
+
25
+
26
+ return returnObject;
27
+ }
@@ -8,10 +8,15 @@ export default class EditPage extends Dbm.react.BaseObject {
8
8
  let page = this.context.page;
9
9
 
10
10
  this.item.setValue("title", page.title);
11
+ this.item.setValue("navigationName", page.navigationName);
11
12
  this.item.setValue("content", page.content);
12
13
  this.item.setValue("description", page["meta/description"]);
13
14
  this.item.setValue("url", page.url);
14
15
 
16
+ let descriptionLength = Dbm.flow.updatefunctions.basic.length(this.item.properties.description);
17
+
18
+ this.item.requireProperty("descriptionLength", 0).connectInput(descriptionLength.output.properties.length);
19
+
15
20
  //METODO: add editors
16
21
  }
17
22
 
@@ -21,16 +26,33 @@ export default class EditPage extends Dbm.react.BaseObject {
21
26
  let page = this.context.page;
22
27
  let id = page.id;
23
28
  let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
29
+ //console.log(this.item.content);
30
+ //console.log(this.item.content.blocks[1].data.text);
24
31
 
25
32
  graphApi.editItem(id, [
26
33
  {"type": "setField", "data": {"value": this.item.content, "field": "content"}},
27
34
  {"type": "setField", "data": {"value": this.item.title, "field": "title"}},
35
+ {"type": "setField", "data": {"value": this.item.navigationName, "field": "navigationName"}},
28
36
  {"type": "setField", "data": {"value": this.item.description, "field": "meta/description"}},
29
37
  {"type": "setField", "data": {"value": (new Date()).toISOString(), "field": "lastModified"}},
30
38
  {"type": "setUrl", "data": {"value": this.item.url}}
31
39
  ], ["content", "title", "url", "meta/description"]);
32
40
  }
33
41
 
42
+ _generateSeoSummary() {
43
+ let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
44
+
45
+ let request = graphApi.requestData("admin/seoSummary", {"value": {"title": this.item.title, "content": this.item.content}});
46
+ Dbm.flow.addUpdateCommandWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._dataLoaded.bind(this), [request]));
47
+
48
+ }
49
+
50
+ _dataLoaded(aRequest) {
51
+ let summary = Dbm.objectPath(aRequest, "data.seoSummary");
52
+
53
+ this.item.description = summary;
54
+ }
55
+
34
56
  _renderMainElement() {
35
57
 
36
58
  return React.createElement("div", {},
@@ -42,6 +64,13 @@ export default class EditPage extends Dbm.react.BaseObject {
42
64
  React.createElement(Dbm.react.form.FormField, {"value": this.item.properties.title, className: "standard-field standard-field-padding full-width page-title-form-field", placeholder: "Title"}),
43
65
  ),
44
66
  React.createElement("div", {className: "spacing standard"}),
67
+ React.createElement("div", {},
68
+ React.createElement("label", {className: "standard-field-label"},
69
+ "Navigation name"
70
+ ),
71
+ React.createElement(Dbm.react.form.FormField, {"value": this.item.properties.navigationName, className: "standard-field standard-field-padding full-width", placeholder: "Name showed in menues and breadcrumbs"}),
72
+ ),
73
+ React.createElement("div", {className: "spacing standard"}),
45
74
  React.createElement("div", {},
46
75
  React.createElement("label", {className: "standard-field-label"},
47
76
  "Url"
@@ -55,6 +84,17 @@ export default class EditPage extends Dbm.react.BaseObject {
55
84
  "Seo description"
56
85
  ),
57
86
  React.createElement(Dbm.react.form.FormField, {"value": this.item.properties.description, className: "standard-field standard-field-padding full-width", placeholder: "Description"}),
87
+ React.createElement("div", {className: "spacing micro"}),
88
+ React.createElement("div", {className: "flex-row justify-between"},
89
+ React.createElement("div", {className: "flex-row-item"},
90
+ React.createElement("div", {onClick: () => {this._generateSeoSummary()}}, "Generate"),
91
+ ),
92
+ React.createElement("div", {className: "flex-row-item"},
93
+ Dbm.react.text.text(this.item.properties.descriptionLength),
94
+ " / ",
95
+ "155"
96
+ )
97
+ )
58
98
  ),
59
99
  React.createElement("div", {className: "spacing standard"}),
60
100
  React.createElement("div", {"className": "dbm-admin-box dbm-admin-box-padding"},
@@ -62,7 +102,7 @@ export default class EditPage extends Dbm.react.BaseObject {
62
102
  "Content"
63
103
  ),
64
104
  React.createElement("div", {},
65
- React.createElement(Dbm.react.admin.Editor, {"value": this.item.properties.content}),
105
+ React.createElement(Dbm.react.admin.editor.Editor, {"value": this.item.properties.content}),
66
106
  )
67
107
  ),
68
108
  React.createElement("div", {className: "spacing standard"}),