@processmaker/screen-builder 2.21.1 → 2.22.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-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@processmaker/screen-builder",
3
- "version": "2.21.1",
3
+ "version": "2.22.0",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -1738,9 +1738,9 @@
1738
1738
  }
1739
1739
  },
1740
1740
  "@processmaker/vue-form-elements": {
1741
- "version": "0.28.2",
1742
- "resolved": "https://registry.npmjs.org/@processmaker/vue-form-elements/-/vue-form-elements-0.28.2.tgz",
1743
- "integrity": "sha512-oHFBh/BTfsUmE6RXpTVbi+UfzIKdRBJWwXs2xz/N3I2e8EyQZBotOoK6uq6TsavttLZ2wm4LWKJ9kHygI3FnGw==",
1741
+ "version": "0.28.5",
1742
+ "resolved": "https://registry.npmjs.org/@processmaker/vue-form-elements/-/vue-form-elements-0.28.5.tgz",
1743
+ "integrity": "sha512-vnThQAH0TI/ZSMl4GPQA8H+AooPyv65RZnQzaBEWKUeFSpdwFFUJUIc1lMH4ji4L3qKPBEy/qQFhB541QFeh2w==",
1744
1744
  "dev": true,
1745
1745
  "requires": {
1746
1746
  "@tinymce/tinymce-vue": "2.0.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@processmaker/screen-builder",
3
- "version": "2.21.1",
3
+ "version": "2.22.0",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
@@ -44,7 +44,7 @@
44
44
  "@cypress/code-coverage": "^3.8.1",
45
45
  "@fortawesome/fontawesome-free": "^5.6.1",
46
46
  "@panter/vue-i18next": "^0.15.2",
47
- "@processmaker/vue-form-elements": "0.28.2",
47
+ "@processmaker/vue-form-elements": "0.28.5",
48
48
  "@processmaker/vue-multiselect": "^2.2.0",
49
49
  "@vue/cli-plugin-babel": "^3.6.0",
50
50
  "@vue/cli-plugin-e2e-cypress": "^4.0.3",
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "peerDependencies": {
87
87
  "@panter/vue-i18next": "^0.15.0",
88
- "@processmaker/vue-form-elements": "0.28.1",
88
+ "@processmaker/vue-form-elements": "0.28.5",
89
89
  "i18next": "^15.0.8",
90
90
  "vue": "^2.6.12",
91
91
  "vuex": "^3.1.1"
@@ -167,19 +167,8 @@ class FormElementValidations extends Validations {
167
167
  }
168
168
  const fieldName = this.element.config.name;
169
169
  const validationConfig = this.element.config.validation;
170
+ const conditionalHide = this.element.config.conditionalHide;
170
171
 
171
- // Disable validations if field is hidden
172
- if (this.element.config.conditionalHide) {
173
- let visible = true;
174
- try {
175
- visible = !!Parser.evaluate(this.element.config.conditionalHide, this.data);
176
- } catch (error) {
177
- visible = false;
178
- }
179
- if (!visible) {
180
- return;
181
- }
182
- }
183
172
 
184
173
  set(validations, fieldName, get(validations, fieldName, {}));
185
174
  const fieldValidation = get(validations, fieldName);
@@ -203,7 +192,22 @@ class FormElementValidations extends Validations {
203
192
  params.push(fieldName);
204
193
  validationFn = validationFn(...params);
205
194
  }
206
- fieldValidation[rule] = validationFn;
195
+ fieldValidation[rule] = function(...props) {
196
+ const data = props[1];
197
+ const dataWithParent = this.addReferenceToParents(data);
198
+ let visible = true;
199
+ if (conditionalHide) {
200
+ try {
201
+ visible = !!Parser.evaluate(conditionalHide, dataWithParent);
202
+ } catch (error) {
203
+ visible = false;
204
+ }
205
+ }
206
+ if (!visible) {
207
+ return true;
208
+ }
209
+ return validationFn.apply(this,props);
210
+ };
207
211
  });
208
212
  } else if (typeof validationConfig === 'string' && validationConfig) {
209
213
  let validationFn = validators[validationConfig];
@@ -212,7 +216,22 @@ class FormElementValidations extends Validations {
212
216
  console.error(`Undefined validation rule "${validationConfig}"`);
213
217
  return;
214
218
  }
215
- fieldValidation[validationConfig] = validationFn;
219
+ fieldValidation[validationConfig] = function(...props) {
220
+ const data = props[1];
221
+ const dataWithParent = this.addReferenceToParents(data);
222
+ let visible = true;
223
+ if (conditionalHide) {
224
+ try {
225
+ visible = !!Parser.evaluate(conditionalHide, dataWithParent);
226
+ } catch (error) {
227
+ visible = false;
228
+ }
229
+ }
230
+ if (!visible) {
231
+ return true;
232
+ }
233
+ return validationFn.apply(this,props);
234
+ };
216
235
  }
217
236
  if (this.element.items) {
218
237
  ValidationsFactory(this.element.items, { screen: this.screen, data: this.data }).addValidations(validations);
@@ -74,6 +74,7 @@
74
74
  :title="$t('Add')"
75
75
  header-close-content="×"
76
76
  data-cy="modal-add"
77
+ @shown="emitShownEvent"
77
78
  >
78
79
  <vue-form-renderer
79
80
  :page="0"
@@ -99,6 +100,7 @@
99
100
  :title="$t('Edit Record')"
100
101
  header-close-content="&times;"
101
102
  data-cy="modal-edit"
103
+ @shown="emitShownEvent"
102
104
  >
103
105
  <vue-form-renderer
104
106
  :page="0"
@@ -259,6 +261,9 @@ export default {
259
261
  },
260
262
  },
261
263
  methods: {
264
+ emitShownEvent() {
265
+ window.ProcessMaker.EventBus.$emit('modal-shown');
266
+ },
262
267
  formatIfDate(string) {
263
268
  return dateUtils.formatIfDate(string);
264
269
  },
@@ -96,7 +96,8 @@ export const keyNameProperty = {
96
96
  config: {
97
97
  label: 'Variable Name',
98
98
  name: 'Variable Name',
99
- validation: 'regex:/^(?:[A-Za-z])(?:[0-9A-Z_.a-z])*[^.]$/|required|not_in:' + javascriptReservedKeywords,
99
+ // Update tests/e2e/specs/Builder.spec.js when changing this
100
+ validation: 'regex:/^([a-zA-Z]([a-zA-Z0-9_]?)+\\.?)+(?<!\\.)$/|required|not_in:' + javascriptReservedKeywords,
100
101
  helper: 'A variable name is a symbolic name to reference information.',
101
102
  },
102
103
  };
@@ -102,7 +102,15 @@ export default {
102
102
  },
103
103
  mustache(text) {
104
104
  try {
105
- const data = Object.assign({_parent: this._parent}, this.vdata);
105
+ const data = new Proxy(this, {
106
+ get(target, name) {
107
+ if (name === '_parent') {
108
+ return target._parent;
109
+ } else {
110
+ return target.vdata[name];
111
+ }
112
+ },
113
+ });
106
114
  return text && Mustache.render(text, data);
107
115
  } catch (e) {
108
116
  return 'MUSTACHE: ' + e.message;
@@ -23,6 +23,7 @@ import {
23
23
  and,
24
24
  maxItems,
25
25
  minItems,
26
+ type,
26
27
  } from 'vuelidate/lib/validators';
27
28
 
28
29
  export const ValidationMsg = {
@@ -59,6 +60,7 @@ export const ValidationMsg = {
59
60
  regex: 'Invalid value',
60
61
  maxItems: 'Should NOT have more than {max} items',
61
62
  minItems: 'Must have at least {min}',
63
+ type: 'Invalid type',
62
64
  };
63
65
 
64
66
  export const custom_date = (date) => {
@@ -231,4 +233,5 @@ export const validators = {
231
233
  afterOrEqual: after_or_equal,
232
234
  maxItems,
233
235
  minItems,
236
+ type,
234
237
  };
@@ -35,11 +35,7 @@ export default {
35
35
  get: new Function(`return this.tryFormField(${JSON.stringify(name)}, () => ${value});`),
36
36
  set() {},
37
37
  };
38
-
39
- // Do not reset default values on nested objects after a data has changed
40
- const watchOptions = { deep: false };
41
-
42
- this.addWatch(screen, defaultComputedName, `!this.${name}_was_filled__ && this.setValue(${JSON.stringify(name)}, this.${defaultComputedName}, this.vdata, this);`, watchOptions);
38
+ this.addWatch(screen, defaultComputedName, `!this.${name}_was_filled__ && this.setValue(${JSON.stringify(name)}, this.${defaultComputedName}, this.vdata, this);`);
43
39
  },
44
40
  },
45
41
  mounted() {