dbm 1.1.4 → 1.1.5
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/dbm.js +25 -0
- package/flow/controllers/index.js +2 -1
- package/flow/controllers/transform/PartOfObject.js +51 -0
- package/flow/controllers/transform/index.js +1 -0
- package/package.json +1 -1
- package/react/admin/index.js +2 -1
- package/react/admin/pages/PageList.js +66 -0
- package/react/admin/pages/index.js +1 -0
- package/react/blocks/index.js +1 -0
- package/react/image/ContainScaledImage.js +37 -0
- package/react/image/index.js +1 -0
- package/site/SiteNavigation.js +6 -2
- package/tracking/Controller.js +1 -1
- package/tracking/index.js +5 -1
- package/utils/ArrayFunctions.js +1 -1
package/dbm.js
CHANGED
|
@@ -57,6 +57,31 @@ export let objectPath = function(aObject, aPath) {
|
|
|
57
57
|
return currentObject;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
+
export let setAtObjectPath = function(aObject, aPath, aValue) {
|
|
61
|
+
aPath += "";
|
|
62
|
+
if(aPath.length === 0) {
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let baseObject = aObject;
|
|
67
|
+
let propertyName = aPath;
|
|
68
|
+
|
|
69
|
+
let paths = aPath.split(".");
|
|
70
|
+
if(paths.length > 1) {
|
|
71
|
+
propertyName = paths.pop();
|
|
72
|
+
|
|
73
|
+
baseObject = objectPath(baseObject, paths.join("."));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if(baseObject) {
|
|
77
|
+
let partAsInt = parseInt(propertyName, 10);
|
|
78
|
+
if(partAsInt.toString() === propertyName) {
|
|
79
|
+
propertyName = partAsInt;
|
|
80
|
+
}
|
|
81
|
+
baseObject[propertyName] = aValue;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
60
85
|
export * as utils from "./utils/index.js";
|
|
61
86
|
export * as core from "./core/index.js";
|
|
62
87
|
export * as loading from "./loading/index.js";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import Dbm from "../../../index.js";
|
|
2
|
+
|
|
3
|
+
export default class PartOfObject extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
this.item.requireProperty("object", null);
|
|
8
|
+
this.item.requireProperty("path", null);
|
|
9
|
+
this.item.requireProperty("value", null);
|
|
10
|
+
|
|
11
|
+
this._lastUpdatedValue = null;
|
|
12
|
+
|
|
13
|
+
let objectUpdatedCommand = Dbm.commands.callFunction(this._objectUpdated.bind(this));
|
|
14
|
+
Dbm.flow.addUpdateCommand(this.item.properties.object, objectUpdatedCommand);
|
|
15
|
+
Dbm.flow.addUpdateCommand(this.item.properties.path, objectUpdatedCommand);
|
|
16
|
+
|
|
17
|
+
Dbm.flow.addUpdateCommand(this.item.properties.value, Dbm.commands.callFunction(this._valueUpdated.bind(this)));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_objectUpdated() {
|
|
21
|
+
console.log("_objectUpdated");
|
|
22
|
+
|
|
23
|
+
if(this.item.path !== null) {
|
|
24
|
+
let stringValue = JSON.stringify(Dbm.objectPath(this.item.object, this.item.path));
|
|
25
|
+
|
|
26
|
+
if(stringValue !== this._lastUpdatedValue) {
|
|
27
|
+
this._lastUpdatedValue = stringValue;
|
|
28
|
+
let newValue = JSON.parse(stringValue);
|
|
29
|
+
this.item.value = newValue;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_valueUpdated() {
|
|
35
|
+
console.log("_valueUpdated");
|
|
36
|
+
|
|
37
|
+
if(this.item.path !== null) {
|
|
38
|
+
let stringValue = JSON.stringify(this.item.value);
|
|
39
|
+
|
|
40
|
+
if(stringValue !== this._lastUpdatedValue) {
|
|
41
|
+
this._lastUpdatedValue = stringValue;
|
|
42
|
+
let object = JSON.parse(JSON.stringify(this.item.object));
|
|
43
|
+
Dbm.setAtObjectPath(object, this.item.path, JSON.parse(stringValue));
|
|
44
|
+
|
|
45
|
+
this.item.properties.object.getMostUpstreamProperty().value = object;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as PartOfObject} from "./PartOfObject.js";
|
package/package.json
CHANGED
package/react/admin/index.js
CHANGED
|
@@ -2,4 +2,5 @@ export {default as CreatePage} from "./CreatePage.js";
|
|
|
2
2
|
export {default as EditPage} from "./EditPage.js";
|
|
3
3
|
export {default as SelectImageFromLibrary} from "./SelectImageFromLibrary.js";
|
|
4
4
|
|
|
5
|
-
export * as editor from "./editor/index.js";
|
|
5
|
+
export * as editor from "./editor/index.js";
|
|
6
|
+
export * as pages from "./pages/index.js";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class PageList extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
|
|
9
|
+
|
|
10
|
+
this.item.requireProperty("items", []);
|
|
11
|
+
|
|
12
|
+
let request = graphApi.requestRange(
|
|
13
|
+
[
|
|
14
|
+
{"type": "includePrivate"},
|
|
15
|
+
{"type": "includeDraft"},
|
|
16
|
+
{"type": "byObjectType", "objectType": "page"},
|
|
17
|
+
],
|
|
18
|
+
["urlRequest"]
|
|
19
|
+
);
|
|
20
|
+
Dbm.flow.addUpdateCommandWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._loaded.bind(this), [request]));
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_loaded(aRequest) {
|
|
25
|
+
console.log("_loaded");
|
|
26
|
+
console.log(aRequest);
|
|
27
|
+
|
|
28
|
+
let items = [...aRequest.items];
|
|
29
|
+
let field = "url";
|
|
30
|
+
items.sort(function(aA, aB) {
|
|
31
|
+
|
|
32
|
+
let aValue = Dbm.objectPath(aA, field);
|
|
33
|
+
let bValue = Dbm.objectPath(aB, field);
|
|
34
|
+
|
|
35
|
+
if(aValue < bValue) {
|
|
36
|
+
return -1;
|
|
37
|
+
}
|
|
38
|
+
else if(aValue < bValue) {
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
console.log(items);
|
|
47
|
+
|
|
48
|
+
this.item.setValue("items", items);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
_renderMainElement() {
|
|
52
|
+
|
|
53
|
+
return React.createElement("div", {"className": "centered-site"},
|
|
54
|
+
React.createElement(Dbm.react.area.List, {"items": this.item.properties.items},
|
|
55
|
+
React.createElement("div", {},
|
|
56
|
+
React.createElement(Dbm.react.text.Link, {"href": Dbm.react.source.contextVariable("item.url")},
|
|
57
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("item.url")),
|
|
58
|
+
" - ",
|
|
59
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("item.title")),
|
|
60
|
+
)
|
|
61
|
+
)
|
|
62
|
+
)
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as PageList} from "./PageList.js";
|
package/react/blocks/index.js
CHANGED
|
@@ -100,4 +100,5 @@ export let getDefaultEditorModule = function() {
|
|
|
100
100
|
export let registerAllBlocks = function() {
|
|
101
101
|
registerBlock("cookie/settings", "Cookie settings", createElement(Dbm.react.cookies.CookieSettings));
|
|
102
102
|
registerBlock("login/loginForm", "Login form", createElement(Dbm.react.login.LoginForm));
|
|
103
|
+
registerBlock("admin/pageList", "Admin / Page list", createElement(Dbm.react.admin.pages.PageList), createElement(Dbm.react.admin.pages.PageList));
|
|
103
104
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Dbm from "../../index.js";
|
|
2
|
+
import React from "react";
|
|
3
|
+
|
|
4
|
+
export default class ContainedScaledImage extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_removedUsedProps(aProps) {
|
|
10
|
+
delete aProps["image"];
|
|
11
|
+
delete aProps["targetWidth"];
|
|
12
|
+
delete aProps["targetHeight"];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_renderMainElement() {
|
|
16
|
+
|
|
17
|
+
let image = this.getPropValue("image");
|
|
18
|
+
let width = this.getPropValue("targetWidth");
|
|
19
|
+
let height = this.getPropValue("targetHeight");
|
|
20
|
+
let url = Dbm.utils.UrlFunctions.createContainScaledImageUrl(image, width, height);
|
|
21
|
+
|
|
22
|
+
let newProps = this._copyProps({src: url});
|
|
23
|
+
|
|
24
|
+
let altText = Dbm.objectPath(image, "altText");
|
|
25
|
+
if(altText) {
|
|
26
|
+
newProps["alt"] = altText;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let elementType = this.getPropValue("elementType");
|
|
30
|
+
if(elementType) {
|
|
31
|
+
newProps["elementType"] = elementType;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return React.createElement(Dbm.react.image.Image, newProps, this.getPropValue("children"));
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
}
|
package/react/image/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export {default as Image} from "./Image.js";
|
|
2
2
|
export {default as WidthScaledImage} from "./WidthScaledImage.js";
|
|
3
3
|
export {default as CoverScaledImage} from "./CoverScaledImage.js";
|
|
4
|
+
export {default as ContainScaledImage} from "./ContainScaledImage.js";
|
|
4
5
|
export {default as LocalImage} from "./LocalImage.js";
|
package/site/SiteNavigation.js
CHANGED
|
@@ -172,7 +172,7 @@ export default class SiteNavigation extends Dbm.core.BaseObject {
|
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
-
history.pushState({}, "
|
|
175
|
+
history.pushState({}, "", aUrl);
|
|
176
176
|
this.item.url = aUrl;
|
|
177
177
|
|
|
178
178
|
this._addUrlToPath(aUrl);
|
|
@@ -201,9 +201,13 @@ export default class SiteNavigation extends Dbm.core.BaseObject {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
updateQueryString(aUrl) {
|
|
205
|
+
history.replaceState({}, "", aUrl);
|
|
206
|
+
}
|
|
207
|
+
|
|
204
208
|
setUrlFromLocation() {
|
|
205
209
|
let url = document.location.href;
|
|
206
|
-
this.item.url = url
|
|
210
|
+
this.item.url = url;
|
|
207
211
|
|
|
208
212
|
this._addUrlToPath(url);
|
|
209
213
|
|
package/tracking/Controller.js
CHANGED
|
@@ -197,7 +197,7 @@ export default class Controller extends Dbm.core.BaseObject {
|
|
|
197
197
|
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
|
|
200
|
+
trackCheckoutStarted(aProductOrProducts) {
|
|
201
201
|
let items = Dbm.utils.ArrayFunctions.singleOrArray(aProductOrProducts);
|
|
202
202
|
|
|
203
203
|
let data = {
|
package/tracking/index.js
CHANGED
|
@@ -19,5 +19,9 @@ export const setup = function() {
|
|
|
19
19
|
export const addMetaPixel = function(aPixelId) {
|
|
20
20
|
let tracker = new Dbm.tracking.MetaPixelTracker();
|
|
21
21
|
tracker.item.pixelId = aPixelId;
|
|
22
|
-
Dbm.getInstance().repository.getItem("trackingController").controller.addTracker();
|
|
22
|
+
Dbm.getInstance().repository.getItem("trackingController").controller.addTracker(tracker.item);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const setCurrency = function(aCurrency) {
|
|
26
|
+
Dbm.getInstance().repository.getItem("trackingController").currency = aCurrency;
|
|
23
27
|
}
|
package/utils/ArrayFunctions.js
CHANGED
|
@@ -138,7 +138,7 @@ export const mapField = function(aArray, aField) {
|
|
|
138
138
|
|
|
139
139
|
let currentArray = aArray;
|
|
140
140
|
let currentArrayLength = currentArray.length;
|
|
141
|
-
let returnArray = new Array(
|
|
141
|
+
let returnArray = new Array(currentArrayLength);
|
|
142
142
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
143
143
|
returnArray[i] = Dbm.objectPath(aArray[i], aField);
|
|
144
144
|
}
|