dbm 1.1.5 → 1.1.7
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.
- package/flow/controllers/index.js +2 -1
- package/flow/controllers/interaction/MoveElement.js +176 -0
- package/flow/controllers/interaction/index.js +1 -0
- package/flow/updatefunctions/dom/ElementPosition.js +1 -1
- package/flow/updatefunctions/logic/PositionedItems.js +68 -0
- package/flow/updatefunctions/logic/index.js +1 -0
- package/graphapi/webclient/WebSocketConnection.js +1 -0
- package/graphapi/webclient/decode/DecodeBaseObject.js +6 -1
- package/graphapi/webclient/decode/index.js +16 -0
- package/package.json +1 -1
- package/react/BaseObject.js +4 -0
- package/react/admin/EditPage.js +66 -3
- package/react/admin/editor/Editor.js +8 -0
- package/react/admin/editor/fields/SelectObjectField.js +57 -0
- package/react/admin/editor/fields/index.js +2 -1
- package/react/area/List.js +4 -0
- package/react/context/AddItemToContext.js +24 -0
- package/react/context/index.js +2 -1
- package/react/form/GraphApiObjectSelection.js +53 -0
- package/react/form/Selection.js +29 -0
- package/react/form/index.js +3 -1
- package/tracking/MetaPixelTracker.js +7 -1
- package/tracking/TagManagerTracker.js +58 -0
- package/tracking/index.js +8 -0
- package/utils/ArrayFunctions.js +124 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class MoveElement extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
this._element = null;
|
|
8
|
+
this._startX = 0;
|
|
9
|
+
this._startY = 0;
|
|
10
|
+
this._startXParameter = 0;
|
|
11
|
+
this._startYParameter = 0;
|
|
12
|
+
|
|
13
|
+
this._callback_mouseMoveBound = this._callback_mouseMove.bind(this);
|
|
14
|
+
this._callback_mouseUpBound = this._callback_mouseUp.bind(this);
|
|
15
|
+
this._callback_startDragBound = this._callback_startDrag.bind(this);
|
|
16
|
+
|
|
17
|
+
this.item.requireProperty("element", null);
|
|
18
|
+
Dbm.flow.addUpdateCommand(this.item.properties.element, Dbm.commands.callFunction(this._elementUpdated.bind(this)));
|
|
19
|
+
|
|
20
|
+
let updateXCommand = Dbm.commands.callFunction(this._updateX.bind(this));
|
|
21
|
+
let updateYCommand = Dbm.commands.callFunction(this._updateY.bind(this));
|
|
22
|
+
|
|
23
|
+
let clampXCommand = Dbm.commands.callFunction(this._clampX.bind(this));
|
|
24
|
+
let clampYCommand = Dbm.commands.callFunction(this._clampY.bind(this));
|
|
25
|
+
|
|
26
|
+
this.item.requireProperty("minX", 0);
|
|
27
|
+
Dbm.flow.addUpdateCommand(this.item.properties.minX, updateXCommand);
|
|
28
|
+
Dbm.flow.addUpdateCommand(this.item.properties.minX, clampXCommand);
|
|
29
|
+
this.item.requireProperty("maxX", 0);
|
|
30
|
+
Dbm.flow.addUpdateCommand(this.item.properties.maxX, updateXCommand);
|
|
31
|
+
Dbm.flow.addUpdateCommand(this.item.properties.maxX, clampXCommand);
|
|
32
|
+
|
|
33
|
+
this.item.requireProperty("minY", 0);
|
|
34
|
+
Dbm.flow.addUpdateCommand(this.item.properties.minY, updateYCommand);
|
|
35
|
+
Dbm.flow.addUpdateCommand(this.item.properties.minY, clampYCommand);
|
|
36
|
+
this.item.requireProperty("maxY", 0);
|
|
37
|
+
Dbm.flow.addUpdateCommand(this.item.properties.maxY, updateYCommand);
|
|
38
|
+
Dbm.flow.addUpdateCommand(this.item.properties.maxY, clampYCommand);
|
|
39
|
+
|
|
40
|
+
this.item.requireProperty("xParameter", 0);
|
|
41
|
+
Dbm.flow.addUpdateCommand(this.item.properties.xParameter, updateXCommand);
|
|
42
|
+
this.item.requireProperty("yParameter", 0);
|
|
43
|
+
Dbm.flow.addUpdateCommand(this.item.properties.yParameter, updateYCommand);
|
|
44
|
+
|
|
45
|
+
this.item.requireProperty("scaleX", 1);
|
|
46
|
+
Dbm.flow.addUpdateCommand(this.item.properties.scaleX, updateXCommand);
|
|
47
|
+
this.item.requireProperty("scaleY", 1);
|
|
48
|
+
Dbm.flow.addUpdateCommand(this.item.properties.scaleY, updateYCommand);
|
|
49
|
+
|
|
50
|
+
this.item.requireProperty("invertX", 1);
|
|
51
|
+
this.item.requireProperty("invertY", 1);
|
|
52
|
+
|
|
53
|
+
this.item.requireProperty("x", 0);
|
|
54
|
+
this.item.requireProperty("y", 0);
|
|
55
|
+
|
|
56
|
+
this.item.requireProperty("isDragging", false);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_elementUpdated() {
|
|
60
|
+
console.log("_elementUpdated");
|
|
61
|
+
|
|
62
|
+
if(this._element) {
|
|
63
|
+
let element = this._element;
|
|
64
|
+
element.removeEventListener("mousedown", this._callback_startDragBound);
|
|
65
|
+
element.removeEventListener("touchstart", this._callback_startDragBound);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if(this.item.element) {
|
|
69
|
+
let element = this.item.element;
|
|
70
|
+
element.addEventListener("mousedown", this._callback_startDragBound);
|
|
71
|
+
element.addEventListener("touchstart", this._callback_startDragBound);
|
|
72
|
+
}
|
|
73
|
+
this._element = this.item.element;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_updateX() {
|
|
77
|
+
this.item.x = this.item.xParameter*this.item.scaleX;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
_clampX() {
|
|
81
|
+
let minX = this.item.minX;
|
|
82
|
+
let maxX = this.item.maxX;
|
|
83
|
+
|
|
84
|
+
this.item.xParameter = Math.max(minX, Math.min(this.item.xParameter, maxX));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
_clampY() {
|
|
88
|
+
let minY = this.item.minY;
|
|
89
|
+
let maxY = this.item.maxY;
|
|
90
|
+
|
|
91
|
+
this.item.yParameter = Math.max(minY, Math.min(this.item.yParameter, maxY));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
_updateY() {
|
|
95
|
+
this.item.y = this.item.yParameter*this.item.scaleY;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
_startMove(aX, aY) {
|
|
100
|
+
//console.log(aX, aY);
|
|
101
|
+
|
|
102
|
+
this._startXParameter = this.item.xParameter;
|
|
103
|
+
this._startYParameter = this.item.yParameter;
|
|
104
|
+
this._startX = aX;
|
|
105
|
+
this._startY = aY;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
_updateMove(aX, aY) {
|
|
109
|
+
console.log("_updateMove");
|
|
110
|
+
//console.log(aX, aY);
|
|
111
|
+
|
|
112
|
+
let x = this._startXParameter + this.item.invertX*(aX-this._startX)/this.item.scaleX;
|
|
113
|
+
let y = this._startYParameter + this.item.invertY*(aY-this._startY)/this.item.scaleY;
|
|
114
|
+
|
|
115
|
+
let minX = this.item.minX;
|
|
116
|
+
let maxX = this.item.maxX;
|
|
117
|
+
|
|
118
|
+
let minY = this.item.minY;
|
|
119
|
+
let maxY = this.item.maxY;
|
|
120
|
+
|
|
121
|
+
this.item.properties.xParameter.getMostUpstreamProperty().value = Math.max(minX, Math.min(x, maxX));
|
|
122
|
+
this.item.properties.yParameter.getMostUpstreamProperty().value = Math.max(minY, Math.min(y, maxY));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
_callback_mouseUp(aEvent) {
|
|
126
|
+
console.log("_callback_mouseUp");
|
|
127
|
+
//console.log(aEvent);
|
|
128
|
+
|
|
129
|
+
if(aEvent.type === "touchend") {
|
|
130
|
+
this._updateMove(aEvent.touches[0].pageX, aEvent.touches[0].pageY);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
this._updateMove(aEvent.pageX, aEvent.pageY);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
document.removeEventListener("mousemove", this._callback_mouseMoveBound, false);
|
|
137
|
+
document.removeEventListener("mouseup", this._callback_mouseUpBound, false);
|
|
138
|
+
|
|
139
|
+
document.removeEventListener("touchmove", this._callback_mouseMoveBound, false);
|
|
140
|
+
document.removeEventListener("touchup", this._callback_mouseUpBound, false);
|
|
141
|
+
|
|
142
|
+
this.item.isDragging = false;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
_callback_mouseMove(aEvent) {
|
|
146
|
+
//console.log("_callback_mouseMove");
|
|
147
|
+
//console.log(aEvent);
|
|
148
|
+
|
|
149
|
+
if(aEvent.type === "touchmove") {
|
|
150
|
+
this._updateMove(aEvent.touches[0].pageX, aEvent.touches[0].pageY);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
this._updateMove(aEvent.pageX, aEvent.pageY);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
_callback_startDrag(aEvent) {
|
|
158
|
+
//console.log("_callback_startDrag");
|
|
159
|
+
//console.log(aEvent, aEvent.type);
|
|
160
|
+
|
|
161
|
+
if(aEvent.type === "touchstart") {
|
|
162
|
+
this._startMove(aEvent.touches[0].pageX, aEvent.touches[0].pageY);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
this._startMove(aEvent.pageX, aEvent.pageY);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
document.addEventListener("mousemove", this._callback_mouseMoveBound, false);
|
|
169
|
+
document.addEventListener("mouseup", this._callback_mouseUpBound, false);
|
|
170
|
+
|
|
171
|
+
document.addEventListener("touchmove", this._callback_mouseMoveBound, false);
|
|
172
|
+
document.addEventListener("touchup", this._callback_mouseUpBound, false);
|
|
173
|
+
|
|
174
|
+
this.item.isDragging = true;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as MoveElement} from "./MoveElement.js";
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class PoisitonedItems extends Dbm.flow.FlowUpdateFunction {
|
|
4
|
+
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.input.register("elementWidth", 0);
|
|
9
|
+
this.input.register("itemWidth", 0);
|
|
10
|
+
this.input.register("itemSpacing", 0);
|
|
11
|
+
this.input.register("padding", 0);
|
|
12
|
+
this.input.register("numberOfItems", 0);
|
|
13
|
+
|
|
14
|
+
this.output.register("startPosition", 0);
|
|
15
|
+
this.output.register("parameterLength", 0);
|
|
16
|
+
|
|
17
|
+
this.output.register("minParameter", 0);
|
|
18
|
+
this.output.register("maxParameter", 0);
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
let parameter = minParameter;
|
|
22
|
+
|
|
23
|
+
let x = padding+startPosition-parameter*parameterLength;
|
|
24
|
+
|
|
25
|
+
console.log(minParameter, maxParameter, fullWidth, startPosition);
|
|
26
|
+
console.log(x);
|
|
27
|
+
|
|
28
|
+
parameter = maxParameter;
|
|
29
|
+
|
|
30
|
+
x = padding+startPosition-parameter*parameterLength;
|
|
31
|
+
|
|
32
|
+
console.log(x);
|
|
33
|
+
*/
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
_update() {
|
|
37
|
+
//console.log("_update");
|
|
38
|
+
|
|
39
|
+
let elementWidth = this.input.elementWidth;
|
|
40
|
+
let itemWidth = this.input.itemWidth;
|
|
41
|
+
let itemSpacing = this.input.itemSpacing;
|
|
42
|
+
let padding = this.input.padding;
|
|
43
|
+
|
|
44
|
+
let visualWidth = elementWidth-2*padding;
|
|
45
|
+
let startPosition = (visualWidth-itemWidth)/2;
|
|
46
|
+
|
|
47
|
+
let parameterLength = itemWidth+itemSpacing;
|
|
48
|
+
let fullWidth = this.input.numberOfItems*parameterLength-itemSpacing;
|
|
49
|
+
|
|
50
|
+
let minParameter = 0;
|
|
51
|
+
let maxParameter = 0;
|
|
52
|
+
|
|
53
|
+
if(fullWidth > visualWidth) {
|
|
54
|
+
minParameter = startPosition/parameterLength;
|
|
55
|
+
maxParameter = (fullWidth-(visualWidth-startPosition))/parameterLength;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
startPosition = (visualWidth-fullWidth)/2;
|
|
59
|
+
parameterLength = 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this.output.startPosition = startPosition;
|
|
63
|
+
this.output.parameterLength = parameterLength;
|
|
64
|
+
|
|
65
|
+
this.output.minParameter = minParameter;
|
|
66
|
+
this.output.maxParameter = maxParameter;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -11,6 +11,7 @@ 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
13
|
export {default as Invert} from "./Invert.js";
|
|
14
|
+
export {default as PositionedItems} from "./PositionedItems.js";
|
|
14
15
|
|
|
15
16
|
export let subtract = function(aInput1 = 0, aInput2 = 0) {
|
|
16
17
|
let updateFunction = new Dbm.flow.updatefunctions.logic.Subtraction();
|
|
@@ -65,6 +65,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
65
65
|
requestRange(aSelect, aEncode) {
|
|
66
66
|
let item = this._getRequestItem();
|
|
67
67
|
item.setValue("requestData", {"type": "range", "select": aSelect, "encode": aEncode, "requestId": item.id});
|
|
68
|
+
item.requireProperty("items", []);
|
|
68
69
|
this._runRequest(item);
|
|
69
70
|
|
|
70
71
|
return item;
|
|
@@ -41,7 +41,12 @@ export default class DecodeBaseObject extends Dbm.core.BaseObject {
|
|
|
41
41
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
42
42
|
let currentField = currentArray[i];
|
|
43
43
|
let currentIds = aData[currentField];
|
|
44
|
-
|
|
44
|
+
if(currentIds) {
|
|
45
|
+
aItem.setValue(currentField, Dbm.getInstance().repository.getItems(currentIds));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
aItem.setValue(currentField, []);
|
|
49
|
+
}
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
}
|
|
@@ -63,6 +63,14 @@ export const fullSetup = function() {
|
|
|
63
63
|
currentDecoder.item.register(decodePrefix + name);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
{
|
|
67
|
+
let name = "pageRepresentation";
|
|
68
|
+
let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
|
|
69
|
+
currentDecoder.item.setValue("copyLink", ["representing"]);
|
|
70
|
+
currentDecoder.item.setValue("encodingType", name);
|
|
71
|
+
currentDecoder.item.register(decodePrefix + name);
|
|
72
|
+
}
|
|
73
|
+
|
|
66
74
|
{
|
|
67
75
|
let name = "navigationName";
|
|
68
76
|
let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
|
|
@@ -101,4 +109,12 @@ export const fullSetup = function() {
|
|
|
101
109
|
currentDecoder.item.setValue("encodingType", name);
|
|
102
110
|
currentDecoder.item.register(decodePrefix + name);
|
|
103
111
|
}
|
|
112
|
+
|
|
113
|
+
{
|
|
114
|
+
let name = "representingPage";
|
|
115
|
+
let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
|
|
116
|
+
currentDecoder.item.setValue("copyLink", ["representingPage"]);
|
|
117
|
+
currentDecoder.item.setValue("encodingType", name);
|
|
118
|
+
currentDecoder.item.register(decodePrefix + name);
|
|
119
|
+
}
|
|
104
120
|
}
|
package/package.json
CHANGED
package/react/BaseObject.js
CHANGED
package/react/admin/EditPage.js
CHANGED
|
@@ -22,6 +22,8 @@ export default class EditPage extends Dbm.react.BaseObject {
|
|
|
22
22
|
let descriptionEditor = itemEditor.addFieldEditor("meta/description", page["meta/description"], "meta/description");
|
|
23
23
|
let descriptionLength = Dbm.flow.updatefunctions.basic.length(descriptionEditor.item.editValue.value);
|
|
24
24
|
this.item.requireProperty("descriptionLength", 0).connectInput(descriptionLength.output.properties.length);
|
|
25
|
+
|
|
26
|
+
this.item.requireProperty("importText", "");
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
_save() {
|
|
@@ -37,11 +39,64 @@ export default class EditPage extends Dbm.react.BaseObject {
|
|
|
37
39
|
itemSaveData.setField("lastModified", (new Date()).toISOString());
|
|
38
40
|
itemSaveData.createChange("clearCache", {});
|
|
39
41
|
|
|
40
|
-
console.log(editorGroup, saveData);
|
|
41
|
-
|
|
42
42
|
saveData.save();
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
_export() {
|
|
46
|
+
let editorGroup = this.item.editorGroup;
|
|
47
|
+
|
|
48
|
+
let page = this.context.page;
|
|
49
|
+
let id = page.id;
|
|
50
|
+
let itemEditor = editorGroup.getItemEditor(id);
|
|
51
|
+
let url = itemEditor.addFieldEditor("url").item.editValue.value.value;
|
|
52
|
+
let content = itemEditor.addFieldEditor("content").item.editValue.value.value;
|
|
53
|
+
|
|
54
|
+
let blob = new Blob([JSON.stringify(content, null, 2)], { type: 'application/json' });
|
|
55
|
+
let downloadUrl = URL.createObjectURL(blob);
|
|
56
|
+
|
|
57
|
+
let fileName = id + Dbm.utils.StringFunctions.createNiceFilePath(url) + ".json";
|
|
58
|
+
let a = document.createElement('a');
|
|
59
|
+
a.href = downloadUrl;
|
|
60
|
+
a.download = fileName;
|
|
61
|
+
document.body.appendChild(a);
|
|
62
|
+
a.click();
|
|
63
|
+
|
|
64
|
+
document.body.removeChild(a);
|
|
65
|
+
URL.revokeObjectURL(downloadUrl);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
_import() {
|
|
69
|
+
|
|
70
|
+
let editorGroup = this.item.editorGroup;
|
|
71
|
+
|
|
72
|
+
let page = this.context.page;
|
|
73
|
+
let id = page.id;
|
|
74
|
+
let itemEditor = editorGroup.getItemEditor(id);
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
let data = JSON.parse(this.item.importText);
|
|
78
|
+
console.log(data);
|
|
79
|
+
|
|
80
|
+
let newContent = {...itemEditor.addFieldEditor("content").item.editValue.value.value};
|
|
81
|
+
if(!newContent) {
|
|
82
|
+
newContent = {};
|
|
83
|
+
}
|
|
84
|
+
if(!newContent.blocks) {
|
|
85
|
+
newContent.blocks = [];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let currentArray = data.blocks;
|
|
89
|
+
let currentArrayLength = currentArray.length;
|
|
90
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
91
|
+
let currentBlock = currentArray[i];
|
|
92
|
+
delete currentBlock["id"];
|
|
93
|
+
newContent.blocks.push(currentBlock);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
itemEditor.addFieldEditor("content").item.editValue.value.value = newContent;
|
|
97
|
+
this.item.editor.contentUpdatedExternally();
|
|
98
|
+
}
|
|
99
|
+
|
|
45
100
|
_generateSeoSummary() {
|
|
46
101
|
|
|
47
102
|
let page = this.context.page;
|
|
@@ -122,7 +177,15 @@ export default class EditPage extends Dbm.react.BaseObject {
|
|
|
122
177
|
"Content"
|
|
123
178
|
),
|
|
124
179
|
React.createElement("div", {},
|
|
125
|
-
React.createElement(Dbm.react.admin.editor.Editor, {"value": itemEditor.getEditor("content").item.editValue.value}),
|
|
180
|
+
React.createElement(Dbm.react.admin.editor.Editor, {"value": itemEditor.getEditor("content").item.editValue.value, "ref": this.createRef("editor")}),
|
|
181
|
+
),
|
|
182
|
+
React.createElement("div", {className: "spacing small"}),
|
|
183
|
+
React.createElement("div", {"className": "standard-button standard-button-padding", "onClick": () => {this._export()}},
|
|
184
|
+
"Export"
|
|
185
|
+
),
|
|
186
|
+
React.createElement(Dbm.react.form.FormField, {value: this.item.properties.importText}),
|
|
187
|
+
React.createElement("div", {"className": "standard-button standard-button-padding", "onClick": () => {this._import()}},
|
|
188
|
+
"Import"
|
|
126
189
|
)
|
|
127
190
|
),
|
|
128
191
|
React.createElement("div", {className: "spacing standard"}),
|
|
@@ -153,6 +153,14 @@ export default class Editor extends Dbm.react.BaseObject {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
contentUpdatedExternally() {
|
|
157
|
+
|
|
158
|
+
let data = this.getDynamicProp("value").value;
|
|
159
|
+
this.item.editor.render(data);
|
|
160
|
+
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
|
|
156
164
|
/*
|
|
157
165
|
_save() {
|
|
158
166
|
this.item.editor.save().then((aOutputData) => {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class SelectObjectField extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this._valueChangedBound = this._valueChanged.bind(this);
|
|
9
|
+
this._objectChangedBound = this._objectChanged.bind(this);
|
|
10
|
+
|
|
11
|
+
Dbm.flow.addUpdateCommand(this.item.requireProperty("value", this._getObjectData()), Dbm.commands.callFunction(this._valueChangedBound));
|
|
12
|
+
|
|
13
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
14
|
+
Dbm.flow.addUpdateCommand(editorData.properties.data, Dbm.commands.callFunction(this._objectChangedBound));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_getObjectData() {
|
|
18
|
+
let fieldName = this.getPropValue("name");
|
|
19
|
+
|
|
20
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
21
|
+
|
|
22
|
+
console.log(">>>>>", editorData);
|
|
23
|
+
|
|
24
|
+
let returnData = editorData.data[fieldName];
|
|
25
|
+
if(!returnData) {
|
|
26
|
+
returnData = 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return returnData;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
_valueChanged() {
|
|
34
|
+
//console.log("_valueChanged");
|
|
35
|
+
|
|
36
|
+
let fieldName = this.getPropValue("name");
|
|
37
|
+
let newValue = this.item.value;
|
|
38
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
39
|
+
|
|
40
|
+
let newData = {...editorData.data};
|
|
41
|
+
newData[fieldName] = newValue;
|
|
42
|
+
|
|
43
|
+
editorData.data = newData;
|
|
44
|
+
|
|
45
|
+
this.context.moduleData.editorData.editorBlock.dataUpdated();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
_objectChanged() {
|
|
49
|
+
//console.log("_objectChanged");
|
|
50
|
+
|
|
51
|
+
this.item.value = this._getObjectData();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_renderMainElement() {
|
|
55
|
+
return this._createMainElement(Dbm.react.form.GraphApiObjectSelection, {value: this.item.properties.value, objectType: this.getPropValue("objectType"), className: "standard-field standard-field-padding full-width"});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export {default as TextField} from "./TextField.js";
|
|
2
2
|
export {default as RichTextField} from "./RichTextField.js";
|
|
3
3
|
export {default as ImageField} from "./ImageField.js";
|
|
4
|
-
export {default as CheckboxField} from "./CheckboxField.js";
|
|
4
|
+
export {default as CheckboxField} from "./CheckboxField.js";
|
|
5
|
+
export {default as SelectObjectField} from "./SelectObjectField.js";
|
package/react/area/List.js
CHANGED
|
@@ -27,6 +27,10 @@ export default class List extends Dbm.react.BaseObject {
|
|
|
27
27
|
let mainChildren = slots.main;
|
|
28
28
|
|
|
29
29
|
let currentArray = items;
|
|
30
|
+
if(!currentArray || isNaN(currentArray.length)) {
|
|
31
|
+
console.error("Items is not an array", this);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
30
34
|
let currentArrayLength = currentArray.length;
|
|
31
35
|
let newChildren = [];
|
|
32
36
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class AddItemToContext extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
render() {
|
|
10
|
+
|
|
11
|
+
let item = this.getPropValue("item");
|
|
12
|
+
let id = Dbm.objectPath(item, "id");
|
|
13
|
+
|
|
14
|
+
let as = this.getPropValue("as");
|
|
15
|
+
if(!as) {
|
|
16
|
+
as = "item";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let values = {};
|
|
20
|
+
values[as] = item;
|
|
21
|
+
|
|
22
|
+
return React.createElement(Dbm.react.context.AddContextVariables, {"values": values, "key": id}, this.props.children);
|
|
23
|
+
}
|
|
24
|
+
}
|
package/react/context/index.js
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class GraphApiObjectSelection extends Dbm.react.form.Selection {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.getDynamicProp("value", "");
|
|
9
|
+
this.item.requireProperty("items", []);
|
|
10
|
+
|
|
11
|
+
let objectType = this.getPropValue("objectType")
|
|
12
|
+
|
|
13
|
+
let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
|
|
14
|
+
{
|
|
15
|
+
let request = graphApi.requestRange(
|
|
16
|
+
[
|
|
17
|
+
{"type": "byObjectType", "objectType": objectType},
|
|
18
|
+
{"type": "includeDraft"},
|
|
19
|
+
{"type": "includePrivate"}
|
|
20
|
+
],
|
|
21
|
+
["name"]
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
Dbm.flow.addUpdateCommandWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._itemsLoaded.bind(this), [request]));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_itemsLoaded(aRequest) {
|
|
30
|
+
let options = [];
|
|
31
|
+
|
|
32
|
+
options.push(React.createElement("option", {key: 0, value: 0}, "None"));
|
|
33
|
+
|
|
34
|
+
let currentArray = [].concat(aRequest.items);
|
|
35
|
+
Dbm.utils.ArrayFunctions.sortOnField(currentArray, "name");
|
|
36
|
+
|
|
37
|
+
let currentArrayLength = currentArray.length;
|
|
38
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
39
|
+
let currentItem = currentArray[i];
|
|
40
|
+
options.push(React.createElement("option", {key: currentItem["id"], value: currentItem["id"]}, currentItem["name"] + " (id: " + currentItem["id"] + ")"));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.item.items = options;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_renderMainElement() {
|
|
47
|
+
|
|
48
|
+
let value = this.getDynamicProp("value");
|
|
49
|
+
|
|
50
|
+
return this._createMainElement(Dbm.react.form.Selection, {"value": value}, this.item.properties.items);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class Selection extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.getDynamicProp("value", "");
|
|
9
|
+
|
|
10
|
+
this._callback_changeBound = this._callback_change.bind(this);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
_callback_change(aEvent) {
|
|
14
|
+
//console.log("_callback_change");
|
|
15
|
+
//console.log(aEvent);
|
|
16
|
+
|
|
17
|
+
let value = aEvent.target.value;
|
|
18
|
+
|
|
19
|
+
this.getDynamicProp("value").getMostUpstreamProperty().setValue(value);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_renderMainElement() {
|
|
23
|
+
|
|
24
|
+
let value = this.getDynamicProp("value").value;
|
|
25
|
+
|
|
26
|
+
return this._createMainElement("select", {"value": value, onChange: this._callback_changeBound}, this.getPropValue("children"));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
package/react/form/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export {default as Checkbox} from "./Checkbox.js";
|
|
2
2
|
export {default as FormField} from "./FormField.js";
|
|
3
3
|
export {default as LabelledArea} from "./LabelledArea.js";
|
|
4
|
-
export {default as FileDropArea} from "./FileDropArea.js";
|
|
4
|
+
export {default as FileDropArea} from "./FileDropArea.js";
|
|
5
|
+
export {default as Selection} from "./Selection.js";
|
|
6
|
+
export {default as GraphApiObjectSelection} from "./GraphApiObjectSelection.js";
|
|
@@ -4,7 +4,8 @@ export default class MetaPixelTracker extends Dbm.core.BaseObject {
|
|
|
4
4
|
_construct() {
|
|
5
5
|
super._construct();
|
|
6
6
|
|
|
7
|
-
this.
|
|
7
|
+
this._isStarted = false;
|
|
8
|
+
this.item.requireProperty("pixelId");
|
|
8
9
|
}
|
|
9
10
|
|
|
10
11
|
_setupFunction() {
|
|
@@ -45,6 +46,7 @@ export default class MetaPixelTracker extends Dbm.core.BaseObject {
|
|
|
45
46
|
|
|
46
47
|
startMarketingTracking() {
|
|
47
48
|
|
|
49
|
+
this._isStarted = true;
|
|
48
50
|
this._setupFunction();
|
|
49
51
|
Dbm.loading.loadScript("https://connect.facebook.net/en_US/fbevents.js");
|
|
50
52
|
|
|
@@ -85,6 +87,8 @@ export default class MetaPixelTracker extends Dbm.core.BaseObject {
|
|
|
85
87
|
console.log("trackEvent");
|
|
86
88
|
console.log(aEventName, aData);
|
|
87
89
|
|
|
90
|
+
if(!this._isStarted) return;
|
|
91
|
+
|
|
88
92
|
if(aEventName === "Purchase") {
|
|
89
93
|
window.fbq('track', 'Purchase', this._convertGooogleAnalyctisData(aData), {eventID: aData.transaction_id});
|
|
90
94
|
}
|
|
@@ -103,10 +107,12 @@ export default class MetaPixelTracker extends Dbm.core.BaseObject {
|
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
trackCurrentPage() {
|
|
110
|
+
if(!this._isStarted) return;
|
|
106
111
|
window.fbq("track", "PageView");
|
|
107
112
|
}
|
|
108
113
|
|
|
109
114
|
trackPage(aUrl) {
|
|
115
|
+
if(!this._isStarted) return;
|
|
110
116
|
window.fbq("track", "PageView");
|
|
111
117
|
}
|
|
112
118
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import Dbm from "../index.js";
|
|
2
|
+
|
|
3
|
+
export default class TagManagerTracker extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
this.item.requireProperty("tagManagerId");
|
|
8
|
+
this.item.requireProperty("customDataLayerName");
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
loadTagManager() {
|
|
13
|
+
|
|
14
|
+
let id = this.item.tagManagerId;
|
|
15
|
+
|
|
16
|
+
let url = "https://www.googletagmanager.com/gtm.js?id="+id;
|
|
17
|
+
if(this.item.customDataLayerName) {
|
|
18
|
+
url += "&l=" + this.customDataLayerName;
|
|
19
|
+
}
|
|
20
|
+
Dbm.loading.loadScript(url);
|
|
21
|
+
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
startTracking() {
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
startStatisticsTracking() {
|
|
30
|
+
console.log("TagManagerTracker::startStatisticsTracking");
|
|
31
|
+
this.loadTagManager();
|
|
32
|
+
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
startMarketingTracking() {
|
|
37
|
+
|
|
38
|
+
this.loadTagManager();
|
|
39
|
+
|
|
40
|
+
return this;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
stopTracking() {
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
trackEvent(aEventName, aData) {
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
trackCurrentPage() {
|
|
52
|
+
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
trackPage(aUrl) {
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
}
|
package/tracking/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import Dbm from "../index.js";
|
|
|
3
3
|
export {default as Controller} from "./Controller.js";
|
|
4
4
|
export {default as DataLayerTracker} from "./DataLayerTracker.js";
|
|
5
5
|
export {default as MetaPixelTracker} from "./MetaPixelTracker.js";
|
|
6
|
+
export {default as TagManagerTracker} from "./TagManagerTracker.js";
|
|
6
7
|
|
|
7
8
|
export const setup = function() {
|
|
8
9
|
|
|
@@ -24,4 +25,11 @@ export const addMetaPixel = function(aPixelId) {
|
|
|
24
25
|
|
|
25
26
|
export const setCurrency = function(aCurrency) {
|
|
26
27
|
Dbm.getInstance().repository.getItem("trackingController").currency = aCurrency;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const addTagManagerTracking = function(aId) {
|
|
31
|
+
console.log("addTagManagerTracking");
|
|
32
|
+
let tracker = new Dbm.tracking.TagManagerTracker();
|
|
33
|
+
tracker.item.tagManagerId = aId;
|
|
34
|
+
Dbm.getInstance().repository.getItem("trackingController").controller.addTracker(tracker.item);
|
|
27
35
|
}
|
package/utils/ArrayFunctions.js
CHANGED
|
@@ -117,6 +117,17 @@ export const arrayOrSeparatedString = function(aData, aSeparator = ",", aTrim =
|
|
|
117
117
|
return [];
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
export const numericArrayOrSeparatedString = function(aData, aSeparator = ",", aTrim = 3) {
|
|
121
|
+
let returnArray = new Array();
|
|
122
|
+
let currentArray = arrayOrSeparatedString(aData, aSeparator, aTrim);
|
|
123
|
+
let currentarrayLength = currentArray.length;
|
|
124
|
+
for(let i = 0; i < currentarrayLength; i++) {
|
|
125
|
+
returnArray.push(parseFloat(currentArray[i]));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return returnArray;
|
|
129
|
+
}
|
|
130
|
+
|
|
120
131
|
export const filterByField = function(aArray, aField, aValue) {
|
|
121
132
|
let returnArray = [];
|
|
122
133
|
|
|
@@ -144,4 +155,117 @@ export const mapField = function(aArray, aField) {
|
|
|
144
155
|
}
|
|
145
156
|
|
|
146
157
|
return returnArray;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export const group = function(aArray, aField) {
|
|
161
|
+
|
|
162
|
+
let groups = new Map();
|
|
163
|
+
|
|
164
|
+
let currentArray = aArray;
|
|
165
|
+
let currentArrayLength = currentArray.length;
|
|
166
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
167
|
+
let currentObject = aArray[i];
|
|
168
|
+
let groupValue = Dbm.objectPath(aArray[i], aField);
|
|
169
|
+
|
|
170
|
+
if(!groups.has(groupValue)) {
|
|
171
|
+
groups.set(groupValue, []);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
groups.get(groupValue).push(currentObject);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
let returnArray = [];
|
|
178
|
+
|
|
179
|
+
for (const value of groups.entries()) {
|
|
180
|
+
returnArray.push({"key": value[0], "value": value[1]});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return returnArray;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export const makeFlat = function(aArray) {
|
|
187
|
+
let returnArray = [];
|
|
188
|
+
|
|
189
|
+
let currentArray = aArray;
|
|
190
|
+
let currentArrayLength = currentArray.length;
|
|
191
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
192
|
+
returnArray = returnArray.concat(currentArray[i]);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return returnArray;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export const getUnselectedItems = function(aSelectedItems, aAllItems) {
|
|
199
|
+
let returnItems = new Array();
|
|
200
|
+
|
|
201
|
+
let currentArray = aAllItems;
|
|
202
|
+
let currentArrayLength = currentArray.length;
|
|
203
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
204
|
+
let currentItem = currentArray[i];
|
|
205
|
+
if(aSelectedItems.indexOf(currentItem) === -1) {
|
|
206
|
+
returnItems.push(currentItem);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return returnItems;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export const sortOnField = function(aArray, aField) {
|
|
214
|
+
let sortFunction = function(aA, aB) {
|
|
215
|
+
let aValue = Dbm.objectPath(aA, aField);
|
|
216
|
+
let bValue = Dbm.objectPath(aB, aField);
|
|
217
|
+
|
|
218
|
+
if(aValue < bValue) {
|
|
219
|
+
return -1;
|
|
220
|
+
}
|
|
221
|
+
else if(aValue > bValue) {
|
|
222
|
+
return 1;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return 0;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
aArray.sort(sortFunction);
|
|
229
|
+
|
|
230
|
+
return aArray;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export const sortOnNumericField = function(aArray, aField) {
|
|
234
|
+
let sortFunction = function(aA, aB) {
|
|
235
|
+
let aValue = 1*Dbm.objectPath(aA, aField);
|
|
236
|
+
let bValue = 1*Dbm.objectPath(aB, aField);
|
|
237
|
+
|
|
238
|
+
if(aValue < bValue) {
|
|
239
|
+
return -1;
|
|
240
|
+
}
|
|
241
|
+
else if(aValue > bValue) {
|
|
242
|
+
return 1;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return 0;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
aArray.sort(sortFunction);
|
|
249
|
+
|
|
250
|
+
return aArray;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export const getItemIndexByIfExists = function(aArray, aField, aIdentifier) {
|
|
254
|
+
|
|
255
|
+
if(!Array.isArray(aArray)) {
|
|
256
|
+
console.warn("No array provided", aArray);
|
|
257
|
+
return -1;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
let currentArray = aArray;
|
|
261
|
+
let currentArrayLength = currentArray.length;
|
|
262
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
263
|
+
let currentItem = currentArray[i];
|
|
264
|
+
let currentValue = Dbm.objectPath(currentItem, aField);
|
|
265
|
+
if(currentValue == aIdentifier) {
|
|
266
|
+
return i;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return -1;
|
|
147
271
|
}
|