@processmaker/screen-builder 3.8.37 → 3.8.38
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/dist/vue-form-builder.css +1 -1
- package/dist/vue-form-builder.es.js +5106 -5079
- package/dist/vue-form-builder.es.js.map +1 -1
- package/dist/vue-form-builder.umd.js +38 -38
- package/dist/vue-form-builder.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/collectionFieldUtils.js +89 -0
- package/src/components/inspector/collection-data-source.vue +2 -21
- package/src/components/inspector/column-setup.vue +5 -21
- package/src/components/renderer/form-record-list.vue +24 -26
package/package.json
CHANGED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
const COLLECTION_DATA_PREFIX = "data.";
|
|
2
|
+
|
|
3
|
+
export function normalizeCollectionFieldPath(fieldPath) {
|
|
4
|
+
if (typeof fieldPath !== "string") {
|
|
5
|
+
return fieldPath;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
return fieldPath.startsWith(COLLECTION_DATA_PREFIX)
|
|
9
|
+
? fieldPath.slice(COLLECTION_DATA_PREFIX.length)
|
|
10
|
+
: fieldPath;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function getCollectionFieldOptions(collection = {}) {
|
|
14
|
+
const options = [];
|
|
15
|
+
const values = new Set();
|
|
16
|
+
|
|
17
|
+
const addOption = ({ text, value }) => {
|
|
18
|
+
const normalizedValue = normalizeCollectionFieldPath(value);
|
|
19
|
+
|
|
20
|
+
if (!normalizedValue || values.has(normalizedValue)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
values.add(normalizedValue);
|
|
25
|
+
options.push({
|
|
26
|
+
text: text || normalizedValue,
|
|
27
|
+
value: normalizedValue
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
if (Array.isArray(collection?.fields) && collection.fields.length > 0) {
|
|
32
|
+
collection.fields.forEach((field) => {
|
|
33
|
+
if (!field) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
addOption({
|
|
38
|
+
text: field.text || field.value,
|
|
39
|
+
value: field.value
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
const [firstRecord] = collection?.dataRecordList || [];
|
|
44
|
+
|
|
45
|
+
if (firstRecord?.data) {
|
|
46
|
+
Object.keys(firstRecord.data).forEach((field) => {
|
|
47
|
+
addOption({ text: field, value: field });
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
addOption({ text: "id", value: "id" });
|
|
53
|
+
|
|
54
|
+
return options;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function mapCollectionRecordData(data = {}, options = []) {
|
|
58
|
+
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!Array.isArray(options) || options.length === 0) {
|
|
63
|
+
return { ...data };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const mappedData = {};
|
|
67
|
+
|
|
68
|
+
options.forEach((option) => {
|
|
69
|
+
if (!option) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const targetKey = normalizeCollectionFieldPath(
|
|
74
|
+
option.key || option.content
|
|
75
|
+
);
|
|
76
|
+
const sourceKey = [option.content, option.key]
|
|
77
|
+
.map(normalizeCollectionFieldPath)
|
|
78
|
+
.find(
|
|
79
|
+
(candidate) =>
|
|
80
|
+
candidate && Object.prototype.hasOwnProperty.call(data, candidate)
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
if (sourceKey && targetKey) {
|
|
84
|
+
mappedData[targetKey] = data[sourceKey];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
return mappedData;
|
|
89
|
+
}
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
<script>
|
|
61
61
|
import { cloneDeep } from "lodash";
|
|
62
62
|
import CollectionRecordsList from "./collection-records-list.vue";
|
|
63
|
+
import { getCollectionFieldOptions } from "../../collectionFieldUtils";
|
|
63
64
|
|
|
64
65
|
const CONFIG_FIELDS = [
|
|
65
66
|
"collectionFields",
|
|
@@ -185,27 +186,7 @@ export default {
|
|
|
185
186
|
}
|
|
186
187
|
},
|
|
187
188
|
getCollectionColumns(records) {
|
|
188
|
-
this.singleFieldOptions =
|
|
189
|
-
|
|
190
|
-
// Prefer the collection schema when CollectionRecordsList has
|
|
191
|
-
// forwarded it on the v-model payload.
|
|
192
|
-
if (Array.isArray(records?.fields) && records.fields.length > 0) {
|
|
193
|
-
records.fields.forEach((field) => {
|
|
194
|
-
this.singleFieldOptions.push({
|
|
195
|
-
text: field.text || field.value,
|
|
196
|
-
value: field.value
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
// Fallback: get columns from the first record's populated keys.
|
|
203
|
-
const [firstRecord] = records?.dataRecordList || [];
|
|
204
|
-
if (firstRecord?.data) {
|
|
205
|
-
for (const [key] of Object.entries(firstRecord.data)) {
|
|
206
|
-
this.singleFieldOptions.push({ text: key, value: key });
|
|
207
|
-
}
|
|
208
|
-
}
|
|
189
|
+
this.singleFieldOptions = getCollectionFieldOptions(records);
|
|
209
190
|
}
|
|
210
191
|
}
|
|
211
192
|
};
|
|
@@ -216,6 +216,7 @@ import draggable from 'vuedraggable';
|
|
|
216
216
|
import { dataSources, dataSourceValues } from './data-source-types';
|
|
217
217
|
import MonacoEditor from 'vue-monaco';
|
|
218
218
|
import { cloneDeep } from "lodash";
|
|
219
|
+
import { getCollectionFieldOptions } from "../../collectionFieldUtils";
|
|
219
220
|
|
|
220
221
|
export default {
|
|
221
222
|
components: {
|
|
@@ -394,27 +395,10 @@ export default {
|
|
|
394
395
|
}
|
|
395
396
|
},
|
|
396
397
|
getCollectionColumns(collection) {
|
|
397
|
-
this.collectionOptions = [
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
if (Array.isArray(collection?.fields) && collection.fields.length > 0) {
|
|
402
|
-
collection.fields.forEach((field) => {
|
|
403
|
-
this.collectionOptions.push({
|
|
404
|
-
text: field.text || field.value,
|
|
405
|
-
value: field.value
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// Fallback: get columns from the first record's populated keys.
|
|
412
|
-
const [firstRecord] = collection?.dataRecordList || [];
|
|
413
|
-
if (firstRecord?.data) {
|
|
414
|
-
for (const [key] of Object.entries(firstRecord.data)) {
|
|
415
|
-
this.collectionOptions.push({ text: key, value: key });
|
|
416
|
-
}
|
|
417
|
-
}
|
|
398
|
+
this.collectionOptions = [
|
|
399
|
+
{ text: "All columns", value: "all" },
|
|
400
|
+
...getCollectionFieldOptions(collection)
|
|
401
|
+
];
|
|
418
402
|
},
|
|
419
403
|
initData() {
|
|
420
404
|
this.dataSource = this.options.dataSource;
|
|
@@ -259,6 +259,10 @@ import VueFormRenderer from "@/components/vue-form-renderer.vue";
|
|
|
259
259
|
import mustacheEvaluation from "../../mixins/mustacheEvaluation";
|
|
260
260
|
import MustacheHelper from "../inspector/mustache-helper.vue";
|
|
261
261
|
import Mustache from "mustache";
|
|
262
|
+
import {
|
|
263
|
+
mapCollectionRecordData,
|
|
264
|
+
normalizeCollectionFieldPath
|
|
265
|
+
} from "../../collectionFieldUtils";
|
|
262
266
|
|
|
263
267
|
const jsonOptionsActionsColumn = {
|
|
264
268
|
key: "__actions",
|
|
@@ -581,7 +585,10 @@ export default {
|
|
|
581
585
|
onRadioChange(selectedItem, index) {
|
|
582
586
|
const globalIndex = (this.currentPage - 1) * this.perPage + index;
|
|
583
587
|
if(this.source?.singleField) {
|
|
584
|
-
|
|
588
|
+
const singleField = normalizeCollectionFieldPath(
|
|
589
|
+
this.source.singleField
|
|
590
|
+
);
|
|
591
|
+
const valueOfColumn = selectedItem[singleField];
|
|
585
592
|
this.componentOutput(valueOfColumn);
|
|
586
593
|
} else {
|
|
587
594
|
selectedItem = { ...selectedItem, selectedRowIndex: globalIndex};
|
|
@@ -728,27 +735,14 @@ export default {
|
|
|
728
735
|
|
|
729
736
|
this.$emit("change", this.field);
|
|
730
737
|
},
|
|
731
|
-
changeCollectionColumns(collectionFieldsColumns,columnsSelected) {
|
|
732
|
-
|
|
738
|
+
changeCollectionColumns(collectionFieldsColumns, columnsSelected) {
|
|
733
739
|
const optionsList = columnsSelected.optionsList;
|
|
740
|
+
const mappedColumns = collectionFieldsColumns.map((column) => ({
|
|
741
|
+
...column,
|
|
742
|
+
data: mapCollectionRecordData(column.data, optionsList)
|
|
743
|
+
}));
|
|
734
744
|
|
|
735
|
-
|
|
736
|
-
let dataObject = column.data;
|
|
737
|
-
let newDataObject = {};
|
|
738
|
-
|
|
739
|
-
Object.keys(dataObject).forEach(dataKey => {
|
|
740
|
-
const matchingOption = optionsList.find(option => option.content === dataKey);
|
|
741
|
-
|
|
742
|
-
if (matchingOption) {
|
|
743
|
-
newDataObject[matchingOption.key] = dataObject[dataKey];
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
|
|
747
|
-
column.data = newDataObject;
|
|
748
|
-
});
|
|
749
|
-
|
|
750
|
-
this.setCollectionIntoList(collectionFieldsColumns);
|
|
751
|
-
|
|
745
|
+
this.setCollectionIntoList(mappedColumns);
|
|
752
746
|
},
|
|
753
747
|
setCollectionIntoList(arrayCollection) {
|
|
754
748
|
const result = [];
|
|
@@ -825,7 +819,10 @@ export default {
|
|
|
825
819
|
|
|
826
820
|
if (this.source?.singleField) {
|
|
827
821
|
// singleField mode emits a scalar; find the row whose field matches
|
|
828
|
-
const
|
|
822
|
+
const singleField = normalizeCollectionFieldPath(
|
|
823
|
+
this.source.singleField
|
|
824
|
+
);
|
|
825
|
+
const match = rows.find(row => row[singleField] === this.value);
|
|
829
826
|
if (match) {
|
|
830
827
|
this.selectedRow = match;
|
|
831
828
|
}
|
|
@@ -915,17 +912,18 @@ export default {
|
|
|
915
912
|
const { jsonData, key, value, dataName } = this.fields;
|
|
916
913
|
|
|
917
914
|
let convertToVuetableFormat = {};
|
|
918
|
-
if(this.source?.sourceOptions === "Collection") {
|
|
919
|
-
|
|
915
|
+
if (this.source?.sourceOptions === "Collection") {
|
|
916
|
+
convertToVuetableFormat = (option) => {
|
|
917
|
+
const keyValue = normalizeCollectionFieldPath(option[key || "key"]);
|
|
920
918
|
return {
|
|
921
|
-
key:
|
|
919
|
+
key: keyValue,
|
|
922
920
|
sortable: true,
|
|
923
|
-
label: option.label ||
|
|
921
|
+
label: option.label || keyValue,
|
|
924
922
|
tdClass: "table-column"
|
|
925
923
|
};
|
|
926
924
|
};
|
|
927
925
|
} else {
|
|
928
|
-
|
|
926
|
+
convertToVuetableFormat = (option) => {
|
|
929
927
|
return {
|
|
930
928
|
key: option[key || "value"],
|
|
931
929
|
sortable: true,
|