dbm 1.2.6 → 1.2.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/commands/CommandBaseObject.js +4 -0
- package/commands/SetProperty.js +2 -2
- package/commands/index.js +6 -1
- package/ecommerce/CartLineItem.js +2 -2
- package/ecommerce/LocalStorageCartLoader.js +0 -2
- package/flow/updatefunctions/dom/ElementPosition.js +10 -1
- package/flow/updatefunctions/thirdparty/google/maps/AutoComplete.js +2 -2
- package/graphapi/index.js +1 -2
- package/graphapi/webclient/WebSocketConnection.js +2 -0
- package/graphapi/webclient/admin/ItemEditor.js +54 -0
- package/graphapi/webclient/decode/index.js +9 -0
- package/package.json +1 -1
- package/react/AddProps.js +127 -0
- package/react/BaseObject.js +1 -1
- package/react/ChildFunctions.js +55 -1
- package/react/admin/EditLanguage.js +91 -0
- package/react/admin/EditObject.js +1 -1
- package/react/admin/EditObjectById.js +1 -1
- package/react/admin/EditPage.js +25 -35
- package/react/admin/EditTranslationGroup.js +174 -0
- package/react/admin/PageTranslations.js +226 -0
- package/react/admin/SelectTranslation.js +72 -0
- package/react/admin/editorsgroup/EditItem.js +1 -1
- package/react/admin/editorsgroup/EditMultipleRelations.js +39 -0
- package/react/admin/editorsgroup/EditPartOfObject.js +32 -0
- package/react/admin/editorsgroup/EditRelation.js +2 -7
- package/react/admin/editorsgroup/EditUrl.js +22 -0
- package/react/admin/editorsgroup/index.js +4 -1
- package/react/admin/index.js +4 -0
- package/react/admin/objects/itemeditors/DraggableHierarchyDisplay.js +45 -0
- package/react/admin/objects/itemeditors/HierarchyOrderedRelationsList.js +335 -0
- package/react/admin/objects/itemeditors/RelationsList.js +77 -0
- package/react/admin/objects/itemeditors/Url.js +21 -0
- package/react/admin/objects/itemeditors/index.js +5 -1
- package/react/animation/AnimatedElement.js +4 -0
- package/react/area/FixedWidthInfiniteSlideshow.js +8 -1
- package/react/area/HasData.js +1 -1
- package/react/area/InsertElement.js +9 -2
- package/react/area/InsertElementWithChildren.js +33 -0
- package/react/area/OpenCloseExpandableArea.js +10 -3
- package/react/area/PopoverLayer.js +64 -0
- package/react/area/index.js +2 -0
- package/react/blocks/admin/objects/Edit.js +1 -1
- package/react/blocks/index.js +169 -3
- package/react/blocks/redirect/SignedInRedirect.js +38 -0
- package/react/blocks/redirect/index.js +1 -0
- package/react/blocks/section/ColoredBackgroundSection.js +32 -0
- package/react/blocks/section/ColoredBoxSection.js +30 -0
- package/react/blocks/section/index.js +2 -0
- package/react/blocks/signin/SignIn.js +14 -0
- package/react/blocks/signin/index.js +1 -0
- package/react/context/AddItemByIdToContext.js +5 -2
- package/react/form/Dropdown.js +46 -0
- package/react/form/Option.js +1 -1
- package/react/form/index.js +2 -1
- package/react/interaction/CommandButton.js +12 -64
- package/react/interaction/HoverArea.js +77 -0
- package/react/interaction/HoverDropdown.js +38 -0
- package/react/interaction/drag/DraggableItem.js +94 -0
- package/react/interaction/drag/index.js +3 -0
- package/react/interaction/index.js +5 -1
- package/react/login/LoginForm.js +4 -4
- package/react/source/index.js +10 -2
- package/site/index.js +3 -0
- package/site/translation/TranslationLoader.js +3 -3
- package/tracking/index.js +1 -1
- package/utils/ArrayFunctions.js +21 -16
- package/utils/TranslationFunctions.js +49 -0
- package/utils/index.js +1 -0
- package/graphapi/admin/EditGroup.js +0 -50
- package/graphapi/admin/index.js +0 -1
|
@@ -33,4 +33,8 @@ export default class CommandBaseObject extends Dbm.core.BaseObject {
|
|
|
33
33
|
getInput(aName) {
|
|
34
34
|
return this._resolveSource(this.item[aName]);
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
getInputFrom(aName, aFromObject = null, aData = null) {
|
|
38
|
+
return this._resolveSource(this.item[aName], aFromObject, aData);
|
|
39
|
+
}
|
|
36
40
|
}
|
package/commands/SetProperty.js
CHANGED
|
@@ -11,8 +11,8 @@ export default class SetProperty extends CommandBaseObject {
|
|
|
11
11
|
|
|
12
12
|
perform(aFromObject, aData) {
|
|
13
13
|
|
|
14
|
-
let value = this.
|
|
14
|
+
let value = this.getInputFrom("value", aFromObject, aData);
|
|
15
15
|
|
|
16
|
-
this._resolveSourceWithoutFlow(this.item.property, aFromObject, aData).value = value;
|
|
16
|
+
this._resolveSourceWithoutFlow(this.item.property, aFromObject, aData).getMostUpstreamProperty().value = value;
|
|
17
17
|
}
|
|
18
18
|
}
|
package/commands/index.js
CHANGED
|
@@ -52,6 +52,11 @@ export const performCommands = function(aCommands, aFromObject = null, aEventDat
|
|
|
52
52
|
let currentArrayLength = currentArray.length;
|
|
53
53
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
54
54
|
let currentCommand = currentArray[i];
|
|
55
|
-
|
|
55
|
+
try {
|
|
56
|
+
currentCommand.perform(aFromObject, aEventData);
|
|
57
|
+
}
|
|
58
|
+
catch(theError) {
|
|
59
|
+
console.error("Error while running command", theError, currentCommand);
|
|
60
|
+
}
|
|
56
61
|
}
|
|
57
62
|
}
|
|
@@ -22,8 +22,8 @@ export default class CartLineItem extends Dbm.core.BaseObject {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
setQuantity(aQuantity) {
|
|
25
|
-
console.log("setQuantity");
|
|
26
|
-
console.log(aQuantity);
|
|
25
|
+
//console.log("setQuantity");
|
|
26
|
+
//console.log(aQuantity);
|
|
27
27
|
|
|
28
28
|
this.item.quantity = aQuantity;
|
|
29
29
|
|
|
@@ -28,13 +28,11 @@ export default class LocalStorageCartLoader extends Dbm.core.BaseObject {
|
|
|
28
28
|
let cartDataString = localStorage.getItem(this.item.storageKey);
|
|
29
29
|
if(cartDataString) {
|
|
30
30
|
let cartData = JSON.parse(cartDataString);
|
|
31
|
-
console.log(cartData);
|
|
32
31
|
let currentArray = cartData.lineItems;
|
|
33
32
|
let currentArrayLength = currentArray.length;
|
|
34
33
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
35
34
|
let currentData = currentArray[i];
|
|
36
35
|
|
|
37
|
-
console.log(">>>>>>>>", currentData["quantity"]);
|
|
38
36
|
this.item.cart.controller.addProduct(repository.getItem(currentData["product"]), currentData["quantity"]);
|
|
39
37
|
}
|
|
40
38
|
}
|
|
@@ -12,6 +12,9 @@ export default class ElementPosition extends Dbm.flow.FlowUpdateFunction {
|
|
|
12
12
|
this.output.register("screenX", NaN);
|
|
13
13
|
this.output.register("screenY", NaN);
|
|
14
14
|
|
|
15
|
+
this.output.register("pageX", NaN);
|
|
16
|
+
this.output.register("pageY", NaN);
|
|
17
|
+
|
|
15
18
|
this.output.register("parameterX", NaN);
|
|
16
19
|
this.output.register("parameterY", NaN);
|
|
17
20
|
|
|
@@ -22,6 +25,7 @@ export default class ElementPosition extends Dbm.flow.FlowUpdateFunction {
|
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
start() {
|
|
28
|
+
//console.log("start");
|
|
25
29
|
window.addEventListener("resize", this._callback_scrollBound, false);
|
|
26
30
|
window.addEventListener("scroll", this._callback_scrollBound, false);
|
|
27
31
|
this.output.properties.prepare.startUpdating();
|
|
@@ -47,7 +51,6 @@ export default class ElementPosition extends Dbm.flow.FlowUpdateFunction {
|
|
|
47
51
|
//console.log(theInnerWidth, theInnerHeight);
|
|
48
52
|
|
|
49
53
|
let rect = element.getBoundingClientRect();
|
|
50
|
-
//console.log(rect);
|
|
51
54
|
|
|
52
55
|
let prepareX = this.input.prepareX;
|
|
53
56
|
let prepareY = this.input.prepareY;
|
|
@@ -66,6 +69,9 @@ export default class ElementPosition extends Dbm.flow.FlowUpdateFunction {
|
|
|
66
69
|
|
|
67
70
|
this.output.screenX = screenX;
|
|
68
71
|
this.output.screenY = screenY;
|
|
72
|
+
|
|
73
|
+
this.output.pageX = screenX-window.scrollX;
|
|
74
|
+
this.output.pageY = screenY-window.scrollY;
|
|
69
75
|
|
|
70
76
|
this.output.parameterX = parameterX;
|
|
71
77
|
this.output.parameterY = parameterY;
|
|
@@ -116,6 +122,9 @@ export default class ElementPosition extends Dbm.flow.FlowUpdateFunction {
|
|
|
116
122
|
|
|
117
123
|
this.output.properties.screenX._internal_setValueInFlowOutsideOfUpdate(screenX);
|
|
118
124
|
this.output.properties.screenY._internal_setValueInFlowOutsideOfUpdate(screenY);
|
|
125
|
+
|
|
126
|
+
this.output.properties.pageX._internal_setValueInFlowOutsideOfUpdate(screenX+window.scrollX);
|
|
127
|
+
this.output.properties.pageY._internal_setValueInFlowOutsideOfUpdate(screenY+window.scrollY);
|
|
119
128
|
|
|
120
129
|
this.output.properties.parameterX._internal_setValueInFlowOutsideOfUpdate(parameterX);
|
|
121
130
|
this.output.properties.parameterY._internal_setValueInFlowOutsideOfUpdate(parameterY);
|
|
@@ -26,7 +26,7 @@ export default class AutoComplete extends Dbm.flow.FlowUpdateFunction {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
_scriptLoaded() {
|
|
29
|
-
console.log("_scriptLoaded");
|
|
29
|
+
//console.log("_scriptLoaded");
|
|
30
30
|
if(!this._loadedScript) {
|
|
31
31
|
this._loadedScript = true;
|
|
32
32
|
this._update();
|
|
@@ -46,7 +46,7 @@ export default class AutoComplete extends Dbm.flow.FlowUpdateFunction {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
_update() {
|
|
49
|
-
console.log("_update");
|
|
49
|
+
//console.log("_update");
|
|
50
50
|
|
|
51
51
|
let text = this.input.text;
|
|
52
52
|
this._currentText = text;
|
package/graphapi/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export * as webclient from "./webclient/index.js";
|
|
2
|
-
export * as admin from "./admin/index.js";
|
|
1
|
+
export * as webclient from "./webclient/index.js";
|
|
@@ -300,6 +300,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
300
300
|
item.setValue("user", null);
|
|
301
301
|
}
|
|
302
302
|
repository.getItem("site").currentUser = item.user;
|
|
303
|
+
repository.getItem("site").checkedUser = true;
|
|
303
304
|
item.setValue("status", Dbm.loading.LoadingStatus.LOADED);
|
|
304
305
|
}
|
|
305
306
|
break;
|
|
@@ -311,6 +312,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
311
312
|
else {
|
|
312
313
|
repository.getItem("site").currentUser = null;
|
|
313
314
|
}
|
|
315
|
+
repository.getItem("site").checkedUser = true;
|
|
314
316
|
this._connectionReady();
|
|
315
317
|
}
|
|
316
318
|
break;
|
|
@@ -42,6 +42,15 @@ export default class ItemEditor extends Dbm.core.BaseObject {
|
|
|
42
42
|
return this.addEditor(aField, aInitialValue, Dbm.graphapi.webclient.admin.SaveFunctions.setField, aUpdateEncoding);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
getAdminFieldEditor(aField) {
|
|
46
|
+
let item = this.item.editedItem;
|
|
47
|
+
|
|
48
|
+
let initialDataPath = "fields." + aField;
|
|
49
|
+
let initialData = Dbm.objectPath(item, initialDataPath);
|
|
50
|
+
|
|
51
|
+
return this.addFieldEditor(aField, initialData);
|
|
52
|
+
}
|
|
53
|
+
|
|
45
54
|
addFieldTranslationEditor(aField, aLanguage, aInitialValue, aUpdateEncoding = null) {
|
|
46
55
|
let name = "translation_" + aField + "_" + aLanguage;
|
|
47
56
|
let valueEditor = this.item["editor_" + name];
|
|
@@ -80,11 +89,29 @@ export default class ItemEditor extends Dbm.core.BaseObject {
|
|
|
80
89
|
return this._addRelationEditor(name, aType, aObjectType, aInitialValue, Dbm.graphapi.webclient.admin.SaveFunctions.incomingRelation, aUpdateEncoding);
|
|
81
90
|
}
|
|
82
91
|
|
|
92
|
+
getDefaultIncomingRelationEditor(aType, aObjectType) {
|
|
93
|
+
let item = this.item.editedItem;
|
|
94
|
+
|
|
95
|
+
let relations = Dbm.utils.ArrayFunctions.filterByField(Dbm.objectPath(item, "relations/in." + aType + ".objects"), "objectTypes", aObjectType, "arrayContains");
|
|
96
|
+
let relation = (relations && relations.length) ? relations[0].id : null;
|
|
97
|
+
|
|
98
|
+
return this.addIncomingRelationEditor(aType, aObjectType, relation, ["relations"]);
|
|
99
|
+
}
|
|
100
|
+
|
|
83
101
|
addOutgoingRelationEditor(aType, aObjectType, aInitialValue, aUpdateEncoding = null) {
|
|
84
102
|
let name = "out_" + aType + "_" + aObjectType;
|
|
85
103
|
return this._addRelationEditor(name, aType, aObjectType, aInitialValue, Dbm.graphapi.webclient.admin.SaveFunctions.outgoingRelation, aUpdateEncoding);
|
|
86
104
|
}
|
|
87
105
|
|
|
106
|
+
getDefaultOutgoingRelationEditor(aType, aObjectType) {
|
|
107
|
+
let item = this.item.editedItem;
|
|
108
|
+
|
|
109
|
+
let relations = Dbm.utils.ArrayFunctions.filterByField(Dbm.objectPath(item, "relations/out." + aType + ".objects"), "objectTypes", aObjectType, "arrayContains");
|
|
110
|
+
let relation = (relations && relations.length) ? relations[0].id : null;
|
|
111
|
+
|
|
112
|
+
return this.addOutgoingRelationEditor(aType, aObjectType, relation, ["relations"]);
|
|
113
|
+
}
|
|
114
|
+
|
|
88
115
|
_addMultipleRelationsEditor(aName, aType, aObjectType, aInitialValue, aSaveFunction, aUpdateEncoding = null) {
|
|
89
116
|
let valueEditor = this.item["editor_relation_" + aName];
|
|
90
117
|
if(!valueEditor) {
|
|
@@ -183,6 +210,33 @@ export default class ItemEditor extends Dbm.core.BaseObject {
|
|
|
183
210
|
return valueEditor;
|
|
184
211
|
}
|
|
185
212
|
|
|
213
|
+
getUrlEditor(aInitialValue) {
|
|
214
|
+
let name = "url";
|
|
215
|
+
let valueEditor = this.item["url"];
|
|
216
|
+
if(!valueEditor) {
|
|
217
|
+
valueEditor = new Dbm.graphapi.webclient.admin.ValueEditor();
|
|
218
|
+
valueEditor.item.editValue.setInitialValue(aInitialValue);
|
|
219
|
+
|
|
220
|
+
valueEditor.item.setValue("itemEditor", this.item);
|
|
221
|
+
valueEditor.item.setValue("updateEncoding", "url");
|
|
222
|
+
|
|
223
|
+
this.item.anyChange.addCheck(valueEditor.item.properties.changed);
|
|
224
|
+
this.item.setValue(name, valueEditor);
|
|
225
|
+
this.item.editors = [].concat(this.item.editors, valueEditor);
|
|
226
|
+
|
|
227
|
+
valueEditor.addSaveFunction(Dbm.graphapi.webclient.admin.SaveFunctions.setUrl);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return valueEditor;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
getAdminUrlEditor() {
|
|
234
|
+
let item = this.item.editedItem;
|
|
235
|
+
let value = Dbm.objectPath(item, "url");
|
|
236
|
+
|
|
237
|
+
return this.getUrlEditor(value);
|
|
238
|
+
}
|
|
239
|
+
|
|
186
240
|
addCommandsToSaveData(aSaveData) {
|
|
187
241
|
|
|
188
242
|
let editedItemId = Dbm.objectPath(this.item, "editedItem.id");
|
|
@@ -216,4 +216,13 @@ export const fullSetup = function() {
|
|
|
216
216
|
|
|
217
217
|
setupDefaultDecoder("name_translations", ["name/translations"], [], [], [Dbm.commands.callFunction(connectTranslations, [Dbm.core.source.event("item"), "name/translations", "name/translated", "name"])]);
|
|
218
218
|
setupDefaultDecoder("title_translations", ["title/translations"], [], [], [Dbm.commands.callFunction(connectTranslations, [Dbm.core.source.event("item"), "title/translations", "title/translated", "title"])]);
|
|
219
|
+
|
|
220
|
+
let linkUpMenu = function(aItem) {
|
|
221
|
+
console.log("linkUpMenu");
|
|
222
|
+
console.log(aItem);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
setupDefaultDecoder("menuLocation", ["identifier"], ["menu"], []);
|
|
226
|
+
setupDefaultDecoder("menu", ["order"], [], ["menuItems"], [Dbm.commands.callFunction(linkUpMenu, [Dbm.core.source.event("item")])]);
|
|
227
|
+
setupDefaultDecoder("menuItem", ["label", "link"], [], []);
|
|
219
228
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../index.js";
|
|
3
|
+
|
|
4
|
+
export default class AddProps extends Dbm.react.BaseObject {
|
|
5
|
+
|
|
6
|
+
_construct() {
|
|
7
|
+
super._construct();
|
|
8
|
+
|
|
9
|
+
this._clonedElement = null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
_getMainElementProps() {
|
|
13
|
+
//console.log("wprr/manipulation/ManipulationBaseObject::_getMainElementProps");
|
|
14
|
+
let returnObject = {};
|
|
15
|
+
|
|
16
|
+
for(let objectName in this.props) {
|
|
17
|
+
if(objectName === "children") {
|
|
18
|
+
//MENOTE: children should not be passed on
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
returnObject[objectName] = this.props[objectName];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return returnObject;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
_performCloneWithNewChildren(aChild, aProps, aChildren) {
|
|
28
|
+
var callArray = [aChild, aProps];
|
|
29
|
+
|
|
30
|
+
callArray = callArray.concat(aChildren);
|
|
31
|
+
|
|
32
|
+
return React.cloneElement.apply(React, callArray);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_performClone(aChild, aProps) {
|
|
36
|
+
|
|
37
|
+
if(aChild instanceof Array) {
|
|
38
|
+
let returnArray = [];
|
|
39
|
+
|
|
40
|
+
let currentArray = aChild;
|
|
41
|
+
let currentArrayLength = currentArray.length;
|
|
42
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
43
|
+
let currentChild = currentArray[i];
|
|
44
|
+
returnArray.push(this._performClone(currentChild, aProps));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return returnArray;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let newProps = aProps;
|
|
51
|
+
if(aChild && aChild.props && aChild.props.className) {
|
|
52
|
+
newProps = {};
|
|
53
|
+
for(let objectName in aProps) {
|
|
54
|
+
newProps[objectName] = aProps[objectName];
|
|
55
|
+
}
|
|
56
|
+
if(aProps.className) {
|
|
57
|
+
newProps.className = aProps.className + " " + aChild.props.className;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
newProps.className = aChild.props.className;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let callArray = [aChild, newProps];
|
|
65
|
+
|
|
66
|
+
if(aChild && aChild.props) {
|
|
67
|
+
let firstChildChildren = aChild.props.children;
|
|
68
|
+
if(!firstChildChildren) {
|
|
69
|
+
callArray.push(null);
|
|
70
|
+
}
|
|
71
|
+
else if(firstChildChildren instanceof Array) {
|
|
72
|
+
callArray = callArray.concat(firstChildChildren);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
callArray.push(firstChildChildren);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return React.cloneElement.apply(React, callArray);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
_cloneChildrenAndAddProps(aChildren) {
|
|
83
|
+
//console.log("wprr/manipulation/ManipulationBaseObject::_cloneChildrenAndAddProps");
|
|
84
|
+
|
|
85
|
+
let children = aChildren;
|
|
86
|
+
|
|
87
|
+
if(children.length === 0) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
else if(children.length === 1) {
|
|
91
|
+
return this._performClone(children[0], this.props);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let returnArray = new Array();
|
|
95
|
+
|
|
96
|
+
let mainElementProps = this.props;
|
|
97
|
+
|
|
98
|
+
let currentArray = children;
|
|
99
|
+
let currentArrayLength = currentArray.length;
|
|
100
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
101
|
+
let currentChild = currentArray[i];
|
|
102
|
+
|
|
103
|
+
if(currentChild !== null) {
|
|
104
|
+
let newChild = this._performClone(currentChild, mainElementProps);
|
|
105
|
+
returnArray.push(newChild);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
let callArray = [Fragment, {}].concat(returnArray);
|
|
110
|
+
return React.createElement.apply(React, callArray);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
_renderClonedElement() {
|
|
114
|
+
return this._cloneChildrenAndAddProps(this.getPropValue("children"));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
_createClonedElement() {
|
|
118
|
+
//console.log("wprr/manipulation/ManipulationBaseObject::_createClonedElement");
|
|
119
|
+
|
|
120
|
+
this._clonedElement = this._renderClonedElement();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
_renderMainElement() {
|
|
124
|
+
this._createClonedElement();
|
|
125
|
+
return this._clonedElement;
|
|
126
|
+
}
|
|
127
|
+
}
|
package/react/BaseObject.js
CHANGED
|
@@ -145,7 +145,7 @@ export default class BaseObject extends Component {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
_renderMainElement() {
|
|
148
|
-
return this._createMainElement("div", {}, this.props.children);
|
|
148
|
+
return this._createMainElement("div", {ref: this.createRef("mainElement")}, this.props.children);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
_mainElement(aReactElement) {
|
package/react/ChildFunctions.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Dbm from "../index.js";
|
|
2
|
+
import React from "react";
|
|
2
3
|
|
|
3
4
|
export const splitIntoSlots = function(aChildren) {
|
|
4
5
|
let returnObject = {};
|
|
@@ -24,4 +25,57 @@ export const splitIntoSlots = function(aChildren) {
|
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
return returnObject;
|
|
27
|
-
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const clone = function(aChild, aProps) {
|
|
31
|
+
|
|
32
|
+
if(aChild instanceof Array) {
|
|
33
|
+
let returnArray = [];
|
|
34
|
+
|
|
35
|
+
let currentArray = aChild;
|
|
36
|
+
let currentArrayLength = currentArray.length;
|
|
37
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
38
|
+
let currentChild = currentArray[i];
|
|
39
|
+
returnArray.push(clone(currentChild, aProps));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if(currentArrayLength === 1) {
|
|
43
|
+
return returnArray[0];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return returnArray;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let newProps = aProps;
|
|
50
|
+
|
|
51
|
+
if(aChild && aChild.props && aChild.props.className) {
|
|
52
|
+
newProps = {...aProps};
|
|
53
|
+
|
|
54
|
+
if(aProps.className) {
|
|
55
|
+
newProps.className = aProps.className + " " + aChild.props.className;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
newProps.className = aChild.props.className;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//METODO: combine styles
|
|
63
|
+
//METODO: combine listeners
|
|
64
|
+
|
|
65
|
+
let callArray = [aChild, newProps];
|
|
66
|
+
|
|
67
|
+
if(aChild && aChild.props) {
|
|
68
|
+
let firstChildChildren = aChild.props.children;
|
|
69
|
+
if(!firstChildChildren) {
|
|
70
|
+
//MENOTE: do nothing
|
|
71
|
+
}
|
|
72
|
+
else if(firstChildChildren instanceof Array) {
|
|
73
|
+
callArray = callArray.concat(firstChildChildren);
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
callArray.push(firstChildChildren);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return React.cloneElement.apply(React, callArray);
|
|
81
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class EditLanguage extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.item.requireProperty("availableLanguages", []);
|
|
9
|
+
|
|
10
|
+
{
|
|
11
|
+
let request = Dbm.getGraphApi().requestRange([{"type": "byObjectType", "objectType": "language"}], ["type"]);
|
|
12
|
+
this.item.propertyInput("languages", request.properties.items);
|
|
13
|
+
Dbm.flow.runWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._languagesLoaded.bind(this), []));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
_languagesLoaded() {
|
|
18
|
+
//console.log("_languagesLoaded");
|
|
19
|
+
//console.log(this.item.languages);
|
|
20
|
+
|
|
21
|
+
let availableLanguageCodes = Dbm.utils.ArrayFunctions.mapField(Dbm.getRepositoryItem("site").availableLanguages, "code");
|
|
22
|
+
|
|
23
|
+
let filteredLanguages = Dbm.utils.ArrayFunctions.filterByField(this.item.languages, "identifier", availableLanguageCodes, "inArray");
|
|
24
|
+
this.item.availableLanguages = filteredLanguages;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
getFlagUrl(aLanguageCode) {
|
|
28
|
+
|
|
29
|
+
let countryCode = aLanguageCode;
|
|
30
|
+
if(aLanguageCode === "en") {
|
|
31
|
+
countryCode = "gb";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return "https://flagcdn.com/" + countryCode + ".svg";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
_renderMainElement() {
|
|
38
|
+
|
|
39
|
+
return React.createElement("div", {},
|
|
40
|
+
React.createElement(Dbm.react.admin.editorsgroup.EditRelation, {direction: "in", relationType: "for", objectType: "language"},
|
|
41
|
+
React.createElement(Dbm.react.context.AddItemByIdToContext, {"id": Dbm.react.source.contextVariable("valueEditor.editValue.value"), "as": "language"},
|
|
42
|
+
|
|
43
|
+
React.createElement(Dbm.react.form.Dropdown, {},
|
|
44
|
+
React.createElement("div", {"data-slot": "button", "className": "standard-field standard-field-padding"},
|
|
45
|
+
React.createElement("div", {className: "flex-row micro-item-spacing vertically-center-items"},
|
|
46
|
+
React.createElement("div", {className: "flex-row-item flex-no-resize"},
|
|
47
|
+
React.createElement(Dbm.react.area.HasData, {check: Dbm.react.source.contextVariable("language.id")},
|
|
48
|
+
React.createElement("div", {className: "language-circle centered-cell-holder overflow-hidden"},
|
|
49
|
+
React.createElement(Dbm.react.image.Image, {"src": Dbm.core.source.command(Dbm.commands.callFunction(this.getFlagUrl, [Dbm.react.source.contextVariable("language.identifier")])), "className": "background-cover full-size"})
|
|
50
|
+
)
|
|
51
|
+
),
|
|
52
|
+
React.createElement(Dbm.react.area.HasData, {check: Dbm.react.source.contextVariable("language.id"), checkType: "invert/default"},
|
|
53
|
+
React.createElement("div", {className: "language-circle centered-cell-holder"},
|
|
54
|
+
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
),
|
|
59
|
+
React.createElement("div", {className: "flex-row-item flex-resize"},
|
|
60
|
+
React.createElement(Dbm.react.area.HasData, {check: Dbm.react.source.contextVariable("language.id")},
|
|
61
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("language.name"))
|
|
62
|
+
),
|
|
63
|
+
React.createElement(Dbm.react.area.HasData, {check: Dbm.react.source.contextVariable("language.id"), checkType: "invert/default"},
|
|
64
|
+
"Language"
|
|
65
|
+
)
|
|
66
|
+
),
|
|
67
|
+
React.createElement("div", {className: "flex-row-item flex-no-resize"},
|
|
68
|
+
"v"
|
|
69
|
+
)
|
|
70
|
+
)
|
|
71
|
+
),
|
|
72
|
+
React.createElement("div", {"className": "dropdown-menu-max-height standard-dropdown"},
|
|
73
|
+
React.createElement(Dbm.react.area.List, {items: this.item.properties.availableLanguages, "as": "availableLanguage"},
|
|
74
|
+
React.createElement(Dbm.react.interaction.CommandButton, {"commands": [
|
|
75
|
+
Dbm.commands.setProperty(Dbm.react.source.contextVariable("valueEditor.editValue.value"), Dbm.react.source.contextVariable("availableLanguage.id")),
|
|
76
|
+
Dbm.commands.setProperty(Dbm.react.source.contextVariable("open"), false)
|
|
77
|
+
]},
|
|
78
|
+
React.createElement("div", {className: "standard-dropdown-row standard-dropdown-row-padding hover-row cursor-pointer"},
|
|
79
|
+
Dbm.react.text.text(Dbm.react.source.contextVariable("availableLanguage.name"))
|
|
80
|
+
)
|
|
81
|
+
),
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
)
|
|
87
|
+
),
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
@@ -26,7 +26,7 @@ export default class EditObject extends Dbm.react.BaseObject {
|
|
|
26
26
|
{"type": "includeDraft"},
|
|
27
27
|
{"type": "idSelection", "ids": [item.id]},
|
|
28
28
|
],
|
|
29
|
-
["admin_fields", "admin_fieldTranslations", "relations"]
|
|
29
|
+
["admin_fields", "admin_fieldTranslations", "relations", "url", "identifier", "visibility"]
|
|
30
30
|
);
|
|
31
31
|
allLoaded.addCheck(request.properties.status);
|
|
32
32
|
}
|
|
@@ -26,7 +26,7 @@ export default class EditObjectById extends Dbm.react.BaseObject {
|
|
|
26
26
|
{"type": "includeDraft"},
|
|
27
27
|
{"type": "idSelection", "ids": [id]},
|
|
28
28
|
],
|
|
29
|
-
["admin_fields", "admin_fieldTranslations", "relations"]
|
|
29
|
+
["admin_fields", "admin_fieldTranslations", "relations", "url", "identifier", "visibility"]
|
|
30
30
|
);
|
|
31
31
|
allLoaded.addCheck(request.properties.status);
|
|
32
32
|
}
|