@processmaker/screen-builder 3.8.45 → 3.8.47

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.
Files changed (33) hide show
  1. package/dist/vue-form-builder.css +1 -1
  2. package/dist/vue-form-builder.es.js +5729 -5040
  3. package/dist/vue-form-builder.es.js.map +1 -1
  4. package/dist/vue-form-builder.umd.js +43 -42
  5. package/dist/vue-form-builder.umd.js.map +1 -1
  6. package/package.json +3 -3
  7. package/src/DataProvider.js +2 -0
  8. package/src/ValidationsFactory.js +15 -12
  9. package/src/components/index.js +4 -0
  10. package/src/components/inspector/vueRender/EditorFieldInspector.vue +239 -0
  11. package/src/components/renderer/add-loop-row.vue +27 -1
  12. package/src/components/renderer/form-collection-record-control.vue +44 -10
  13. package/src/components/renderer/form-collection-view-control.vue +2 -0
  14. package/src/components/renderer/form-loop.vue +29 -2
  15. package/src/components/renderer/form-nested-screen.vue +17 -1
  16. package/src/components/renderer/form-record-list.vue +93 -13
  17. package/src/components/renderer/vueRender/VueRenderEditor.vue +99 -0
  18. package/src/components/renderer/vueRender/VueRenderPreview.vue +36 -0
  19. package/src/components/renderer/vueRender/VueRenderTemplate.js +245 -0
  20. package/src/components/screen-renderer.vue +5 -0
  21. package/src/components/task.vue +37 -5
  22. package/src/components/vue-form-renderer.vue +51 -8
  23. package/src/form-builder-controls.js +68 -1
  24. package/src/main.js +11 -0
  25. package/src/mixins/DeviceDetector.js +19 -3
  26. package/src/mixins/Json2Vue.js +12 -1
  27. package/src/mixins/ScreenBase.js +43 -16
  28. package/src/mixins/VisibilityRule.js +3 -3
  29. package/src/mixins/extensions/FormDynamicPanel.js +2 -2
  30. package/src/mixins/extensions/LoadFieldComponents.js +64 -39
  31. package/src/mixins/extensions/LoopContainer.js +2 -2
  32. package/src/mixins/extensions/VisibilityRule.js +8 -8
  33. package/src/stories/VueRender.stories.js +274 -0
@@ -11,9 +11,11 @@
11
11
  :computed="computed"
12
12
  :custom-css="customCSS"
13
13
  :watchers="watchers"
14
+ :is-mobile="isMobile"
14
15
  debug-context="Nested Screen"
15
16
  @css-errors="cssErrors = $event"
16
17
  :_parent="_parent"
18
+ :read-only="isDisabled"
17
19
  />
18
20
  </template>
19
21
 
@@ -42,6 +44,9 @@ export default {
42
44
  validationData: null,
43
45
  _parent: null,
44
46
  ancestorScreens: {type: Array, default: () => []},
47
+ isMobile: {type: Boolean, default: false},
48
+ disabled: { type: [Boolean, String], default: false },
49
+ readonly: { type: [Boolean, String], default: false },
45
50
  },
46
51
  data() {
47
52
  return {
@@ -54,6 +59,17 @@ export default {
54
59
  };
55
60
  },
56
61
  computed: {
62
+ isDisabled() {
63
+ return Boolean(
64
+ this.disabled === true
65
+ || this.disabled === "true"
66
+ || this.disabled === ""
67
+ || this.readonly === true
68
+ || this.readonly === "true"
69
+ || this.readonly === ""
70
+ || this.$attrs.disabled
71
+ );
72
+ },
57
73
  validatedConfig() {
58
74
  return this.config && this.config[0] ? this.config : defaultConfig;
59
75
  },
@@ -133,7 +149,7 @@ export default {
133
149
  this.watchers = response.data.watchers;
134
150
  this.screenTitle = response.data.title;
135
151
 
136
- if (this.$attrs['disabled']) {
152
+ if (this.isDisabled) {
137
153
  this.disableForm(this.config);
138
154
  }
139
155
 
@@ -6,7 +6,7 @@
6
6
  </div>
7
7
  <div v-if="styleMode === 'Classic'" class="col text-right">
8
8
  <button
9
- v-if="editable && !selfReferenced"
9
+ v-if="canEditRecords && !selfReferenced"
10
10
  class="btn btn-primary"
11
11
  data-cy="add-row"
12
12
  @click="showAddForm"
@@ -40,6 +40,7 @@
40
40
  <template #head(checkbox)="data">
41
41
  <b-form-checkbox
42
42
  v-model="allRowsSelected"
43
+ :disabled="!canChangeSelection"
43
44
  @change="selectAllRows"
44
45
  :indeterminate="indeterminate"
45
46
  aria-label="Select All"
@@ -50,6 +51,7 @@
50
51
  <b-form-checkbox
51
52
  v-model="selectedRows"
52
53
  :value="item"
54
+ :disabled="!canChangeSelection"
53
55
  @change="onMultipleSelectionChange(index)"
54
56
  />
55
57
  </template>
@@ -58,6 +60,7 @@
58
60
  <b-form-radio
59
61
  v-model="selectedRow"
60
62
  :value="item"
63
+ :disabled="!canChangeSelection"
61
64
  @change="onRadioChange(item, index)"
62
65
 
63
66
  />
@@ -82,7 +85,7 @@
82
85
 
83
86
  </template>
84
87
  <template #cell(__actions)="{ index, item }">
85
- <div class="actions">
88
+ <div v-if="canEditRecords" class="actions">
86
89
  <div
87
90
  class="btn-group btn-group-sm"
88
91
  role="group"
@@ -148,7 +151,7 @@
148
151
  </div>
149
152
  <div v-if="styleMode === 'Modern'" class="col text-right">
150
153
  <button
151
- v-if="editable && !selfReferenced"
154
+ v-if="canEditRecords && !selfReferenced"
152
155
  class="btn btn-link text-primary class-button-modern"
153
156
  data-cy="add-row"
154
157
  @click="showAddForm"
@@ -160,7 +163,7 @@
160
163
  </template>
161
164
 
162
165
  <b-modal
163
- v-if="editable && !selfReferenced"
166
+ v-if="canEditRecords && !selfReferenced"
164
167
  ref="addModal"
165
168
  :static="true"
166
169
  size="lg"
@@ -182,13 +185,14 @@
182
185
  :current-page="form"
183
186
  :computed="formComputed"
184
187
  :watchers="formWatchers"
188
+ :is-mobile="isMobile"
185
189
  debug-context="Record List Add"
186
190
  :_parent="validationData"
187
191
  @update="updateRowDataNamePrefix"
188
192
  />
189
193
  </b-modal>
190
194
  <b-modal
191
- v-if="editable && !selfReferenced"
195
+ v-if="canEditRecords && !selfReferenced"
192
196
  ref="editModal"
193
197
  :static="true"
194
198
  size="lg"
@@ -210,13 +214,14 @@
210
214
  :current-page="form"
211
215
  :computed="formComputed"
212
216
  :watchers="formWatchers"
217
+ :is-mobile="isMobile"
213
218
  debug-context="Record List Edit"
214
219
  :_parent="validationData"
215
220
  @update="updateRowDataNamePrefix"
216
221
  />
217
222
  </b-modal>
218
223
  <b-modal
219
- v-if="editable && !selfReferenced"
224
+ v-if="canEditRecords && !selfReferenced"
220
225
  ref="deleteModal"
221
226
  size="lg"
222
227
  :ok-title="$t('Delete')"
@@ -229,7 +234,7 @@
229
234
  <p>{{ $t("Are you sure you want to remove this record?") }}</p>
230
235
  </b-modal>
231
236
  <b-modal
232
- v-if="editable && !selfReferenced"
237
+ v-if="canEditRecords && !selfReferenced"
233
238
  ref="infoModal"
234
239
  size="sm"
235
240
  :ok-title="$t('OK')"
@@ -242,7 +247,7 @@
242
247
  <p>{{ $t("The form to be displayed is not assigned.") }}</p>
243
248
  </b-modal>
244
249
 
245
- <div v-if="editable && selfReferenced" class="alert alert-danger">
250
+ <div v-if="canEditRecords && selfReferenced" class="alert alert-danger">
246
251
  {{
247
252
  $t(
248
253
  "The Record List control is not allowed to reference other controls on its own page to add or edit records. Specify a secondary page with controls to enter records."
@@ -280,12 +285,20 @@ export default {
280
285
  MustacheHelper
281
286
  },
282
287
  mixins: [mustacheEvaluation],
288
+ inject: {
289
+ formReadOnlyState: {
290
+ default: () => ({ value: false })
291
+ }
292
+ },
283
293
  props: [
284
294
  "name",
285
295
  "label",
286
296
  "fields",
287
297
  "value",
288
298
  "editable",
299
+ "disabled",
300
+ "readonly",
301
+ "config",
289
302
  "_config",
290
303
  "form",
291
304
  "validationData",
@@ -296,7 +309,8 @@ export default {
296
309
  "source",
297
310
  "paginationOption",
298
311
  "designerMode",
299
- "bgcolormodern"
312
+ "bgcolormodern",
313
+ "isMobile"
300
314
  ],
301
315
  data() {
302
316
  return {
@@ -340,6 +354,26 @@ export default {
340
354
  };
341
355
  },
342
356
  computed: {
357
+ canEditRecords() {
358
+ if (this.isFormReadOnlyContext()) {
359
+ return false;
360
+ }
361
+ const cfg = this.config || this._config;
362
+ if (
363
+ this.disabled
364
+ || this.readonly
365
+ || (cfg && (cfg.disabled || cfg.readonly || cfg.editable === false))
366
+ ) {
367
+ return false;
368
+ }
369
+ return Boolean(this.editable);
370
+ },
371
+ // Collection radio/checkbox selection must stay active in Screen Builder
372
+ // preview and active tasks. Block only in Tasks Preview Pane for
373
+ // CLOSED/COMPLETED (formReadOnlyState / forceFormReadOnly).
374
+ canChangeSelection() {
375
+ return !this.isFormReadOnlyContext();
376
+ },
343
377
  tableClassModern() {
344
378
  if (this.styleMode === 'Modern') {
345
379
  switch (this.bgcolormodern) {
@@ -428,14 +462,17 @@ export default {
428
462
  },
429
463
  // The fields used for our vue table
430
464
  tableFields() {
431
- const fields = this.getTableFieldsFromDataSource();
465
+ const fields = this.getTableFieldsFromDataSource().filter(
466
+ (field) => field.key !== "__actions"
467
+ );
432
468
 
433
- if (this.editable && !this.selfReferenced) {
469
+ if (this.canEditRecords && !this.selfReferenced) {
434
470
  fields.push(jsonOptionsActionsColumn);
435
471
  }
436
472
 
437
- // Adds radio buttons or checkbox to the table depending selected option
438
- if(this.source?.sourceOptions === "Collection") {
473
+ // Selection controls stay visible so the chosen record remains obvious;
474
+ // they are disabled when the form is read-only (closed/completed preview).
475
+ if (this.source?.sourceOptions === "Collection") {
439
476
  if (['single-field', 'single-record'].includes(this.source?.dataSelectionOptions)) {
440
477
  fields.unshift({
441
478
  key: 'radio',
@@ -520,7 +557,28 @@ export default {
520
557
  this.$root.$emit("record-list-option", this.source?.sourceOptions);
521
558
  },
522
559
  methods: {
560
+ isFormReadOnlyContext() {
561
+ if (this.formReadOnlyState && this.formReadOnlyState.value) {
562
+ return true;
563
+ }
564
+ let parent = this.$parent;
565
+ let depth = 0;
566
+ while (parent && depth < 30) {
567
+ if (parent.formReadOnlyState && parent.formReadOnlyState.value) {
568
+ return true;
569
+ }
570
+ if (parent.forceFormReadOnly || parent.isFormReadOnly) {
571
+ return true;
572
+ }
573
+ parent = parent.$parent;
574
+ depth += 1;
575
+ }
576
+ return false;
577
+ },
523
578
  togglePopover(index, event, rowId) {
579
+ if (!this.canEditRecords) {
580
+ return;
581
+ }
524
582
  this.deleteIndex = _.find(this.tableData.data, { row_id: rowId });
525
583
  this.isPopoverVisible = this.isPopoverVisible === index ? null : index;
526
584
  if (this.isPopoverVisible !== null) {
@@ -572,6 +630,9 @@ export default {
572
630
  this.styleMode = value ? value : "Classic";
573
631
  },
574
632
  selectAllRows() {
633
+ if (!this.canChangeSelection) {
634
+ return;
635
+ }
575
636
  if (this.allRowsSelected) {
576
637
  const updatedRows = this.tableData.data.map((item, index) => {
577
638
  return {
@@ -625,6 +686,9 @@ export default {
625
686
  return this.source?.pmql || "";
626
687
  },
627
688
  onRadioChange(selectedItem, pageRelativeIndex) {
689
+ if (!this.canChangeSelection) {
690
+ return;
691
+ }
628
692
  // b-table cell slot `index` is page-relative; convert once here.
629
693
  this.componentOutput(
630
694
  buildRadioSelectionValue(
@@ -638,6 +702,9 @@ export default {
638
702
  );
639
703
  },
640
704
  onMultipleSelectionChange(selIndex) {
705
+ if (!this.canChangeSelection) {
706
+ return;
707
+ }
641
708
  this.collectionData.forEach((item, index) => {
642
709
  this.selectedRows.forEach((selectedItem) => {
643
710
  // Compares both objects all keys and values
@@ -989,6 +1056,9 @@ export default {
989
1056
  }
990
1057
  },
991
1058
  showEditForm(index, rowId) {
1059
+ if (!this.canEditRecords) {
1060
+ return;
1061
+ }
992
1062
  const pageIndex = (this.currentPage - 1) * this.perPage + index;
993
1063
  // Reset edit to be a copy of our data model item
994
1064
  this.editItem = JSON.parse(
@@ -1025,6 +1095,9 @@ export default {
1025
1095
  this.$emit("input", data);
1026
1096
  },
1027
1097
  showAddForm() {
1098
+ if (!this.canEditRecords) {
1099
+ return;
1100
+ }
1028
1101
  const uniqueId =
1029
1102
  Math.random().toString(36).substring(2) + Date.now().toString(36);
1030
1103
  this.$set(this.addItem, "row_id", uniqueId);
@@ -1042,6 +1115,7 @@ export default {
1042
1115
  },
1043
1116
  handleHideAddModal() {
1044
1117
  this.addItem = this.initFormValues;
1118
+ window.ProcessMaker.EventBus.$emit("record-list-add-modal-hidden");
1045
1119
  this.$refs.addRenderer.hasSubmitted(false);
1046
1120
  },
1047
1121
  async handleOk(bvModalEvt) {
@@ -1074,6 +1148,9 @@ export default {
1074
1148
  });
1075
1149
  },
1076
1150
  showDeleteConfirmation(index, rowId) {
1151
+ if (!this.canEditRecords) {
1152
+ return;
1153
+ }
1077
1154
  this.deleteIndex = _.find(this.tableData.data, { row_id: rowId });
1078
1155
  this.$refs.deleteModal.show();
1079
1156
  },
@@ -1108,6 +1185,9 @@ export default {
1108
1185
  });
1109
1186
  },
1110
1187
  remove() {
1188
+ if (!this.canEditRecords) {
1189
+ return;
1190
+ }
1111
1191
  // Add the item to our model and emit change
1112
1192
  // @todo Also check that value is an array type, if not, reset it to an array
1113
1193
  const data = this.tableData.data
@@ -0,0 +1,99 @@
1
+ <template>
2
+ <div class="form-group pointer-events-none">
3
+ <div :class="classList">
4
+ <VueRenderTemplate
5
+ :key="componentRenderKey"
6
+ :templateVue="templateVue"
7
+ :handlerVue="handlerVue"
8
+ :validation-data="validationData || {}"
9
+ :transient-data="validationData || {}"
10
+ />
11
+ </div>
12
+ <div
13
+ v-if="error"
14
+ class="invalid-feedback"
15
+ >
16
+ {{ error }}
17
+ </div>
18
+ <small
19
+ v-if="helper"
20
+ class="form-text text-muted"
21
+ >{{ helper }}</small>
22
+ </div>
23
+ </template>
24
+ <script>
25
+ import VueRenderTemplate from './VueRenderTemplate';
26
+
27
+ export default {
28
+ name: 'VueRenderEditor',
29
+ components: { VueRenderTemplate },
30
+ inheritAttrs: false,
31
+ props: {
32
+ error: { type: String, default: null },
33
+ name: { type: String, default: null },
34
+ helper: { type: String, default: null },
35
+ controlClass: { type: String, default: null },
36
+ templateVue: { type: String, default: null },
37
+ handlerVue: { type: String, default: null },
38
+ validationData: { type: Object, default: null },
39
+ label: { type: String, default: null },
40
+ renderVarHtml: { type: Boolean, default: null },
41
+ },
42
+ data() {
43
+ return {
44
+ originalEscapeFn: null,
45
+ customFunctions: {},
46
+ editorSettings: {
47
+ inline: true,
48
+ menubar: false,
49
+ plugins: ['link', 'lists'],
50
+ toolbar: `undo redo | link | styleselect | bold italic forecolor |
51
+ alignleft aligncenter alignright alignjustify | bullist numlist outdent indent`,
52
+ skin: false,
53
+ relative_urls: false,
54
+ convert_urls: false,
55
+ remove_script_host: false,
56
+ },
57
+ };
58
+ },
59
+ computed: {
60
+ componentRenderKey() {
61
+ return [this.templateVue, this.handlerVue].join('::');
62
+ },
63
+ classList() {
64
+ const classList = {
65
+ 'is-invalid': Boolean(this.error),
66
+ };
67
+ if (this.controlClass) {
68
+ classList[this.controlClass] = true;
69
+ }
70
+ return classList;
71
+ },
72
+ rendered() {
73
+ // If we have't validationData, we can't evaluate the mustache variables
74
+ // Used by ScreenBuilder in Design Mode
75
+ return this.templateVue;
76
+ },
77
+ inPreviewMode() {
78
+ return ((this.mode === 'preview' && !window.exampleScreens) || this.mode === 'editor');
79
+ },
80
+ mode() {
81
+ return this.$root.$children[0].mode;
82
+ },
83
+ },
84
+ };
85
+ </script>
86
+
87
+ <style scoped>
88
+ .invalid-feedback {
89
+ display: block;
90
+ }
91
+
92
+ .is-invalid {
93
+ border: 1px solid #dc3545;
94
+ border-radius: 0.25rem;
95
+ }
96
+ .pointer-events-none {
97
+ pointer-events: none;
98
+ }
99
+ </style>
@@ -0,0 +1,36 @@
1
+ <template>
2
+ <vue-render-template
3
+ v-bind="$attrs"
4
+ :name="name"
5
+ :helper="helper"
6
+ :error="error"
7
+ :control-class="controlClass"
8
+ :templateVue="templateVue"
9
+ :handlerVue="handlerVue"
10
+ :validation-data="validationData"
11
+ :label="label"
12
+ :render-var-html="renderVarHtml"
13
+ v-on="$listeners"
14
+ />
15
+ </template>
16
+
17
+ <script>
18
+ import VueRenderTemplate from './VueRenderTemplate';
19
+
20
+ export default {
21
+ name: 'VueRenderPreview',
22
+ components: { VueRenderTemplate },
23
+ inheritAttrs: false,
24
+ props: {
25
+ name: { type: String, default: null },
26
+ helper: { type: String, default: null },
27
+ error: { type: String, default: null },
28
+ controlClass: { type: String, default: null },
29
+ templateVue: { type: String, default: null },
30
+ handlerVue: { type: String, default: null },
31
+ validationData: { type: Object, default: null },
32
+ label: { type: String, default: null },
33
+ renderVarHtml: { type: Boolean, default: null },
34
+ },
35
+ };
36
+ </script>