@processmaker/screen-builder 3.8.36 → 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 +5133 -5082
- 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 +3 -3
- package/src/DataProvider.js +21 -5
- package/src/collectionFieldUtils.js +89 -0
- package/src/components/inspector/collection-data-source.vue +2 -10
- package/src/components/inspector/collection-records-list.vue +8 -11
- package/src/components/inspector/column-setup.vue +5 -10
- package/src/components/renderer/form-record-list.vue +24 -26
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@processmaker/screen-builder",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.38",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"dev": "VITE_COVERAGE=true vite",
|
|
6
6
|
"build": "vite build",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@fortawesome/fontawesome-free": "^5.6.1",
|
|
62
62
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
63
63
|
"@panter/vue-i18next": "^0.15.2",
|
|
64
|
-
"@processmaker/vue-form-elements": "0.65.
|
|
64
|
+
"@processmaker/vue-form-elements": "0.65.10",
|
|
65
65
|
"@processmaker/vue-multiselect": "2.3.2",
|
|
66
66
|
"@storybook/addon-essentials": "^7.6.13",
|
|
67
67
|
"@storybook/addon-interactions": "^7.6.13",
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
},
|
|
126
126
|
"peerDependencies": {
|
|
127
127
|
"@panter/vue-i18next": "^0.15.0",
|
|
128
|
-
"@processmaker/vue-form-elements": "0.65.
|
|
128
|
+
"@processmaker/vue-form-elements": "0.65.10",
|
|
129
129
|
"i18next": "^15.0.8",
|
|
130
130
|
"vue": "^2.6.12",
|
|
131
131
|
"vuex": "^3.1.1"
|
package/src/DataProvider.js
CHANGED
|
@@ -7,6 +7,15 @@ import i18next from "i18next";
|
|
|
7
7
|
|
|
8
8
|
const FIVE_MINUTES = 1000 * 60 * 5;
|
|
9
9
|
|
|
10
|
+
function normalizeDataSourceId(dataSourceId) {
|
|
11
|
+
const match =
|
|
12
|
+
typeof dataSourceId === "string"
|
|
13
|
+
? dataSourceId.match(/^data_source-(\d+)$/)
|
|
14
|
+
: null;
|
|
15
|
+
|
|
16
|
+
return match ? match[1] : dataSourceId;
|
|
17
|
+
}
|
|
18
|
+
|
|
10
19
|
export default {
|
|
11
20
|
screensCache: [],
|
|
12
21
|
cachedScreenPromises: [],
|
|
@@ -196,12 +205,13 @@ export default {
|
|
|
196
205
|
);
|
|
197
206
|
},
|
|
198
207
|
|
|
199
|
-
postDataSource(
|
|
208
|
+
postDataSource(dataSourceId, requestId, params) {
|
|
209
|
+
const normalizedDataSourceId = normalizeDataSourceId(dataSourceId);
|
|
200
210
|
let url;
|
|
201
211
|
if (requestId) {
|
|
202
|
-
url = `/requests/${requestId}/data_sources/${
|
|
212
|
+
url = `/requests/${requestId}/data_sources/${normalizedDataSourceId}`;
|
|
203
213
|
} else {
|
|
204
|
-
url = `/requests/data_sources/${
|
|
214
|
+
url = `/requests/data_sources/${normalizedDataSourceId}`;
|
|
205
215
|
}
|
|
206
216
|
url += this.authQueryString();
|
|
207
217
|
|
|
@@ -215,14 +225,20 @@ export default {
|
|
|
215
225
|
* @returns {object}
|
|
216
226
|
*/
|
|
217
227
|
getDataSource(dataSourceId, params, nonce = null) {
|
|
228
|
+
const normalizedDataSourceId = normalizeDataSourceId(dataSourceId);
|
|
218
229
|
// keep backwards compatibility
|
|
219
230
|
if (
|
|
220
231
|
!window.ProcessMaker.screen.cacheEnabled &&
|
|
221
232
|
!window.ProcessMaker.screen.cacheTimeout
|
|
222
233
|
) {
|
|
223
|
-
return this.postDataSource(dataSourceId, null, params).then(r => [
|
|
234
|
+
return this.postDataSource(dataSourceId, null, params).then((r) => [
|
|
235
|
+
r,
|
|
236
|
+
nonce
|
|
237
|
+
]);
|
|
224
238
|
}
|
|
225
|
-
let url =
|
|
239
|
+
let url =
|
|
240
|
+
`/requests/data_sources/${normalizedDataSourceId}` +
|
|
241
|
+
`/resources/${params.config.endpoint}/data`;
|
|
226
242
|
url += this.authQueryString();
|
|
227
243
|
return this.get(url, {
|
|
228
244
|
useCache: window.ProcessMaker.screen.cacheEnabled,
|
|
@@ -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,16 +186,7 @@ export default {
|
|
|
185
186
|
}
|
|
186
187
|
},
|
|
187
188
|
getCollectionColumns(records) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (firstRecord?.data) {
|
|
191
|
-
this.singleFieldOptions = [];
|
|
192
|
-
const dataObject = firstRecord.data;
|
|
193
|
-
|
|
194
|
-
for (const [key] of Object.entries(dataObject)) {
|
|
195
|
-
this.singleFieldOptions.push({ text: key, value: key });
|
|
196
|
-
}
|
|
197
|
-
}
|
|
189
|
+
this.singleFieldOptions = getCollectionFieldOptions(records);
|
|
198
190
|
}
|
|
199
191
|
}
|
|
200
192
|
};
|
|
@@ -35,7 +35,8 @@ import ScreenVariableSelector from "../screen-variable-selector.vue";
|
|
|
35
35
|
const CONFIG_FIELDS = [
|
|
36
36
|
"collectionId",
|
|
37
37
|
"pmql",
|
|
38
|
-
"dataRecordList"
|
|
38
|
+
"dataRecordList",
|
|
39
|
+
"fields"
|
|
39
40
|
];
|
|
40
41
|
|
|
41
42
|
export default {
|
|
@@ -144,22 +145,18 @@ export default {
|
|
|
144
145
|
},
|
|
145
146
|
getFields() {
|
|
146
147
|
if (!this.collectionId) {
|
|
148
|
+
this.fields = [];
|
|
147
149
|
return;
|
|
148
150
|
}
|
|
149
151
|
|
|
150
152
|
this.$dataProvider
|
|
151
153
|
.getCollectionFields(this.collectionId)
|
|
152
154
|
.then((response) => {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
text: field.label,
|
|
159
|
-
value: field.field
|
|
160
|
-
};
|
|
161
|
-
})
|
|
162
|
-
];
|
|
155
|
+
const dataColumns = response?.data?.data || [];
|
|
156
|
+
this.fields = dataColumns.map((field) => ({
|
|
157
|
+
text: field.label || field.field,
|
|
158
|
+
value: field.field
|
|
159
|
+
}));
|
|
163
160
|
|
|
164
161
|
this.onCollectionChange();
|
|
165
162
|
});
|
|
@@ -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,16 +395,10 @@ export default {
|
|
|
394
395
|
}
|
|
395
396
|
},
|
|
396
397
|
getCollectionColumns(collection) {
|
|
397
|
-
this.collectionOptions = [
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
const dataObject = firstRecord.data;
|
|
402
|
-
|
|
403
|
-
for (const [key, value] of Object.entries(dataObject)) {
|
|
404
|
-
this.collectionOptions.push({ text: key, value: key });
|
|
405
|
-
}
|
|
406
|
-
}
|
|
398
|
+
this.collectionOptions = [
|
|
399
|
+
{ text: "All columns", value: "all" },
|
|
400
|
+
...getCollectionFieldOptions(collection)
|
|
401
|
+
];
|
|
407
402
|
},
|
|
408
403
|
initData() {
|
|
409
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,
|