dbm 1.4.7 → 1.4.8
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/core/BaseObject.js +4 -5
- package/core/LifeCycleObject.js +13 -1
- package/dbm.js +2 -1
- package/flow/FlowProperty.js +38 -0
- package/flow/index.js +4 -4
- package/form/Field.js +76 -0
- package/form/Form.js +87 -0
- package/form/index.js +6 -0
- package/form/validation/Validation.js +23 -0
- package/form/validation/ValidationFunctions.js +23 -0
- package/form/validation/index.js +4 -0
- package/graphapi/webclient/WebSocketConnection.js +6 -2
- package/loading/FontLoader.js +47 -0
- package/loading/index.js +21 -0
- package/package.json +1 -1
- package/react/BaseObject.js +27 -0
- package/react/area/SwitchableArea.js +1 -1
- package/react/area/index.js +11 -0
- package/react/form/FormField.js +18 -1
- package/react/form/index.js +26 -1
- package/startup/index.js +3 -0
- package/tracking/Controller.js +8 -8
- package/tracking/DataLayerTracker.js +23 -4
- package/tracking/index.js +5 -3
package/core/BaseObject.js
CHANGED
|
@@ -33,20 +33,19 @@ export default class BaseObject extends Dbm.core.LifeCycleObject {
|
|
|
33
33
|
|
|
34
34
|
_propertyOrName(aPropertyOrName) {
|
|
35
35
|
if(typeof(aPropertyOrName) === "string") {
|
|
36
|
-
return this.item[aPropertyOrName];
|
|
36
|
+
return this.item.properties[aPropertyOrName];
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
return aPropertyOrName;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
addUpdateCall(aPropertyOrName, aFunction, aArguments = []) {
|
|
43
|
-
|
|
44
|
-
addUpdateCommand(this._propertyOrName(aPropertyOrName), aMatchValue, this._getScopedCallFunctionCommand(aFunction, aArguments));
|
|
43
|
+
this._propertyOrName(aPropertyOrName).addUpdate(this._getScopedCallFunctionCommand(aFunction, aArguments));
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
addUpdateCallWhenMatched(aPropertyOrName, aMatchValue, aFunction, aArguments = []) {
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
console.log(this._propertyOrName(aPropertyOrName), aPropertyOrName, this);
|
|
48
|
+
this._propertyOrName(aPropertyOrName).addUpdateWhenMatched(aMatchValue, this._getScopedCallFunctionCommand(aFunction, aArguments));
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
destroy() {
|
package/core/LifeCycleObject.js
CHANGED
|
@@ -19,7 +19,19 @@ export default class LifeCycleObject {
|
|
|
19
19
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
retain() {
|
|
23
|
+
//METODO
|
|
24
|
+
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
release() {
|
|
23
29
|
//METODO
|
|
24
30
|
}
|
|
31
|
+
|
|
32
|
+
destroy() {
|
|
33
|
+
if(process.env.NODE_ENV === "development") {
|
|
34
|
+
this._debugId = null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
25
37
|
}
|
package/dbm.js
CHANGED
|
@@ -113,4 +113,5 @@ export * as startup from "./startup/index.js";
|
|
|
113
113
|
export * as site from "./site/index.js";
|
|
114
114
|
export * as tracking from "./tracking/index.js";
|
|
115
115
|
export * as ecommerce from "./ecommerce/index.js";
|
|
116
|
-
export * as node from "./node/index.js";
|
|
116
|
+
export * as node from "./node/index.js";
|
|
117
|
+
export * as form from "./form/index.js";
|
package/flow/FlowProperty.js
CHANGED
|
@@ -155,4 +155,42 @@ export default class FlowProperty extends Dbm.flow.FlowBaseObject {
|
|
|
155
155
|
this._upstreamConnection = null;
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
+
|
|
159
|
+
addUpdate(aCommand) {
|
|
160
|
+
let addUpdateCommand = Dbm.objectPath(Dbm.getRepositoryItem("library"), "Dbm/flow/addUpdateCommand");
|
|
161
|
+
addUpdateCommand(this, aCommand);
|
|
162
|
+
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
addUpdateWhenMatched(aMatchValue, aCommand) {
|
|
167
|
+
let addUpdateCommandWhenMatched = Dbm.objectPath(Dbm.getRepositoryItem("library"), "Dbm/flow/addUpdateCommandWhenMatched");
|
|
168
|
+
addUpdateCommandWhenMatched(this, aMatchValue, aCommand);
|
|
169
|
+
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
createCondition(aMatchValue, aCompareType = "===") {
|
|
174
|
+
let UpdateFunctionClass = Dbm.objectPath(Dbm.getRepositoryItem("library"), "Dbm/flow/updatefunctions/logic/Condition");
|
|
175
|
+
let updateFunction = new UpdateFunctionClass();
|
|
176
|
+
updateFunction.input.properties.input1.connectInput(this);
|
|
177
|
+
updateFunction.input.input2 = aMatchValue;
|
|
178
|
+
updateFunction.input.operation = aCompareType;
|
|
179
|
+
|
|
180
|
+
return updateFunction.output.properties.result;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
createSwitch(aDefaultValue, aValues) {
|
|
184
|
+
let UpdateFunctionClass = Dbm.objectPath(Dbm.getRepositoryItem("library"), "Dbm/flow/updatefunctions/logic/Switch");
|
|
185
|
+
let updateFunction = new UpdateFunctionClass();
|
|
186
|
+
updateFunction.input.properties.value.connectInput(this);
|
|
187
|
+
updateFunction.setDefaultValue(aDefaultValue);
|
|
188
|
+
|
|
189
|
+
//METODO: do better normalization
|
|
190
|
+
for(let objectName in aValues) {
|
|
191
|
+
updateFunction.addCase(objectName, aValues[objectName]);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return updateFunction.output.properties.value;
|
|
195
|
+
}
|
|
158
196
|
}
|
package/flow/index.js
CHANGED
|
@@ -18,7 +18,7 @@ export const addUpdateCommand = function(aProperty, aCommand) {
|
|
|
18
18
|
updateFunction.input.command = aCommand;
|
|
19
19
|
updateFunction.noFirstTriggger();
|
|
20
20
|
|
|
21
|
-
let updatePropertyCommand = Dbm.commands.callFunction(Dbm.
|
|
21
|
+
let updatePropertyCommand = Dbm.commands.callFunction(Dbm.repository.getControllerIfExists("propertyUpdater").addSinglePropertyUpdateBound, [Dbm.core.source.staticObject(updateFunction.output.properties.value)]);
|
|
22
22
|
|
|
23
23
|
let dirtyCommands = new Dbm.flow.DirtyCommands();
|
|
24
24
|
updateFunction.output.properties.value.connectOutput(dirtyCommands);
|
|
@@ -43,11 +43,11 @@ export const addDirectUpdateCommand = function(aProperty, aCommand) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
export const addUpdateCommandWhenMatched = function(aProperty, aMatchValue, aCommand) {
|
|
46
|
-
let
|
|
46
|
+
let matchUpdateFunction = Dbm.flow.updatefunctions.logic.whenMatched(aProperty, aMatchValue);
|
|
47
47
|
|
|
48
|
-
let updateData = Dbm.flow.addUpdateCommand(
|
|
48
|
+
let updateData = Dbm.flow.addUpdateCommand(matchUpdateFunction.output.properties.value, aCommand);
|
|
49
49
|
|
|
50
|
-
updateData["
|
|
50
|
+
updateData["matchUpdateFunction"] = matchUpdateFunction;
|
|
51
51
|
|
|
52
52
|
return updateData;
|
|
53
53
|
}
|
package/form/Field.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import Dbm from "../index.js";
|
|
2
|
+
|
|
3
|
+
export default class Field extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
let changeCommand = this._getScopedCallFunctionCommand(this._changed);
|
|
8
|
+
let focusChangedCommand = this._getScopedCallFunctionCommand(this._focusChanged);
|
|
9
|
+
let validationChangedCommand = this._getScopedCallFunctionCommand(this._validationActiveChange);
|
|
10
|
+
|
|
11
|
+
this.item.requireProperty("value", null).addUpdate(changeCommand);
|
|
12
|
+
|
|
13
|
+
let validation = new Dbm.form.validation.Validation();
|
|
14
|
+
validation.item.field = this.item;
|
|
15
|
+
validation.item.properties.active.addUpdate(validationChangedCommand);
|
|
16
|
+
validation.item.properties.validationFunction.addUpdate(validationChangedCommand);
|
|
17
|
+
|
|
18
|
+
this.item.requireProperty("validation", validation.item);
|
|
19
|
+
this.item.requireProperty("editing", false).addUpdate(focusChangedCommand);
|
|
20
|
+
this.item.requireProperty("valid", true);
|
|
21
|
+
this.item.requireProperty("validationState", "notValidated");
|
|
22
|
+
this.item.requireProperty("validationMode", null);
|
|
23
|
+
this.item.requireProperty("focusMode", "reset");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
validate() {
|
|
27
|
+
if(this.item.validation.active) {
|
|
28
|
+
let newState = this.item.valid ? "valid" : "invalid";
|
|
29
|
+
this.item.validationState = newState;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
this.item.valid = true;
|
|
33
|
+
this.item.validationState = "notValidated";
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return this.item.valid;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getValue() {
|
|
40
|
+
return this.item.value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
_validationActiveChange() {
|
|
44
|
+
//console.log("_validationActiveChange");
|
|
45
|
+
if(this.item.validation.active) {
|
|
46
|
+
this._changed();
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
this.item.valid = true;
|
|
50
|
+
this.item.validationState = "notValidated";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_changed() {
|
|
55
|
+
//console.log("_changed");
|
|
56
|
+
this.item.valid = this.item.validation.controller.validate();
|
|
57
|
+
|
|
58
|
+
if(this.item.validationMode === "onChange") {
|
|
59
|
+
this.validate();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
_focusChanged() {
|
|
64
|
+
//console.log("_focus");
|
|
65
|
+
if(this.item.editing) {
|
|
66
|
+
if(this.item.focusMode === "reset") {
|
|
67
|
+
this.item.validationState = "notValidated";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
if(this.item.validationMode === "onBlur") {
|
|
72
|
+
this.validate();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
package/form/Form.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import Dbm from "../index.js";
|
|
2
|
+
|
|
3
|
+
export default class Form extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
let all = Dbm.flow.updatefunctions.logic.all();
|
|
8
|
+
this.item.requireProperty("all", all);
|
|
9
|
+
|
|
10
|
+
this.item.requireProperty("valid", true).connectInput(all.output.properties.value);
|
|
11
|
+
this.item.requireProperty("fields", new Dbm.repository.Item());
|
|
12
|
+
this.item.requireProperty("fieldNames", []);
|
|
13
|
+
this.item.requireProperty("defaultValidationMode", "onBlur");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
addExistingField(aName, aField) {
|
|
17
|
+
this.item.fields.setValue(aName, aField.item);
|
|
18
|
+
this.item.all.addCheck(aField.item.properties.valid);
|
|
19
|
+
this.item.addToArray("fieldNames", aName);
|
|
20
|
+
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
createField(aName, aValue = null, aValidationFunction = null, aValidationActive = null) {
|
|
25
|
+
|
|
26
|
+
if(this.item.fields[aName]) {
|
|
27
|
+
console.error("Field " + aName + " already exists");
|
|
28
|
+
return this.item.fields[aName].controller;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let newField = new Dbm.form.Field();
|
|
32
|
+
newField.item.value = aValue;
|
|
33
|
+
newField.item.validationMode = this.item.defaultValidationMode;
|
|
34
|
+
if(aValidationFunction) {
|
|
35
|
+
newField.item.validation.validationFunction = aValidationFunction;
|
|
36
|
+
}
|
|
37
|
+
if(aValidationActive) {
|
|
38
|
+
newField.item.validation.properties.active.setOrConnect(aValidationActive);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
this.addExistingField(aName, newField);
|
|
42
|
+
|
|
43
|
+
return newField;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
createGroup(aName) {
|
|
47
|
+
let newForm = new Dbm.form.Form();
|
|
48
|
+
newForm.item.defaultValidationMode = this.item.defaultValidationMode;
|
|
49
|
+
|
|
50
|
+
this.addExistingField(aName, newForm);
|
|
51
|
+
|
|
52
|
+
return newForm;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
validate() {
|
|
56
|
+
console.log("validate");
|
|
57
|
+
|
|
58
|
+
let currentArray = this.item.fieldNames;
|
|
59
|
+
let currentArrayLength = currentArray.length;
|
|
60
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
61
|
+
let currentName = currentArray[i];
|
|
62
|
+
|
|
63
|
+
let result = this.item.fields[currentName].controller.validate();
|
|
64
|
+
|
|
65
|
+
if(!result) {
|
|
66
|
+
console.log("Field " + currentName + " is not valid.", this.item.fields[currentName]);
|
|
67
|
+
}
|
|
68
|
+
//METODO: return the result in some format
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return this.item.valid;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
getValue() {
|
|
75
|
+
let returnObject = {};
|
|
76
|
+
|
|
77
|
+
let currentArray = this.item.fieldNames;
|
|
78
|
+
let currentArrayLength = currentArray.length;
|
|
79
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
80
|
+
let currentName = currentArray[i];
|
|
81
|
+
|
|
82
|
+
returnObject[currentName] = this.item.fields[currentName].controller.getValue();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return returnObject;
|
|
86
|
+
}
|
|
87
|
+
}
|
package/form/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class Validation extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
this.item.requireProperty("field", null);
|
|
8
|
+
this.item.requireProperty("active", true);
|
|
9
|
+
this.item.requireProperty("validationFunction", Dbm.form.validation.ValidationFunctions.noValidation);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
validate() {
|
|
13
|
+
if(!this.item.active) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
let validationFunction = this.item.validationFunction;
|
|
17
|
+
return validationFunction(this.item);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static noValidation(aValidation) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
|
|
3
|
+
export const noValidation = function(aValidation) {
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const notEmpty = function(aValidation) {
|
|
8
|
+
//console.log("notEmpty");
|
|
9
|
+
|
|
10
|
+
if(aValidation.field.value && aValidation.field.value.length > 0) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const checked = function(aValidation) {
|
|
17
|
+
//console.log("notEmpty");
|
|
18
|
+
|
|
19
|
+
if(aValidation.field.value) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
@@ -294,7 +294,9 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
294
294
|
{
|
|
295
295
|
let item = repository.getItem(data["requestId"]);
|
|
296
296
|
if(data["id"]) {
|
|
297
|
-
|
|
297
|
+
let userItem = repository.getItem(data["user"]);
|
|
298
|
+
userItem.setValue("roles", data["roles"]);
|
|
299
|
+
item.setValue("user", userItem);
|
|
298
300
|
}
|
|
299
301
|
else {
|
|
300
302
|
item.setValue("user", null);
|
|
@@ -307,7 +309,9 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
307
309
|
case "connectionReady":
|
|
308
310
|
{
|
|
309
311
|
if(data["user"]) {
|
|
310
|
-
|
|
312
|
+
let userItem = repository.getItem(data["user"]);
|
|
313
|
+
userItem.setValue("roles", data["roles"]);
|
|
314
|
+
repository.getItem("site").currentUser = userItem;
|
|
311
315
|
}
|
|
312
316
|
else {
|
|
313
317
|
repository.getItem("site").currentUser = null;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import Dbm from "../index.js";
|
|
2
|
+
|
|
3
|
+
export default class FontLoader extends Dbm.core.BaseObject {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
|
|
7
|
+
this._url = null;
|
|
8
|
+
this._fontName = null;
|
|
9
|
+
this._element = null;
|
|
10
|
+
this._promise = null;
|
|
11
|
+
|
|
12
|
+
this.item.setValue("status", Dbm.loading.LoadingStatus.NOT_STARTED);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
setUrl(aUrl) {
|
|
16
|
+
this._url = aUrl;
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
setFontName(aFontName) {
|
|
21
|
+
this._fontName = aFontName;
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
load() {
|
|
26
|
+
|
|
27
|
+
if(!this._element) {
|
|
28
|
+
this.item.setValue("status", Dbm.loading.LoadingStatus.LOADING);
|
|
29
|
+
|
|
30
|
+
let element = document.createElement("link");
|
|
31
|
+
element.href = this._url;
|
|
32
|
+
element.rel = "stylesheet";
|
|
33
|
+
|
|
34
|
+
this._element = element;
|
|
35
|
+
|
|
36
|
+
document.head.appendChild(element);
|
|
37
|
+
|
|
38
|
+
this._promise = document.fonts.load("16px " + JSON.stringify(this._fontName));
|
|
39
|
+
this._promise.then(() => {
|
|
40
|
+
this.item.setValue("status", Dbm.loading.LoadingStatus.LOADED);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
}
|
package/loading/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export {default as ScriptLoader} from "./ScriptLoader.js";
|
|
|
4
4
|
export {default as JsonLoader} from "./JsonLoader.js";
|
|
5
5
|
export {default as ImageLoader} from "./ImageLoader.js";
|
|
6
6
|
export {default as LoadingSequence} from "./LoadingSequence.js";
|
|
7
|
+
export {default as FontLoader} from "./FontLoader.js";
|
|
7
8
|
|
|
8
9
|
export * as LoadingStatus from "./LoadingStatus.js";
|
|
9
10
|
|
|
@@ -52,5 +53,25 @@ export const loadImage = function(aUrl) {
|
|
|
52
53
|
let loader = getImageLoader(aUrl);
|
|
53
54
|
loader.load();
|
|
54
55
|
|
|
56
|
+
return loader;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const loadFont = function(aUrl, aFontName) {
|
|
60
|
+
let loaderName = "loader-" + aUrl;
|
|
61
|
+
let loaderItem = Dbm.getInstance().repository.getItemIfExists(loaderName);
|
|
62
|
+
|
|
63
|
+
let loader;
|
|
64
|
+
if(!loaderItem) {
|
|
65
|
+
loader = new Dbm.loading.FontLoader();
|
|
66
|
+
loader.item.register(loaderName);
|
|
67
|
+
loader.setUrl(aUrl);
|
|
68
|
+
loader.setFontName(aFontName);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
loader = loaderItem.controller;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
loader.load();
|
|
75
|
+
|
|
55
76
|
return loader;
|
|
56
77
|
}
|
package/package.json
CHANGED
package/react/BaseObject.js
CHANGED
|
@@ -227,6 +227,33 @@ export default class BaseObject extends Component {
|
|
|
227
227
|
|
|
228
228
|
return createElement.apply(null, callArray);
|
|
229
229
|
}
|
|
230
|
+
|
|
231
|
+
_getScopedCallFunctionCommand(aFunction, aArguments = []) {
|
|
232
|
+
let CallFunction = Dbm.objectPath(Dbm.getRepositoryItem("library"), "Dbm/commands/CallFunction");
|
|
233
|
+
let command = new CallFunction();
|
|
234
|
+
command.item.scopeObject = this;
|
|
235
|
+
command.item.callFunction = aFunction;
|
|
236
|
+
command.item.callArguments = aArguments;
|
|
237
|
+
|
|
238
|
+
return command;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
_propertyOrName(aPropertyOrName) {
|
|
242
|
+
if(typeof(aPropertyOrName) === "string") {
|
|
243
|
+
return this.item.properties[aPropertyOrName];
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return aPropertyOrName;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
addUpdateCall(aPropertyOrName, aFunction, aArguments = []) {
|
|
250
|
+
this._propertyOrName(aPropertyOrName).addUpdate(this._getScopedCallFunctionCommand(aFunction, aArguments));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
addUpdateCallWhenMatched(aPropertyOrName, aMatchValue, aFunction, aArguments = []) {
|
|
254
|
+
console.log(this._propertyOrName(aPropertyOrName), aPropertyOrName);
|
|
255
|
+
this._propertyOrName(aPropertyOrName).addUpdateWhenMatched(aMatchValue, this._getScopedCallFunctionCommand(aFunction, aArguments));
|
|
256
|
+
}
|
|
230
257
|
}
|
|
231
258
|
|
|
232
259
|
BaseObject.contextType = Context;
|
|
@@ -27,7 +27,7 @@ export default class SwitchableArea extends Dbm.react.BaseObject {
|
|
|
27
27
|
slotElement = mainChildren;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
this.item.element = React.createElement(React.Fragment, {key:
|
|
30
|
+
this.item.element = React.createElement(React.Fragment, {key: area}, slotElement);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
_renderMainElement() {
|
package/react/area/index.js
CHANGED
|
@@ -29,4 +29,15 @@ export const centeredFlexDiv = function(aChildren) {
|
|
|
29
29
|
return React.createElement("div", {className: "flex-row justify-center"},
|
|
30
30
|
React.createElement("div", {className: "flex-row-item"}, aChildren)
|
|
31
31
|
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const processStateElement = function(aState, aIdleElement, aProcessingElement, aCompletedElement) {
|
|
35
|
+
let updateFunction = Dbm.flow.updatefunctions.logic.switchValue(aState);
|
|
36
|
+
updateFunction.setDefaultValue(aIdleElement);
|
|
37
|
+
updateFunction.addCase(Dbm.loading.LoadingStatus.LOADING, aProcessingElement);
|
|
38
|
+
updateFunction.addCase(Dbm.loading.LoadingStatus.LOADED, aCompletedElement);
|
|
39
|
+
|
|
40
|
+
let element = React.createElement(Dbm.react.area.InsertElement, {"element": updateFunction.output.properties.value});
|
|
41
|
+
|
|
42
|
+
return updateFunction;
|
|
32
43
|
}
|
package/react/form/FormField.js
CHANGED
|
@@ -6,9 +6,12 @@ export default class FormField extends Dbm.react.BaseObject {
|
|
|
6
6
|
super._construct();
|
|
7
7
|
|
|
8
8
|
this.getDynamicProp("value", "");
|
|
9
|
+
this.getDynamicPropWithoutState("editing", false);
|
|
9
10
|
this.state["formUpdate"] = 0;
|
|
10
11
|
|
|
11
12
|
this._callback_changeBound = this._callback_change.bind(this);
|
|
13
|
+
this._callback_focusBound = this._callback_focus.bind(this);
|
|
14
|
+
this._callback_blurBound = this._callback_blur.bind(this);
|
|
12
15
|
}
|
|
13
16
|
|
|
14
17
|
_callback_change(aEvent) {
|
|
@@ -21,11 +24,25 @@ export default class FormField extends Dbm.react.BaseObject {
|
|
|
21
24
|
this.setState({"formUpdate": this.state.formUpdate}); //MENOTE: trigger change direct to not lose focus on input
|
|
22
25
|
}
|
|
23
26
|
|
|
27
|
+
_callback_focus(aEvent) {
|
|
28
|
+
//console.log("_callback_focus");
|
|
29
|
+
//console.log(aEvent);
|
|
30
|
+
|
|
31
|
+
this.getDynamicProp("editing").getMostUpstreamProperty().setValue(true);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_callback_blur(aEvent) {
|
|
35
|
+
//console.log("_callback_blur");
|
|
36
|
+
//console.log(aEvent);
|
|
37
|
+
|
|
38
|
+
this.getDynamicProp("editing").getMostUpstreamProperty().setValue(false);
|
|
39
|
+
}
|
|
40
|
+
|
|
24
41
|
_renderMainElement() {
|
|
25
42
|
|
|
26
43
|
let value = this.getDynamicProp("value").value;
|
|
27
44
|
|
|
28
|
-
return this._createMainElement("input", {"value": value, onChange: this._callback_changeBound});
|
|
45
|
+
return this._createMainElement("input", {"value": value, onChange: this._callback_changeBound, onFocus: this._callback_focusBound, onBlur: this._callback_blurBound});
|
|
29
46
|
}
|
|
30
47
|
}
|
|
31
48
|
|
package/react/form/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
1
4
|
export {default as Checkbox} from "./Checkbox.js";
|
|
2
5
|
export {default as FormField} from "./FormField.js";
|
|
3
6
|
export {default as LabelledArea} from "./LabelledArea.js";
|
|
@@ -12,4 +15,26 @@ export {default as EditObjectProperty} from "./EditObjectProperty.js";
|
|
|
12
15
|
export {default as Form} from "./Form.js";
|
|
13
16
|
export {default as Option} from "./Option.js";
|
|
14
17
|
export {default as Dropdown} from "./Dropdown.js";
|
|
15
|
-
export {default as GraphApiObjectOptions} from "./GraphApiObjectOptions.js";
|
|
18
|
+
export {default as GraphApiObjectOptions} from "./GraphApiObjectOptions.js";
|
|
19
|
+
|
|
20
|
+
export const validationStateClassName = function(aChildren) {
|
|
21
|
+
return React.createElement(Dbm.react.AddProps, {className: Dbm.react.source.contextVariable("field.properties.validationState")},
|
|
22
|
+
aChildren
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const fieldWithValidation = function(aFieldName, aPlaceHolderText = null, aClasses = "standard-field standard-field-padding full-width") {
|
|
27
|
+
let returnElement = React.createElement(Dbm.react.context.AddItemToContext, {item: Dbm.react.source.contextVariable("form.fields." + aFieldName), as: "field"},
|
|
28
|
+
validationStateClassName(
|
|
29
|
+
React.createElement(Dbm.react.form.FormField, {
|
|
30
|
+
value: Dbm.react.source.contextVariable("field.properties.value"),
|
|
31
|
+
editing: Dbm.react.source.contextVariable("field.properties.editing"),
|
|
32
|
+
className: aClasses,
|
|
33
|
+
placeholder: aPlaceHolderText
|
|
34
|
+
})
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
return returnElement;
|
|
39
|
+
}
|
|
40
|
+
|
package/startup/index.js
CHANGED
|
@@ -32,4 +32,7 @@ export const setupLibrary = function() {
|
|
|
32
32
|
library.setValue("Dbm/commands/CallFunction", Dbm.commands.CallFunction);
|
|
33
33
|
library.setValue("Dbm/flow/addUpdateCommand", Dbm.flow.addUpdateCommand);
|
|
34
34
|
library.setValue("Dbm/flow/addUpdateCommandWhenMatched", Dbm.flow.addUpdateCommandWhenMatched);
|
|
35
|
+
library.setValue("Dbm/flow/updatefunctions/logic/Condition", Dbm.flow.updatefunctions.logic.Condition);
|
|
36
|
+
library.setValue("Dbm/flow/updatefunctions/logic/Switch", Dbm.flow.updatefunctions.logic.Switch);
|
|
37
|
+
|
|
35
38
|
}
|
package/tracking/Controller.js
CHANGED
|
@@ -120,7 +120,7 @@ export default class Controller extends Dbm.core.BaseObject {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
trackEvent(aEventName, aData) {
|
|
123
|
+
trackEvent(aEventName, aData, aDataStructure = null) {
|
|
124
124
|
console.log("trackEvent");
|
|
125
125
|
console.log(aEventName, aData);
|
|
126
126
|
|
|
@@ -128,7 +128,7 @@ export default class Controller extends Dbm.core.BaseObject {
|
|
|
128
128
|
let currentArray = this.item.trackers;
|
|
129
129
|
let currentArrayLength = currentArray.length;
|
|
130
130
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
131
|
-
currentArray[i].controller.trackEvent(aEventName, aData);
|
|
131
|
+
currentArray[i].controller.trackEvent(aEventName, aData, aDataStructure);
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
@@ -184,7 +184,7 @@ export default class Controller extends Dbm.core.BaseObject {
|
|
|
184
184
|
items: items
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
this.trackEvent("Product view", data);
|
|
187
|
+
this.trackEvent("Product view", data, "ecommerce");
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
trackAddedToCart(aProductOrProducts) {
|
|
@@ -196,7 +196,7 @@ export default class Controller extends Dbm.core.BaseObject {
|
|
|
196
196
|
items: items
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
this.trackEvent("Added to cart", data);
|
|
199
|
+
this.trackEvent("Added to cart", data, "ecommerce");
|
|
200
200
|
|
|
201
201
|
}
|
|
202
202
|
|
|
@@ -209,7 +209,7 @@ export default class Controller extends Dbm.core.BaseObject {
|
|
|
209
209
|
items: items
|
|
210
210
|
}
|
|
211
211
|
|
|
212
|
-
this.trackEvent("Checkout started", data);
|
|
212
|
+
this.trackEvent("Checkout started", data, "ecommerce");
|
|
213
213
|
}
|
|
214
214
|
|
|
215
215
|
trackAddShipping(aProductOrProducts) {
|
|
@@ -221,7 +221,7 @@ export default class Controller extends Dbm.core.BaseObject {
|
|
|
221
221
|
items: items
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
this.trackEvent("Add shipping", data);
|
|
224
|
+
this.trackEvent("Add shipping", data, "ecommerce");
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
trackAddPayment(aProductOrProducts) {
|
|
@@ -233,7 +233,7 @@ export default class Controller extends Dbm.core.BaseObject {
|
|
|
233
233
|
items: items
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
this.trackEvent("Add payment", data);
|
|
236
|
+
this.trackEvent("Add payment", data, "ecommerce");
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
trackPurchase(aTransactionId, aProductOrProducts) {
|
|
@@ -246,7 +246,7 @@ export default class Controller extends Dbm.core.BaseObject {
|
|
|
246
246
|
items: items
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
this.trackEvent("Purchase", data);
|
|
249
|
+
this.trackEvent("Purchase", data, "ecommerce");
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
createProductItemData(aId, aName, aPrice, aQuantity = 1, aAddtionalData = {}) {
|
|
@@ -6,6 +6,9 @@ export default class DataLayerTracker extends Dbm.core.BaseObject {
|
|
|
6
6
|
|
|
7
7
|
this._statisticsTracking = false;
|
|
8
8
|
this._marketingTracking = false;
|
|
9
|
+
|
|
10
|
+
this.item.setValue("ecommerceDataWrapper", null);
|
|
11
|
+
this.item.setValue("eventNameMap", new Dbm.repository.Item());
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
addToDataLayer(aData) {
|
|
@@ -67,18 +70,34 @@ export default class DataLayerTracker extends Dbm.core.BaseObject {
|
|
|
67
70
|
return this;
|
|
68
71
|
}
|
|
69
72
|
|
|
70
|
-
trackEvent(aEventName, aData) {
|
|
73
|
+
trackEvent(aEventName, aData, aDataStructure = null) {
|
|
71
74
|
console.log("trackEvent");
|
|
72
|
-
console.log(aEventName, aData);
|
|
75
|
+
console.log(aEventName, aData, aDataStructure);
|
|
76
|
+
|
|
77
|
+
let translatedEventName = this.item.eventNameMap[aEventName];
|
|
78
|
+
if(translatedEventName) {
|
|
79
|
+
aEventName = translatedEventName;
|
|
80
|
+
}
|
|
73
81
|
|
|
74
82
|
if(this._statisticsTracking) {
|
|
75
83
|
this.addToDataLayer({"event": "trackEvent", "value": {"name": aEventName, "data": aData}});
|
|
76
|
-
|
|
84
|
+
if(aDataStructure === "ecommerce" && this.item.ecommerceDataWrapper) {
|
|
85
|
+
this.addToDataLayer({"event": aEventName, [this.item.ecommerceDataWrapper]: aData});
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this._gtag("event", aEventName, aData);
|
|
89
|
+
}
|
|
90
|
+
|
|
77
91
|
}
|
|
78
92
|
|
|
79
93
|
if(this._marketingTracking) {
|
|
80
94
|
this.addToDataLayer({"event": "trackMarketingEvent", "value": {"name": aEventName, "data": aData}});
|
|
81
|
-
|
|
95
|
+
if(aDataStructure === "ecommerce" && this.item.ecommerceDataWrapper) {
|
|
96
|
+
this.addToDataLayer({"event": "Marketing / " + aEventName, [this.item.ecommerceDataWrapper]: aData});
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
this._gtag("event", "Marketing / " + aEventName, aData);
|
|
100
|
+
}
|
|
82
101
|
}
|
|
83
102
|
}
|
|
84
103
|
|
package/tracking/index.js
CHANGED
|
@@ -14,22 +14,24 @@ export const setup = function() {
|
|
|
14
14
|
controller.start();
|
|
15
15
|
|
|
16
16
|
let dataLayerTracker = new Dbm.tracking.DataLayerTracker();
|
|
17
|
+
dataLayerTracker.item.register("tracking/dataLayerTracker");
|
|
17
18
|
controller.addTracker(dataLayerTracker.item);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export const addMetaPixel = function(aPixelId) {
|
|
21
22
|
let tracker = new Dbm.tracking.MetaPixelTracker();
|
|
22
23
|
tracker.item.pixelId = aPixelId;
|
|
23
|
-
|
|
24
|
+
tracker.item.register("tracking/metaPixelTracker");
|
|
25
|
+
Dbm.getRepositoryItem("trackingController").controller.addTracker(tracker.item);
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export const setCurrency = function(aCurrency) {
|
|
27
|
-
Dbm.
|
|
29
|
+
Dbm.getRepositoryItem("trackingController").currency = aCurrency;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
export const addTagManagerTracking = function(aId) {
|
|
31
33
|
//console.log("addTagManagerTracking");
|
|
32
34
|
let tracker = new Dbm.tracking.TagManagerTracker();
|
|
33
35
|
tracker.item.tagManagerId = aId;
|
|
34
|
-
Dbm.
|
|
36
|
+
Dbm.getRepositoryItem("trackingController").controller.addTracker(tracker.item);
|
|
35
37
|
}
|