@processmaker/screen-builder 2.76.0 → 2.76.1

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": "2.76.0",
3
+ "version": "2.76.1",
4
4
  "scripts": {
5
5
  "serve": "vue-cli-service serve",
6
6
  "build": "vue-cli-service build",
@@ -39,7 +39,7 @@
39
39
  "@cypress/code-coverage": "^3.8.1",
40
40
  "@fortawesome/fontawesome-free": "^5.6.1",
41
41
  "@panter/vue-i18next": "^0.15.2",
42
- "@processmaker/vue-form-elements": "0.49.1",
42
+ "@processmaker/vue-form-elements": "0.49.2",
43
43
  "@processmaker/vue-multiselect": "^2.2.0",
44
44
  "@vue/cli-plugin-babel": "^3.6.0",
45
45
  "@vue/cli-plugin-e2e-cypress": "^4.0.3",
@@ -88,7 +88,7 @@
88
88
  },
89
89
  "peerDependencies": {
90
90
  "@panter/vue-i18next": "^0.15.0",
91
- "@processmaker/vue-form-elements": "0.49.1",
91
+ "@processmaker/vue-form-elements": "0.49.2",
92
92
  "i18next": "^15.0.8",
93
93
  "vue": "^2.6.12",
94
94
  "vuex": "^3.1.1"
package/src/.DS_Store CHANGED
Binary file
@@ -36,6 +36,14 @@ class Validations {
36
36
  */
37
37
  isVisible() {
38
38
  // Disable validations if field is hidden
39
+ const visibleInDevice =
40
+ this.element.visibleInDevice === null || this.element.visibleInDevice === undefined
41
+ ? true
42
+ : this.element.visibleInDevice;
43
+ if (!visibleInDevice) {
44
+ return false;
45
+ }
46
+
39
47
  let visible = true;
40
48
  if (this.element.config.conditionalHide) {
41
49
  try {
@@ -177,13 +185,13 @@ class FormLoopValidations extends Validations {
177
185
  });
178
186
 
179
187
  if (Object.keys(siblingValidations).length != 0) {
180
- // Update the loop validations with its siblings.
188
+ // Update the loop validations with its siblings.
181
189
  const loopValidations = get(validations, this.element.config.name);
182
190
  if (loopValidations.hasOwnProperty('$each')) {
183
- merge(loopValidations['$each'], siblingValidations);
191
+ merge(loopValidations['$each'], siblingValidations);
184
192
  }
185
193
  set(validations[this.element.config.name]['$each'], loopValidations);
186
- }
194
+ }
187
195
  }
188
196
  camelCase(name) {
189
197
  return name.replace(/_\w/g, m => m.substr(1, 1).toUpperCase());
@@ -249,6 +257,9 @@ class FormElementValidations extends Validations {
249
257
  const conditionalHide = this.element.config.conditionalHide;
250
258
  const parentVisibilityRule = this.parentVisibilityRule;
251
259
  const insideLoop = this.insideLoop || false;
260
+ const deviceConfig = this.element.config.deviceVisibility
261
+ ? this.element.config.deviceVisibility
262
+ : { showForDesktop: true, showForMobile: true };
252
263
 
253
264
  set(validations, fieldName, get(validations, fieldName, {}));
254
265
  const fieldValidation = get(validations, fieldName);
@@ -280,7 +291,7 @@ class FormElementValidations extends Validations {
280
291
  const parentDataWithParent = this.getDataAccordingToFieldLevel(this.getRootScreen().addReferenceToParents(data), level + nextParentLevel);
281
292
  let isParentVisible = true;
282
293
  try {
283
- isParentVisible = !!Parser.evaluate(parentVisibilityRule, parentDataWithParent);
294
+ isParentVisible = !!Parser.evaluate(parentVisibilityRule, parentDataWithParent);
284
295
  } catch (error) {
285
296
  isParentVisible = false;
286
297
  }
@@ -289,6 +300,21 @@ class FormElementValidations extends Validations {
289
300
  return true;
290
301
  }
291
302
  }
303
+
304
+ // Check Device Visibility
305
+ let visibleInDevice = true;
306
+ try {
307
+ const isMobileScreen = this.$root.$children[0].$refs.renderer.definition.isMobile;
308
+ visibleInDevice =
309
+ (isMobileScreen && deviceConfig.showForMobile) ||
310
+ (!isMobileScreen && deviceConfig.showForDesktop);
311
+ } catch (error) {
312
+ visibleInDevice = true;
313
+ }
314
+ if (!visibleInDevice) {
315
+ return true;
316
+ }
317
+
292
318
  // Check Field Visibility
293
319
  let visible = true;
294
320
  if (conditionalHide) {
@@ -1,23 +1,26 @@
1
- import { Parser } from "expr-eval";
1
+ import { Parser } from 'expr-eval';
2
2
 
3
3
  export default {
4
4
  methods: {
5
5
  visibilityRuleIsVisible(rule, name, deviceVisibility) {
6
- const visibility = deviceVisibility || {showForDesktop: true, showForMobile: true, isMobile: false};
6
+ const visibility = deviceVisibility || { showForDesktop: true, showForMobile: true, isMobile: false };
7
7
  const visibleInDevice =
8
- (visibility.isMobile && visibility.showForMobile) ||
9
- (!visibility.isMobile && visibility.showForDesktop);
8
+ (visibility.isMobile && visibility.showForMobile) || (!visibility.isMobile && visibility.showForDesktop);
10
9
 
11
10
  try {
12
11
  if (rule && rule.trim().length > 0) {
13
12
  const dataWithParent = this.getDataReference();
14
13
  const isVisible = Boolean(Parser.evaluate(rule, dataWithParent));
14
+
15
15
  return isVisible && visibleInDevice;
16
16
  }
17
+
17
18
  return visibleInDevice;
18
19
  } catch (e) {
19
- return visibleInDevice;
20
+ // empty.
20
21
  }
22
+
23
+ return false;
21
24
  }
22
25
  }
23
26
  };
@@ -7,6 +7,11 @@ export default {
7
7
  const visibility = element.config.deviceVisibility || { showForDesktop: true, showForMobile: true }
8
8
  const restrictDeviceVisibility = !visibility.showForDesktop || !visibility.showForMobile;
9
9
 
10
+
11
+ element.visibleInDevice =
12
+ (definition.isMobile && visibility.showForMobile) ||
13
+ (!definition.isMobile && visibility.showForDesktop);
14
+
10
15
  if (element.config.conditionalHide || restrictDeviceVisibility) {
11
16
  const deviceVisibility = JSON.stringify( { ...visibility, isMobile: definition.isMobile } );
12
17
  wrapper.setAttribute(