dbm 1.4.12 → 1.4.13

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 CHANGED
@@ -61,6 +61,12 @@ export const performCommands = function(aCommands, aFromObject = null, aEventDat
61
61
  let currentArrayLength = currentArray.length;
62
62
  for(let i = 0; i < currentArrayLength; i++) {
63
63
  let currentCommand = currentArray[i];
64
+
65
+ if(currentCommand && currentCommand.isSource) {
66
+ currentCommand = currentCommand.getSource(aFromObject);
67
+ }
68
+ //METODO: add flow property
69
+
64
70
  try {
65
71
  currentCommand.perform(aFromObject, aEventData);
66
72
  }
package/css/all.css CHANGED
@@ -5,4 +5,5 @@
5
5
  @import './rows.css';
6
6
  @import './icons.css';
7
7
  @import './tags.css';
8
- @import './elements.css';
8
+ @import './elements.css';
9
+ @import './text.css';
package/css/tags.css CHANGED
@@ -107,8 +107,17 @@
107
107
  overflow: hidden;
108
108
  }
109
109
 
110
- .standard-tag-list .standard-tag-list-item{
110
+ .standard-tag-list .standard-tag-list-item {
111
111
  float: left;
112
112
  margin-right: var(--standard-tag-list-horizontal-margin, 10px);
113
113
  margin-bottom: var(--standard-tag-list-vertical-margin, 5px);
114
+ }
115
+
116
+ .option {
117
+ cursor: pointer;
118
+ }
119
+
120
+ .option.selected {
121
+ background-color: var(--standard-tag-option-selected-background-color, #555555);
122
+ color: var(--standard-tag-option-selected-text-color, #ffffff);
114
123
  }
package/css/text.css ADDED
@@ -0,0 +1,4 @@
1
+ .small-description {
2
+ font-size: 12px;
3
+ color: #828282;
4
+ }
@@ -0,0 +1,20 @@
1
+ import Dbm from "../../../index.js";
2
+
3
+ export default class GetItemBy extends Dbm.flow.FlowUpdateFunction {
4
+
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.input.register("value", null);
9
+ this.input.register("items", []);
10
+ this.input.register("path", "id");
11
+
12
+ this.output.register("value", null);
13
+ }
14
+
15
+ _update() {
16
+ //console.log("GetItemBy::_update");
17
+
18
+ this.output.value = Dbm.utils.ArrayFunctions.getItemBy(this.input.items, this.input.path, this.input.value);
19
+ }
20
+ }
@@ -8,6 +8,7 @@ export {default as PropertyOfWithDefault} from "./PropertyOfWithDefault.js";
8
8
  export {default as MappedList} from "./MappedList.js";
9
9
  export {default as Translation} from "./Translation.js";
10
10
  export {default as SetProperty} from "./SetProperty.js";
11
+ export {default as GetItemBy} from "./GetItemBy.js";
11
12
 
12
13
  export const runCommand = function(aValue, aCommand) {
13
14
  let updateFunction = new Dbm.flow.updatefunctions.basic.RunCommand();
@@ -134,5 +135,16 @@ export const setProperty = function(aObject, aPropertyName, aValue = null) {
134
135
  properties.object.setOrConnect(aObject);
135
136
  properties.propertyName.setOrConnect(aPropertyName);
136
137
 
138
+ return updateFunction;
139
+ }
140
+
141
+ export const getItemBy = function(aItems, aValue, aPath = "id") {
142
+ let updateFunction = new Dbm.flow.updatefunctions.basic.GetItemBy();
143
+
144
+ let properties = updateFunction.input.properties;
145
+ properties.value.setOrConnect(aValue);
146
+ properties.items.setOrConnect(aItems);
147
+ properties.path.setOrConnect(aPath);
148
+
137
149
  return updateFunction;
138
150
  }
@@ -17,13 +17,13 @@ export default class Condition extends Dbm.flow.FlowUpdateFunction {
17
17
 
18
18
  let operation = this.input.operation;
19
19
  if(typeof(operation) === "string") {
20
- if(operation === "!==") {
21
- operation = function(aA, aB) {return aA !== aB;}
22
- }
23
- else {
24
- //METODO: add more operations
25
- operation = function(aA, aB) {return aA === aB;}
20
+ let compareFunction = Dbm.getInstance().repository.getItem("compareFunctions/" + operation).compare;
21
+ if(!compareFunction) {
22
+ console.warn("No copmare function registered for: " + operation + ". Using ==", this);
23
+ compareFunction = Dbm.utils.CompareFunctions.equals;
26
24
  }
25
+
26
+ operation = compareFunction
27
27
  }
28
28
 
29
29
  this.output.result = operation.call(this, this.input.input1, this.input.input2);
@@ -65,4 +65,16 @@ export const performAction = function(aType, aData, aCallback = null) {
65
65
  }
66
66
 
67
67
  return request.properties.data;
68
+ }
69
+
70
+ export const loadRange = function(aSelects, aEncodings, aCommand) {
71
+ let graphApi = Dbm.getRepositoryItem("cachedGraphApi").controller;
72
+
73
+ let request = graphApi.requestRange(aSelects, aEncodings);
74
+
75
+ if(aCommand) {
76
+ Dbm.flow.runWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, aCommand);
77
+ }
78
+
79
+ return request.properties.items;
68
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dbm",
3
- "version": "1.4.12",
3
+ "version": "1.4.13",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -19,7 +19,7 @@ export default class EditObject extends Dbm.react.BaseObject {
19
19
  {"type": "includeDraft"},
20
20
  {"type": "idSelection", "ids": [id]},
21
21
  ],
22
- ["objectTypes"]
22
+ ["objectTypes", "name", "identifier"]
23
23
  );
24
24
  allLoaded.addCheck(request.properties.status);
25
25
  }
@@ -38,11 +38,23 @@ export default class EditObject extends Dbm.react.BaseObject {
38
38
 
39
39
  React.createElement(Dbm.react.area.HasData, {check: this.item.properties.loaded},
40
40
  React.createElement(Dbm.react.context.AddContextVariables, {"values": {"item": item}},
41
- React.createElement(Dbm.react.admin.editorsgroup.EditItem, {},
42
- React.createElement(Dbm.react.area.List, {items: Dbm.react.source.contextVariable("item.objectTypes"), "as": "objectType", "keyField": "(root)"},
43
- Dbm.react.text.text(Dbm.react.source.contextVariable("objectType"))
41
+ React.createElement(Dbm.react.admin.editorsgroup.EditItem, {},
42
+ React.createElement("h2", {"className": "no-margins"},
43
+ Dbm.react.text.text(Dbm.react.source.item("id")),
44
+ " - ",
45
+ Dbm.react.text.text(Dbm.react.source.item("name")),
44
46
  ),
45
- React.createElement(Dbm.react.area.List, {items: Dbm.react.source.contextVariable("item.objectTypes"), "as": "objectType", "keyField": "(root)"},
47
+ React.createElement("div", {"className": "small-description"},
48
+ Dbm.react.text.text(Dbm.react.source.item("identifier"))
49
+ ),
50
+ React.createElement("div", {"className": "spacing small"}),
51
+ React.createElement(Dbm.react.area.List, {items: Dbm.react.source.item("objectTypes"), className: "inline-list standard-tag-list standard-tag-list-expand", "as": "objectType", "keyField": "(root)"},
52
+ React.createElement("div", {"className": "standard-tag standard-tag-padding standard-tag-list-item inline-list-item display-inline-block"},
53
+ Dbm.react.text.text(Dbm.react.source.contextVariable("objectType"))
54
+ )
55
+ ),
56
+ React.createElement("div", {"className": "spacing small"}),
57
+ React.createElement(Dbm.react.area.List, {items: Dbm.react.source.item("objectTypes"), "as": "objectType", "keyField": "(root)"},
46
58
  React.createElement(Dbm.react.admin.objects.InjectObjectTypeEditor, {type: Dbm.react.source.contextVariable("objectType")})
47
59
  )
48
60
  )
@@ -0,0 +1,69 @@
1
+ import React from "react";
2
+ import Dbm from "../../index.js";
3
+
4
+ export default class CustomSelection extends Dbm.react.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+
8
+ let valueProperty = this.getDynamicPropWithoutState("value", null);
9
+ let itemsProperty = this.getDynamicPropWithoutState("items", []);
10
+
11
+ let openProperty = this.item.requireProperty("open", false);
12
+ this.item.requireProperty("rows", []);
13
+
14
+ this.item.requireProperty("selectedItem", null);
15
+
16
+ let mappedList = Dbm.flow.updatefunctions.basic.mappedList(itemsProperty, [this._getScopedCallFunctionCommand(this._newRow, [Dbm.core.source.event("mappedItem")])]);
17
+ this.item.setValue("mappedList", mappedList);
18
+ this.item.properties.rows.connectInput(mappedList.output.properties.items);
19
+
20
+ let singleSelection = new Dbm.flow.controllers.select.SingleSelection();
21
+ this.item.setValue("singleSelection", singleSelection.item);
22
+ singleSelection.item.properties.value.connectInput(valueProperty);
23
+
24
+ let closeCommand = Dbm.commands.setProperty(openProperty, false);
25
+ this.item.setValue("closeCommand", closeCommand);
26
+
27
+ let path = this.getPropValueWithDefault("path", "id");
28
+ let getItemBy = Dbm.flow.updatefunctions.basic.getItemBy(itemsProperty, valueProperty, path);
29
+ this.item.setValue("getItemBy", getItemBy);
30
+
31
+ this.item.properties.selectedItem.connectInput(getItemBy.output.properties.value);
32
+ }
33
+
34
+ _newRow(aRow) {
35
+ //console.log("_newRow");
36
+ //console.log(aRow);
37
+
38
+ let path = this.getPropValueWithDefault("path", "id");
39
+
40
+ let value = Dbm.objectPath(aRow, "forItem." + path);
41
+
42
+ let selectedProperty = this.item.singleSelection.controller.addSelectionValue(value);
43
+
44
+ aRow.setValue("value", value);
45
+ aRow.requireProperty("selected", false).connectInput(selectedProperty);
46
+ }
47
+
48
+ _renderMainElement() {
49
+
50
+ let children = Dbm.utils.ArrayFunctions.singleOrArray(this.getPropValue("children"));
51
+
52
+ let slots = Dbm.react.ChildFunctions.splitIntoSlots(children);
53
+
54
+ let buttonElement = slots["button"];
55
+ let mainChildren = slots.main;
56
+
57
+ let contextValues = {"value": this.item.properties["props/value"], "selectedItem": this.item.properties.selectedItem, "rows": this.item.properties.rows, "closeCommand": this.item.closeCommand};
58
+
59
+ return this._createMainElement(Dbm.react.form.Dropdown, {"open": this.item.properties.open},
60
+ React.createElement(Dbm.react.context.AddContextVariables, {"data-slot": "button", "values": contextValues},
61
+ React.createElement(Dbm.react.area.InsertElement, {"element": buttonElement})
62
+ ),
63
+ React.createElement(Dbm.react.context.AddContextVariables, {"values": contextValues},
64
+ React.createElement(Dbm.react.area.InsertElement, {"element": mainChildren})
65
+ )
66
+ );
67
+ }
68
+ }
69
+
@@ -0,0 +1,105 @@
1
+ import React from "react";
2
+ import Dbm from "../../index.js";
3
+
4
+ export default class GraphApiObjectSelection extends Dbm.react.BaseObject {
5
+ _construct() {
6
+ super._construct();
7
+
8
+ this.getDynamicProp("value", "");
9
+ this.item.requireProperty("items", []);
10
+ this.item.requireProperty("sortedItems", []);
11
+
12
+ let objectType = this.getPropValue("objectType");
13
+ let encodings = Dbm.utils.ArrayFunctions.arrayOrSeparatedString(this.getPropValueWithDefault("encoding", "name"), ",", true);
14
+
15
+ {
16
+ let selects = [
17
+ {"type": "byObjectType", "objectType": objectType},
18
+ {"type": "includeDraft"},
19
+ {"type": "includePrivate"}
20
+ ];
21
+ if(this.getPropValue("anyStatus")) {
22
+ selects = [
23
+ {"type": "byObjectType", "objectType": objectType},
24
+ {"type": "includeAnyStatus"}
25
+ ];
26
+ }
27
+
28
+ let request = Dbm.getCachedGraphApi().requestRange(
29
+ selects,
30
+ encodings
31
+ );
32
+
33
+ this.item.properties.items.connectInput(request.properties.items);
34
+
35
+ Dbm.flow.runWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._itemsLoaded.bind(this), [request]));
36
+ }
37
+ }
38
+
39
+ _itemsLoaded(aRequest) {
40
+
41
+ let nameField = this.getPropValueWithDefault("nameField", "name");
42
+
43
+ let currentArray = [].concat(aRequest.items);
44
+ Dbm.utils.ArrayFunctions.naturalSortOnField(currentArray, nameField);
45
+
46
+ this.item.sortedItems = currentArray;
47
+ }
48
+
49
+ _renderMainElement() {
50
+
51
+ let value = this.getDynamicProp("value");
52
+ let nameField = this.getPropValueWithDefault("nameField", "name");
53
+
54
+ return this._createMainElement(Dbm.react.form.CustomSelection, {"value": value, "items": this.item.properties.sortedItems, "path": nameField},
55
+
56
+ React.createElement("div", {
57
+ "data-slot": "button",
58
+ children: [React.createElement(Dbm.react.area.HasData, {
59
+ check: Dbm.react.source.contextVariable("value"),
60
+ children: React.createElement(Dbm.react.context.AddItemToContext, {
61
+ item: Dbm.react.source.contextVariable("selectedItem"),
62
+ children: [React.createElement(Dbm.react.area.HasData, {
63
+ check: Dbm.react.source.item(),
64
+ children: React.createElement("div", {
65
+ children: Dbm.react.text.text(Dbm.react.source.item("name"))
66
+ })
67
+ }), React.createElement(Dbm.react.area.HasData, {
68
+ check: Dbm.react.source.item(),
69
+ checkType: "invert/default",
70
+ children: React.createElement("div", {
71
+ children: Dbm.react.text.text(Dbm.react.source.contextVariable("value"))
72
+ })
73
+ })]
74
+ })
75
+ }), React.createElement(Dbm.react.area.HasData, {
76
+ check: Dbm.react.source.contextVariable("value"),
77
+ checkType: "invert/default",
78
+ children: React.createElement("div", {
79
+ children: Dbm.react.text.translatedText("Select")
80
+ })
81
+ })]
82
+ }), React.createElement("div", {
83
+ children: React.createElement(Dbm.react.area.HasData, {
84
+ check: Dbm.react.source.contextVariable("isVisible"),
85
+ children: React.createElement(Dbm.react.area.List, {
86
+ items: Dbm.react.source.contextVariable("rows"),
87
+ as: "row",
88
+ children: React.createElement(Dbm.react.context.AddItemToContext, {
89
+ item: Dbm.react.source.contextVariable("row.forItem"),
90
+ children: React.createElement(Dbm.react.interaction.CommandButton, {
91
+ commands: [Dbm.commands.setProperty(Dbm.react.source.contextVariable("row.properties.selected"), true), Dbm.react.source.contextVariable("closeCommand")],
92
+ children: React.createElement("div", {
93
+ children: Dbm.react.text.text(Dbm.react.source.item("name"))
94
+ })
95
+ })
96
+ })
97
+ })
98
+ })
99
+ })
100
+
101
+
102
+ );
103
+ }
104
+ }
105
+
@@ -7,6 +7,7 @@ export {default as LabelledArea} from "./LabelledArea.js";
7
7
  export {default as FileDropArea} from "./FileDropArea.js";
8
8
  export {default as Selection} from "./Selection.js";
9
9
  export {default as GraphApiObjectSelection} from "./GraphApiObjectSelection.js";
10
+ export {default as GraphApiObjectCustomSelection} from "./GraphApiObjectCustomSelection.js";
10
11
  export {default as GraphApiSelectOrCreateObject} from "./GraphApiSelectOrCreateObject.js";
11
12
  export {default as GraphApiImage} from "./GraphApiImage.js";
12
13
  export {default as EditArray} from "./EditArray.js";
@@ -16,6 +17,7 @@ export {default as Form} from "./Form.js";
16
17
  export {default as Option} from "./Option.js";
17
18
  export {default as Dropdown} from "./Dropdown.js";
18
19
  export {default as GraphApiObjectOptions} from "./GraphApiObjectOptions.js";
20
+ export {default as CustomSelection} from "./CustomSelection.js";
19
21
 
20
22
  export const validationStateClassName = function(aChildren) {
21
23
  return React.createElement(Dbm.react.AddProps, {className: Dbm.react.source.contextVariable("field.properties.validationState")},