dbm 1.1.9 → 1.1.11
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/source/SourceBaseObject.js +11 -0
- package/dbm.js +2 -1
- package/ecommerce/Cart.js +79 -0
- package/ecommerce/CartLineItem.js +44 -0
- package/ecommerce/LocalStorageCartLoader.js +74 -0
- package/ecommerce/index.js +16 -0
- package/graphapi/webclient/WebSocketConnection.js +3 -1
- package/graphapi/webclient/decode/index.js +25 -1
- package/package.json +1 -1
- package/react/BaseObject.js +2 -4
- package/react/admin/EditPage.js +14 -0
- package/react/admin/editor/fields/SelectionField.js +55 -0
- package/react/admin/editor/fields/index.js +2 -1
- package/react/admin/editorsgroup/EditField.js +28 -0
- package/react/admin/editorsgroup/index.js +1 -0
- package/react/admin/index.js +4 -1
- package/react/admin/objects/EditObject.js +50 -0
- package/react/admin/objects/InjectObjectTypeEditor.js +30 -0
- package/react/admin/objects/ObjectList.js +92 -0
- package/react/admin/objects/ObjectListRow.js +35 -0
- package/react/admin/objects/index.js +6 -0
- package/react/admin/objects/itemeditors/Content.js +48 -0
- package/react/admin/objects/itemeditors/Link.js +46 -0
- package/react/admin/objects/itemeditors/Name.js +46 -0
- package/react/admin/objects/itemeditors/Title.js +46 -0
- package/react/admin/objects/itemeditors/Visibility.js +44 -0
- package/react/admin/objects/itemeditors/index.js +5 -0
- package/react/admin/website/EditLocalBusiness.js +153 -0
- package/react/admin/website/EditWebsite.js +168 -0
- package/react/admin/website/index.js +2 -0
- package/react/area/List.js +7 -2
- package/react/blocks/admin/index.js +1 -0
- package/react/blocks/admin/objects/Edit.js +42 -0
- package/react/blocks/admin/objects/List.js +17 -0
- package/react/blocks/admin/objects/index.js +2 -0
- package/react/blocks/content/Card.js +64 -0
- package/react/blocks/content/ContentBlock.js +47 -0
- package/react/blocks/content/index.js +2 -0
- package/react/blocks/faq/AskAQuestion.js +155 -0
- package/react/blocks/faq/index.js +1 -0
- package/react/blocks/gallery/DoubleImage.js +52 -0
- package/react/blocks/gallery/ImageGallery.js +136 -0
- package/react/blocks/gallery/index.js +2 -0
- package/react/blocks/index.js +188 -0
- package/react/cookies/CookieBar.js +4 -5
- package/site/SiteNavigation.js +6 -5
- package/updater/PropertyUpdater.js +10 -0
|
@@ -4,6 +4,7 @@ export default class SourceBaseObject extends Dbm.core.BaseObject {
|
|
|
4
4
|
_construct() {
|
|
5
5
|
super._construct();
|
|
6
6
|
|
|
7
|
+
this._log = false;
|
|
7
8
|
this.item.setValue("path", null);
|
|
8
9
|
}
|
|
9
10
|
|
|
@@ -20,10 +21,20 @@ export default class SourceBaseObject extends Dbm.core.BaseObject {
|
|
|
20
21
|
|
|
21
22
|
let path = this.item.path;
|
|
22
23
|
let baseObject = this.getBaseObject(aFromObject, aEventData);
|
|
24
|
+
|
|
25
|
+
if(this._log) {
|
|
26
|
+
console.log("Source>>>>>", baseObject, path);
|
|
27
|
+
}
|
|
28
|
+
|
|
23
29
|
if(!path) {
|
|
24
30
|
return baseObject;
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
return Dbm.objectPath(baseObject, path);
|
|
28
34
|
}
|
|
35
|
+
|
|
36
|
+
addLogs() {
|
|
37
|
+
this._log = true;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
29
40
|
}
|
package/dbm.js
CHANGED
|
@@ -93,4 +93,5 @@ export * as flow from "./flow/index.js";
|
|
|
93
93
|
export * as updater from "./updater/index.js";
|
|
94
94
|
export * as startup from "./startup/index.js";
|
|
95
95
|
export * as site from "./site/index.js";
|
|
96
|
-
export * as tracking from "./tracking/index.js";
|
|
96
|
+
export * as tracking from "./tracking/index.js";
|
|
97
|
+
export * as ecommerce from "./ecommerce/index.js";
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import Dbm from "../index.js";
|
|
2
|
+
|
|
3
|
+
export default class Cart extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
this._changeCommand = Dbm.commands.callFunction(this._changed.bind(this));
|
|
8
|
+
|
|
9
|
+
this.item.setValue("lineItems", []);
|
|
10
|
+
Dbm.flow.addUpdateCommand(this.item.properties.lineItems, this._changeCommand);
|
|
11
|
+
this.item.setValue("numberOfItems", 0);
|
|
12
|
+
this.item.setValue("numberOfLines", 0);
|
|
13
|
+
|
|
14
|
+
this.item.setValue("changeCount", 0);
|
|
15
|
+
|
|
16
|
+
//METODO: integrate local storage
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
addProduct(aProduct, aQuantity = 1) {
|
|
20
|
+
//console.log("addProduct");
|
|
21
|
+
//console.log(aQuantity);
|
|
22
|
+
|
|
23
|
+
let lineItems = this.item.lineItems;
|
|
24
|
+
let lineItem;
|
|
25
|
+
let index = Dbm.utils.ArrayFunctions.getItemIndexByIfExists(lineItems, "product", aProduct);
|
|
26
|
+
|
|
27
|
+
if(index !== -1) {
|
|
28
|
+
lineItem = lineItems[index];
|
|
29
|
+
lineItem.controller.increaseQuantity(aQuantity);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
let id = "lineItem" + Dbm.getInstance().getNextId();
|
|
33
|
+
lineItem = new Dbm.ecommerce.CartLineItem();
|
|
34
|
+
lineItem.item.setId(id);
|
|
35
|
+
lineItem.setProduct(aProduct);
|
|
36
|
+
lineItem.setQuantity(aQuantity);
|
|
37
|
+
lineItem.setCart(this.item);
|
|
38
|
+
|
|
39
|
+
Dbm.flow.addUpdateCommand(lineItem.item.properties.quantity, this._changeCommand);
|
|
40
|
+
|
|
41
|
+
let newLineItems = [].concat(lineItems);
|
|
42
|
+
newLineItems.push(lineItem.item);
|
|
43
|
+
this.item.lineItems = newLineItems;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return lineItem;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
removeLineItem(aItem) {
|
|
50
|
+
let lineItems = [].concat(this.item.lineItems);
|
|
51
|
+
|
|
52
|
+
let index = lineItems.indexOf(aItem);
|
|
53
|
+
if(index >= 0) {
|
|
54
|
+
lineItems.splice(index, 1);
|
|
55
|
+
this.item.lineItems = lineItems;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_changed() {
|
|
60
|
+
//console.log("_changed");
|
|
61
|
+
|
|
62
|
+
let lineItems = this.item.lineItems;
|
|
63
|
+
|
|
64
|
+
this.item.numberOfLines = lineItems.length;
|
|
65
|
+
|
|
66
|
+
let itemsCount = 0;
|
|
67
|
+
let currentArray = lineItems;
|
|
68
|
+
let currentArrayLength = currentArray.length;
|
|
69
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
70
|
+
let currentItem = currentArray[i];
|
|
71
|
+
itemsCount += currentItem.quantity;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this.item.numberOfItems = itemsCount;
|
|
75
|
+
this.item.changeCount++;
|
|
76
|
+
|
|
77
|
+
//METODO: calculate totals
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import Dbm from "../index.js";
|
|
2
|
+
|
|
3
|
+
export default class CartLineItem extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
this.item.setValue("cart", null);
|
|
8
|
+
this.item.setValue("product", null);
|
|
9
|
+
this.item.setValue("quantity", 0);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
setCart(aItem) {
|
|
13
|
+
this.item.cart = aItem;
|
|
14
|
+
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
setProduct(aProduct) {
|
|
19
|
+
this.item.product = aProduct;
|
|
20
|
+
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
setQuantity(aQuantity) {
|
|
25
|
+
console.log("setQuantity");
|
|
26
|
+
console.log(aQuantity);
|
|
27
|
+
|
|
28
|
+
this.item.quantity = aQuantity;
|
|
29
|
+
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
increaseQuantity(aQuantity) {
|
|
34
|
+
this.item.quantity += aQuantity;
|
|
35
|
+
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
remove() {
|
|
40
|
+
this.item.cart.controller.removeLineItem(this.item);
|
|
41
|
+
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import Dbm from "../index.js";
|
|
2
|
+
|
|
3
|
+
export default class LocalStorageCartLoader extends Dbm.core.BaseObject {
|
|
4
|
+
_construct() {
|
|
5
|
+
super._construct();
|
|
6
|
+
|
|
7
|
+
this._changeCommand = Dbm.commands.callFunction(this._changed.bind(this));
|
|
8
|
+
|
|
9
|
+
this._isLoading = false;
|
|
10
|
+
this.item.requireProperty("storageKey", "cart");
|
|
11
|
+
this.item.requireProperty("cart", null);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
setCart(aCart) {
|
|
15
|
+
this.item.cart = aCart;
|
|
16
|
+
Dbm.flow.addUpdateCommand(aCart.properties.changeCount, this._changeCommand);
|
|
17
|
+
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
load() {
|
|
22
|
+
//console.log("load");
|
|
23
|
+
|
|
24
|
+
let repository = Dbm.getInstance().repository;
|
|
25
|
+
|
|
26
|
+
this._isLoading = true;
|
|
27
|
+
try {
|
|
28
|
+
let cartDataString = localStorage.getItem(this.item.storageKey);
|
|
29
|
+
if(cartDataString) {
|
|
30
|
+
let cartData = JSON.parse(cartDataString);
|
|
31
|
+
console.log(cartData);
|
|
32
|
+
let currentArray = cartData.lineItems;
|
|
33
|
+
let currentArrayLength = currentArray.length;
|
|
34
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
35
|
+
let currentData = currentArray[i];
|
|
36
|
+
|
|
37
|
+
console.log(">>>>>>>>", currentData["quantity"]);
|
|
38
|
+
this.item.cart.controller.addProduct(repository.getItem(currentData["product"]), currentData["quantity"]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
catch(theError) {
|
|
43
|
+
console.error(theError);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
this._isLoading = false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
_changed() {
|
|
50
|
+
//console.log("_changed");
|
|
51
|
+
|
|
52
|
+
if(this._isLoading) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let encodedLineItems = [];
|
|
57
|
+
|
|
58
|
+
let currentArray = this.item.cart.lineItems;
|
|
59
|
+
let currentArrayLength = currentArray.length;
|
|
60
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
61
|
+
let currentData = currentArray[i];
|
|
62
|
+
|
|
63
|
+
let encodedData = {"product": currentData.product.id, "quantity": currentData.quantity};
|
|
64
|
+
encodedLineItems.push(encodedData);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
try {
|
|
68
|
+
let cartDataString = localStorage.setItem(this.item.storageKey, JSON.stringify({"lineItems": encodedLineItems}));
|
|
69
|
+
}
|
|
70
|
+
catch(theError) {
|
|
71
|
+
console.error(theError);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Dbm from "../index.js";
|
|
2
|
+
|
|
3
|
+
export {default as Cart} from "./Cart.js";
|
|
4
|
+
export {default as CartLineItem} from "./CartLineItem.js";
|
|
5
|
+
export {default as LocalStorageCartLoader} from "./LocalStorageCartLoader.js";
|
|
6
|
+
|
|
7
|
+
export const setup = function() {
|
|
8
|
+
|
|
9
|
+
let cart = new Dbm.ecommerce.Cart();
|
|
10
|
+
cart.item.register("cart");
|
|
11
|
+
|
|
12
|
+
let localStorageLoader = new Dbm.ecommerce.LocalStorageCartLoader();
|
|
13
|
+
localStorageLoader.setCart(cart.item);
|
|
14
|
+
localStorageLoader.load();
|
|
15
|
+
|
|
16
|
+
}
|
|
@@ -4,6 +4,8 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
4
4
|
_construct() {
|
|
5
5
|
super._construct();
|
|
6
6
|
|
|
7
|
+
this._connectBound = this._connect.bind(this);
|
|
8
|
+
|
|
7
9
|
this._url = null;
|
|
8
10
|
this._webSocket = null;
|
|
9
11
|
this._reconnectIfDisconnected = false;
|
|
@@ -161,7 +163,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
161
163
|
this.item.setValue("status", 0);
|
|
162
164
|
|
|
163
165
|
if(this._reconnectIfDisconnected) {
|
|
164
|
-
this.
|
|
166
|
+
setTimeout(this._connectBound, 2*1000);
|
|
165
167
|
}
|
|
166
168
|
}
|
|
167
169
|
|
|
@@ -58,7 +58,7 @@ export const fullSetup = function() {
|
|
|
58
58
|
{
|
|
59
59
|
let name = "urlRequest";
|
|
60
60
|
let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
|
|
61
|
-
currentDecoder.item.setValue("copyFields", ["meta/description"]);
|
|
61
|
+
currentDecoder.item.setValue("copyFields", ["meta/description", "seo/noIndex", "seo/noFollow"]);
|
|
62
62
|
currentDecoder.item.setValue("encodingType", name);
|
|
63
63
|
currentDecoder.item.register(decodePrefix + name);
|
|
64
64
|
}
|
|
@@ -117,4 +117,28 @@ export const fullSetup = function() {
|
|
|
117
117
|
currentDecoder.item.setValue("encodingType", name);
|
|
118
118
|
currentDecoder.item.register(decodePrefix + name);
|
|
119
119
|
}
|
|
120
|
+
|
|
121
|
+
{
|
|
122
|
+
let name = "admin_fields";
|
|
123
|
+
let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
|
|
124
|
+
currentDecoder.item.setValue("copyFields", ["fields"]);
|
|
125
|
+
currentDecoder.item.setValue("encodingType", name);
|
|
126
|
+
currentDecoder.item.register(decodePrefix + name);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
{
|
|
130
|
+
let name = "objectTypes";
|
|
131
|
+
let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
|
|
132
|
+
currentDecoder.item.setValue("copyFields", ["objectTypes"]);
|
|
133
|
+
currentDecoder.item.setValue("encodingType", name);
|
|
134
|
+
currentDecoder.item.register(decodePrefix + name);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
{
|
|
138
|
+
let name = "helpSection";
|
|
139
|
+
let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
|
|
140
|
+
currentDecoder.item.setValue("copyFields", ["title", "link"]);
|
|
141
|
+
currentDecoder.item.setValue("encodingType", name);
|
|
142
|
+
currentDecoder.item.register(decodePrefix + name);
|
|
143
|
+
}
|
|
120
144
|
}
|
package/package.json
CHANGED
package/react/BaseObject.js
CHANGED
|
@@ -53,8 +53,7 @@ export default class BaseObject extends Component {
|
|
|
53
53
|
|
|
54
54
|
getDynamicProp(aName, aInitialValue = null) {
|
|
55
55
|
if(!this._dynamicProps[aName]) {
|
|
56
|
-
let newProperty =
|
|
57
|
-
newProperty.value = aInitialValue;
|
|
56
|
+
let newProperty = this.item.requireProperty("props/" + aName, aInitialValue);
|
|
58
57
|
this._dynamicProps[aName] = newProperty;
|
|
59
58
|
let updateState = this._getStateUpdate();
|
|
60
59
|
let stateProperty = updateState.input.register(aName, aInitialValue);
|
|
@@ -65,8 +64,7 @@ export default class BaseObject extends Component {
|
|
|
65
64
|
|
|
66
65
|
getDynamicPropWithoutState(aName, aInitialValue = null) {
|
|
67
66
|
if(!this._dynamicProps[aName]) {
|
|
68
|
-
let newProperty =
|
|
69
|
-
newProperty.value = aInitialValue;
|
|
67
|
+
let newProperty = this.item.requireProperty("props/" + aName, aInitialValue);
|
|
70
68
|
this._dynamicProps[aName] = newProperty;
|
|
71
69
|
}
|
|
72
70
|
return this._dynamicProps[aName];
|
package/react/admin/EditPage.js
CHANGED
|
@@ -23,6 +23,9 @@ export default class EditPage extends Dbm.react.BaseObject {
|
|
|
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
25
|
|
|
26
|
+
itemEditor.addFieldEditor("seo/noIndex", page["seo/noIndex"], "seo/noIndex");
|
|
27
|
+
itemEditor.addFieldEditor("seo/noFollow", page["seo/noFollow"], "seo/noFollow");
|
|
28
|
+
|
|
26
29
|
this.item.requireProperty("importText", "");
|
|
27
30
|
}
|
|
28
31
|
|
|
@@ -169,6 +172,17 @@ export default class EditPage extends Dbm.react.BaseObject {
|
|
|
169
172
|
" / ",
|
|
170
173
|
"155"
|
|
171
174
|
)
|
|
175
|
+
),
|
|
176
|
+
|
|
177
|
+
React.createElement("div", {className: "flex-row small-item-spacing"},
|
|
178
|
+
React.createElement("div", {className: "flex-row-item"},
|
|
179
|
+
React.createElement(Dbm.react.form.Checkbox, {checked: itemEditor.getEditor("seo/noIndex").item.editValue.value}),
|
|
180
|
+
"Noindex"
|
|
181
|
+
),
|
|
182
|
+
React.createElement("div", {className: "flex-row-item"},
|
|
183
|
+
React.createElement(Dbm.react.form.Checkbox, {checked: itemEditor.getEditor("seo/noFollow").item.editValue.value}),
|
|
184
|
+
"Nofollow"
|
|
185
|
+
),
|
|
172
186
|
)
|
|
173
187
|
),
|
|
174
188
|
React.createElement("div", {className: "spacing standard"}),
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class SelectionField 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
|
+
let returnData = editorData.data[fieldName];
|
|
23
|
+
if(!returnData) {
|
|
24
|
+
returnData = null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return returnData;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
_valueChanged() {
|
|
32
|
+
//console.log("_valueChanged");
|
|
33
|
+
|
|
34
|
+
let fieldName = this.getPropValue("name");
|
|
35
|
+
let newValue = this.item.value;
|
|
36
|
+
|
|
37
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
38
|
+
|
|
39
|
+
let newData = {...editorData.data};
|
|
40
|
+
newData[fieldName] = newValue;
|
|
41
|
+
|
|
42
|
+
editorData.data = newData;
|
|
43
|
+
this.context.moduleData.editorData.editorBlock.dataUpdated();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_objectChanged() {
|
|
47
|
+
//console.log("_objectChanged");
|
|
48
|
+
|
|
49
|
+
this.item.value = this._getObjectData();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_renderMainElement() {
|
|
53
|
+
return this._createMainElement(Dbm.react.form.Selection, {value: this.item.properties.value, className: "full-width"}, this.getPropValue("children"));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -2,4 +2,5 @@ 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
4
|
export {default as CheckboxField} from "./CheckboxField.js";
|
|
5
|
-
export {default as SelectObjectField} from "./SelectObjectField.js";
|
|
5
|
+
export {default as SelectObjectField} from "./SelectObjectField.js";
|
|
6
|
+
export {default as SelectionField} from "./SelectionField.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class EditField extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
let item = this.context.item;
|
|
9
|
+
let itemEditor = this.context.itemEditor;
|
|
10
|
+
let fieldName = this.getPropValue("fieldName");
|
|
11
|
+
let initialDataPath = this.getPropValueWithDefault("initialDataPath", fieldName);
|
|
12
|
+
let initialData = Dbm.objectPath(item, initialDataPath);
|
|
13
|
+
|
|
14
|
+
console.log(">>>>>>>>>>", initialData, item, initialDataPath);
|
|
15
|
+
|
|
16
|
+
let editor = itemEditor.addFieldEditor(fieldName, initialData);
|
|
17
|
+
this.item.setValue("editor", editor.item);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
_renderMainElement() {
|
|
21
|
+
|
|
22
|
+
let children = this.getPropValue("children")
|
|
23
|
+
|
|
24
|
+
return React.createElement("div", {},
|
|
25
|
+
React.createElement(Dbm.react.context.AddContextVariables, {"values": {"valueEditor": this.item.editor}}, children)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {default as EditField} from "./EditField.js";
|
package/react/admin/index.js
CHANGED
|
@@ -3,4 +3,7 @@ export {default as EditPage} from "./EditPage.js";
|
|
|
3
3
|
export {default as SelectImageFromLibrary} from "./SelectImageFromLibrary.js";
|
|
4
4
|
|
|
5
5
|
export * as editor from "./editor/index.js";
|
|
6
|
-
export * as pages from "./pages/index.js";
|
|
6
|
+
export * as pages from "./pages/index.js";
|
|
7
|
+
export * as website from "./website/index.js";
|
|
8
|
+
export * as objects from "./objects/index.js";
|
|
9
|
+
export * as editorsgroup from "./editorsgroup/index.js";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class EditObject extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
|
|
9
|
+
|
|
10
|
+
let id = this.getPropValue("id");
|
|
11
|
+
|
|
12
|
+
let allLoaded = Dbm.flow.updatefunctions.logic.allAtValue(Dbm.loading.LoadingStatus.LOADED);
|
|
13
|
+
this.item.requireProperty("loaded", false);
|
|
14
|
+
|
|
15
|
+
{
|
|
16
|
+
let request = graphApi.requestRange(
|
|
17
|
+
[
|
|
18
|
+
{"type": "includePrivate"},
|
|
19
|
+
{"type": "includeDraft"},
|
|
20
|
+
{"type": "idSelection", "ids": [id]},
|
|
21
|
+
],
|
|
22
|
+
["objectTypes"]
|
|
23
|
+
);
|
|
24
|
+
allLoaded.addCheck(request.properties.status);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
this.item.properties.loaded.connectInput(allLoaded.output.properties.value);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
_renderMainElement() {
|
|
33
|
+
|
|
34
|
+
let id = this.getPropValue("id");
|
|
35
|
+
let item = Dbm.getInstance().repository.getItem(id);
|
|
36
|
+
let itemEditor = this.context.editorGroup.getItemEditor(id);
|
|
37
|
+
|
|
38
|
+
return React.createElement("div", {},
|
|
39
|
+
|
|
40
|
+
React.createElement(Dbm.react.area.HasData, {check: this.item.properties.loaded},
|
|
41
|
+
React.createElement(Dbm.react.context.AddContextVariables, {"values": {"item": item, "itemEditor": itemEditor}},
|
|
42
|
+
React.createElement(Dbm.react.area.List, {items: Dbm.react.source.contextVariable("item.objectTypes"), "as": "objectType", "keyField": "(root)"},
|
|
43
|
+
React.createElement(Dbm.react.admin.objects.InjectObjectTypeEditor, {type: Dbm.react.source.contextVariable("objectType")})
|
|
44
|
+
)
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class InjectObjectTypeEditor extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
_renderMainElement() {
|
|
12
|
+
|
|
13
|
+
let type = this.getPropValue("type");
|
|
14
|
+
let editor = Dbm.getInstance().repository.getItem("admin/objectTypeEditors/" + type);
|
|
15
|
+
|
|
16
|
+
let editors = editor.editors;
|
|
17
|
+
if(!editors) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
let elements = Dbm.utils.ArrayFunctions.mapField(editors, "element");
|
|
21
|
+
|
|
22
|
+
console.log(editors, elements);
|
|
23
|
+
|
|
24
|
+
if(!elements) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return React.createElement(Dbm.react.area.InsertElement, {element: elements});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class ObjectList 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 objectType = this.getPropValue("objectType");
|
|
13
|
+
let encodings = this.getPropValueWithDefault("encodings", ["name"]);
|
|
14
|
+
|
|
15
|
+
let allLoaded = Dbm.flow.updatefunctions.logic.allAtValue(Dbm.loading.LoadingStatus.LOADED);
|
|
16
|
+
this.item.requireProperty("loaded", false);
|
|
17
|
+
|
|
18
|
+
{
|
|
19
|
+
let request = graphApi.requestRange(
|
|
20
|
+
[
|
|
21
|
+
{"type": "includePrivate"},
|
|
22
|
+
{"type": "includeDraft"},
|
|
23
|
+
{"type": "byObjectType", "objectType": objectType},
|
|
24
|
+
],
|
|
25
|
+
encodings
|
|
26
|
+
);
|
|
27
|
+
Dbm.flow.addUpdateCommandWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._loaded.bind(this), [request]));
|
|
28
|
+
allLoaded.addCheck(request.properties.status);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
this.item.properties.loaded.connectInput(allLoaded.output.properties.value);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_loaded(aRequest) {
|
|
35
|
+
console.log("_loaded");
|
|
36
|
+
|
|
37
|
+
let currentArray = [].concat(aRequest.items);
|
|
38
|
+
|
|
39
|
+
let nameField = this.getPropValueWithDefault("nameField", "name");
|
|
40
|
+
Dbm.utils.ArrayFunctions.sortOnField(currentArray, nameField);
|
|
41
|
+
|
|
42
|
+
this.item.items = currentArray;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
_create() {
|
|
46
|
+
console.log("_create");
|
|
47
|
+
let objectType = this.getPropValue("objectType");
|
|
48
|
+
let encodings = this.getPropValueWithDefault("encodings", ["name"]);
|
|
49
|
+
let visibility = this.getPropValueWithDefault("visibility", "private");
|
|
50
|
+
|
|
51
|
+
let changes = [
|
|
52
|
+
{"type": "setField", "data": {"value": "Unnamed " + objectType, "field": "name"}}
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
let request = Dbm.getInstance().repository.getItem("graphApi").controller.createItem([objectType], visibility, changes, encodings);
|
|
56
|
+
|
|
57
|
+
Dbm.flow.addUpdateCommand(request.properties.status, Dbm.commands.callFunction(this._created.bind(this), [request]));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
_created(aRequest) {
|
|
61
|
+
console.log("_created");
|
|
62
|
+
console.log(aRequest);
|
|
63
|
+
|
|
64
|
+
let newItems = [].concat(this.item.items);
|
|
65
|
+
console.log(newItems);
|
|
66
|
+
newItems.push(aRequest.item);
|
|
67
|
+
this.item.items = newItems;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_renderMainElement() {
|
|
71
|
+
|
|
72
|
+
let nameField = this.getPropValueWithDefault("nameField", "name");
|
|
73
|
+
|
|
74
|
+
let id = Dbm.react.source.contextVariable("item.id");
|
|
75
|
+
let text = Dbm.react.source.contextVariable("item." + nameField);
|
|
76
|
+
|
|
77
|
+
return React.createElement("div", {"className": "standard-alternating-rows"},
|
|
78
|
+
React.createElement(Dbm.react.area.List, {items: this.item.properties.items},
|
|
79
|
+
React.createElement(Dbm.react.admin.objects.ObjectListRow, {"id": id, "text": text})
|
|
80
|
+
),
|
|
81
|
+
React.createElement("div", {"className": "spacing standard"}),
|
|
82
|
+
React.createElement("div", {"className": "flex-row"},
|
|
83
|
+
React.createElement("div", {"className": "flex-row-item"},
|
|
84
|
+
React.createElement(Dbm.react.interaction.CommandButton, {"command": Dbm.commands.callFunction(this._create.bind(this))},
|
|
85
|
+
React.createElement("div", {"className": "standard-button standard-button-padding"}, "Create")
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
}
|