@processmaker/screen-builder 3.8.33 → 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.33",
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 = '';
@@ -154,6 +154,18 @@ export default {
154
154
  components: { ...uploader, RequiredAsterisk },
155
155
  mixins: [uniqIdsMixin],
156
156
  props: ['label', 'error', 'helper', 'name', 'value', 'controlClass', 'endpoint', 'accept', 'validation', 'parent', 'config', 'multipleUpload', 'screenType'],
157
+ created() {
158
+ const vm = this;
159
+ // File Manager > Public + multi: see isFileManagerPublicInterface(); processParams fixes
160
+ // data_name per chunk (processParams runs after getParams merges `filename` for this chunk).
161
+ this.options.processParams = (params, file) => {
162
+ if (!vm.isFileManagerPublicInterface() || !vm.multipleUpload) {
163
+ return params;
164
+ }
165
+ params.data_name = params.filename || file.name;
166
+ return params;
167
+ };
168
+ },
157
169
  updated() {
158
170
  this.removeDefaultClasses();
159
171
  },
@@ -373,6 +385,15 @@ export default {
373
385
  };
374
386
  },
375
387
  methods: {
388
+ isFileManagerPublicInterface() {
389
+ if (typeof window === 'undefined' || !window.location) {
390
+ return false;
391
+ }
392
+ const p = String(window.location.pathname || '');
393
+ const h = String(window.location.hash || '');
394
+ return p.includes('/file-manager/public')
395
+ || (/\/file-manager\/?$/i.test(p) && /^#\/public(\/|$)/i.test(h));
396
+ },
376
397
  clearFiles() {
377
398
  this.showComponent = false;
378
399
  this.$nextTick(() => {
@@ -573,7 +594,7 @@ export default {
573
594
  }
574
595
  }
575
596
  file.ignored = false;
576
- if (!this.name) {
597
+ if (!this.name && !(this.isFileManagerPublicInterface() && this.multipleUpload)) {
577
598
  this.options.query.data_name = file.name;
578
599
  }
579
600
  return true;
@@ -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,16 +110,19 @@
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
  >
118
118
  <i v-if="styleMode === 'Classic'" class="fas fa-trash-alt" />
119
119
  <img v-else src="../../assets/Shape.svg" alt="delete" />
120
120
  </button>
121
-
122
- <div v-show="isPopoverVisible === index" class="popover-content">
121
+ <div
122
+ v-show="isPopoverVisible === index"
123
+ class="popover-content"
124
+ :style="popoverPosition"
125
+ >
123
126
  <p>Are you sure you want to delete it?</p>
124
127
  <button class="btn btn-light" @click="hidePopover">CANCEL</button>
125
128
  <button class="btn btn-danger" @click="popover_remove()">DELETE</button>
@@ -128,7 +131,7 @@
128
131
  </div>
129
132
  </div>
130
133
  </template>
131
-
134
+
132
135
  </b-table>
133
136
  <div class="d-flex justify-content-between align-items-center">
134
137
  <div class="col text-left">
@@ -238,7 +241,7 @@
238
241
  >
239
242
  <p>{{ $t("The form to be displayed is not assigned.") }}</p>
240
243
  </b-modal>
241
-
244
+
242
245
  <div v-if="editable && selfReferenced" class="alert alert-danger">
243
246
  {{
244
247
  $t(
@@ -321,7 +324,7 @@ export default {
321
324
  collectionData: {},
322
325
  selectedRow: null,
323
326
  selectedRows: [],
324
- selectedIndex: null,
327
+ selectedIndex: null,
325
328
  rows: [],
326
329
  selectAll: false,
327
330
  styleMode: "Classic",
@@ -387,10 +390,6 @@ export default {
387
390
  ? this.collectionData
388
391
  : (Array.isArray(this.value) ? this.value : []);
389
392
 
390
- if(this.value) {
391
- this.selectedIndex = this.value.selectedRowIndex;
392
- }
393
-
394
393
  const from = this.paginatorPage - 1;
395
394
  // eslint-disable-next-line vue/no-side-effects-in-computed-properties
396
395
  this.lastPage = Math.ceil(value.length / this.perPage);
@@ -408,22 +407,17 @@ export default {
408
407
  lastSortConfig: false
409
408
  };
410
409
 
411
- // Enable Radio button selected when process finishes
412
- if (this.selectedIndex !== null && this.selectedIndex < data.data.length) {
413
- this.selectedRow = data.data[this.selectedIndex];
414
- }
415
-
416
410
  //Enable Checkbox selected when process finishes
417
411
  if (Array.isArray(this.value) && this.value.length > 0) {
418
412
  if(this.rows.length === 0) {
419
413
  this.value.forEach(item => {
420
414
  if (item.hasOwnProperty('selectedRowsIndex')) {
421
415
  this.selectedRows.push(data.data[item.selectedRowsIndex]);
422
- }
416
+ }
423
417
  });
424
418
  }
425
419
  }
426
- return data;
420
+ return data;
427
421
  },
428
422
  // The fields used for our vue table
429
423
  tableFields() {
@@ -434,7 +428,7 @@ export default {
434
428
  }
435
429
 
436
430
  // Adds radio buttons or checkbox to the table depending selected option
437
- if(this.source?.sourceOptions === "Collection") {
431
+ if(this.source?.sourceOptions === "Collection") {
438
432
  if (['single-field', 'single-record'].includes(this.source?.dataSelectionOptions)) {
439
433
  fields.unshift({
440
434
  key: 'radio',
@@ -442,7 +436,7 @@ export default {
442
436
  sortable: false,
443
437
  });
444
438
  }
445
-
439
+
446
440
  if (this.source?.dataSelectionOptions === 'multiple-records') {
447
441
  fields.unshift({
448
442
  key: 'checkbox',
@@ -451,7 +445,7 @@ export default {
451
445
  });
452
446
  }
453
447
  }
454
-
448
+
455
449
  return fields;
456
450
  },
457
451
  // Determines if the form used for add/edit is self referencing. If so, we should not show it
@@ -469,12 +463,21 @@ export default {
469
463
  this.currentPage = this.currentPage == 0 ? 1 : this.currentPage;
470
464
  }
471
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
+ },
472
475
  // Watch for changes in validationData to handle any Mustache variable changes
473
476
  validationData: {
474
477
  handler(newValue, oldValue) {
475
478
  if (this.source?.sourceOptions === "Collection" && this.source?.collectionFields?.pmql) {
476
479
  this.onCollectionChange(
477
- this.source?.collectionFields?.collectionId,
480
+ this.source?.collectionFields?.collectionId,
478
481
  this.source?.collectionFields?.pmql
479
482
  );
480
483
  }
@@ -499,7 +502,7 @@ export default {
499
502
  if(this.source?.sourceOptions === "Collection") {
500
503
  this.onCollectionChange(this.source?.collectionFields?.collectionId, this.source?.collectionFields?.pmql);
501
504
  }
502
-
505
+
503
506
  this.setStyleMode(this.designerMode?.designerOptions);
504
507
  this.$root.$emit("record-list-option", this.source?.sourceOptions);
505
508
  },
@@ -508,10 +511,34 @@ export default {
508
511
  this.deleteIndex = _.find(this.tableData.data, { row_id: rowId });
509
512
  this.isPopoverVisible = this.isPopoverVisible === index ? null : index;
510
513
  if (this.isPopoverVisible !== null) {
511
- const rect = event.target.getBoundingClientRect();
514
+ const buttonEl = event.target.closest("button") || event.target;
515
+ const rect = buttonEl.getBoundingClientRect();
516
+ const popoverWidth = 285;
517
+ const estimatedPopoverHeight = 130;
518
+ const viewportMargin = 8;
519
+
520
+ // Default: anchor below the button, aligned to its left edge
521
+ let top = rect.bottom + viewportMargin;
522
+ let left = rect.left;
523
+
524
+ // Flip above the button if there isn't enough room below
525
+ if (
526
+ top + estimatedPopoverHeight >
527
+ window.innerHeight - viewportMargin
528
+ ) {
529
+ top = Math.max(
530
+ viewportMargin,
531
+ rect.top - estimatedPopoverHeight - viewportMargin
532
+ );
533
+ }
534
+
535
+ // Clamp horizontally so the popover never overflows the viewport
536
+ const maxLeft = window.innerWidth - popoverWidth - viewportMargin;
537
+ left = Math.max(viewportMargin, Math.min(left, maxLeft));
538
+
512
539
  this.popoverPosition = {
513
- top: `${rect.bottom + window.scrollY}px`,
514
- left: `${rect.left + window.scrollX}px`
540
+ top: `${top}px`,
541
+ left: `${left}px`
515
542
  };
516
543
  }
517
544
  },
@@ -588,15 +615,15 @@ export default {
588
615
  this.fetchAllRecords(collectionId);
589
616
  return;
590
617
  }
591
-
618
+
592
619
  // Process Mustache variables in PMQL
593
620
  const processedPmql = this.processMustacheInPmql(pmql);
594
-
621
+
595
622
  // If processing failed or resulted in invalid PMQL, return
596
623
  if (!processedPmql) {
597
624
  return;
598
625
  }
599
-
626
+
600
627
  // Fetch records with processed PMQL
601
628
  this.fetchRecordsWithPmql(collectionId, processedPmql);
602
629
  },
@@ -614,7 +641,7 @@ export default {
614
641
  try {
615
642
  // Get data from validationData
616
643
  const data = this.validationData || {};
617
-
644
+
618
645
  // First, process all Mustache variables (both quoted and unquoted)
619
646
  let processedPmql = Mustache.render(pmql, data);
620
647
 
@@ -623,14 +650,14 @@ export default {
623
650
  this.collectionData = [];
624
651
  return null;
625
652
  }
626
-
653
+
627
654
  // Add quotes around string values in PMQL if they don't have them
628
655
  // This regex now properly handles values with spaces by looking for the end of the comparison
629
656
  processedPmql = processedPmql.replace(
630
657
  /= ([^"'\s][^"']*[^"'\s]|[^"'\s]+)(?=\s|$)/g,
631
658
  '= "$1"'
632
659
  );
633
-
660
+
634
661
  return processedPmql;
635
662
  } catch (error) {
636
663
  this.collectionData = [];
@@ -654,8 +681,8 @@ export default {
654
681
  * @returns {boolean} - True if valid
655
682
  */
656
683
  isValidPmql(processedPmql) {
657
- return processedPmql &&
658
- processedPmql.trim() !== "" &&
684
+ return processedPmql &&
685
+ processedPmql.trim() !== "" &&
659
686
  !processedPmql.includes("{{");
660
687
  },
661
688
 
@@ -686,9 +713,9 @@ export default {
686
713
  this.collectionData = [];
687
714
  return;
688
715
  }
689
-
716
+
690
717
  const param = { params: { pmql: processedPmql } };
691
-
718
+
692
719
  this.$dataProvider
693
720
  .getCollectionRecordsList(collectionId, param)
694
721
  .then((response) => {
@@ -702,7 +729,7 @@ export default {
702
729
  this.$emit("change", this.field);
703
730
  },
704
731
  changeCollectionColumns(collectionFieldsColumns,columnsSelected) {
705
-
732
+
706
733
  const optionsList = columnsSelected.optionsList;
707
734
 
708
735
  collectionFieldsColumns.forEach(column => {
@@ -721,7 +748,7 @@ export default {
721
748
  });
722
749
 
723
750
  this.setCollectionIntoList(collectionFieldsColumns);
724
-
751
+
725
752
  },
726
753
  setCollectionIntoList(arrayCollection) {
727
754
  const result = [];
@@ -740,6 +767,7 @@ export default {
740
767
  //sets Collection result(columns and rows) into this.collectionData
741
768
  this.collectionData = result;
742
769
  this.reapplyCollectionSelections(result);
770
+ this.restoreRadioSelection(result);
743
771
  },
744
772
  // Keep selected rows in sync after collection refreshes triggered by PMQL filters.
745
773
  reapplyCollectionSelections(newCollection) {
@@ -788,6 +816,27 @@ export default {
788
816
 
789
817
  this.selectedRows = updatedSelection;
790
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
+ },
791
840
  shouldPersistCollectionSelection() {
792
841
  const pmql = this.source?.collectionFields?.pmql;
793
842
  return (
@@ -864,14 +913,14 @@ export default {
864
913
  },
865
914
  getTableFieldsFromDataSource() {
866
915
  const { jsonData, key, value, dataName } = this.fields;
867
-
916
+
868
917
  let convertToVuetableFormat = {};
869
918
  if(this.source?.sourceOptions === "Collection") {
870
919
  convertToVuetableFormat = (option) => {
871
920
  return {
872
921
  key: option[key || "key"],
873
922
  sortable: true,
874
- label: option[key || "key"],
923
+ label: option.label || option[key || "key"],
875
924
  tdClass: "table-column"
876
925
  };
877
926
  };
@@ -880,7 +929,7 @@ export default {
880
929
  return {
881
930
  key: option[key || "value"],
882
931
  sortable: true,
883
- label: option[value || "content"],
932
+ label: option.label || option[value || "content"],
884
933
  tdClass: "table-column"
885
934
  };
886
935
  };
@@ -1075,8 +1124,9 @@ export default {
1075
1124
  position: fixed;
1076
1125
  z-index: 1000;
1077
1126
  width: 285px;
1127
+ max-width: calc(100vw - 16px);
1078
1128
  text-align: center;
1079
- margin-top: 30px;
1129
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
1080
1130
  }
1081
1131
  .popover-content p {
1082
1132
  margin: 0 0 10px;
@@ -1088,15 +1138,15 @@ export default {
1088
1138
  background-color: #eaf2ff;
1089
1139
  }
1090
1140
  .class-button-modern {
1091
- font-size: 14px;
1092
- font-weight: bold;
1141
+ font-size: 14px;
1142
+ font-weight: bold;
1093
1143
  text-decoration: none;
1094
1144
  }
1095
1145
 
1096
1146
  .record-list-table-base {
1097
1147
  border-collapse: separate;
1098
1148
  border-spacing: 0;
1099
-
1149
+
1100
1150
  thead th {
1101
1151
  border-top: 1px solid;
1102
1152
  border-bottom: 1px solid;
@@ -1114,7 +1164,7 @@ export default {
1114
1164
  td {
1115
1165
  border-bottom: 1px solid;
1116
1166
  }
1117
-
1167
+
1118
1168
  td:first-child {
1119
1169
  border-left: 1px solid;
1120
1170
  }