@processmaker/screen-builder 3.8.39 → 3.8.41

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.39",
3
+ "version": "3.8.41",
4
4
  "scripts": {
5
5
  "dev": "VITE_COVERAGE=true vite",
6
6
  "build": "vite build",
@@ -157,7 +157,7 @@ class FormLoopValidations extends Validations {
157
157
  return;
158
158
  }
159
159
  page.items.filter(item => {
160
- if (item.component === 'FormLoop' && item.config.name === this.element.config.name) {
160
+ if (item.component === 'FormLoop' && item.config.name === this.element.config.name && item !== this.element) {
161
161
  siblings.push(item);
162
162
  }
163
163
  });
@@ -239,31 +239,52 @@ class PageNavigateValidations extends Validations {
239
239
  * Add validations for a form element
240
240
  */
241
241
  class FormElementValidations extends Validations {
242
- async addValidations(validations) {
243
- // Disable validations if field is hidden
244
- if (!this.isVisible()) {
245
- return;
242
+ /**
243
+ * Returns true when this field should be skipped entirely (not validated).
244
+ * Inside loops, conditionalHide is per-row and handled by the runtime closure,
245
+ * so only the device-level visibleInDevice flag is checked statically.
246
+ */
247
+ shouldSkipValidation() {
248
+ if (this.insideLoop) {
249
+ const visibleInDevice =
250
+ this.element.visibleInDevice === null || this.element.visibleInDevice === undefined
251
+ ? true
252
+ : this.element.visibleInDevice;
253
+ return !visibleInDevice;
246
254
  }
247
- if (this.element.config && this.element.config.readonly) {
248
- //readonly elements do not need validation
249
- return;
255
+ return !this.isVisible();
256
+ }
257
+
258
+ /**
259
+ * Returns true when the element has a usable config with a valid variable name
260
+ * and is neither readonly nor disabled.
261
+ */
262
+ isValidElement() {
263
+ const { config } = this.element;
264
+ if (!config || config.readonly || config.disabled) {
265
+ return false;
250
266
  }
251
- if (this.element.config && this.element.config.disabled) {
252
- //disabled elements do not need validation
267
+ return config.name &&
268
+ typeof config.name === 'string' &&
269
+ config.name.match(/^[a-zA-Z_][0-9a-zA-Z_.]*$/);
270
+ }
271
+
272
+ async addValidations(validations) {
273
+ if (this.shouldSkipValidation()) {
253
274
  return;
254
275
  }
255
- if (!(this.element.config && this.element.config.name && typeof this.element.config.name === 'string' && this.element.config.name.match(/^[a-zA-Z_][0-9a-zA-Z_.]*$/))) {
256
- //element invalid
276
+ if (!this.isValidElement()) {
257
277
  return;
258
278
  }
259
279
  const fieldName = this.element.config.name;
260
280
  const validationConfig = this.element.config.validation;
261
- const conditionalHide = this.element.config.conditionalHide;
262
- const parentVisibilityRule = this.parentVisibilityRule;
263
- const insideLoop = this.insideLoop || false;
264
- const deviceConfig = this.element.config.deviceVisibility
265
- ? this.element.config.deviceVisibility
266
- : { showForDesktop: true, showForMobile: true };
281
+ const closureOptions = {
282
+ fieldName,
283
+ conditionalHide: this.element.config.conditionalHide,
284
+ parentVisibilityRule: this.parentVisibilityRule,
285
+ insideLoop: this.insideLoop || false,
286
+ deviceConfig: this.element.config.deviceVisibility || { showForDesktop: true, showForMobile: true },
287
+ };
267
288
 
268
289
  set(validations, fieldName, get(validations, fieldName, {}));
269
290
  const fieldValidation = get(validations, fieldName);
@@ -275,109 +296,77 @@ class FormElementValidations extends Validations {
275
296
  }
276
297
  let validationFn = validators[rule];
277
298
  if (!validationFn) {
278
- // eslint-disable-next-line no-console
279
299
  return;
280
300
  }
281
301
  if (validation.configs instanceof Array) {
282
- const params = [];
283
- validation.configs.forEach((cnf) => {
284
- params.push(cnf.value);
285
- });
302
+ const params = validation.configs.map((cnf) => cnf.value);
286
303
  params.push(fieldName);
287
304
  validationFn = validationFn(...params);
288
305
  }
289
- fieldValidation[rule] = function(...props) {
290
- const data = props[1];
291
- const level = fieldName.split('.').length - 1;
292
- const dataWithParent = this.getDataAccordingToFieldLevel(this.getRootScreen().addReferenceToParents(data), level);
293
- if (parentVisibilityRule) {
294
- const nextParentLevel = insideLoop ? 1 : 0;
295
- const parentDataWithParent = this.getDataAccordingToFieldLevel(this.getRootScreen().addReferenceToParents(data), level + nextParentLevel);
296
- let isParentVisible = true;
297
- try {
298
- isParentVisible = !!Parser.evaluate(parentVisibilityRule, parentDataWithParent);
299
- } catch (error) {
300
- isParentVisible = false;
301
- }
302
-
303
- if (!isParentVisible ) {
304
- return true;
305
- }
306
- }
307
-
308
- // Check Device Visibility
309
- let visibleInDevice = true;
310
- try {
311
- const isMobileScreen = this.$root.$children[0].$refs.renderer.definition.isMobile;
312
- visibleInDevice =
313
- (isMobileScreen && deviceConfig.showForMobile) ||
314
- (!isMobileScreen && deviceConfig.showForDesktop);
315
- } catch (error) {
316
- visibleInDevice = true;
317
- }
318
- if (!visibleInDevice) {
319
- return true;
320
- }
321
-
322
- // Check Field Visibility
323
- let visible = true;
324
- if (conditionalHide) {
325
- try {
326
- visible = !!Parser.evaluate(conditionalHide, dataWithParent);
327
- } catch (error) {
328
- visible = false;
329
- }
330
- }
331
- if (!visible) {
332
- return true;
333
- }
334
- return validationFn.apply(this,props);
335
- };
306
+ fieldValidation[rule] = this.buildClosure(validationFn, closureOptions);
336
307
  });
337
308
  } else if (typeof validationConfig === 'string' && validationConfig) {
338
- let validationFn = validators[validationConfig];
309
+ const validationFn = validators[validationConfig];
339
310
  if (!validationFn) {
340
- // eslint-disable-next-line no-console
341
311
  return;
342
312
  }
343
- fieldValidation[validationConfig] = function(...props) {
344
- const data = props[1];
345
- const level = fieldName.split('.').length - 1;
346
- const dataWithParent = this.getDataAccordingToFieldLevel(this.getRootScreen().addReferenceToParents(data), level);
347
- // Check Parent Visibility
348
- if (parentVisibilityRule) {
349
- const nextParentLevel = insideLoop ? 1 : 0;
350
- const parentDataWithParent = this.getDataAccordingToFieldLevel(this.getRootScreen().addReferenceToParents(data), level + nextParentLevel);
351
- let isParentVisible = true;
352
- try {
353
- isParentVisible = !!Parser.evaluate(parentVisibilityRule, parentDataWithParent);
354
- } catch (error) {
355
- isParentVisible = false;
356
- }
357
-
358
- if (!isParentVisible) {
359
- return true;
360
- }
361
- }
362
- // Check Field Visibility
363
- let visible = true;
364
- if (conditionalHide) {
365
- try {
366
- visible = !!Parser.evaluate(conditionalHide, dataWithParent);
367
- } catch (error) {
368
- visible = false;
369
- }
370
- }
371
- if (!visible) {
372
- return true;
373
- }
374
- return validationFn.apply(this,props);
375
- };
313
+ fieldValidation[validationConfig] = this.buildClosure(validationFn, closureOptions);
376
314
  }
377
315
  if (this.element.items) {
378
316
  ValidationsFactory(this.element.items, { screen: this.screen, data: this.data }).addValidations(validations);
379
317
  }
380
318
  }
319
+
320
+ buildClosure(validationFn, { fieldName, parentVisibilityRule, insideLoop, deviceConfig, conditionalHide }) {
321
+ return function (...props) {
322
+ const data = props[1];
323
+ const level = fieldName.split('.').length - 1;
324
+ const dataWithParent = this.getDataAccordingToFieldLevel(this.getRootScreen().addReferenceToParents(data), level);
325
+
326
+ if (parentVisibilityRule) {
327
+ const nextParentLevel = insideLoop ? 1 : 0;
328
+ const parentDataWithParent = this.getDataAccordingToFieldLevel(this.getRootScreen().addReferenceToParents(data), level + nextParentLevel);
329
+ let isParentVisible = true;
330
+ try {
331
+ isParentVisible = !!Parser.evaluate(parentVisibilityRule, parentDataWithParent);
332
+ } catch (error) {
333
+ isParentVisible = false;
334
+ }
335
+ if (!isParentVisible) {
336
+ return true;
337
+ }
338
+ }
339
+
340
+ // Check Device Visibility
341
+ let visibleInDevice = true;
342
+ try {
343
+ const isMobileScreen = this.$root.$children[0].$refs.renderer.definition.isMobile;
344
+ visibleInDevice =
345
+ (isMobileScreen && deviceConfig.showForMobile) ||
346
+ (!isMobileScreen && deviceConfig.showForDesktop);
347
+ } catch (error) {
348
+ visibleInDevice = true;
349
+ }
350
+ if (!visibleInDevice) {
351
+ return true;
352
+ }
353
+
354
+ // Check Field Visibility
355
+ let visible = true;
356
+ if (conditionalHide) {
357
+ try {
358
+ visible = !!Parser.evaluate(conditionalHide, dataWithParent);
359
+ } catch (error) {
360
+ visible = false;
361
+ }
362
+ }
363
+ if (!visible) {
364
+ return true;
365
+ }
366
+ return validationFn.apply(this, props);
367
+ };
368
+ }
369
+
381
370
  camelCase(name) {
382
371
  return name.replace(/_\w/g, m => m.substr(1, 1).toUpperCase());
383
372
  }
@@ -121,6 +121,9 @@ export default {
121
121
  this.setFilesInfo();
122
122
  },
123
123
  methods: {
124
+ isWebEntryTemporaryFileId(fileId) {
125
+ return typeof fileId === "string" && fileId.startsWith("webentry_");
126
+ },
124
127
  downloadFile(file) {
125
128
  if (this.collection) {
126
129
  this.downloadCollectionFile(file);
@@ -209,6 +212,12 @@ export default {
209
212
  const fileId = this.value
210
213
  ? this.value
211
214
  : _.get(this.requestData, this.fileDataName, null);
215
+
216
+ if (this.isWebEntryTemporaryFileId(fileId)) {
217
+ this.filesInfo = [];
218
+ return;
219
+ }
220
+
212
221
  let { endpoint } = this;
213
222
 
214
223
  if (this.requestFiles) {
@@ -0,0 +1,219 @@
1
+ /**
2
+ * Pure helpers for FormRecordList collection radio/checkbox selection.
3
+ * Kept outside the Vue SFC so unit tests can exercise production logic
4
+ * without mounting the heavy FormRecordList component tree.
5
+ */
6
+
7
+ import {
8
+ mapCollectionRecordData,
9
+ normalizeCollectionFieldPath
10
+ } from "../../collectionFieldUtils";
11
+
12
+ export function isSingleFieldSelectionMode(source) {
13
+ return (
14
+ source?.dataSelectionOptions === "single-field" ||
15
+ (source?.dataSelectionOptions == null && !!source?.singleField)
16
+ );
17
+ }
18
+
19
+ function uniqueFieldKeys(...keys) {
20
+ return keys.filter(
21
+ (key, index, arr) => key != null && key !== "" && arr.indexOf(key) === index
22
+ );
23
+ }
24
+
25
+ /**
26
+ * Resolve the configured singleField value from a collection row.
27
+ * Rows are remapped from collection field names (content) to column keys,
28
+ * so singleField may not match Object.keys(row) directly.
29
+ * Supports legacy `data.` prefixed field paths via collectionFieldUtils.
30
+ */
31
+ export function getSingleFieldValue(selectedItem, source, fields) {
32
+ const rawField = source?.singleField;
33
+ const normalizedField = normalizeCollectionFieldPath(rawField);
34
+ if (!normalizedField || !selectedItem || typeof selectedItem !== "object") {
35
+ return undefined;
36
+ }
37
+
38
+ for (const key of uniqueFieldKeys(normalizedField, rawField)) {
39
+ if (Object.hasOwn(selectedItem, key)) {
40
+ return selectedItem[key];
41
+ }
42
+ }
43
+
44
+ const optionsList = fields?.optionsList || [];
45
+ const byContent = optionsList.find(
46
+ (opt) =>
47
+ normalizeCollectionFieldPath(opt.content) === normalizedField ||
48
+ opt.content === rawField
49
+ );
50
+ if (byContent) {
51
+ for (const key of uniqueFieldKeys(
52
+ normalizeCollectionFieldPath(byContent.key),
53
+ byContent.key
54
+ )) {
55
+ if (Object.hasOwn(selectedItem, key)) {
56
+ return selectedItem[key];
57
+ }
58
+ }
59
+ }
60
+
61
+ const byKey = optionsList.find(
62
+ (opt) =>
63
+ normalizeCollectionFieldPath(opt.key) === normalizedField ||
64
+ opt.key === rawField
65
+ );
66
+ if (byKey) {
67
+ for (const key of uniqueFieldKeys(
68
+ normalizeCollectionFieldPath(byKey.key),
69
+ byKey.key
70
+ )) {
71
+ if (Object.hasOwn(selectedItem, key)) {
72
+ return selectedItem[key];
73
+ }
74
+ }
75
+ }
76
+
77
+ const lower = String(normalizedField).toLowerCase();
78
+ const matchedKey = Object.keys(selectedItem).find(
79
+ (key) =>
80
+ String(normalizeCollectionFieldPath(key)).toLowerCase() === lower
81
+ );
82
+ return matchedKey ? selectedItem[matchedKey] : undefined;
83
+ }
84
+
85
+ export function rowMatchesSingleFieldValue(row, value, source, fields) {
86
+ return getSingleFieldValue(row, source, fields) === value;
87
+ }
88
+
89
+ /**
90
+ * Convert a b-table page-relative cell index into a global row index.
91
+ * @change already provides a page-relative index; do not pass a global
92
+ * index here or the page offset will be applied twice.
93
+ */
94
+ export function toGlobalRowIndex(pageRelativeIndex, currentPage, perPage) {
95
+ return (currentPage - 1) * perPage + pageRelativeIndex;
96
+ }
97
+
98
+ /**
99
+ * Build the value emitted for a radio selection.
100
+ * Returns undefined for missing single-field values (caller should not emit).
101
+ */
102
+ export function buildRadioSelectionValue(
103
+ selectedItem,
104
+ pageRelativeIndex,
105
+ currentPage,
106
+ perPage,
107
+ source,
108
+ fields
109
+ ) {
110
+ if (isSingleFieldSelectionMode(source) && source?.singleField) {
111
+ return getSingleFieldValue(selectedItem, source, fields);
112
+ }
113
+
114
+ return {
115
+ ...selectedItem,
116
+ selectedRowIndex: toGlobalRowIndex(
117
+ pageRelativeIndex,
118
+ currentPage,
119
+ perPage
120
+ )
121
+ };
122
+ }
123
+
124
+ export function getCollectionRowKey(item) {
125
+ if (!item || typeof item !== "object") {
126
+ return null;
127
+ }
128
+
129
+ const entries = Object.entries(item).filter(
130
+ ([key]) => key !== "selectedRowsIndex" && key !== "selectedRowIndex"
131
+ );
132
+
133
+ if (entries.length === 0) {
134
+ return null;
135
+ }
136
+
137
+ entries.sort(([keyA], [keyB]) => {
138
+ if (keyA > keyB) return 1;
139
+ if (keyA < keyB) return -1;
140
+ return 0;
141
+ });
142
+ return JSON.stringify(entries);
143
+ }
144
+
145
+ export function findSingleRecordRadioMatch(value, rows) {
146
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
147
+ return null;
148
+ }
149
+
150
+ const valueKey = getCollectionRowKey(value);
151
+ if (valueKey) {
152
+ const byContent = rows.find(
153
+ (row) => getCollectionRowKey(row) === valueKey
154
+ );
155
+ if (byContent) {
156
+ return byContent;
157
+ }
158
+ }
159
+
160
+ const idx = value.selectedRowIndex;
161
+ if (idx != null && idx >= 0 && idx < rows.length) {
162
+ return rows[idx];
163
+ }
164
+ return null;
165
+ }
166
+
167
+ export function findRadioSelectionMatch(value, rows, source, fields) {
168
+ if (value == null || value === "" || !Array.isArray(rows) || rows.length === 0) {
169
+ return null;
170
+ }
171
+
172
+ if (isSingleFieldSelectionMode(source) && source?.singleField) {
173
+ return (
174
+ rows.find((row) =>
175
+ rowMatchesSingleFieldValue(row, value, source, fields)
176
+ ) || null
177
+ );
178
+ }
179
+
180
+ if (typeof value === "object" && !Array.isArray(value)) {
181
+ return findSingleRecordRadioMatch(value, rows);
182
+ }
183
+
184
+ return null;
185
+ }
186
+
187
+ /**
188
+ * Remap collection API rows from field content names to column keys using
189
+ * collectionFieldUtils, always preserving the configured singleField.
190
+ */
191
+ export function remapCollectionRowData(dataObject, optionsList, singleField) {
192
+ const sourceData = dataObject || {};
193
+ const mapped = mapCollectionRecordData(sourceData, optionsList || []);
194
+
195
+ if (!singleField) {
196
+ return mapped;
197
+ }
198
+
199
+ const normalizedField = normalizeCollectionFieldPath(singleField);
200
+ const directSourceKey = uniqueFieldKeys(
201
+ singleField,
202
+ normalizedField,
203
+ `data.${normalizedField}`
204
+ ).find((candidate) => Object.hasOwn(sourceData, candidate));
205
+
206
+ if (directSourceKey) {
207
+ mapped[normalizedField] = sourceData[directSourceKey];
208
+ return mapped;
209
+ }
210
+
211
+ const matchedKey = Object.keys(sourceData).find(
212
+ (key) => normalizeCollectionFieldPath(key) === normalizedField
213
+ );
214
+ if (matchedKey) {
215
+ mapped[normalizedField] = sourceData[matchedKey];
216
+ }
217
+
218
+ return mapped;
219
+ }
@@ -259,10 +259,13 @@ 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 { normalizeCollectionFieldPath } from "../../collectionFieldUtils";
262
263
  import {
263
- mapCollectionRecordData,
264
- normalizeCollectionFieldPath
265
- } from "../../collectionFieldUtils";
264
+ buildRadioSelectionValue,
265
+ findRadioSelectionMatch,
266
+ getCollectionRowKey,
267
+ remapCollectionRowData
268
+ } from "./form-record-list-selection";
266
269
 
267
270
  const jsonOptionsActionsColumn = {
268
271
  key: "__actions",
@@ -478,12 +481,15 @@ export default {
478
481
  },
479
482
  // Watch for changes in validationData to handle any Mustache variable changes
480
483
  validationData: {
481
- handler(newValue, oldValue) {
482
- if (this.source?.sourceOptions === "Collection" && this.source?.collectionFields?.pmql) {
483
- this.onCollectionChange(
484
- this.source?.collectionFields?.collectionId,
485
- this.source?.collectionFields?.pmql
486
- );
484
+ handler() {
485
+ if (this.source?.sourceOptions === "Collection") {
486
+ const pmql = this.getCollectionPmql();
487
+ if (pmql) {
488
+ this.onCollectionChange(
489
+ this.source?.collectionFields?.collectionId,
490
+ pmql
491
+ );
492
+ }
487
493
  }
488
494
  },
489
495
  deep: true,
@@ -504,7 +510,10 @@ export default {
504
510
  }
505
511
 
506
512
  if(this.source?.sourceOptions === "Collection") {
507
- this.onCollectionChange(this.source?.collectionFields?.collectionId, this.source?.collectionFields?.pmql);
513
+ this.onCollectionChange(
514
+ this.source?.collectionFields?.collectionId,
515
+ this.getCollectionPmql()
516
+ );
508
517
  }
509
518
 
510
519
  this.setStyleMode(this.designerMode?.designerOptions);
@@ -580,20 +589,53 @@ export default {
580
589
  }
581
590
  },
582
591
  componentOutput(data) {
583
- this.$emit('input', data);
592
+ // Avoid emitting undefined, which would leave the bound variable as null
593
+ // and lose the selection when submitting to the next task.
594
+ if (typeof data === "undefined") {
595
+ return;
596
+ }
597
+ this.$emit("input", data);
598
+ // Also write directly to validationData (screen vdata). Submit reads vdata, and
599
+ // v-model/@input listener order can drop object selections before they sync.
600
+ this.persistValueToFormData(data);
584
601
  },
585
- onRadioChange(selectedItem, index) {
586
- const globalIndex = (this.currentPage - 1) * this.perPage + index;
587
- if(this.source?.singleField) {
588
- const singleField = normalizeCollectionFieldPath(
589
- this.source.singleField
590
- );
591
- const valueOfColumn = selectedItem[singleField];
592
- this.componentOutput(valueOfColumn);
593
- } else {
594
- selectedItem = { ...selectedItem, selectedRowIndex: globalIndex};
595
- this.componentOutput(selectedItem);
602
+ persistValueToFormData(data) {
603
+ if (
604
+ !this.name ||
605
+ !this.validationData ||
606
+ typeof this.validationData !== "object"
607
+ ) {
608
+ return;
596
609
  }
610
+ if (String(this.name).includes(".")) {
611
+ _.set(this.validationData, this.name, data);
612
+ const rootKey = String(this.name).split(".")[0];
613
+ this.$set(this.validationData, rootKey, this.validationData[rootKey]);
614
+ return;
615
+ }
616
+ this.$set(this.validationData, this.name, data);
617
+ },
618
+ getCollectionPmql() {
619
+ // PMQL can live on source.pmql and/or source.collectionFields.pmql depending
620
+ // on how the inspector synced the config; prefer the nested copy when present.
621
+ const nestedPmql = this.source?.collectionFields?.pmql;
622
+ if (typeof nestedPmql === "string") {
623
+ return nestedPmql;
624
+ }
625
+ return this.source?.pmql || "";
626
+ },
627
+ onRadioChange(selectedItem, pageRelativeIndex) {
628
+ // b-table cell slot `index` is page-relative; convert once here.
629
+ this.componentOutput(
630
+ buildRadioSelectionValue(
631
+ selectedItem,
632
+ pageRelativeIndex,
633
+ this.currentPage,
634
+ this.perPage,
635
+ this.source,
636
+ this.fields
637
+ )
638
+ );
597
639
  },
598
640
  onMultipleSelectionChange(selIndex) {
599
641
  this.collectionData.forEach((item, index) => {
@@ -732,14 +774,14 @@ export default {
732
774
  .catch(() => {
733
775
  this.collectionData = [];
734
776
  });
735
-
736
- this.$emit("change", this.field);
737
777
  },
738
778
  changeCollectionColumns(collectionFieldsColumns, columnsSelected) {
739
- const optionsList = columnsSelected.optionsList;
779
+ const optionsList = columnsSelected?.optionsList || [];
780
+ const singleField = this.source?.singleField;
781
+
740
782
  const mappedColumns = collectionFieldsColumns.map((column) => ({
741
783
  ...column,
742
- data: mapCollectionRecordData(column.data, optionsList)
784
+ data: remapCollectionRowData(column.data, optionsList, singleField)
743
785
  }));
744
786
 
745
787
  this.setCollectionIntoList(mappedColumns);
@@ -813,29 +855,18 @@ export default {
813
855
  // Restore selectedRow after collection data (re)loads or when value prop changes.
814
856
  // Mirrors reapplyCollectionSelections for the single-record (radio) case.
815
857
  restoreRadioSelection(rows) {
816
- if (!this.value || !Array.isArray(rows) || rows.length === 0) {
817
- return;
818
- }
819
-
820
- if (this.source?.singleField) {
821
- // singleField mode emits a scalar; find the row whose field matches
822
- const singleField = normalizeCollectionFieldPath(
823
- this.source.singleField
824
- );
825
- const match = rows.find(row => row[singleField] === this.value);
826
- if (match) {
827
- this.selectedRow = match;
828
- }
829
- } else if (typeof this.value === "object" && !Array.isArray(this.value)) {
830
- // Regular single-record mode emits { ...item, selectedRowIndex: N }
831
- const idx = this.value.selectedRowIndex;
832
- if (idx != null && idx >= 0 && idx < rows.length) {
833
- this.selectedRow = rows[idx];
834
- }
858
+ const match = findRadioSelectionMatch(
859
+ this.value,
860
+ rows,
861
+ this.source,
862
+ this.fields
863
+ );
864
+ if (match) {
865
+ this.selectedRow = match;
835
866
  }
836
867
  },
837
868
  shouldPersistCollectionSelection() {
838
- const pmql = this.source?.collectionFields?.pmql;
869
+ const pmql = this.getCollectionPmql();
839
870
  return (
840
871
  this.source?.sourceOptions === "Collection" &&
841
872
  this.source?.dataSelectionOptions === "multiple-records" &&
@@ -844,24 +875,7 @@ export default {
844
875
  );
845
876
  },
846
877
  getCollectionRowKey(item) {
847
- if (!item || typeof item !== "object") {
848
- return null;
849
- }
850
-
851
- const entries = Object.entries(item).filter(
852
- ([key]) => key !== "selectedRowsIndex"
853
- );
854
-
855
- if (entries.length === 0) {
856
- return null;
857
- }
858
-
859
- entries.sort(([keyA], [keyB]) => {
860
- if (keyA > keyB) return 1;
861
- if (keyA < keyB) return -1;
862
- return 0;
863
- });
864
- return JSON.stringify(entries);
878
+ return getCollectionRowKey(item);
865
879
  },
866
880
  updateRowDataNamePrefix() {
867
881
  this.setUploadDataNamePrefix(this.currentRowIndex);