@processmaker/screen-builder 3.8.36 → 3.8.37

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@processmaker/screen-builder",
3
- "version": "3.8.36",
3
+ "version": "3.8.37",
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.9",
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.9",
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"
@@ -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(scriptId, requestId, params) {
208
+ postDataSource(dataSourceId, requestId, params) {
209
+ const normalizedDataSourceId = normalizeDataSourceId(dataSourceId);
200
210
  let url;
201
211
  if (requestId) {
202
- url = `/requests/${requestId}/data_sources/${scriptId}`;
212
+ url = `/requests/${requestId}/data_sources/${normalizedDataSourceId}`;
203
213
  } else {
204
- url = `/requests/data_sources/${scriptId}`;
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 => [r, nonce]);
234
+ return this.postDataSource(dataSourceId, null, params).then((r) => [
235
+ r,
236
+ nonce
237
+ ]);
224
238
  }
225
- let url = `/requests/data_sources/${dataSourceId}/resources/${params.config.endpoint}/data`;
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,
@@ -185,13 +185,24 @@ export default {
185
185
  }
186
186
  },
187
187
  getCollectionColumns(records) {
188
- const [firstRecord] = records?.dataRecordList || [];
188
+ this.singleFieldOptions = [];
189
189
 
190
- if (firstRecord?.data) {
191
- this.singleFieldOptions = [];
192
- const dataObject = firstRecord.data;
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
+ }
193
201
 
194
- for (const [key] of Object.entries(dataObject)) {
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)) {
195
206
  this.singleFieldOptions.push({ text: key, value: key });
196
207
  }
197
208
  }
@@ -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
- this.fields = [
154
- { value: null, text: this.$t("Select a field") },
155
- { value: "id", text: this.$t("Collection Record ID") },
156
- ...response.data.data.map((field) => {
157
- return {
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
  });
@@ -395,12 +395,23 @@ export default {
395
395
  },
396
396
  getCollectionColumns(collection) {
397
397
  this.collectionOptions = [{ text: "All columns", value: "all" }];
398
- const [firstRecord] = collection?.dataRecordList || [];
399
398
 
400
- if (firstRecord?.data) {
401
- const dataObject = firstRecord.data;
399
+ // Prefer the collection schema when CollectionRecordsList
400
+ // has forwarded it on the v-model payload.
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
+ }
402
410
 
403
- for (const [key, value] of Object.entries(dataObject)) {
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)) {
404
415
  this.collectionOptions.push({ text: key, value: key });
405
416
  }
406
417
  }