dbm 1.1.6 → 1.1.7
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/flow/controllers/interaction/MoveElement.js +4 -7
- package/graphapi/webclient/WebSocketConnection.js +1 -0
- package/graphapi/webclient/decode/DecodeBaseObject.js +6 -1
- package/graphapi/webclient/decode/index.js +16 -0
- package/package.json +1 -1
- package/react/admin/EditPage.js +66 -3
- package/react/admin/editor/Editor.js +8 -0
- package/react/admin/editor/fields/SelectObjectField.js +57 -0
- package/react/admin/editor/fields/index.js +2 -1
- package/react/area/List.js +4 -0
- package/react/context/AddItemToContext.js +24 -0
- package/react/context/index.js +2 -1
- package/react/form/GraphApiObjectSelection.js +53 -0
- package/react/form/Selection.js +29 -0
- package/react/form/index.js +3 -1
- package/utils/ArrayFunctions.js +124 -0
|
@@ -118,11 +118,8 @@ export default class MoveElement extends Dbm.core.BaseObject {
|
|
|
118
118
|
let minY = this.item.minY;
|
|
119
119
|
let maxY = this.item.maxY;
|
|
120
120
|
|
|
121
|
-
this.item.xParameter = Math.max(minX, Math.min(x, maxX));
|
|
122
|
-
this.item.yParameter = Math.max(minY, Math.min(y, maxY));
|
|
123
|
-
|
|
124
|
-
console.log(this.item.xParameter);
|
|
125
|
-
console.log(this.item.yParameter);
|
|
121
|
+
this.item.properties.xParameter.getMostUpstreamProperty().value = Math.max(minX, Math.min(x, maxX));
|
|
122
|
+
this.item.properties.yParameter.getMostUpstreamProperty().value = Math.max(minY, Math.min(y, maxY));
|
|
126
123
|
}
|
|
127
124
|
|
|
128
125
|
_callback_mouseUp(aEvent) {
|
|
@@ -146,7 +143,7 @@ export default class MoveElement extends Dbm.core.BaseObject {
|
|
|
146
143
|
}
|
|
147
144
|
|
|
148
145
|
_callback_mouseMove(aEvent) {
|
|
149
|
-
console.log("_callback_mouseMove");
|
|
146
|
+
//console.log("_callback_mouseMove");
|
|
150
147
|
//console.log(aEvent);
|
|
151
148
|
|
|
152
149
|
if(aEvent.type === "touchmove") {
|
|
@@ -158,7 +155,7 @@ export default class MoveElement extends Dbm.core.BaseObject {
|
|
|
158
155
|
}
|
|
159
156
|
|
|
160
157
|
_callback_startDrag(aEvent) {
|
|
161
|
-
console.log("_callback_startDrag");
|
|
158
|
+
//console.log("_callback_startDrag");
|
|
162
159
|
//console.log(aEvent, aEvent.type);
|
|
163
160
|
|
|
164
161
|
if(aEvent.type === "touchstart") {
|
|
@@ -65,6 +65,7 @@ export default class WebSocketConnection extends Dbm.core.BaseObject {
|
|
|
65
65
|
requestRange(aSelect, aEncode) {
|
|
66
66
|
let item = this._getRequestItem();
|
|
67
67
|
item.setValue("requestData", {"type": "range", "select": aSelect, "encode": aEncode, "requestId": item.id});
|
|
68
|
+
item.requireProperty("items", []);
|
|
68
69
|
this._runRequest(item);
|
|
69
70
|
|
|
70
71
|
return item;
|
|
@@ -41,7 +41,12 @@ export default class DecodeBaseObject extends Dbm.core.BaseObject {
|
|
|
41
41
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
42
42
|
let currentField = currentArray[i];
|
|
43
43
|
let currentIds = aData[currentField];
|
|
44
|
-
|
|
44
|
+
if(currentIds) {
|
|
45
|
+
aItem.setValue(currentField, Dbm.getInstance().repository.getItems(currentIds));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
aItem.setValue(currentField, []);
|
|
49
|
+
}
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
}
|
|
@@ -63,6 +63,14 @@ export const fullSetup = function() {
|
|
|
63
63
|
currentDecoder.item.register(decodePrefix + name);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
{
|
|
67
|
+
let name = "pageRepresentation";
|
|
68
|
+
let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
|
|
69
|
+
currentDecoder.item.setValue("copyLink", ["representing"]);
|
|
70
|
+
currentDecoder.item.setValue("encodingType", name);
|
|
71
|
+
currentDecoder.item.register(decodePrefix + name);
|
|
72
|
+
}
|
|
73
|
+
|
|
66
74
|
{
|
|
67
75
|
let name = "navigationName";
|
|
68
76
|
let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
|
|
@@ -101,4 +109,12 @@ export const fullSetup = function() {
|
|
|
101
109
|
currentDecoder.item.setValue("encodingType", name);
|
|
102
110
|
currentDecoder.item.register(decodePrefix + name);
|
|
103
111
|
}
|
|
112
|
+
|
|
113
|
+
{
|
|
114
|
+
let name = "representingPage";
|
|
115
|
+
let currentDecoder = new Dbm.graphapi.webclient.decode.DecodeBaseObject();
|
|
116
|
+
currentDecoder.item.setValue("copyLink", ["representingPage"]);
|
|
117
|
+
currentDecoder.item.setValue("encodingType", name);
|
|
118
|
+
currentDecoder.item.register(decodePrefix + name);
|
|
119
|
+
}
|
|
104
120
|
}
|
package/package.json
CHANGED
package/react/admin/EditPage.js
CHANGED
|
@@ -22,6 +22,8 @@ export default class EditPage extends Dbm.react.BaseObject {
|
|
|
22
22
|
let descriptionEditor = itemEditor.addFieldEditor("meta/description", page["meta/description"], "meta/description");
|
|
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
|
+
|
|
26
|
+
this.item.requireProperty("importText", "");
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
_save() {
|
|
@@ -37,11 +39,64 @@ export default class EditPage extends Dbm.react.BaseObject {
|
|
|
37
39
|
itemSaveData.setField("lastModified", (new Date()).toISOString());
|
|
38
40
|
itemSaveData.createChange("clearCache", {});
|
|
39
41
|
|
|
40
|
-
console.log(editorGroup, saveData);
|
|
41
|
-
|
|
42
42
|
saveData.save();
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
_export() {
|
|
46
|
+
let editorGroup = this.item.editorGroup;
|
|
47
|
+
|
|
48
|
+
let page = this.context.page;
|
|
49
|
+
let id = page.id;
|
|
50
|
+
let itemEditor = editorGroup.getItemEditor(id);
|
|
51
|
+
let url = itemEditor.addFieldEditor("url").item.editValue.value.value;
|
|
52
|
+
let content = itemEditor.addFieldEditor("content").item.editValue.value.value;
|
|
53
|
+
|
|
54
|
+
let blob = new Blob([JSON.stringify(content, null, 2)], { type: 'application/json' });
|
|
55
|
+
let downloadUrl = URL.createObjectURL(blob);
|
|
56
|
+
|
|
57
|
+
let fileName = id + Dbm.utils.StringFunctions.createNiceFilePath(url) + ".json";
|
|
58
|
+
let a = document.createElement('a');
|
|
59
|
+
a.href = downloadUrl;
|
|
60
|
+
a.download = fileName;
|
|
61
|
+
document.body.appendChild(a);
|
|
62
|
+
a.click();
|
|
63
|
+
|
|
64
|
+
document.body.removeChild(a);
|
|
65
|
+
URL.revokeObjectURL(downloadUrl);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
_import() {
|
|
69
|
+
|
|
70
|
+
let editorGroup = this.item.editorGroup;
|
|
71
|
+
|
|
72
|
+
let page = this.context.page;
|
|
73
|
+
let id = page.id;
|
|
74
|
+
let itemEditor = editorGroup.getItemEditor(id);
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
let data = JSON.parse(this.item.importText);
|
|
78
|
+
console.log(data);
|
|
79
|
+
|
|
80
|
+
let newContent = {...itemEditor.addFieldEditor("content").item.editValue.value.value};
|
|
81
|
+
if(!newContent) {
|
|
82
|
+
newContent = {};
|
|
83
|
+
}
|
|
84
|
+
if(!newContent.blocks) {
|
|
85
|
+
newContent.blocks = [];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let currentArray = data.blocks;
|
|
89
|
+
let currentArrayLength = currentArray.length;
|
|
90
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
91
|
+
let currentBlock = currentArray[i];
|
|
92
|
+
delete currentBlock["id"];
|
|
93
|
+
newContent.blocks.push(currentBlock);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
itemEditor.addFieldEditor("content").item.editValue.value.value = newContent;
|
|
97
|
+
this.item.editor.contentUpdatedExternally();
|
|
98
|
+
}
|
|
99
|
+
|
|
45
100
|
_generateSeoSummary() {
|
|
46
101
|
|
|
47
102
|
let page = this.context.page;
|
|
@@ -122,7 +177,15 @@ export default class EditPage extends Dbm.react.BaseObject {
|
|
|
122
177
|
"Content"
|
|
123
178
|
),
|
|
124
179
|
React.createElement("div", {},
|
|
125
|
-
React.createElement(Dbm.react.admin.editor.Editor, {"value": itemEditor.getEditor("content").item.editValue.value}),
|
|
180
|
+
React.createElement(Dbm.react.admin.editor.Editor, {"value": itemEditor.getEditor("content").item.editValue.value, "ref": this.createRef("editor")}),
|
|
181
|
+
),
|
|
182
|
+
React.createElement("div", {className: "spacing small"}),
|
|
183
|
+
React.createElement("div", {"className": "standard-button standard-button-padding", "onClick": () => {this._export()}},
|
|
184
|
+
"Export"
|
|
185
|
+
),
|
|
186
|
+
React.createElement(Dbm.react.form.FormField, {value: this.item.properties.importText}),
|
|
187
|
+
React.createElement("div", {"className": "standard-button standard-button-padding", "onClick": () => {this._import()}},
|
|
188
|
+
"Import"
|
|
126
189
|
)
|
|
127
190
|
),
|
|
128
191
|
React.createElement("div", {className: "spacing standard"}),
|
|
@@ -153,6 +153,14 @@ export default class Editor extends Dbm.react.BaseObject {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
contentUpdatedExternally() {
|
|
157
|
+
|
|
158
|
+
let data = this.getDynamicProp("value").value;
|
|
159
|
+
this.item.editor.render(data);
|
|
160
|
+
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
|
|
156
164
|
/*
|
|
157
165
|
_save() {
|
|
158
166
|
this.item.editor.save().then((aOutputData) => {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class SelectObjectField 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
|
+
console.log(">>>>>", editorData);
|
|
23
|
+
|
|
24
|
+
let returnData = editorData.data[fieldName];
|
|
25
|
+
if(!returnData) {
|
|
26
|
+
returnData = 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return returnData;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
_valueChanged() {
|
|
34
|
+
//console.log("_valueChanged");
|
|
35
|
+
|
|
36
|
+
let fieldName = this.getPropValue("name");
|
|
37
|
+
let newValue = this.item.value;
|
|
38
|
+
let editorData = Dbm.objectPath(this.context, "moduleData.editorData");
|
|
39
|
+
|
|
40
|
+
let newData = {...editorData.data};
|
|
41
|
+
newData[fieldName] = newValue;
|
|
42
|
+
|
|
43
|
+
editorData.data = newData;
|
|
44
|
+
|
|
45
|
+
this.context.moduleData.editorData.editorBlock.dataUpdated();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
_objectChanged() {
|
|
49
|
+
//console.log("_objectChanged");
|
|
50
|
+
|
|
51
|
+
this.item.value = this._getObjectData();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
_renderMainElement() {
|
|
55
|
+
return this._createMainElement(Dbm.react.form.GraphApiObjectSelection, {value: this.item.properties.value, objectType: this.getPropValue("objectType"), className: "standard-field standard-field-padding full-width"});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
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
|
-
export {default as CheckboxField} from "./CheckboxField.js";
|
|
4
|
+
export {default as CheckboxField} from "./CheckboxField.js";
|
|
5
|
+
export {default as SelectObjectField} from "./SelectObjectField.js";
|
package/react/area/List.js
CHANGED
|
@@ -27,6 +27,10 @@ export default class List extends Dbm.react.BaseObject {
|
|
|
27
27
|
let mainChildren = slots.main;
|
|
28
28
|
|
|
29
29
|
let currentArray = items;
|
|
30
|
+
if(!currentArray || isNaN(currentArray.length)) {
|
|
31
|
+
console.error("Items is not an array", this);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
30
34
|
let currentArrayLength = currentArray.length;
|
|
31
35
|
let newChildren = [];
|
|
32
36
|
for(let i = 0; i < currentArrayLength; i++) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class AddItemToContext extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
render() {
|
|
10
|
+
|
|
11
|
+
let item = this.getPropValue("item");
|
|
12
|
+
let id = Dbm.objectPath(item, "id");
|
|
13
|
+
|
|
14
|
+
let as = this.getPropValue("as");
|
|
15
|
+
if(!as) {
|
|
16
|
+
as = "item";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let values = {};
|
|
20
|
+
values[as] = item;
|
|
21
|
+
|
|
22
|
+
return React.createElement(Dbm.react.context.AddContextVariables, {"values": values, "key": id}, this.props.children);
|
|
23
|
+
}
|
|
24
|
+
}
|
package/react/context/index.js
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class GraphApiObjectSelection extends Dbm.react.form.Selection {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.getDynamicProp("value", "");
|
|
9
|
+
this.item.requireProperty("items", []);
|
|
10
|
+
|
|
11
|
+
let objectType = this.getPropValue("objectType")
|
|
12
|
+
|
|
13
|
+
let graphApi = Dbm.getInstance().repository.getItem("graphApi").controller;
|
|
14
|
+
{
|
|
15
|
+
let request = graphApi.requestRange(
|
|
16
|
+
[
|
|
17
|
+
{"type": "byObjectType", "objectType": objectType},
|
|
18
|
+
{"type": "includeDraft"},
|
|
19
|
+
{"type": "includePrivate"}
|
|
20
|
+
],
|
|
21
|
+
["name"]
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
Dbm.flow.addUpdateCommandWhenMatched(request.properties.status, Dbm.loading.LoadingStatus.LOADED, Dbm.commands.callFunction(this._itemsLoaded.bind(this), [request]));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
_itemsLoaded(aRequest) {
|
|
30
|
+
let options = [];
|
|
31
|
+
|
|
32
|
+
options.push(React.createElement("option", {key: 0, value: 0}, "None"));
|
|
33
|
+
|
|
34
|
+
let currentArray = [].concat(aRequest.items);
|
|
35
|
+
Dbm.utils.ArrayFunctions.sortOnField(currentArray, "name");
|
|
36
|
+
|
|
37
|
+
let currentArrayLength = currentArray.length;
|
|
38
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
39
|
+
let currentItem = currentArray[i];
|
|
40
|
+
options.push(React.createElement("option", {key: currentItem["id"], value: currentItem["id"]}, currentItem["name"] + " (id: " + currentItem["id"] + ")"));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.item.items = options;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_renderMainElement() {
|
|
47
|
+
|
|
48
|
+
let value = this.getDynamicProp("value");
|
|
49
|
+
|
|
50
|
+
return this._createMainElement(Dbm.react.form.Selection, {"value": value}, this.item.properties.items);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Dbm from "../../index.js";
|
|
3
|
+
|
|
4
|
+
export default class Selection extends Dbm.react.BaseObject {
|
|
5
|
+
_construct() {
|
|
6
|
+
super._construct();
|
|
7
|
+
|
|
8
|
+
this.getDynamicProp("value", "");
|
|
9
|
+
|
|
10
|
+
this._callback_changeBound = this._callback_change.bind(this);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
_callback_change(aEvent) {
|
|
14
|
+
//console.log("_callback_change");
|
|
15
|
+
//console.log(aEvent);
|
|
16
|
+
|
|
17
|
+
let value = aEvent.target.value;
|
|
18
|
+
|
|
19
|
+
this.getDynamicProp("value").getMostUpstreamProperty().setValue(value);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_renderMainElement() {
|
|
23
|
+
|
|
24
|
+
let value = this.getDynamicProp("value").value;
|
|
25
|
+
|
|
26
|
+
return this._createMainElement("select", {"value": value, onChange: this._callback_changeBound}, this.getPropValue("children"));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
package/react/form/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export {default as Checkbox} from "./Checkbox.js";
|
|
2
2
|
export {default as FormField} from "./FormField.js";
|
|
3
3
|
export {default as LabelledArea} from "./LabelledArea.js";
|
|
4
|
-
export {default as FileDropArea} from "./FileDropArea.js";
|
|
4
|
+
export {default as FileDropArea} from "./FileDropArea.js";
|
|
5
|
+
export {default as Selection} from "./Selection.js";
|
|
6
|
+
export {default as GraphApiObjectSelection} from "./GraphApiObjectSelection.js";
|
package/utils/ArrayFunctions.js
CHANGED
|
@@ -117,6 +117,17 @@ export const arrayOrSeparatedString = function(aData, aSeparator = ",", aTrim =
|
|
|
117
117
|
return [];
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
export const numericArrayOrSeparatedString = function(aData, aSeparator = ",", aTrim = 3) {
|
|
121
|
+
let returnArray = new Array();
|
|
122
|
+
let currentArray = arrayOrSeparatedString(aData, aSeparator, aTrim);
|
|
123
|
+
let currentarrayLength = currentArray.length;
|
|
124
|
+
for(let i = 0; i < currentarrayLength; i++) {
|
|
125
|
+
returnArray.push(parseFloat(currentArray[i]));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return returnArray;
|
|
129
|
+
}
|
|
130
|
+
|
|
120
131
|
export const filterByField = function(aArray, aField, aValue) {
|
|
121
132
|
let returnArray = [];
|
|
122
133
|
|
|
@@ -144,4 +155,117 @@ export const mapField = function(aArray, aField) {
|
|
|
144
155
|
}
|
|
145
156
|
|
|
146
157
|
return returnArray;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export const group = function(aArray, aField) {
|
|
161
|
+
|
|
162
|
+
let groups = new Map();
|
|
163
|
+
|
|
164
|
+
let currentArray = aArray;
|
|
165
|
+
let currentArrayLength = currentArray.length;
|
|
166
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
167
|
+
let currentObject = aArray[i];
|
|
168
|
+
let groupValue = Dbm.objectPath(aArray[i], aField);
|
|
169
|
+
|
|
170
|
+
if(!groups.has(groupValue)) {
|
|
171
|
+
groups.set(groupValue, []);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
groups.get(groupValue).push(currentObject);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
let returnArray = [];
|
|
178
|
+
|
|
179
|
+
for (const value of groups.entries()) {
|
|
180
|
+
returnArray.push({"key": value[0], "value": value[1]});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return returnArray;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export const makeFlat = function(aArray) {
|
|
187
|
+
let returnArray = [];
|
|
188
|
+
|
|
189
|
+
let currentArray = aArray;
|
|
190
|
+
let currentArrayLength = currentArray.length;
|
|
191
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
192
|
+
returnArray = returnArray.concat(currentArray[i]);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
return returnArray;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export const getUnselectedItems = function(aSelectedItems, aAllItems) {
|
|
199
|
+
let returnItems = new Array();
|
|
200
|
+
|
|
201
|
+
let currentArray = aAllItems;
|
|
202
|
+
let currentArrayLength = currentArray.length;
|
|
203
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
204
|
+
let currentItem = currentArray[i];
|
|
205
|
+
if(aSelectedItems.indexOf(currentItem) === -1) {
|
|
206
|
+
returnItems.push(currentItem);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return returnItems;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export const sortOnField = function(aArray, aField) {
|
|
214
|
+
let sortFunction = function(aA, aB) {
|
|
215
|
+
let aValue = Dbm.objectPath(aA, aField);
|
|
216
|
+
let bValue = Dbm.objectPath(aB, aField);
|
|
217
|
+
|
|
218
|
+
if(aValue < bValue) {
|
|
219
|
+
return -1;
|
|
220
|
+
}
|
|
221
|
+
else if(aValue > bValue) {
|
|
222
|
+
return 1;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return 0;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
aArray.sort(sortFunction);
|
|
229
|
+
|
|
230
|
+
return aArray;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export const sortOnNumericField = function(aArray, aField) {
|
|
234
|
+
let sortFunction = function(aA, aB) {
|
|
235
|
+
let aValue = 1*Dbm.objectPath(aA, aField);
|
|
236
|
+
let bValue = 1*Dbm.objectPath(aB, aField);
|
|
237
|
+
|
|
238
|
+
if(aValue < bValue) {
|
|
239
|
+
return -1;
|
|
240
|
+
}
|
|
241
|
+
else if(aValue > bValue) {
|
|
242
|
+
return 1;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return 0;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
aArray.sort(sortFunction);
|
|
249
|
+
|
|
250
|
+
return aArray;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export const getItemIndexByIfExists = function(aArray, aField, aIdentifier) {
|
|
254
|
+
|
|
255
|
+
if(!Array.isArray(aArray)) {
|
|
256
|
+
console.warn("No array provided", aArray);
|
|
257
|
+
return -1;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
let currentArray = aArray;
|
|
261
|
+
let currentArrayLength = currentArray.length;
|
|
262
|
+
for(let i = 0; i < currentArrayLength; i++) {
|
|
263
|
+
let currentItem = currentArray[i];
|
|
264
|
+
let currentValue = Dbm.objectPath(currentItem, aField);
|
|
265
|
+
if(currentValue == aIdentifier) {
|
|
266
|
+
return i;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return -1;
|
|
147
271
|
}
|