dbm 1.4.7 → 1.4.9

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 (46) hide show
  1. package/commands/IncreaseProperty.js +19 -0
  2. package/commands/index.js +9 -0
  3. package/core/BaseObject.js +4 -5
  4. package/core/LifeCycleObject.js +13 -1
  5. package/dbm.js +2 -1
  6. package/ecommerce/Cart.js +31 -25
  7. package/ecommerce/CartLineItem.js +22 -2
  8. package/ecommerce/LocalStorageCartLoader.js +23 -2
  9. package/flow/FlowProperty.js +38 -0
  10. package/flow/index.js +4 -4
  11. package/form/Field.js +76 -0
  12. package/form/Form.js +87 -0
  13. package/form/index.js +6 -0
  14. package/form/validation/Validation.js +23 -0
  15. package/form/validation/ValidationFunctions.js +23 -0
  16. package/form/validation/index.js +4 -0
  17. package/graphapi/webclient/WebSocketConnection.js +6 -2
  18. package/graphapi/webclient/admin/ItemEditor.js +1 -1
  19. package/loading/FontLoader.js +47 -0
  20. package/loading/index.js +21 -0
  21. package/package.json +1 -1
  22. package/react/BaseObject.js +27 -0
  23. package/react/admin/editor/fields/EditorBlocks.js +62 -0
  24. package/react/admin/editor/fields/index.js +2 -1
  25. package/react/area/ResponsiveLayout.js +1 -1
  26. package/react/area/RowOrStacked.js +74 -0
  27. package/react/area/SelectResponsiveLayout.js +77 -0
  28. package/react/area/SwitchableArea.js +1 -1
  29. package/react/area/index.js +13 -0
  30. package/react/context/AddItemToContext.js +1 -1
  31. package/react/cookies/CookieBar.js +42 -22
  32. package/react/cookies/CookieOverlayMessage.js +30 -16
  33. package/react/cookies/CookieSettings.js +39 -23
  34. package/react/form/FormField.js +18 -1
  35. package/react/form/index.js +26 -1
  36. package/repository/index.js +4 -0
  37. package/site/index.js +2 -0
  38. package/startup/index.js +3 -0
  39. package/tracking/Controller.js +35 -50
  40. package/tracking/DataLayerTracker.js +39 -4
  41. package/tracking/index.js +5 -3
  42. package/utils/ArrayFunctions.js +41 -0
  43. package/utils/KeywordReplace.js +1 -2
  44. package/utils/LocalCache.js +36 -0
  45. package/utils/NamedArray.js +91 -0
  46. package/utils/index.js +2 -0
@@ -0,0 +1,19 @@
1
+ import Dbm from "../index.js";
2
+ import CommandBaseObject from "./CommandBaseObject.js"
3
+
4
+ export default class IncreaseProperty extends CommandBaseObject {
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.item.setValue("property", null);
9
+ this.item.setValue("value", 1);
10
+ }
11
+
12
+ perform(aFromObject, aData) {
13
+
14
+ let value = this.getInputFrom("value", aFromObject, aData);
15
+
16
+ let property = this._resolveSourceWithoutFlow(this.item.property, aFromObject, aData);
17
+ property.getMostUpstreamProperty().value = property.value + value;
18
+ }
19
+ }
package/commands/index.js CHANGED
@@ -3,6 +3,7 @@ import Dbm from "../index.js";
3
3
  export {default as CommandBaseObject} from "./CommandBaseObject.js";
4
4
  export {default as CallFunction} from "./CallFunction.js";
5
5
  export {default as SetProperty} from "./SetProperty.js";
6
+ export {default as IncreaseProperty} from "./IncreaseProperty.js";
6
7
  export {default as ResolvePromise} from "./ResolvePromise.js";
7
8
  export {default as TrackEvent} from "./TrackEvent.js";
8
9
 
@@ -39,6 +40,14 @@ export const setProperty = function(aProperty, aValue) {
39
40
  return newCommand;
40
41
  }
41
42
 
43
+ export const increaseProperty = function(aProperty, aValue = 1) {
44
+ let newCommand = new Dbm.commands.SetProperty();
45
+ newCommand.item.setValue("property", aProperty);
46
+ newCommand.item.setValue("value", aValue);
47
+
48
+ return newCommand;
49
+ }
50
+
42
51
  export const trackEvent = function(aEventName, aAdditionalData = {}) {
43
52
  let newCommand = new Dbm.commands.TrackEvent();
44
53
  newCommand.item.setValue("eventName", aEventName);
@@ -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
- let addUpdateCommand = Dbm.objectPath(Dbm.getRepositoryItem("library"), "Dbm/flow/addUpdateCommand");
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
- let addUpdateCommandWhenMatched = Dbm.objectPath(Dbm.getRepositoryItem("library"), "Dbm/flow/addUpdateCommandWhenMatched");
49
- addUpdateCommandWhenMatched(this._propertyOrName(aPropertyOrName), aMatchValue, this._getScopedCallFunctionCommand(aFunction, aArguments));
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() {
@@ -19,7 +19,19 @@ export default class LifeCycleObject {
19
19
 
20
20
  }
21
21
 
22
- destroy() {
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/ecommerce/Cart.js CHANGED
@@ -12,48 +12,54 @@ export default class Cart extends Dbm.core.BaseObject {
12
12
  this.item.setValue("numberOfLines", 0);
13
13
 
14
14
  this.item.setValue("changeCount", 0);
15
+ }
16
+
17
+ createLineItem(aType, aQuantity = 0, aMeta = null) {
18
+
19
+ let id = "lineItem" + Dbm.getInstance().getNextId();
20
+ let lineItem = new Dbm.ecommerce.CartLineItem();
21
+ lineItem.item.setId(id);
22
+ lineItem.item.type = aType;
23
+ lineItem.setQuantity(aQuantity);
24
+ lineItem.setCart(this.item);
25
+
26
+ if(aMeta) {
27
+ for(let objectName in aMeta) {
28
+ lineItem.setMeta(objectName, aMeta[objectName]);
29
+ }
30
+ }
15
31
 
16
- //METODO: integrate local storage
32
+ Dbm.flow.addUpdateCommand(lineItem.item.properties.quantity, this._changeCommand);
33
+
34
+ this.item.addToArray("lineItems", lineItem.item);
35
+
36
+ return lineItem;
17
37
  }
18
38
 
19
39
  addProduct(aProduct, aQuantity = 1, aMeta = null) {
20
40
  //console.log("addProduct");
21
41
  //console.log(aQuantity);
22
42
 
23
- let lineItems = this.item.lineItems;
24
- let lineItem;
25
- let index = Dbm.utils.ArrayFunctions.getItemIndexByIfExists(lineItems, "product", aProduct);
43
+ let lineItem = Dbm.utils.ArrayFunctions.getItemBy(this.item.lineItems, "product", aProduct);
26
44
 
27
- if(index !== -1) {
28
- lineItem = lineItems[index].controller;
45
+ if(lineItem) {
29
46
  lineItem.increaseQuantity(aQuantity);
30
- //METODO: support items with different meta
47
+
31
48
  if(aMeta) {
32
49
  for(let objectName in aMeta) {
33
50
  lineItem.setMeta(objectName, aMeta[objectName]);
34
51
  }
35
52
  }
36
- }
37
- else {
38
- let id = "lineItem" + Dbm.getInstance().getNextId();
39
- lineItem = new Dbm.ecommerce.CartLineItem();
40
- lineItem.item.setId(id);
41
- lineItem.setProduct(aProduct);
42
- lineItem.setQuantity(aQuantity);
43
- lineItem.setCart(this.item);
44
53
 
45
- if(aMeta) {
46
- for(let objectName in aMeta) {
47
- lineItem.setMeta(objectName, aMeta[objectName]);
48
- }
49
- }
54
+ return lineItem;
55
+ }
50
56
 
51
- Dbm.flow.addUpdateCommand(lineItem.item.properties.quantity, this._changeCommand);
57
+ return this.addProductAsSeparateLineItem(aProduct, aQuantity, aMeta);
58
+ }
52
59
 
53
- let newLineItems = [].concat(lineItems);
54
- newLineItems.push(lineItem.item);
55
- this.item.lineItems = newLineItems;
56
- }
60
+ addProductAsSeparateLineItem(aProduct, aQuantity = 1, aMeta = null) {
61
+ let lineItem = this.createLineItem("product", aQuantity, aMeta);
62
+ lineItem.setProduct(aProduct);
57
63
 
58
64
  return lineItem;
59
65
  }
@@ -5,9 +5,13 @@ export default class CartLineItem extends Dbm.core.BaseObject {
5
5
  super._construct();
6
6
 
7
7
  this.item.setValue("cart", null);
8
+
9
+ this.item.setValue("type", null);
8
10
  this.item.setValue("product", null);
9
11
  this.item.setValue("quantity", 0);
10
- this.item.setValue("meta", {});
12
+
13
+ let meta = new Dbm.utils.NamedArray();
14
+ this.item.setValue("meta", meta.item);
11
15
  }
12
16
 
13
17
  setCart(aItem) {
@@ -32,7 +36,9 @@ export default class CartLineItem extends Dbm.core.BaseObject {
32
36
  }
33
37
 
34
38
  setMeta(aKey, aValue) {
35
- this.item.meta[aKey] = aValue;
39
+ //console.log("setMeta");
40
+ //console.log(aKey, aValue);
41
+ this.item.meta.controller.setValue(aKey, aValue);
36
42
 
37
43
  return this;
38
44
  }
@@ -48,4 +54,18 @@ export default class CartLineItem extends Dbm.core.BaseObject {
48
54
 
49
55
  return this;
50
56
  }
57
+
58
+ getAsObject() {
59
+ let returnObject = {
60
+ "type": this.item.type,
61
+ "quantity": this.item.quantity,
62
+ "meta": this.item.meta.controller.getAsObject()
63
+ }
64
+
65
+ if(this.item.product) {
66
+ returnObject["product"] = this.item.product.id;
67
+ }
68
+
69
+ return returnObject;
70
+ }
51
71
  }
@@ -33,7 +33,21 @@ export default class LocalStorageCartLoader extends Dbm.core.BaseObject {
33
33
  for(let i = 0; i < currentArrayLength; i++) {
34
34
  let currentData = currentArray[i];
35
35
 
36
- this.item.cart.controller.addProduct(repository.getItem(currentData["product"]), currentData["quantity"], currentData["meta"]);
36
+ if(!currentData["type"]) {
37
+ continue;
38
+ }
39
+
40
+ let product = null;
41
+ if(currentData["product"]) {
42
+ product = repository.getItem(currentData["product"]);
43
+ }
44
+
45
+ //METODO: encode links in meta
46
+ let lineItem = this.item.cart.controller.createLineItem(currentData["type"], currentData["quantity"], currentData["meta"]);
47
+
48
+ if(product) {
49
+ lineItem.setProduct(product);
50
+ }
37
51
  }
38
52
  }
39
53
  }
@@ -58,10 +72,17 @@ export default class LocalStorageCartLoader extends Dbm.core.BaseObject {
58
72
  for(let i = 0; i < currentArrayLength; i++) {
59
73
  let currentData = currentArray[i];
60
74
 
61
- let encodedData = {"product": currentData.product.id, "quantity": currentData.quantity, "meta": currentData.meta};
75
+ let meta = currentData.meta.controller.getAsObject();
76
+ //METODO: links in meta
77
+ let encodedData = {"type": currentData.type, "quantity": currentData.quantity, "meta": meta};
78
+ if(currentData.product) {
79
+ encodedData["product"] = currentData.product.id;
80
+ }
62
81
  encodedLineItems.push(encodedData);
63
82
  }
64
83
 
84
+ console.log(encodedLineItems);
85
+
65
86
  try {
66
87
  let cartDataString = localStorage.setItem(this.item.storageKey, JSON.stringify({"lineItems": encodedLineItems}));
67
88
  }
@@ -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.getInstance().repository.getItem("propertyUpdater").controller.addSinglePropertyUpdateBound, [Dbm.core.source.staticObject(updateFunction.output.properties.value)]);
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 whenMatched = Dbm.flow.updatefunctions.logic.whenMatched(aProperty, aMatchValue);
46
+ let matchUpdateFunction = Dbm.flow.updatefunctions.logic.whenMatched(aProperty, aMatchValue);
47
47
 
48
- let updateData = Dbm.flow.addUpdateCommand(whenMatched.output.properties.value, aCommand);
48
+ let updateData = Dbm.flow.addUpdateCommand(matchUpdateFunction.output.properties.value, aCommand);
49
49
 
50
- updateData["whenMatched"] = whenMatched;
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,6 @@
1
+ import Dbm from "../index.js";
2
+
3
+ export * as validation from "./validation/index.js";
4
+
5
+ export {default as Form} from "./Form.js";
6
+ export {default as Field} from "./Field.js";
@@ -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
+ }
@@ -0,0 +1,4 @@
1
+ import Dbm from "../../index.js";
2
+
3
+ export {default as Validation} from "./Validation.js";
4
+ export * as ValidationFunctions from "./ValidationFunctions.js";
@@ -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
- item.setValue("user", repository.getItem(data["id"]));
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
- repository.getItem("site").currentUser = repository.getItem(data["user"]);
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;
@@ -160,7 +160,7 @@ export default class ItemEditor extends Dbm.core.BaseObject {
160
160
  let name = "out_" + aType + "_" + aObjectType;
161
161
  let valueEditor = this.item["editor_multipleRelations_" + name];
162
162
  if(!valueEditor) {
163
- let relations = Dbm.utils.ArrayFunctions.filterByField(Dbm.objectPath(this.item.editedItem, "relations/in." + aType + ".objects"), "objectTypes", aObjectType, "arrayContains");
163
+ let relations = Dbm.utils.ArrayFunctions.filterByField(Dbm.objectPath(this.item.editedItem, "relations/out." + aType + ".objects"), "objectTypes", aObjectType, "arrayContains");
164
164
  let ids = Dbm.utils.ArrayFunctions.mapField(relations, "id");
165
165
 
166
166
  valueEditor = this.addMultipleOutgoingRelationsEditor(aType, aObjectType, ids, "relations");
@@ -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
+ }