dbm 1.2.7 → 1.2.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.
- package/commands/index.js +6 -1
- package/ecommerce/CartLineItem.js +2 -2
- package/ecommerce/LocalStorageCartLoader.js +0 -2
- package/flow/updatefunctions/thirdparty/google/maps/AutoComplete.js +2 -2
- package/graphapi/index.js +1 -2
- package/graphapi/webclient/admin/ItemEditor.js +9 -2
- package/graphapi/webclient/decode/index.js +9 -0
- package/package.json +1 -1
- package/react/ChildFunctions.js +55 -1
- package/react/admin/editorsgroup/EditPartOfObject.js +32 -0
- package/react/admin/editorsgroup/index.js +2 -1
- 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/index.js +4 -1
- package/react/animation/AnimatedElement.js +4 -0
- package/react/area/FixedWidthInfiniteSlideshow.js +40 -6
- package/react/area/HasData.js +1 -1
- package/react/area/InsertElement.js +9 -2
- package/react/area/OpenCloseExpandableArea.js +6 -2
- package/react/area/PopoverLayer.js +1 -2
- package/react/blocks/admin/objects/Edit.js +1 -1
- package/react/blocks/index.js +89 -1
- package/react/form/Dropdown.js +2 -4
- 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/source/index.js +10 -2
- package/site/translation/TranslationLoader.js +3 -3
- package/tracking/index.js +1 -1
- package/utils/ArrayFunctions.js +15 -0
- package/utils/ArrayOperationResult.js +15 -0
- package/utils/LevenshteinDistance.js +36 -0
- package/utils/MultidimensionalArrayHolder.js +65 -0
- package/utils/index.js +4 -0
- package/graphapi/admin/EditGroup.js +0 -50
- package/graphapi/admin/index.js +0 -1
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
|
}
|
|
@@ -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";
|
|
@@ -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];
|
|
@@ -224,8 +233,6 @@ export default class ItemEditor extends Dbm.core.BaseObject {
|
|
|
224
233
|
getAdminUrlEditor() {
|
|
225
234
|
let item = this.item.editedItem;
|
|
226
235
|
let value = Dbm.objectPath(item, "url");
|
|
227
|
-
|
|
228
|
-
debugger;
|
|
229
236
|
|
|
230
237
|
return this.getUrlEditor(value);
|
|
231
238
|
}
|
|
@@ -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
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,32 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class EditPartOfObject extends Dbm.react.BaseObject {
|
|
5
|
+
_constructAfterProps() {
|
|
6
|
+
super._constructAfterProps();
|
|
7
|
+
|
|
8
|
+
let valueProperty = this.getDynamicPropWithoutState("value", {});
|
|
9
|
+
|
|
10
|
+
let partObject = new Dbm.flow.controllers.transform.PartOfObject();
|
|
11
|
+
this.item.setValue("partOfObject", partObject);
|
|
12
|
+
let path = this.getPropValue("path");
|
|
13
|
+
|
|
14
|
+
if(!valueProperty.value) {
|
|
15
|
+
valueProperty.getMostUpstreamProperty().value = {};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
partObject.item.properties.object.connectInput(valueProperty);
|
|
19
|
+
partObject.item.path = path;
|
|
20
|
+
|
|
21
|
+
this.item.requireProperty("valuePart", null).connectInput(partObject.item.properties.value);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_renderMainElement() {
|
|
25
|
+
|
|
26
|
+
let children = this.getPropValue("children")
|
|
27
|
+
|
|
28
|
+
return React.createElement("div", {},
|
|
29
|
+
React.createElement(Dbm.react.context.AddContextVariables, {"values": {"value": this.item.properties.valuePart}}, children)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -5,4 +5,5 @@ export {default as EditVisibility} from "./EditVisibility.js";
|
|
|
5
5
|
export {default as EditIdentifer} from "./EditIdentifer.js";
|
|
6
6
|
export {default as EditFieldTranslation} from "./EditFieldTranslation.js";
|
|
7
7
|
export {default as EditMultipleRelations} from "./EditMultipleRelations.js";
|
|
8
|
-
export {default as EditUrl} from "./EditUrl.js";
|
|
8
|
+
export {default as EditUrl} from "./EditUrl.js";
|
|
9
|
+
export {default as EditPartOfObject} from "./EditPartOfObject.js";
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class DraggableHierarchyDisplay extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_renderMainElement() {
|
|
10
|
+
|
|
11
|
+
let children = this.getPropValue("children");
|
|
12
|
+
|
|
13
|
+
return React.createElement("div", {},
|
|
14
|
+
React.createElement(Dbm.react.context.AddItemToContext, {"item": Dbm.react.source.contextVariable("hierarchyItem.linkedItem")},
|
|
15
|
+
React.createElement(Dbm.react.interaction.drag.DraggableItem, {skipDraggable: true, moveMode: "insertBefore"},
|
|
16
|
+
React.createElement("div", {className: "flex-row micro-item-spacing"},
|
|
17
|
+
React.createElement("div", {className: "flex-row-item flex-no-resize cursor-grab", draggable: true},
|
|
18
|
+
React.createElement("div", {className: "spacing small"}),
|
|
19
|
+
React.createElement(Dbm.react.image.Image, {"src": "/assets/img/icons/drag-handle.svg", "className": "background-contain drag-handle-icon action-icon-color"})
|
|
20
|
+
),
|
|
21
|
+
React.createElement("div", {className: "flex-row-item flex-resize"},
|
|
22
|
+
children
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
)
|
|
27
|
+
),
|
|
28
|
+
React.createElement("div", {className: "hierarchy-indent"},
|
|
29
|
+
React.createElement("div", {className: "spacing small"}),
|
|
30
|
+
React.createElement(Dbm.react.area.HasData, {check: Dbm.react.source.contextVariable("hierarchyItem.properties.children"), checkType: "notEmpty"},
|
|
31
|
+
React.createElement(Dbm.react.area.List, {items: Dbm.react.source.contextVariable("hierarchyItem.properties.children"), as: "hierarchyItem"},
|
|
32
|
+
React.createElement(Dbm.react.admin.objects.itemeditors.DraggableHierarchyDisplay, {}, children),
|
|
33
|
+
React.createElement("div", {"data-slot": "spacing", className: "spacing small"}),
|
|
34
|
+
),
|
|
35
|
+
React.createElement("div", {className: "spacing small"})
|
|
36
|
+
),
|
|
37
|
+
React.createElement(Dbm.react.interaction.drag.DraggableItem, {skipDraggable: true, moveMode: "appendChild"},
|
|
38
|
+
React.createElement("div", {className: "append-drop-position centered-cell-holder"},
|
|
39
|
+
React.createElement("div", {})
|
|
40
|
+
)
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class HierarchyOrderedRelationsList extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this._internalId = Dbm.getInstance().getNextId();
|
|
9
|
+
let itemEditor = this.context.itemEditor;
|
|
10
|
+
|
|
11
|
+
this._draggedElement = null;
|
|
12
|
+
this._hierachyMap = {};
|
|
13
|
+
|
|
14
|
+
let hierarchyHolder = new Dbm.repository.Item();
|
|
15
|
+
hierarchyHolder.setValue("children", []);
|
|
16
|
+
|
|
17
|
+
this.item.requireProperty("hierarchy", hierarchyHolder);
|
|
18
|
+
|
|
19
|
+
let direction = this.getPropValue("direction");
|
|
20
|
+
let relationType = this.getPropValue("relationType");
|
|
21
|
+
let objectType = this.getPropValue("objectType");
|
|
22
|
+
|
|
23
|
+
let orderFieldName = this.getPropValue("orderFieldName");
|
|
24
|
+
|
|
25
|
+
this._relationsEditor;
|
|
26
|
+
if(direction === "in") {
|
|
27
|
+
this._relationsEditor = itemEditor.getAdminMultipleIncomingRelationsEditor(relationType, objectType);
|
|
28
|
+
}
|
|
29
|
+
else if(direction === "out") {
|
|
30
|
+
this._relationsEditor = itemEditor.getAdminMultipleOutgoingRelationsEditor(relationType, objectType);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
console.error("Unknown direction", direction, this);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
this._orderEditor = itemEditor.getAdminFieldEditor(orderFieldName);
|
|
37
|
+
|
|
38
|
+
let updateCommand = Dbm.commands.callFunction(this._updateHierarchy.bind(this));
|
|
39
|
+
|
|
40
|
+
Dbm.flow.addUpdateCommand(this._relationsEditor.valueProperty, updateCommand);
|
|
41
|
+
Dbm.flow.addUpdateCommand(this._orderEditor.valueProperty, updateCommand);
|
|
42
|
+
this._updateHierarchy();
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_removeMissingPartsOfHierarchy(aHierarchy, aMustBeInArray) {
|
|
47
|
+
//console.log("_removeMissingPartsOfHierarchy");
|
|
48
|
+
//console.log(aHierarchy, aMustBeInArray);
|
|
49
|
+
let currentArray = aHierarchy;
|
|
50
|
+
let currentArrayLength = currentArray.length;
|
|
51
|
+
|
|
52
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
53
|
+
let currentItem = currentArray[i];
|
|
54
|
+
if(aMustBeInArray.indexOf(currentItem.id) !== -1) {
|
|
55
|
+
this._removeMissingPartsOfHierarchy(currentItem.children, aMustBeInArray);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
_getAllIdsFromHierarchy(aItems, aReturnArray) {
|
|
61
|
+
let currentArray = aItems;
|
|
62
|
+
let currentArrayLength = currentArray.length;
|
|
63
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
64
|
+
let currentItem = currentArray[i];
|
|
65
|
+
|
|
66
|
+
aReturnArray.push(currentItem.id);
|
|
67
|
+
this._getAllIdsFromHierarchy(currentItem.children, aReturnArray);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
_getFullHierarchy() {
|
|
72
|
+
let relations = this._relationsEditor.value;
|
|
73
|
+
let hierarchyValue = this._orderEditor.value;
|
|
74
|
+
if(hierarchyValue) {
|
|
75
|
+
hierarchyValue = JSON.parse(JSON.stringify(hierarchyValue));
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
hierarchyValue = [];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
this._removeMissingPartsOfHierarchy(hierarchyValue, relations);
|
|
82
|
+
|
|
83
|
+
let usedIds = [];
|
|
84
|
+
|
|
85
|
+
this._getAllIdsFromHierarchy(hierarchyValue, usedIds);
|
|
86
|
+
let missingIds = Dbm.utils.ArrayFunctions.getUnselectedItems(usedIds, relations);
|
|
87
|
+
|
|
88
|
+
{
|
|
89
|
+
|
|
90
|
+
let currentArray = missingIds;
|
|
91
|
+
let currentArrayLength = currentArray.length;
|
|
92
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
93
|
+
let currentId = currentArray[i];
|
|
94
|
+
hierarchyValue.push({id: currentId, children: []});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return hierarchyValue;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
_updateHierarchy() {
|
|
102
|
+
this._updateHierarchyItems(this.item.hierarchy, this._getFullHierarchy());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_getHierarchyItem(aId) {
|
|
106
|
+
let returnItem = this._hierachyMap["item" + aId];
|
|
107
|
+
if(!returnItem) {
|
|
108
|
+
returnItem = new Dbm.repository.Item();
|
|
109
|
+
returnItem.setId("_internalHierarchy/" + this._internalId + "/" + aId);
|
|
110
|
+
returnItem.setValue("linkedItem", Dbm.getRepositoryItem(aId));
|
|
111
|
+
returnItem.setValue("children", []);
|
|
112
|
+
this._hierachyMap["item" + aId] = returnItem;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return returnItem;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
_updateHierarchyItems(aHierarchyItem, aItems) {
|
|
119
|
+
//console.log("_updateHierarchyItems");
|
|
120
|
+
let newItems = [];
|
|
121
|
+
let hierarchyChildren = aHierarchyItem.children;
|
|
122
|
+
let hasChange = (hierarchyChildren.length !== aItems.length);
|
|
123
|
+
|
|
124
|
+
let currentArray = aItems;
|
|
125
|
+
let currentArrayLength = currentArray.length;
|
|
126
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
127
|
+
let currentItem = currentArray[i];
|
|
128
|
+
let hierarchyItem = this._getHierarchyItem(currentItem.id);
|
|
129
|
+
newItems.push(hierarchyItem);
|
|
130
|
+
this._updateHierarchyItems(hierarchyItem, currentItem.children);
|
|
131
|
+
if(!hasChange && hierarchyChildren[i] !== hierarchyItem) {
|
|
132
|
+
hasChange = true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if(hasChange) {
|
|
137
|
+
aHierarchyItem.children = newItems;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
startDrag(aComponent) {
|
|
142
|
+
console.log("startDrag");
|
|
143
|
+
console.log(aComponent);
|
|
144
|
+
|
|
145
|
+
this._draggedElement = aComponent;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
_findPosition(aItem, aChildren) {
|
|
149
|
+
let index = aChildren.indexOf(aItem);
|
|
150
|
+
if(index !== -1) {
|
|
151
|
+
return [index];
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
let currentArray = aChildren;
|
|
155
|
+
let currentArrayLength = currentArray.length;
|
|
156
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
157
|
+
let currentChild = currentArray[i];
|
|
158
|
+
let childIndex = this._findPosition(aItem, currentChild.children);
|
|
159
|
+
if(childIndex) {
|
|
160
|
+
childIndex.unshift(i)
|
|
161
|
+
return childIndex;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_isInside(aLastPosition, aNewPosition) {
|
|
169
|
+
return aNewPosition.join(".").indexOf(aLastPosition.join(".")) === 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
itemDroppedOn(aComponent, aData) {
|
|
173
|
+
//console.log("itemDroppedOn");
|
|
174
|
+
//console.log(aComponent, aData);
|
|
175
|
+
|
|
176
|
+
let mode = aComponent.getPropValue("moveMode");
|
|
177
|
+
|
|
178
|
+
console.log(mode);
|
|
179
|
+
|
|
180
|
+
let hierarchyValue = this._getFullHierarchy();
|
|
181
|
+
|
|
182
|
+
if(mode === "insertBefore") {
|
|
183
|
+
|
|
184
|
+
let lastDeepIndex = this._findPosition(this._draggedElement.context.hierarchyItem, this.item.hierarchy.children);
|
|
185
|
+
let newDeepIndex = this._findPosition(aComponent.context.hierarchyItem, this.item.hierarchy.children);
|
|
186
|
+
|
|
187
|
+
if(this._isInside(lastDeepIndex, newDeepIndex)) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
let removeIndex = lastDeepIndex.pop();
|
|
192
|
+
let removeArray;
|
|
193
|
+
if(lastDeepIndex.length === 0) {
|
|
194
|
+
removeArray = hierarchyValue;
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
removeArray = Dbm.objectPath(hierarchyValue, lastDeepIndex.join(".children.") + ".children");
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
let addIndex = newDeepIndex.pop();
|
|
201
|
+
let addArray;
|
|
202
|
+
if(newDeepIndex.length === 0) {
|
|
203
|
+
addArray = hierarchyValue;
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
addArray = Dbm.objectPath(hierarchyValue, newDeepIndex.join(".children.") + ".children");
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
let movedItem = removeArray.splice(removeIndex, 1)[0];
|
|
210
|
+
|
|
211
|
+
if(addIndex > removeIndex && removeArray === addArray) {
|
|
212
|
+
addIndex--;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
addArray.splice(addIndex, 0, movedItem);
|
|
216
|
+
}
|
|
217
|
+
else if(mode === "appendChild") {
|
|
218
|
+
let lastDeepIndex = this._findPosition(this._draggedElement.context.hierarchyItem, this.item.hierarchy.children);
|
|
219
|
+
let newDeepIndex = this._findPosition(aComponent.context.hierarchyItem, this.item.hierarchy.children);
|
|
220
|
+
|
|
221
|
+
if(this._isInside(lastDeepIndex, newDeepIndex)) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
let removeIndex = lastDeepIndex.pop();
|
|
226
|
+
let removeArray;
|
|
227
|
+
if(lastDeepIndex.length === 0) {
|
|
228
|
+
removeArray = hierarchyValue;
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
removeArray = Dbm.objectPath(hierarchyValue, lastDeepIndex.join(".children.") + ".children");
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
let addArray = Dbm.objectPath(hierarchyValue, newDeepIndex.join(".children.") + ".children");
|
|
235
|
+
|
|
236
|
+
let movedItem = removeArray.splice(removeIndex, 1)[0];
|
|
237
|
+
addArray.push(movedItem);
|
|
238
|
+
}
|
|
239
|
+
else if(mode === "last") {
|
|
240
|
+
let lastDeepIndex = this._findPosition(this._draggedElement.context.hierarchyItem, this.item.hierarchy.children);
|
|
241
|
+
|
|
242
|
+
let removeIndex = lastDeepIndex.pop();
|
|
243
|
+
let removeArray;
|
|
244
|
+
if(lastDeepIndex.length === 0) {
|
|
245
|
+
removeArray = hierarchyValue;
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
removeArray = Dbm.objectPath(hierarchyValue, lastDeepIndex.join(".children.") + ".children");
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
let addArray = hierarchyValue;
|
|
252
|
+
|
|
253
|
+
let movedItem = removeArray.splice(removeIndex, 1)[0];
|
|
254
|
+
addArray.push(movedItem);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
this._orderEditor.value = hierarchyValue;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
_create() {
|
|
261
|
+
console.log("_create");
|
|
262
|
+
let objectType = this.getPropValue("objectType");
|
|
263
|
+
let encodings = this.getPropValueWithDefault("encodings", ["id"]);
|
|
264
|
+
let visibility = this.getPropValueWithDefault("visibility", "private");
|
|
265
|
+
|
|
266
|
+
let changes = [];
|
|
267
|
+
|
|
268
|
+
let request = Dbm.getGraphApi().createItem([objectType], visibility, changes, encodings);
|
|
269
|
+
|
|
270
|
+
Dbm.flow.addUpdateCommand(request.properties.status, Dbm.commands.callFunction(this._created.bind(this), [Dbm.core.source.staticObject(request, "item")]));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
_created(aItem) {
|
|
274
|
+
console.log("_created");
|
|
275
|
+
console.log(aItem);
|
|
276
|
+
|
|
277
|
+
let itemEditor = this.context.itemEditor;
|
|
278
|
+
|
|
279
|
+
let direction = this.getPropValue("direction");
|
|
280
|
+
let relationType = this.getPropValue("relationType");
|
|
281
|
+
let objectType = this.getPropValue("objectType");
|
|
282
|
+
|
|
283
|
+
let editor;
|
|
284
|
+
if(direction === "in") {
|
|
285
|
+
editor = itemEditor.getAdminMultipleIncomingRelationsEditor(relationType, objectType);
|
|
286
|
+
}
|
|
287
|
+
else if(direction === "out") {
|
|
288
|
+
editor = itemEditor.getAdminMultipleOutgoingRelationsEditor(relationType, objectType);
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
console.error("Unknown direction", direction, this);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
let newValues = [].concat(editor.value);
|
|
295
|
+
newValues.push(aItem.id);
|
|
296
|
+
editor.value = newValues;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
_renderMainElement() {
|
|
300
|
+
|
|
301
|
+
let label = this.getPropValue("label");
|
|
302
|
+
let children = this.getPropValue("children");
|
|
303
|
+
|
|
304
|
+
return React.createElement("div", {},
|
|
305
|
+
React.createElement(Dbm.react.context.AddContextVariables, {"values": {"dragController": this}},
|
|
306
|
+
React.createElement(Dbm.react.form.LabelledArea, {label: label}),
|
|
307
|
+
React.createElement("div", {"className": ""},
|
|
308
|
+
React.createElement(Dbm.react.area.List, {items: this.item.hierarchy.properties.children, as: "hierarchyItem"},
|
|
309
|
+
React.createElement(Dbm.react.context.AddItemToContext, {"item": Dbm.react.source.contextVariable("hierarchyItem.linkedItem")},
|
|
310
|
+
React.createElement(Dbm.react.admin.objects.itemeditors.DraggableHierarchyDisplay, {},
|
|
311
|
+
children
|
|
312
|
+
)
|
|
313
|
+
),
|
|
314
|
+
React.createElement("div", {"data-slot": "spacing", className: "spacing small"})
|
|
315
|
+
)
|
|
316
|
+
),
|
|
317
|
+
React.createElement("div", {"className": "spacing small"}),
|
|
318
|
+
React.createElement(Dbm.react.interaction.drag.DraggableItem, {skipDraggable: true, moveMode: "last"},
|
|
319
|
+
React.createElement("div", {className: "append-drop-position centered-cell-holder"},
|
|
320
|
+
React.createElement("div", {})
|
|
321
|
+
)
|
|
322
|
+
),
|
|
323
|
+
React.createElement("div", {"className": "spacing small"}),
|
|
324
|
+
React.createElement("div", {"className": "flex-row"},
|
|
325
|
+
React.createElement(Dbm.react.interaction.CommandButton, {command: Dbm.commands.callFunction(this._create.bind(this))},
|
|
326
|
+
React.createElement("div", {"className": "action-button action-button-padding"},
|
|
327
|
+
"Add"
|
|
328
|
+
)
|
|
329
|
+
)
|
|
330
|
+
)
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
)
|
|
334
|
+
}
|
|
335
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class RelationsList extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
_create() {
|
|
10
|
+
console.log("_create");
|
|
11
|
+
let objectType = this.getPropValue("objectType");
|
|
12
|
+
let encodings = this.getPropValueWithDefault("encodings", ["id"]);
|
|
13
|
+
let visibility = this.getPropValueWithDefault("visibility", "private");
|
|
14
|
+
|
|
15
|
+
let changes = [];
|
|
16
|
+
|
|
17
|
+
let request = Dbm.getInstance().repository.getItem("graphApi").controller.createItem([objectType], visibility, changes, encodings);
|
|
18
|
+
|
|
19
|
+
Dbm.flow.addUpdateCommand(request.properties.status, Dbm.commands.callFunction(this._created.bind(this), [Dbm.core.source.staticObject(request, "item")]));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_created(aItem) {
|
|
23
|
+
console.log("_created");
|
|
24
|
+
console.log(aItem);
|
|
25
|
+
|
|
26
|
+
let itemEditor = this.context.itemEditor;
|
|
27
|
+
|
|
28
|
+
let direction = this.getPropValue("direction");
|
|
29
|
+
let relationType = this.getPropValue("relationType");
|
|
30
|
+
let objectType = this.getPropValue("objectType");
|
|
31
|
+
|
|
32
|
+
let editor;
|
|
33
|
+
if(direction === "in") {
|
|
34
|
+
editor = itemEditor.getAdminMultipleIncomingRelationsEditor(relationType, objectType);
|
|
35
|
+
}
|
|
36
|
+
else if(direction === "out") {
|
|
37
|
+
editor = itemEditor.getAdminMultipleOutgoingRelationsEditor(relationType, objectType);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
console.error("Unknown direction", direction, this);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let newValues = [].concat(editor.value);
|
|
44
|
+
newValues.push(aItem.id);
|
|
45
|
+
editor.value = newValues;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
_renderMainElement() {
|
|
49
|
+
|
|
50
|
+
let id = this.context.item.id;
|
|
51
|
+
|
|
52
|
+
let label = this.getPropValue("label");
|
|
53
|
+
let direction = this.getPropValue("direction");
|
|
54
|
+
let relationType = this.getPropValue("relationType");
|
|
55
|
+
let objectType = this.getPropValue("objectType");
|
|
56
|
+
let children = this.getPropValue("children");
|
|
57
|
+
|
|
58
|
+
return React.createElement("div", {},
|
|
59
|
+
React.createElement(Dbm.react.form.LabelledArea, {label: label}),
|
|
60
|
+
React.createElement("div", {"className": "standard-alternating-rows"},
|
|
61
|
+
React.createElement(Dbm.react.admin.editorsgroup.EditMultipleRelations, {"direction": direction, "relationType": relationType, "objectType": objectType},
|
|
62
|
+
React.createElement(Dbm.react.area.List, {items: Dbm.react.source.contextVariable("valueEditor.editValue.value")},
|
|
63
|
+
children
|
|
64
|
+
)
|
|
65
|
+
)
|
|
66
|
+
),
|
|
67
|
+
React.createElement("div", {"className": "spacing small"}),
|
|
68
|
+
React.createElement("div", {"className": "flex-row"},
|
|
69
|
+
React.createElement(Dbm.react.interaction.CommandButton, {command: Dbm.commands.callFunction(this._create.bind(this))},
|
|
70
|
+
React.createElement("div", {"className": "action-button action-button-padding"},
|
|
71
|
+
"Add"
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
)
|
|
75
|
+
)
|
|
76
|
+
}
|
|
77
|
+
}
|