@processmaker/screen-builder 2.60.1 → 2.60.3

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.1",
3
+ "version": "2.60.3",
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.2",
42
+ "@processmaker/vue-form-elements": "0.41.4",
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.2",
91
+ "@processmaker/vue-form-elements": "0.41.4",
92
92
  "i18next": "^15.0.8",
93
93
  "vue": "^2.6.12",
94
94
  "vuex": "^3.1.1"
@@ -99,6 +99,10 @@ export default {
99
99
  });
100
100
  },
101
101
  getScreen(id, query = "") {
102
+ if (!id) {
103
+ return null;
104
+ }
105
+
102
106
  const cachedPromise = this.cachedScreenPromises.find(
103
107
  (item) => item.id === id && item.query === query
104
108
  );
@@ -89,6 +89,9 @@ class FormNestedScreenValidations extends Validations {
89
89
  }
90
90
 
91
91
  async loadScreen(id) {
92
+ if (!id) {
93
+ return null;
94
+ }
92
95
  if (!globalObject['nestedScreens']) {
93
96
  globalObject['nestedScreens'] = {};
94
97
  }
@@ -99,7 +102,6 @@ class FormNestedScreenValidations extends Validations {
99
102
  globalObject.nestedScreens['id_' + id] = response.data.config;
100
103
  return response.data.config;
101
104
  }
102
-
103
105
  }
104
106
 
105
107
  /**
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Gets the screen parent or null if don't have
3
+ * @returns {object|null}
4
+ */
5
+ function findScreenOwner(control) {
6
+ let owner = control;
7
+ let level = 1;
8
+ while (owner) {
9
+ const isScreen = owner.$options.name === "ScreenContent";
10
+ const isNested = owner.$options.name === "FormNestedScreen";
11
+ if (isScreen) {
12
+ level--;
13
+ }
14
+ if (isNested) {
15
+ level++;
16
+ }
17
+ if (level === -1) {
18
+ return owner;
19
+ }
20
+ owner = owner.$parent;
21
+ }
22
+ return null;
23
+ }
24
+ /**
25
+ * Wrap the data of a control using a Proxy
26
+ * @return {object} proxy
27
+ */
28
+ function wrapScreenData(screen, customProperties = null, setter = null) {
29
+ const handler = {
30
+ get: (target, name) => {
31
+ if (customProperties && customProperties[name]) {
32
+ return customProperties[name];
33
+ }
34
+ if (name === "_parent") {
35
+ if (screen.vdata._parent !== undefined) {
36
+ return screen.vdata._parent;
37
+ }
38
+ const screenOwner = findScreenOwner(screen);
39
+ // Get _parent for the current screen (e.g. Inside Loops, Inside Tabs?, RecordLists...?)
40
+ if (screenOwner && screenOwner !== screen) {
41
+ return wrapScreenData(screenOwner);
42
+ }
43
+ return undefined;
44
+ }
45
+ // Check if vdata exists
46
+ if (screen.vdata !== undefined && screen.vdata !== null) {
47
+ return screen.vdata[name];
48
+ }
49
+ return undefined;
50
+ },
51
+ has(target, name) {
52
+ // customProperties is used by RichText controls
53
+ // to add custom Mustache functions
54
+ if (customProperties && customProperties[name]) {
55
+ return true;
56
+ }
57
+ if (name === "_parent") {
58
+ return true;
59
+ }
60
+ // Check if vdata exists
61
+ if (screen.vdata !== undefined && screen.vdata !== null) {
62
+ return screen.vdata[name] !== undefined;
63
+ }
64
+ return false;
65
+ },
66
+ set(target, name, value) {
67
+ if (setter) {
68
+ setter(screen, name, value);
69
+ }
70
+ }
71
+ };
72
+ return new Proxy({}, handler);
73
+ }
74
+
75
+ export default {
76
+ methods: {
77
+ /**
78
+ * Wrap the data of a control using a Proxy
79
+ * @return {object} proxy
80
+ */
81
+ getDataReference(customProperties = null, setter = null) {
82
+ return wrapScreenData(this, customProperties, setter);
83
+ }
84
+ }
85
+ };
@@ -2,12 +2,14 @@ import { get, isEqual, set } from 'lodash';
2
2
  import Mustache from 'mustache';
3
3
  import { mapActions, mapState } from 'vuex';
4
4
  import { ValidationMsg } from './ValidationRules';
5
+ import DataReference from "./DataReference";
5
6
 
6
7
  const stringFormats = ['string', 'datetime', 'date', 'password'];
7
8
  const parentReference = [];
8
9
 
9
10
  export default {
10
11
  name: "ScreenContent",
12
+ mixins: [DataReference],
11
13
  schema: [
12
14
  function() {
13
15
  if (window.ProcessMaker && window.ProcessMaker.packages && window.ProcessMaker.packages.includes('package-vocabularies')) {
@@ -1,79 +1,8 @@
1
1
  import { Parser } from "expr-eval";
2
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
- }
72
-
73
3
  export default {
74
4
  methods: {
75
5
  evaluateExpression(expression, type) {
76
- const self = this;
77
6
  let value = null;
78
7
 
79
8
  try {
@@ -81,30 +10,11 @@ export default {
81
10
  // vdata (external variables)in this way the event is not
82
11
  // executed again when the variable is update
83
12
 
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
- }
99
- return self[name];
100
- },
101
- set() {
102
- throw new Error(
103
- "You are not allowed to set properties from inside an expression"
104
- );
105
- }
106
- }
107
- );
13
+ const data = this.getDataReference(null, () => {
14
+ throw new Error(
15
+ "You are not allowed to set properties from inside an expression"
16
+ );
17
+ });
108
18
 
109
19
  if (type === "expression") {
110
20
  value = Parser.evaluate(expression, data);
@@ -12,7 +12,7 @@ export default {
12
12
  if (config.defaultValue.mode === 'basic') {
13
13
  this.setupDefaultValue(screen, name, `this.mustache(${JSON.stringify(config.defaultValue.value)})`);
14
14
  } else if (config.defaultValue.mode === 'js') {
15
- this.setupDefaultValue(screen, name, `(function() {${config.defaultValue.value}}).bind(this.vdata)()`);
15
+ this.setupDefaultValue(screen, name, `(function() {${config.defaultValue.value}}).bind(this.getDataReference())()`);
16
16
  }
17
17
  }
18
18
  if ('initiallyChecked' in config) {