dbm 1.4.3 → 1.4.4

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.
@@ -25,7 +25,7 @@ export default class PartOfObject extends Dbm.core.BaseObject {
25
25
 
26
26
  if(stringValue !== this._lastUpdatedValue) {
27
27
  this._lastUpdatedValue = stringValue;
28
- let newValue = JSON.parse(stringValue);
28
+ let newValue = stringValue ? JSON.parse(stringValue) : null;
29
29
  this.item.value = newValue;
30
30
  }
31
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbm",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -6,6 +6,15 @@ export default class DraggableHierarchyDisplay extends Dbm.react.BaseObject {
6
6
  super._construct();
7
7
  }
8
8
 
9
+ _remove() {
10
+ console.log("_remove");
11
+ let hierarchyItem = this.context.hierarchyItem;
12
+
13
+ console.log(hierarchyItem);
14
+
15
+ this.context.hierarchyController.removeHierarchyItem(hierarchyItem);
16
+ }
17
+
9
18
  _renderMainElement() {
10
19
 
11
20
  let children = this.getPropValue("children");
@@ -20,7 +29,19 @@ export default class DraggableHierarchyDisplay extends Dbm.react.BaseObject {
20
29
  ),
21
30
  React.createElement("div", {className: "flex-row-item flex-resize"},
22
31
  children
23
- )
32
+ ),
33
+ React.createElement("div", {className: "flex-row-item flex-no-resize"},
34
+ React.createElement("div", {className: "spacing small"}),
35
+ React.createElement(Dbm.react.interaction.ConfirmButton, {"command": Dbm.commands.callFunction(this._remove.bind(this))},
36
+ React.createElement(Dbm.react.image.Image, {"src": "/assets/img/icons/delete.svg", "className": "background-contain text-row-icon action-icon-color cursor-pointer"}),
37
+ React.createElement("div", {"data-slot": "confirm", className: "absolute-container cursor-pointer", title: "Click to remove"},
38
+ React.createElement(Dbm.react.image.Image, {"src": "/assets/img/icons/delete.svg", "className": "background-contain text-row-icon hover-icon remove-action-icon-color cursor-pointer"}),
39
+ React.createElement("div", {className:"centered-tip-text no-pointer-events"},
40
+ "Remove?"
41
+ )
42
+ )
43
+ )
44
+ ),
24
45
  )
25
46
 
26
47
  )
@@ -46,6 +46,7 @@ export default class HierarchyOrderedRelationsList extends Dbm.react.BaseObject
46
46
  _removeMissingPartsOfHierarchy(aHierarchy, aMustBeInArray) {
47
47
  //console.log("_removeMissingPartsOfHierarchy");
48
48
  //console.log(aHierarchy, aMustBeInArray);
49
+
49
50
  let currentArray = aHierarchy;
50
51
  let currentArrayLength = currentArray.length;
51
52
 
@@ -54,6 +55,11 @@ export default class HierarchyOrderedRelationsList extends Dbm.react.BaseObject
54
55
  if(aMustBeInArray.indexOf(currentItem.id) !== -1) {
55
56
  this._removeMissingPartsOfHierarchy(currentItem.children, aMustBeInArray);
56
57
  }
58
+ else {
59
+ currentArray.splice(i, 1);
60
+ i--;
61
+ currentArrayLength--;
62
+ }
57
63
  }
58
64
  }
59
65
 
@@ -68,6 +74,17 @@ export default class HierarchyOrderedRelationsList extends Dbm.react.BaseObject
68
74
  }
69
75
  }
70
76
 
77
+ _getAllLinkedIdsFromHierarchy(aItems, aReturnArray) {
78
+ let currentArray = aItems;
79
+ let currentArrayLength = currentArray.length;
80
+ for(let i = 0; i < currentArrayLength; i++) {
81
+ let currentItem = currentArray[i];
82
+
83
+ aReturnArray.push(currentItem.linkedItem.id);
84
+ this._getAllLinkedIdsFromHierarchy(currentItem.children, aReturnArray);
85
+ }
86
+ }
87
+
71
88
  _getFullHierarchy() {
72
89
  let relations = this._relationsEditor.value;
73
90
  let hierarchyValue = this._orderEditor.value;
@@ -257,6 +274,28 @@ export default class HierarchyOrderedRelationsList extends Dbm.react.BaseObject
257
274
  this._orderEditor.value = hierarchyValue;
258
275
  }
259
276
 
277
+ removeHierarchyItem(aHierarchyItem) {
278
+ console.log("removeHierarchyItem");
279
+ let position = this._findPosition(aHierarchyItem, this.item.hierarchy.children);
280
+
281
+ let idsToRemove = [];
282
+ this._getAllLinkedIdsFromHierarchy([aHierarchyItem], idsToRemove);
283
+
284
+ console.log(position, idsToRemove);
285
+
286
+ let editor = this._getEditor();
287
+ let newValues = [].concat(editor.value);
288
+
289
+ console.log(JSON.stringify(newValues), idsToRemove);
290
+ newValues = Dbm.utils.ArrayFunctions.removeValues(newValues, idsToRemove);
291
+ console.log(JSON.stringify(newValues), idsToRemove);
292
+
293
+ editor.value = newValues;
294
+
295
+ let hierarchyValue = this._getFullHierarchy();
296
+ this._orderEditor.value = hierarchyValue;
297
+ }
298
+
260
299
  _create() {
261
300
  console.log("_create");
262
301
  let objectType = this.getPropValue("objectType");
@@ -270,10 +309,7 @@ export default class HierarchyOrderedRelationsList extends Dbm.react.BaseObject
270
309
  Dbm.flow.addUpdateCommand(request.properties.status, Dbm.commands.callFunction(this._created.bind(this), [Dbm.core.source.staticObject(request, "item")]));
271
310
  }
272
311
 
273
- _created(aItem) {
274
- console.log("_created");
275
- console.log(aItem);
276
-
312
+ _getEditor() {
277
313
  let itemEditor = this.context.itemEditor;
278
314
 
279
315
  let direction = this.getPropValue("direction");
@@ -291,9 +327,21 @@ export default class HierarchyOrderedRelationsList extends Dbm.react.BaseObject
291
327
  console.error("Unknown direction", direction, this);
292
328
  }
293
329
 
330
+ return editor;
331
+ }
332
+
333
+ _created(aItem) {
334
+ console.log("_created");
335
+ console.log(aItem);
336
+
337
+ let editor = this._getEditor();
338
+
294
339
  let newValues = [].concat(editor.value);
295
340
  newValues.push(aItem.id);
296
341
  editor.value = newValues;
342
+
343
+ let hierarchyValue = this._getFullHierarchy();
344
+ this._orderEditor.value = hierarchyValue;
297
345
  }
298
346
 
299
347
  _renderMainElement() {
@@ -302,7 +350,7 @@ export default class HierarchyOrderedRelationsList extends Dbm.react.BaseObject
302
350
  let children = this.getPropValue("children");
303
351
 
304
352
  return React.createElement("div", {},
305
- React.createElement(Dbm.react.context.AddContextVariables, {"values": {"dragController": this}},
353
+ React.createElement(Dbm.react.context.AddContextVariables, {"values": {"dragController": this, "hierarchyController": this}},
306
354
  React.createElement(Dbm.react.form.LabelledArea, {label: label}),
307
355
  React.createElement("div", {"className": ""},
308
356
  React.createElement(Dbm.react.area.List, {items: this.item.hierarchy.properties.children, as: "hierarchyItem"},