@processmaker/screen-builder 3.2.1 → 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.1",
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,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
  };
@@ -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
 
@@ -1,9 +1,9 @@
1
1
  <template>
2
2
  <vue-form-renderer
3
3
  ref="collectionRecordControl"
4
+ v-model="data"
4
5
  class="form-collection-record-control"
5
6
  :placeholder="placeholder"
6
- v-model="data"
7
7
  mode="preview"
8
8
  :config="validatedConfig"
9
9
  :computed="computed"
@@ -14,9 +14,9 @@
14
14
  </template>
15
15
 
16
16
  <script>
17
+ import _ from "lodash";
17
18
  import VueFormRenderer from "../vue-form-renderer.vue";
18
19
  import CollectionRecordsList from "../inspector/collection-records-list.vue";
19
- import _ from 'lodash';
20
20
 
21
21
  const globalObject = typeof window === "undefined" ? global : window;
22
22
 
@@ -43,7 +43,7 @@ export default {
43
43
  collectionmode: {
44
44
  type: Object
45
45
  },
46
- taskdraft: Object,
46
+ taskdraft: Object
47
47
  },
48
48
  data() {
49
49
  return {
@@ -55,7 +55,7 @@ export default {
55
55
  screenTitle: null,
56
56
  selCollectionId: Number,
57
57
  selRecordId: Number,
58
- selDisplayMode: String,
58
+ selDisplayMode: "Edit",
59
59
  screenCollectionId: null,
60
60
  placeholder: "Select a collection",
61
61
  screenType: "",
@@ -72,21 +72,91 @@ export default {
72
72
  },
73
73
  data: {
74
74
  get() {
75
- if(this.hasMustache) {
75
+ if (this.hasMustache) {
76
76
  this.clearDataObject();
77
77
  }
78
78
  return this.localData;
79
79
  },
80
80
  set(data) {
81
81
  Object.keys(data).forEach((variable) => {
82
- this.validationData && this.$set(this.validationData, variable, data[variable]);
82
+ this.validationData &&
83
+ this.$set(this.validationData, variable, data[variable]);
83
84
  });
84
85
  if (this.collection) {
85
- this.$set(this.collection, 'data', Array.isArray(data) ? data : [data]);
86
- this.$set(this.collection, 'screen', this.screenCollectionId);
86
+ this.$set(
87
+ this.collection,
88
+ "data",
89
+ Array.isArray(data) ? data : [data]
90
+ );
91
+ this.$set(this.collection, "screen", this.screenCollectionId);
87
92
  }
88
- },
93
+ }
94
+ }
95
+ },
96
+ watch: {
97
+ collection(collection) {
98
+ if (collection) {
99
+ this.selCollectionId = collection.collectionId;
100
+ const currentData = this.localData;
101
+ this.$set(
102
+ collection,
103
+ "data",
104
+ Array.isArray(currentData) ? currentData : [currentData]
105
+ );
106
+ this.$set(collection, "screen", this.screenCollectionId);
107
+ }
89
108
  },
109
+ record(record) {
110
+ this.hasMustache = false;
111
+ this.enableDraft = false;
112
+ if (
113
+ record &&
114
+ !isNaN(record) &&
115
+ record > 0 &&
116
+ this.collection.collectionId
117
+ ) {
118
+ this.selRecordId = record;
119
+ this.loadRecordCollection(
120
+ this.collection.collectionId,
121
+ record,
122
+ this.selDisplayMode
123
+ );
124
+ } else {
125
+ if (this.isMustache(record)) {
126
+ this.callbackRecord();
127
+ }
128
+ this.localData = {};
129
+ }
130
+ },
131
+ collectionmode(collectionmode) {
132
+ if (collectionmode) {
133
+ this.selDisplayMode = collectionmode.modeId;
134
+ }
135
+ this.loadRecordCollection(
136
+ this.selCollectionId,
137
+ this.selRecordId,
138
+ this.selDisplayMode
139
+ );
140
+ }
141
+ },
142
+ mounted() {
143
+ this.$root.$on("taskdraft-input", (val) => {
144
+ this.taskDraft = val;
145
+ });
146
+
147
+ if (this.collection && this.record) {
148
+ const recordId = this.isMustache(this.record)
149
+ ? this.defaultColumnsRecordId
150
+ : this.record;
151
+ if (this.isMustache(this.record)) {
152
+ this.hasMustache = true;
153
+ }
154
+ this.loadRecordCollection(
155
+ this.collection.collectionId,
156
+ recordId,
157
+ this.collectionmode.modeId
158
+ );
159
+ }
90
160
  },
91
161
  methods: {
92
162
  isSubmitButton(item) {
@@ -98,17 +168,17 @@ export default {
98
168
  },
99
169
  hideSubmitButtons(config) {
100
170
  config.forEach((item) => {
101
- //If the element has containers
171
+ // If the element has containers
102
172
  if (Array.isArray(item)) {
103
173
  this.hideSubmitButtons(item);
104
174
  }
105
175
 
106
- //If the element has items
176
+ // If the element has items
107
177
  if (item.items) {
108
178
  this.hideSubmitButtons(item.items);
109
179
  }
110
180
 
111
- //hidden buttons
181
+ // hidden buttons
112
182
  if (this.isSubmitButton(item)) {
113
183
  item.config.hidden = true;
114
184
  }
@@ -116,17 +186,17 @@ export default {
116
186
  },
117
187
  disableForm(config) {
118
188
  config.forEach((item) => {
119
- //If the element has containers
189
+ // If the element has containers
120
190
  if (Array.isArray(item)) {
121
191
  this.disableForm(item);
122
192
  }
123
193
 
124
- //If the element has items
194
+ // If the element has items
125
195
  if (item.items) {
126
196
  this.disableForm(item.items);
127
197
  }
128
198
 
129
- //Disable element
199
+ // Disable element
130
200
  if (item && item.config) {
131
201
  item.config.disabled = true;
132
202
  item.config.readonly = true;
@@ -149,7 +219,7 @@ export default {
149
219
  this.watchers = response.data.watchers;
150
220
  this.screenTitle = response.data.title;
151
221
 
152
- if (this.$attrs["disabled"]) {
222
+ if (this.$attrs.disabled) {
153
223
  this.disableForm(this.config);
154
224
  }
155
225
  });
@@ -174,81 +244,50 @@ export default {
174
244
  const respData = response.data;
175
245
  const viewScreen = response.collection.read_screen_id;
176
246
  const editScreen = response.collection.update_screen_id;
177
- //Choose screen id regarding of the display Mode
178
- this.screenCollectionId =
179
- typeof this.selDisplayMode === 'function' ?
180
- (this.collectionmode.modeId === "View" ? viewScreen : editScreen) :
181
- (this.selDisplayMode === "View" ? viewScreen : editScreen);
247
+ // Choose screen id regarding of the display Mode
248
+ this.screenCollectionId =
249
+ typeof this.selDisplayMode === "function"
250
+ ? this.collectionmode.modeId === "View"
251
+ ? viewScreen
252
+ : editScreen
253
+ : this.selDisplayMode === "View"
254
+ ? viewScreen
255
+ : editScreen;
182
256
  this.loadScreen(this.screenCollectionId);
183
-
184
- //This section validates if Collection has draft data
185
- if (this.taskDraft?.draft?.data == null || this.taskDraft.draft.data === '' || !this.enableDraft)
186
- {
257
+
258
+ // This section validates if Collection has draft data
259
+ if (
260
+ this.taskDraft?.draft?.data == null ||
261
+ this.taskDraft.draft.data === "" ||
262
+ !this.enableDraft
263
+ ) {
187
264
  this.localData = respData;
188
- }else{
265
+ } else {
189
266
  this.localData = _.merge({}, respData, this.taskDraft.draft.data);
190
267
  }
191
-
192
268
  })
193
269
  .catch(() => {
194
270
  this.localData = {};
195
- globalObject.ProcessMaker.alert(this.$t('This content does not exist. We could not locate indicated data'), "danger");
271
+ globalObject.ProcessMaker.alert(
272
+ this.$t(
273
+ "This content does not exist. We could not locate indicated data"
274
+ ),
275
+ "danger"
276
+ );
196
277
  this.placeholder = "Select a collection";
197
- });;
278
+ });
198
279
  },
199
280
  isMustache(record) {
200
281
  return /\{\{.*\}\}/.test(record);
201
282
  },
202
283
  clearDataObject() {
203
- Object.keys(this.localData).forEach(key => {
284
+ Object.keys(this.localData).forEach((key) => {
204
285
  if (key !== "id") {
205
286
  this.localData[key] = "";
206
287
  }
207
288
  });
208
- },
209
- },
210
- watch: {
211
- collection(collection) {
212
- if(collection) {
213
- this.selCollectionId = collection.collectionId;
214
- const currentData = this.localData;
215
- this.$set(collection, 'data', Array.isArray(currentData) ? currentData : [currentData]);
216
- this.$set(collection, 'screen', this.screenCollectionId);
217
- }
218
- },
219
- record(record) {
220
- this.hasMustache = false;
221
- this.enableDraft = false;
222
- if (record && !isNaN(record) && record > 0 && this.collection.collectionId) {
223
- this.selRecordId = record;
224
- this.loadRecordCollection(this.collection.collectionId, record, this.selDisplayMode);
225
- } else {
226
- if (this.isMustache(record)) {
227
- this.callbackRecord();
228
- }
229
- this.localData = {};
230
- }
231
- },
232
- collectionmode(collectionmode) {
233
- if(collectionmode) {
234
- this.selDisplayMode = collectionmode.modeId;
235
- }
236
- this.loadRecordCollection(this.selCollectionId, this.selRecordId, this.selDisplayMode);
237
- },
238
- },
239
- mounted() {
240
- this.$root.$on("taskdraft-input", (val)=>{
241
- this.taskDraft = val;
242
- });
243
-
244
- if (this.collection && this.record) {
245
- const recordId = this.isMustache(this.record) ? this.defaultColumnsRecordId : this.record;
246
- if(this.isMustache(this.record)) {
247
- this.hasMustache = true;
248
- }
249
- this.loadRecordCollection(this.collection.collectionId, recordId, this.collectionmode.modeId);
250
289
  }
251
- },
290
+ }
252
291
  };
253
292
  </script>
254
293
 
@@ -250,6 +250,7 @@ export default {
250
250
  this.renderComponent = 'simpleErrorMessage';
251
251
  },
252
252
  loadScreen(id) {
253
+ this.disabled = true;
253
254
  let query = '?include=nested';
254
255
  if (this.requestId) {
255
256
  query += '&request_id=' + this.requestId;
@@ -257,6 +258,7 @@ export default {
257
258
 
258
259
  this.$dataProvider.getScreen(id, query).then((response) => {
259
260
  this.screen = response.data;
261
+ this.disabled = false;
260
262
  });
261
263
  },
262
264
  reload() {
@@ -329,7 +329,7 @@
329
329
  : null
330
330
  "
331
331
  @focusout.native="updateState"
332
-
332
+
333
333
  />
334
334
  </div>
335
335
  </div>
@@ -568,9 +568,10 @@ const globalObject = typeof window === "undefined" ? global : window;
568
568
  if (
569
569
  globalObject.ProcessMaker &&
570
570
  globalObject.ProcessMaker.user &&
571
- globalObject.ProcessMaker.user.lang
571
+ globalObject.ProcessMaker.user.lang &&
572
+ typeof globalObject.ProcessMaker.setValidatorLanguage === 'function'
572
573
  ) {
573
- Validator.useLang(globalObject.ProcessMaker.user.lang);
574
+ globalObject.ProcessMaker.setValidatorLanguage(Validator, globalObject.ProcessMaker.user.lang);
574
575
  }
575
576
 
576
577
  // Todo: Validation messages are not translated. These will need to be converted
@@ -1476,8 +1477,12 @@ export default {
1476
1477
  }
1477
1478
 
1478
1479
  // Generate Variable Name
1480
+ const keyNamePropertyToFind = _.cloneDeep(keyNameProperty);
1481
+ delete keyNamePropertyToFind.config.helper;
1482
+ delete keyNamePropertyToFind.config.label;
1483
+
1479
1484
  if (
1480
- _.findIndex(control.inspector, keyNameProperty) !== -1 ||
1485
+ _.findIndex(control.inspector, keyNamePropertyToFind) !== -1 ||
1481
1486
  control.component === "FormLoop"
1482
1487
  ) {
1483
1488
  [this.variables, copy.config.name] = this.generator.generate(
@@ -1157,6 +1157,10 @@ export default [
1157
1157
  field: "collectionmode",
1158
1158
  config: {
1159
1159
  label: "Mode",
1160
+ options: [
1161
+ { value: "Edit", text: "Edit" },
1162
+ { value: "View", text: "View" },
1163
+ ]
1160
1164
  }
1161
1165
  },
1162
1166
  ],
package/src/main.js CHANGED
@@ -163,6 +163,9 @@ window.ProcessMaker = {
163
163
  app: {
164
164
  url: `${protocol}//${hostname}:${port}` // Create a URL with the current port
165
165
  },
166
+ setValidatorLanguage(language) {
167
+ window.ProcessMaker.user.lang = 'en';
168
+ },
166
169
  apiClient: {
167
170
  create() {
168
171
  return this;