@processmaker/screen-builder 3.2.0 → 3.3.0

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.2.0",
3
+ "version": "3.3.0",
4
4
  "scripts": {
5
5
  "dev": "VITE_COVERAGE=true vite",
6
6
  "build": "vite build",
@@ -57,7 +57,7 @@
57
57
  "@fortawesome/fontawesome-free": "^5.6.1",
58
58
  "@originjs/vite-plugin-commonjs": "^1.0.3",
59
59
  "@panter/vue-i18next": "^0.15.2",
60
- "@processmaker/vue-form-elements": "0.63.0",
60
+ "@processmaker/vue-form-elements": "0.64.0",
61
61
  "@processmaker/vue-multiselect": "2.3.0",
62
62
  "@storybook/addon-essentials": "^7.6.13",
63
63
  "@storybook/addon-interactions": "^7.6.13",
@@ -116,7 +116,7 @@
116
116
  },
117
117
  "peerDependencies": {
118
118
  "@panter/vue-i18next": "^0.15.0",
119
- "@processmaker/vue-form-elements": "0.63.0",
119
+ "@processmaker/vue-form-elements": "0.64.0",
120
120
  "i18next": "^15.0.8",
121
121
  "vue": "^2.6.12",
122
122
  "vuex": "^3.1.1"
package/src/App.vue CHANGED
@@ -340,6 +340,10 @@ import "./assets/css/tabs.css";
340
340
  // To include another language in the Validator with variable processmaker
341
341
  const globalObject = typeof window === "undefined" ? global : window;
342
342
 
343
+ if (typeof globalObject.ProcessMaker?.setValidatorLanguage === 'function') {
344
+ globalObject.ProcessMaker.setValidatorLanguage(Validator, globalObject.ProcessMaker.user.lang);
345
+ }
346
+
343
347
  /* istanbul ignore next */
344
348
  Validator.register(
345
349
  "attr-value",
@@ -540,9 +544,11 @@ export default {
540
544
  if (
541
545
  globalObject.ProcessMaker &&
542
546
  globalObject.ProcessMaker.user &&
543
- globalObject.ProcessMaker.user.lang
547
+ globalObject.ProcessMaker.user.lang &&
548
+ typeof globalObject.ProcessMaker.setValidatorLanguage === 'function'
544
549
  ) {
545
- Validator.useLang(globalObject.ProcessMaker.user.lang);
550
+ //Validator.useLang(globalObject.ProcessMaker.user.lang);
551
+ globalObject.ProcessMaker.setValidatorLanguage(Validator, globalObject.ProcessMaker.user.lang);
546
552
  }
547
553
  // Iterate through our initial config set, calling this.addControl
548
554
  controlConfig.forEach((config) => {
@@ -672,9 +678,11 @@ export default {
672
678
  if (
673
679
  globalObject.ProcessMaker &&
674
680
  globalObject.ProcessMaker.user &&
675
- globalObject.ProcessMaker.user.lang
681
+ globalObject.ProcessMaker.user.lang &&
682
+ typeof globalObject.ProcessMaker.setValidatorLanguage === 'function'
676
683
  ) {
677
- Validator.useLang(globalObject.ProcessMaker.user.lang);
684
+ globalObject.ProcessMaker.setValidatorLanguage(Validator, globalObject.ProcessMaker.user.lang);
685
+ //Validator.useLang(globalObject.ProcessMaker.user.lang);
678
686
  }
679
687
 
680
688
  // Validation will not run until you call passes/fails on it
@@ -1,26 +1,25 @@
1
1
  <template>
2
+ <div>
2
3
  <div>
3
- <div>
4
- <label for="collectionsource">{{ $t("Source of Record List") }}</label>
5
- <b-form-select
6
- id="collectionsource"
7
- v-model="sourceOptions"
8
- :options="sourceDisplayOptions"
9
- data-cy="inspector-collection-data-source"
10
- @change="displayOptionChange"
11
- />
12
- <small class="mt-3 form-text text-muted">{{
13
- $t("A record list can display the data of a defined variable or a collection")
14
- }}</small>
15
- </div>
16
- <div class="mt-2" v-if="sourceOptions === 'Collection'">
17
-
18
- <CollectionRecordsList
19
- v-model="collectionFields"
20
- :record-pmql="pmql"
21
- @change="collectionChanged"/>
22
-
23
- <pmql-input
4
+ <label for="collectionsource">{{ $t("Source of Record List") }}</label>
5
+ <b-form-select
6
+ id="collectionsource"
7
+ v-model="sourceOptions"
8
+ :options="sourceDisplayOptions"
9
+ data-cy="inspector-collection-data-source"
10
+ @change="displayOptionChange"
11
+ />
12
+ <small class="mt-3 form-text text-muted">
13
+ {{ $t("A record list can display the data of a defined variable or a collection") }}
14
+ </small>
15
+ </div>
16
+ <div v-if="sourceOptions === 'Collection'" class="mt-2">
17
+ <CollectionRecordsList
18
+ v-model="collectionFields"
19
+ :record-pmql="pmql"
20
+ @change="collectionChanged"
21
+ />
22
+ <pmql-input
24
23
  v-model="pmql"
25
24
  :search-type="'collections_w_mustaches'"
26
25
  class="mt-3 mb-1"
@@ -31,172 +30,171 @@
31
30
  :placeholder="$t('PMQL')"
32
31
  >
33
32
  </pmql-input>
34
- <small class="mt-3 form-text text-muted">{{
35
- $t("Leave this field empty to show all the records of the collection")
36
- }}</small>
37
- <label class="mt-3" id="data-selection">{{ $t("Data Selection") }}</label>
38
-
33
+ <small class="mt-3 form-text text-muted">
34
+ {{ $t("Leave this field empty to show all the records of the collection") }}
35
+ </small>
36
+ <label for="data-selection" class="mt-3">{{ $t("Data Selection") }}</label>
37
+ <b-form-select
38
+ id="data-selection"
39
+ v-model="dataSelectionOptions"
40
+ :options="dataSelectionDisplayOptions"
41
+ data-cy="inspector-collection-data-selection"
42
+ />
43
+ <small class="mt-3 form-text text-muted">
44
+ {{ $t("The user can select specific data to be stored into a variable") }}
45
+ </small>
46
+ <div v-if="dataSelectionOptions === 'single-field'" class="mt-3">
47
+ <label for="single-columns">{{ $t("Column") }}</label>
39
48
  <b-form-select
40
- id="data-selection"
41
- v-model="dataSelectionOptions"
42
- :options="dataSelectionDisplayOptions"
43
- data-cy="inspector-collection-data-selection"
44
- />
45
- <small class="mt-3 form-text text-muted">{{
46
- $t("The user can select specific data to be stored into a variable")
47
- }}</small>
48
-
49
- <div class="mt-3" v-if="dataSelectionOptions === 'single-field'">
50
- <label id="single-columns">{{ $t('Column') }}</label>
51
- <b-form-select
52
49
  id="single-columns"
53
50
  v-model="singleField"
54
51
  :options="singleFieldOptions"
55
52
  data-cy="inspector-collection-single-field"
56
53
  >
57
- <option disabled value="">{{ $t("Select a column") }}</option>
58
- </b-form-select>
59
- </div>
54
+ <option disabled value="">{{ $t("Select a column") }}</option>
55
+ </b-form-select>
60
56
  </div>
61
57
  </div>
62
- </template>
63
- <script>
64
-
65
- import CollectionRecordsList from "./collection-records-list.vue"
66
- import { cloneDeep } from "lodash";
58
+ </div>
59
+ </template>
60
+ <script>
61
+ import { cloneDeep } from "lodash";
62
+ import CollectionRecordsList from "./collection-records-list.vue";
67
63
 
68
- const CONFIG_FIELDS = [
69
- "collectionFields",
70
- "collectionFieldsColumns",
71
- "pmql",
72
- "sourceOptions",
73
- "variableStore",
74
- "dataSelectionOptions",
75
- "singleField"
76
- ];
77
- export default {
78
- components: {
79
- CollectionRecordsList
80
- },
81
- props: ["value", "screenType"],
82
- data() {
83
- return {
84
- fields: [],
85
- sourceOptions: "Variable",
86
- submitCollectionCheck: true,
87
- sourceDisplayOptions: [],
88
- collectionFields: [],
89
- collectionFieldsColumns: [],
90
- variableStore: null,
91
- pmql: null,
92
- sourceDisplayOptions: [
64
+ const CONFIG_FIELDS = [
65
+ "collectionFields",
66
+ "collectionFieldsColumns",
67
+ "pmql",
68
+ "sourceOptions",
69
+ "variableStore",
70
+ "dataSelectionOptions",
71
+ "singleField"
72
+ ];
73
+ export default {
74
+ components: {
75
+ CollectionRecordsList
76
+ },
77
+ props: ["value", "screenType"],
78
+ data() {
79
+ return {
80
+ fields: [],
81
+ sourceOptions: "Variable",
82
+ submitCollectionCheck: true,
83
+ collectionFields: [],
84
+ collectionFieldsColumns: [],
85
+ variableStore: null,
86
+ pmql: null,
87
+ sourceDisplayOptions: [
93
88
  {
94
- text: this.$t('Variable'),
95
- value: 'Variable',
89
+ text: this.$t("Variable"),
90
+ value: "Variable"
96
91
  },
97
92
  {
98
- text: this.$t('Collection'),
99
- value: 'Collection',
100
- },
93
+ text: this.$t("Collection"),
94
+ value: "Collection"
95
+ }
101
96
  ],
102
97
  dataSelectionDisplayOptions: [
103
98
  {
104
- text: this.$t('Do not allow selection'),
105
- value: 'no-selection',
99
+ text: this.$t("Do not allow selection"),
100
+ value: "no-selection"
106
101
  },
107
102
  {
108
- text: this.$t('Single field of record'),
109
- value: 'single-field',
103
+ text: this.$t("Single field of record"),
104
+ value: "single-field"
110
105
  },
111
106
  {
112
- text: this.$t('Single record'),
113
- value: 'single-record',
107
+ text: this.$t("Single record"),
108
+ value: "single-record"
114
109
  },
115
110
  {
116
- text: this.$t('Multiple records'),
117
- value: 'multiple-records',
118
- },
111
+ text: this.$t("Multiple records"),
112
+ value: "multiple-records"
113
+ }
119
114
  ],
120
- dataSelectionOptions: "no-selection",
115
+ dataSelectionOptions: "no-selection",
121
116
  collectionColumns: [],
122
117
  singleFieldOptions: [],
123
118
  singleField: null
124
- };
125
- },
126
- methods: {
127
- displayOptionChange() {
128
- this.collectionFields = [];
129
- this.collectionFieldsColumns = [];
130
- this.pmql = null;
131
- this.$root.$emit("collection-changed", true);
132
- },
133
- collectionChanged(data) {
134
- if (Array.isArray(data)) {
135
- const [firstItem] = data;
136
- const collectionId = firstItem?.collection_id;
137
- if(collectionId !== this.collectionFields.collectionId) {
138
- this.$root.$emit("collection-changed", true);
139
- }
140
- }
141
- },
142
- getCollectionColumns(records) {
143
- const [firstRecord] = records?.dataRecordList || [];
144
-
145
- if (firstRecord?.data) {
146
- const dataObject = firstRecord.data;
147
-
148
- for (const [key, value] of Object.entries(dataObject)) {
149
- this.singleFieldOptions.push({ text: key, value: key });
150
- }
119
+ };
120
+ },
121
+ computed: {
122
+ options() {
123
+ return Object.fromEntries(
124
+ CONFIG_FIELDS.map((field) => [field, this[field]])
125
+ );
126
+ }
127
+ },
128
+ watch: {
129
+ value: {
130
+ handler(value) {
131
+ if (!value) {
132
+ return;
151
133
  }
134
+ CONFIG_FIELDS.forEach((field) => (this[field] = value[field]));
152
135
  },
136
+ immediate: true
153
137
  },
154
- computed: {
155
- options() {
156
- return Object.fromEntries(
157
- CONFIG_FIELDS.map((field) => [field, this[field]])
158
- );
138
+ sourceOptions: {
139
+ handler(changeOption) {
140
+ this.$root.$emit("record-list-option", changeOption);
159
141
  }
160
142
  },
161
- watch: {
162
- value: {
163
- handler(value) {
164
- if (!value) {
165
- return;
166
- }
167
- CONFIG_FIELDS.forEach((field) => (this[field] = value[field]));
168
- },
169
- immediate: true
170
- },
171
- sourceOptions: {
172
- handler(changeOption) {
173
- this.$root.$emit("record-list-option", changeOption);
174
- }
143
+ collectionFields: {
144
+ handler(collectionFieldsData) {
145
+ this.getCollectionColumns(collectionFieldsData);
146
+ this.$root.$emit("record-list-collection", collectionFieldsData);
175
147
  },
176
- collectionFields: {
177
- handler(collectionFieldsData) {
178
- this.getCollectionColumns(collectionFieldsData);
179
- this.$root.$emit("record-list-collection", collectionFieldsData);
180
- },
181
- deep: true
148
+ deep: true
149
+ },
150
+ pmql: {
151
+ handler(newPmql) {
152
+ this.$root.$emit("change-pmql", newPmql);
153
+ }
154
+ },
155
+ submitCollectionCheck(newValue) {
156
+ this.submitCollectionCheck = newValue;
157
+ },
158
+ options: {
159
+ handler() {
160
+ this.$emit("input", this.options);
182
161
  },
183
- pmql: {
184
- handler(newPmql) {
185
- this.$root.$emit("change-pmql", newPmql);
162
+ deep: true
163
+ },
164
+ dataSelectionOptions() {
165
+ this.singleField = null;
166
+ }
167
+ },
168
+ mounted() {
169
+ this.$root.$emit("record-list-option", this.sourceOptions);
170
+ },
171
+ methods: {
172
+ displayOptionChange() {
173
+ this.collectionFields = [];
174
+ this.collectionFieldsColumns = [];
175
+ this.pmql = null;
176
+ this.$root.$emit("collection-changed", true);
177
+ },
178
+ collectionChanged(data) {
179
+ if (Array.isArray(data)) {
180
+ const [firstItem] = data;
181
+ const collectionId = firstItem?.collection_id;
182
+ if (collectionId !== this.collectionFields.collectionId) {
183
+ this.$root.$emit("collection-changed", true);
186
184
  }
187
- },
188
- submitCollectionCheck(newValue) {
189
- this.submitCollectionCheck = newValue;
190
- },
191
- options: {
192
- handler() {
193
- this.$emit("input", this.options);
194
- },
195
- deep: true
196
- },
197
- dataSelectionOptions() {
198
- this.singleField = null;
199
185
  }
200
186
  },
201
- };
202
- </script>
187
+ getCollectionColumns(records) {
188
+ const [firstRecord] = records?.dataRecordList || [];
189
+
190
+ if (firstRecord?.data) {
191
+ const dataObject = firstRecord.data;
192
+
193
+ for (const [key] of Object.entries(dataObject)) {
194
+ this.singleFieldOptions.push({ text: key, value: key });
195
+ }
196
+ }
197
+ }
198
+ }
199
+ };
200
+ </script>
@@ -1,86 +1,68 @@
1
1
  <template>
2
2
  <div>
3
3
  <div>
4
- <label for="collectionmode">{{ $t("Mode") }}</label>
4
+ <label for="collection-mode">{{ $t(label) }}</label>
5
5
  <b-form-select
6
- id="collectionmode"
7
- v-model="modeId"
8
- :options="displayOptions"
6
+ id="collection-mode"
7
+ v-model="mode"
8
+ :options="options"
9
9
  data-cy="inspector-collection"
10
+ @change="saveFields"
10
11
  />
11
12
  </div>
12
- <div class="mt-2" v-if="modeId !== 'View'">
13
- <b-form-checkbox v-model="submitCollectionCheck">
14
- {{ $t("Update collection on submit") }}
13
+ <div v-show="showCollectionCheck" class="mt-2">
14
+ <b-form-checkbox v-model="submitCollectionCheck" @change="saveFields">
15
+ {{ $t("Update collection on submit") }}
15
16
  </b-form-checkbox>
16
17
  </div>
17
18
  </div>
18
19
  </template>
19
20
 
20
21
  <script>
21
- import ScreenVariableSelector from "../screen-variable-selector.vue";
22
-
23
- const CONFIG_FIELDS = ["modeId", "submitCollectionCheck"];
24
22
  export default {
25
- components: {
26
- ScreenVariableSelector
23
+ props: {
24
+ value: {
25
+ type: Object,
26
+ default: () => ({})
27
+ },
28
+ screenType: {
29
+ type: String,
30
+ default: ""
31
+ },
32
+ options: {
33
+ type: Array,
34
+ default: () => []
35
+ },
36
+ label: {
37
+ type: String,
38
+ default: ""
39
+ }
27
40
  },
28
- props: ["value", "screenType"],
29
41
  data() {
30
42
  return {
31
- fields: [],
32
- modeId: null,
33
- submitCollectionCheck: true,
34
- displayOptions: []
43
+ mode: "",
44
+ submitCollectionCheck: null
35
45
  };
36
46
  },
37
- mounted() {
38
- this.getFields();
39
- },
40
47
  computed: {
41
- options() {
42
- return Object.fromEntries(
43
- CONFIG_FIELDS.map((field) => [field, this[field]])
44
- );
48
+ showCollectionCheck() {
49
+ return this.mode === "Edit";
45
50
  }
46
51
  },
47
- watch: {
48
- value: {
49
- handler(value) {
50
- if (!value) {
51
- return;
52
- }
53
- CONFIG_FIELDS.forEach((field) => (this[field] = value[field]));
54
- },
55
- immediate: true
56
- },
57
- modeId: {
58
- handler() {
59
- this.getFields();
60
- }
61
- },
62
- submitCollectionCheck(newValue) {
63
- this.submitCollectionCheck = newValue;
64
- },
65
- screenType: {
66
- handler() {
67
- this.getFields();
68
- },
69
- immediate: true
70
- },
71
- options: {
72
- handler() {
73
- this.$emit("input", this.options);
74
- },
75
- deep: true
76
- }
52
+ mounted() {
53
+ // Set the defaulta data
54
+ this.mode = this.value.modeId || "Edit";
55
+ this.submitCollectionCheck =
56
+ this.value.submitCollectionCheck !== undefined
57
+ ? this.value.submitCollectionCheck
58
+ : true;
77
59
  },
78
60
  methods: {
79
- getFields() {
80
- this.displayOptions = [
81
- { value: "Edit", text: "Edit" },
82
- { value: "View", text: "View" }
83
- ];
61
+ saveFields() {
62
+ this.$emit("input", {
63
+ modeId: this.mode,
64
+ submitCollectionCheck: this.submitCollectionCheck
65
+ });
84
66
  }
85
67
  }
86
68
  };
@@ -360,10 +360,9 @@ export default {
360
360
  mounted() {
361
361
  this.initData();
362
362
  this.$root.$on("record-list-option", (val) => {
363
- this.$nextTick(()=>{
364
- this.isCollection = (val === "Collection") ? true : false;
363
+ this.$nextTick(() => {
364
+ this.isCollection = val === "Collection";
365
365
  });
366
-
367
366
  });
368
367
  this.$root.$on("record-list-collection", (collectionData) => {
369
368
  this.getCollectionColumns(collectionData);
@@ -28,7 +28,7 @@
28
28
  </div>
29
29
  <label class="mt-3" for="option-content">{{ $t('Content') }}</label>
30
30
  <b-form-input id="option-content" v-model="optionContent" data-cy="inspector-option-content" />
31
-
31
+
32
32
  <label v-if="renderAs === 'checkbox'" class="mt-3" for="option-aria-label">{{ $t('Aria Label') }}</label>
33
33
  <b-form-input v-if="renderAs === 'checkbox'" id="option-aria-label" v-model="optionAriaLabel" data-cy="inspector-option-aria-label" />
34
34
  </div>
@@ -294,6 +294,7 @@ export default {
294
294
  endpoints: {},
295
295
  pmqlQuery: '',
296
296
  optionsList: [],
297
+ optionsListExtra: [],
297
298
  showOptionCard: false,
298
299
  showRemoveWarning: false,
299
300
  showJsonEditor: false,
@@ -401,6 +402,14 @@ export default {
401
402
  this.selectedEndPoint = this.endPointList[0].value;
402
403
  }
403
404
  },
405
+ renderAs(val) {
406
+ if (this.dataSource === 'provideData') {
407
+ if (val !== 'dropdown') {
408
+ // add aria label field when renderAs is not dropdown
409
+ this.optionsListExtra = this.optionsList.map(option => ({...option, [this.ariaLabelField]: ''}));
410
+ }
411
+ }
412
+ }
404
413
  },
405
414
  computed: {
406
415
  showTypeOfValueReturned() {
@@ -460,6 +469,7 @@ export default {
460
469
  defaultOptionKey: this.defaultOptionKey,
461
470
  selectedOptions: this.selectedOptions,
462
471
  optionsList: this.optionsList,
472
+ optionsListExtra: this.optionsListExtra,
463
473
  showRenderAs: this.showRenderAs,
464
474
  renderAs: this.renderAs,
465
475
  allowMultiSelect: this.allowMultiSelect,
@@ -492,6 +502,7 @@ export default {
492
502
  this.defaultOptionKey= this.options.defaultOptionKey;
493
503
  this.selectedOptions = this.options.selectedOptions;
494
504
  this.optionsList = this.options.optionsList ? this.options.optionsList : [];
505
+ this.optionsListExtra = this.options.optionsListExtra ? this.options.optionsListExtra : [];
495
506
  this.jsonData = JSON.stringify(this.optionsList);
496
507
  this.showRenderAs = this.options.showRenderAs;
497
508
  this.renderAs = this.options.renderAs;
@@ -590,7 +601,7 @@ export default {
590
601
  this.optionContent = this.optionsList[index][this.valueField];
591
602
  this.optionValue = this.optionsList[index][this.keyField];
592
603
  if (this.renderAs === "checkbox") {
593
- this.optionAriaLabel = this.optionsList[index][this.ariaLabelField];
604
+ this.optionAriaLabel = this.optionsListExtra[index][this.ariaLabelField];
594
605
  }
595
606
  this.optionError = '';
596
607
  },
@@ -611,17 +622,16 @@ export default {
611
622
  this.optionError = 'An item with the same key already exists';
612
623
  return;
613
624
  }
614
- if (this.renderAs === "checkbox") {
615
- this.optionsList.push({
625
+ const newOption = {
616
626
  [this.valueField]: this.optionContent,
617
627
  [this.keyField]: this.optionValue,
618
- [this.ariaLabelField]: this.optionAriaLabel
619
- });
628
+ };
629
+ if (this.renderAs === "checkbox") {
630
+ this.optionsList.push(newOption);
631
+ this.optionsListExtra.push({...newOption, [this.ariaLabelField]: this.optionAriaLabel});
632
+
620
633
  } else {
621
- this.optionsList.push({
622
- [this.valueField]: this.optionContent,
623
- [this.keyField]: this.optionValue
624
- });
634
+ this.optionsList.push(newOption);
625
635
  }
626
636
  } else {
627
637
  if (this.optionsList.find((item, index) => { return item[that.keyField] === this.optionValue && index !== this.editIndex ; })) {
@@ -631,7 +641,7 @@ export default {
631
641
  this.optionsList[this.editIndex][this.keyField] = this.optionValue;
632
642
  this.optionsList[this.editIndex][this.valueField] = this.optionContent;
633
643
  if (this.renderAs === "checkbox") {
634
- this.optionsList[this.editIndex][this.ariaLabelField] = this.optionAriaLabel;
644
+ this.optionsListExtra[this.editIndex] = {...this.optionsList[this.editIndex], [this.ariaLabelField]: this.optionAriaLabel};
635
645
  }
636
646
  }
637
647