@processmaker/screen-builder 2.60.0 → 2.60.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.60.0",
3
+ "version": "2.60.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.41.1",
42
+ "@processmaker/vue-form-elements": "0.41.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.41.1",
91
+ "@processmaker/vue-form-elements": "0.41.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
@@ -1,5 +1,74 @@
1
- import { isEqual } from 'lodash';
2
- import { Parser } from 'expr-eval';
1
+ import { Parser } from "expr-eval";
2
+
3
+ /**
4
+ * Gets the screen parent or null if don't have
5
+ * @returns {object|null}
6
+ */
7
+ function findScreenOwner(control) {
8
+ let owner = control.$parent;
9
+ while (owner) {
10
+ const isScreen = owner.$options.name === "ScreenContent";
11
+ const nestedScreen =
12
+ owner.$parent && owner.$parent.$parent && owner.$parent.$parent.$parent;
13
+ const isNestedScreen =
14
+ nestedScreen &&
15
+ nestedScreen.$options._componentTag === "form-nested-screen";
16
+ if (isScreen && !isNestedScreen) {
17
+ return owner;
18
+ }
19
+ if (isNestedScreen) {
20
+ owner = nestedScreen;
21
+ } else {
22
+ owner = owner.$parent;
23
+ }
24
+ }
25
+ return null;
26
+ }
27
+ /**
28
+ * Wrap the data of a control using a Proxy
29
+ * @return {object} proxy
30
+ */
31
+ function wrapScreenData(screen, customFunctions = null) {
32
+ const handler = {
33
+ get: (target, name) => {
34
+ if (customFunctions && customFunctions[name]) {
35
+ return customFunctions[name];
36
+ }
37
+ if (name === "_parent") {
38
+ const screenOwner = findScreenOwner(screen);
39
+ // Get _parent for the current screen (e.g. Inside Loops, Inside Tabs?, RecordLists...?)
40
+ if (screenOwner) {
41
+ return wrapScreenData(screenOwner);
42
+ }
43
+ if (screen.vdata) {
44
+ return screen.vdata._parent;
45
+ }
46
+ return undefined;
47
+ }
48
+ // Check if vdata exists
49
+ if (screen.vdata !== undefined && screen.vdata !== null) {
50
+ return screen.vdata[name];
51
+ }
52
+ return undefined;
53
+ },
54
+ has(target, name) {
55
+ // customFunctions is used by RichText controls
56
+ // to add custom Mustache functions
57
+ if (screen.customFunctions && screen.customFunctions[name]) {
58
+ return true;
59
+ }
60
+ if (name === "_parent") {
61
+ return true;
62
+ }
63
+ // Check if vdata exists
64
+ if (screen.vdata !== undefined && screen.vdata !== null) {
65
+ return screen.vdata[name] !== undefined;
66
+ }
67
+ return false;
68
+ }
69
+ };
70
+ return new Proxy({}, handler);
71
+ }
3
72
 
4
73
  export default {
5
74
  methods: {
@@ -12,22 +81,35 @@ export default {
12
81
  // vdata (external variables)in this way the event is not
13
82
  // executed again when the variable is update
14
83
 
15
- const data = new Proxy({}, {
16
- get(data, name) {
17
- if (self[name] === undefined || !isEqual(self[name], self.vdata[name])) {
18
- return self.vdata[name];
19
- } else {
84
+ const data = new Proxy(
85
+ {},
86
+ {
87
+ get(data, name) {
88
+ if (name === "_parent") {
89
+ // Recursive access to _parent
90
+ const screen = findScreenOwner(self);
91
+ const parentScreen = screen && findScreenOwner(screen);
92
+ if (parentScreen) {
93
+ return wrapScreenData(parentScreen);
94
+ }
95
+ }
96
+ if (self.vdata[name] !== undefined) {
97
+ return self.vdata[name];
98
+ }
20
99
  return self[name];
100
+ },
101
+ set() {
102
+ throw new Error(
103
+ "You are not allowed to set properties from inside an expression"
104
+ );
21
105
  }
22
- },
23
- set() {
24
- throw 'You are not allowed to set properties from inside an expression';
25
- },
26
- });
106
+ }
107
+ );
27
108
 
28
- if (type === 'expression') {
109
+ if (type === "expression") {
29
110
  value = Parser.evaluate(expression, data);
30
111
  } else {
112
+ // eslint-disable-next-line no-new-func
31
113
  value = new Function(expression).bind(data)();
32
114
  }
33
115
 
@@ -36,10 +118,9 @@ export default {
36
118
  }
37
119
 
38
120
  return value;
39
-
40
121
  } catch (e) {
41
- e;
122
+ console.warn("There was a problem evaluating the expression", e);
42
123
  }
43
- },
44
- },
124
+ }
125
+ }
45
126
  };