@processmaker/screen-builder 3.8.34 → 3.8.35

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.34",
3
+ "version": "3.8.35",
4
4
  "scripts": {
5
5
  "dev": "VITE_COVERAGE=true vite",
6
6
  "build": "vite build",
@@ -188,6 +188,7 @@ export default {
188
188
  const [firstRecord] = records?.dataRecordList || [];
189
189
 
190
190
  if (firstRecord?.data) {
191
+ this.singleFieldOptions = [];
191
192
  const dataObject = firstRecord.data;
192
193
 
193
194
  for (const [key] of Object.entries(dataObject)) {
@@ -473,7 +473,7 @@ export default {
473
473
  this.editIndex = index;
474
474
  this.optionContent = this.optionsList[index][this.valueField];
475
475
  this.optionValue = this.optionsList[index][this.keyField];
476
- this.optionContentCollection = this.optionsList[index][this.keyFieldCollection];
476
+ this.optionContentCollection = this.optionsList[index].label || this.optionsList[index][this.keyFieldCollection];
477
477
  this.optionValueCollection = this.optionsList[index][this.valueField];
478
478
  this.optionError = '';
479
479
  },
@@ -535,15 +535,17 @@ export default {
535
535
 
536
536
  this.optionsList.push(
537
537
  {
538
- [this.keyFieldCollection]: this.optionContentCollection,
538
+ [this.keyFieldCollection]: this.optionValueCollection,
539
539
  [this.valueField]: this.optionValueCollection,
540
+ label: this.optionContentCollection,
540
541
  }
541
542
  );
542
543
  this.optionsList = this.optionsList.filter(option => option["content"] !== "all");
543
544
  }
544
545
  else {
545
- this.optionsList[this.editIndex][this.keyFieldCollection] = this.optionContentCollection;
546
+ this.optionsList[this.editIndex][this.keyFieldCollection] = this.optionValueCollection;
546
547
  this.optionsList[this.editIndex][this.valueField] = this.optionValueCollection;
548
+ this.optionsList[this.editIndex].label = this.optionContentCollection;
547
549
  }
548
550
 
549
551
  this.jsonError = '';
@@ -35,7 +35,7 @@
35
35
  data-cy="table"
36
36
  :tbody-tr-class="rowClass"
37
37
  >
38
-
38
+
39
39
  <!-- Slot header for checkbox (Select All) -->
40
40
  <template #head(checkbox)="data">
41
41
  <b-form-checkbox
@@ -47,8 +47,8 @@
47
47
  </template>
48
48
 
49
49
  <template #cell(checkbox)="{ index, item }">
50
- <b-form-checkbox
51
- v-model="selectedRows"
50
+ <b-form-checkbox
51
+ v-model="selectedRows"
52
52
  :value="item"
53
53
  @change="onMultipleSelectionChange(index)"
54
54
  />
@@ -59,12 +59,12 @@
59
59
  v-model="selectedRow"
60
60
  :value="item"
61
61
  @change="onRadioChange(item, index)"
62
-
62
+
63
63
  />
64
64
  </template>
65
65
 
66
66
  <template #cell()="{ index, field, item }">
67
-
67
+
68
68
  <template v-if="isFiledownload(field, item)">
69
69
  <span href="#" @click="downloadFile(item, field.key, index)">{{
70
70
  mustache(field.key, item)
@@ -79,7 +79,7 @@
79
79
  <template v-else>
80
80
  {{ formatIfDate(mustache(field.key, item)) }}
81
81
  </template>
82
-
82
+
83
83
  </template>
84
84
  <template #cell(__actions)="{ index, item }">
85
85
  <div class="actions">
@@ -110,8 +110,8 @@
110
110
  :title="$t('Delete')"
111
111
  data-cy="remove-row"
112
112
  popover="manual"
113
- @click="styleMode === 'Modern'
114
- ? togglePopover(index, $event, item.row_id)
113
+ @click="styleMode === 'Modern'
114
+ ? togglePopover(index, $event, item.row_id)
115
115
  : showDeleteConfirmation(index, item.row_id)"
116
116
  ref="deleteButton"
117
117
  >
@@ -131,7 +131,7 @@
131
131
  </div>
132
132
  </div>
133
133
  </template>
134
-
134
+
135
135
  </b-table>
136
136
  <div class="d-flex justify-content-between align-items-center">
137
137
  <div class="col text-left">
@@ -241,7 +241,7 @@
241
241
  >
242
242
  <p>{{ $t("The form to be displayed is not assigned.") }}</p>
243
243
  </b-modal>
244
-
244
+
245
245
  <div v-if="editable && selfReferenced" class="alert alert-danger">
246
246
  {{
247
247
  $t(
@@ -324,7 +324,7 @@ export default {
324
324
  collectionData: {},
325
325
  selectedRow: null,
326
326
  selectedRows: [],
327
- selectedIndex: null,
327
+ selectedIndex: null,
328
328
  rows: [],
329
329
  selectAll: false,
330
330
  styleMode: "Classic",
@@ -390,10 +390,6 @@ export default {
390
390
  ? this.collectionData
391
391
  : (Array.isArray(this.value) ? this.value : []);
392
392
 
393
- if(this.value) {
394
- this.selectedIndex = this.value.selectedRowIndex;
395
- }
396
-
397
393
  const from = this.paginatorPage - 1;
398
394
  // eslint-disable-next-line vue/no-side-effects-in-computed-properties
399
395
  this.lastPage = Math.ceil(value.length / this.perPage);
@@ -411,22 +407,17 @@ export default {
411
407
  lastSortConfig: false
412
408
  };
413
409
 
414
- // Enable Radio button selected when process finishes
415
- if (this.selectedIndex !== null && this.selectedIndex < data.data.length) {
416
- this.selectedRow = data.data[this.selectedIndex];
417
- }
418
-
419
410
  //Enable Checkbox selected when process finishes
420
411
  if (Array.isArray(this.value) && this.value.length > 0) {
421
412
  if(this.rows.length === 0) {
422
413
  this.value.forEach(item => {
423
414
  if (item.hasOwnProperty('selectedRowsIndex')) {
424
415
  this.selectedRows.push(data.data[item.selectedRowsIndex]);
425
- }
416
+ }
426
417
  });
427
418
  }
428
419
  }
429
- return data;
420
+ return data;
430
421
  },
431
422
  // The fields used for our vue table
432
423
  tableFields() {
@@ -437,7 +428,7 @@ export default {
437
428
  }
438
429
 
439
430
  // Adds radio buttons or checkbox to the table depending selected option
440
- if(this.source?.sourceOptions === "Collection") {
431
+ if(this.source?.sourceOptions === "Collection") {
441
432
  if (['single-field', 'single-record'].includes(this.source?.dataSelectionOptions)) {
442
433
  fields.unshift({
443
434
  key: 'radio',
@@ -445,7 +436,7 @@ export default {
445
436
  sortable: false,
446
437
  });
447
438
  }
448
-
439
+
449
440
  if (this.source?.dataSelectionOptions === 'multiple-records') {
450
441
  fields.unshift({
451
442
  key: 'checkbox',
@@ -454,7 +445,7 @@ export default {
454
445
  });
455
446
  }
456
447
  }
457
-
448
+
458
449
  return fields;
459
450
  },
460
451
  // Determines if the form used for add/edit is self referencing. If so, we should not show it
@@ -472,12 +463,21 @@ export default {
472
463
  this.currentPage = this.currentPage == 0 ? 1 : this.currentPage;
473
464
  }
474
465
  },
466
+ // Restore radio selection when the value prop is set after collection data is already loaded
467
+ value: {
468
+ immediate: true,
469
+ handler() {
470
+ if (Array.isArray(this.collectionData) && this.collectionData.length) {
471
+ this.restoreRadioSelection(this.collectionData);
472
+ }
473
+ }
474
+ },
475
475
  // Watch for changes in validationData to handle any Mustache variable changes
476
476
  validationData: {
477
477
  handler(newValue, oldValue) {
478
478
  if (this.source?.sourceOptions === "Collection" && this.source?.collectionFields?.pmql) {
479
479
  this.onCollectionChange(
480
- this.source?.collectionFields?.collectionId,
480
+ this.source?.collectionFields?.collectionId,
481
481
  this.source?.collectionFields?.pmql
482
482
  );
483
483
  }
@@ -502,7 +502,7 @@ export default {
502
502
  if(this.source?.sourceOptions === "Collection") {
503
503
  this.onCollectionChange(this.source?.collectionFields?.collectionId, this.source?.collectionFields?.pmql);
504
504
  }
505
-
505
+
506
506
  this.setStyleMode(this.designerMode?.designerOptions);
507
507
  this.$root.$emit("record-list-option", this.source?.sourceOptions);
508
508
  },
@@ -615,15 +615,15 @@ export default {
615
615
  this.fetchAllRecords(collectionId);
616
616
  return;
617
617
  }
618
-
618
+
619
619
  // Process Mustache variables in PMQL
620
620
  const processedPmql = this.processMustacheInPmql(pmql);
621
-
621
+
622
622
  // If processing failed or resulted in invalid PMQL, return
623
623
  if (!processedPmql) {
624
624
  return;
625
625
  }
626
-
626
+
627
627
  // Fetch records with processed PMQL
628
628
  this.fetchRecordsWithPmql(collectionId, processedPmql);
629
629
  },
@@ -641,7 +641,7 @@ export default {
641
641
  try {
642
642
  // Get data from validationData
643
643
  const data = this.validationData || {};
644
-
644
+
645
645
  // First, process all Mustache variables (both quoted and unquoted)
646
646
  let processedPmql = Mustache.render(pmql, data);
647
647
 
@@ -650,14 +650,14 @@ export default {
650
650
  this.collectionData = [];
651
651
  return null;
652
652
  }
653
-
653
+
654
654
  // Add quotes around string values in PMQL if they don't have them
655
655
  // This regex now properly handles values with spaces by looking for the end of the comparison
656
656
  processedPmql = processedPmql.replace(
657
657
  /= ([^"'\s][^"']*[^"'\s]|[^"'\s]+)(?=\s|$)/g,
658
658
  '= "$1"'
659
659
  );
660
-
660
+
661
661
  return processedPmql;
662
662
  } catch (error) {
663
663
  this.collectionData = [];
@@ -681,8 +681,8 @@ export default {
681
681
  * @returns {boolean} - True if valid
682
682
  */
683
683
  isValidPmql(processedPmql) {
684
- return processedPmql &&
685
- processedPmql.trim() !== "" &&
684
+ return processedPmql &&
685
+ processedPmql.trim() !== "" &&
686
686
  !processedPmql.includes("{{");
687
687
  },
688
688
 
@@ -713,9 +713,9 @@ export default {
713
713
  this.collectionData = [];
714
714
  return;
715
715
  }
716
-
716
+
717
717
  const param = { params: { pmql: processedPmql } };
718
-
718
+
719
719
  this.$dataProvider
720
720
  .getCollectionRecordsList(collectionId, param)
721
721
  .then((response) => {
@@ -729,7 +729,7 @@ export default {
729
729
  this.$emit("change", this.field);
730
730
  },
731
731
  changeCollectionColumns(collectionFieldsColumns,columnsSelected) {
732
-
732
+
733
733
  const optionsList = columnsSelected.optionsList;
734
734
 
735
735
  collectionFieldsColumns.forEach(column => {
@@ -748,7 +748,7 @@ export default {
748
748
  });
749
749
 
750
750
  this.setCollectionIntoList(collectionFieldsColumns);
751
-
751
+
752
752
  },
753
753
  setCollectionIntoList(arrayCollection) {
754
754
  const result = [];
@@ -767,6 +767,7 @@ export default {
767
767
  //sets Collection result(columns and rows) into this.collectionData
768
768
  this.collectionData = result;
769
769
  this.reapplyCollectionSelections(result);
770
+ this.restoreRadioSelection(result);
770
771
  },
771
772
  // Keep selected rows in sync after collection refreshes triggered by PMQL filters.
772
773
  reapplyCollectionSelections(newCollection) {
@@ -815,6 +816,27 @@ export default {
815
816
 
816
817
  this.selectedRows = updatedSelection;
817
818
  },
819
+ // Restore selectedRow after collection data (re)loads or when value prop changes.
820
+ // Mirrors reapplyCollectionSelections for the single-record (radio) case.
821
+ restoreRadioSelection(rows) {
822
+ if (!this.value || !Array.isArray(rows) || rows.length === 0) {
823
+ return;
824
+ }
825
+
826
+ if (this.source?.singleField) {
827
+ // singleField mode emits a scalar; find the row whose field matches
828
+ const match = rows.find(row => row[this.source.singleField] === this.value);
829
+ if (match) {
830
+ this.selectedRow = match;
831
+ }
832
+ } else if (typeof this.value === "object" && !Array.isArray(this.value)) {
833
+ // Regular single-record mode emits { ...item, selectedRowIndex: N }
834
+ const idx = this.value.selectedRowIndex;
835
+ if (idx != null && idx >= 0 && idx < rows.length) {
836
+ this.selectedRow = rows[idx];
837
+ }
838
+ }
839
+ },
818
840
  shouldPersistCollectionSelection() {
819
841
  const pmql = this.source?.collectionFields?.pmql;
820
842
  return (
@@ -891,14 +913,14 @@ export default {
891
913
  },
892
914
  getTableFieldsFromDataSource() {
893
915
  const { jsonData, key, value, dataName } = this.fields;
894
-
916
+
895
917
  let convertToVuetableFormat = {};
896
918
  if(this.source?.sourceOptions === "Collection") {
897
919
  convertToVuetableFormat = (option) => {
898
920
  return {
899
921
  key: option[key || "key"],
900
922
  sortable: true,
901
- label: option[key || "key"],
923
+ label: option.label || option[key || "key"],
902
924
  tdClass: "table-column"
903
925
  };
904
926
  };
@@ -907,7 +929,7 @@ export default {
907
929
  return {
908
930
  key: option[key || "value"],
909
931
  sortable: true,
910
- label: option[value || "content"],
932
+ label: option.label || option[value || "content"],
911
933
  tdClass: "table-column"
912
934
  };
913
935
  };
@@ -1116,15 +1138,15 @@ export default {
1116
1138
  background-color: #eaf2ff;
1117
1139
  }
1118
1140
  .class-button-modern {
1119
- font-size: 14px;
1120
- font-weight: bold;
1141
+ font-size: 14px;
1142
+ font-weight: bold;
1121
1143
  text-decoration: none;
1122
1144
  }
1123
1145
 
1124
1146
  .record-list-table-base {
1125
1147
  border-collapse: separate;
1126
1148
  border-spacing: 0;
1127
-
1149
+
1128
1150
  thead th {
1129
1151
  border-top: 1px solid;
1130
1152
  border-bottom: 1px solid;
@@ -1142,7 +1164,7 @@ export default {
1142
1164
  td {
1143
1165
  border-bottom: 1px solid;
1144
1166
  }
1145
-
1167
+
1146
1168
  td:first-child {
1147
1169
  border-left: 1px solid;
1148
1170
  }