@processmaker/screen-builder 2.16.4 → 2.16.5
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/dist/vue-form-builder.common.js +6488 -6220
- package/dist/vue-form-builder.common.js.map +1 -1
- package/dist/vue-form-builder.umd.js +6488 -6220
- package/dist/vue-form-builder.umd.js.map +1 -1
- package/dist/vue-form-builder.umd.min.js +43 -43
- package/dist/vue-form-builder.umd.min.js.map +1 -1
- package/package-lock.json +1 -1
- package/package.json +1 -1
- package/src/DataProvider.js +5 -4
- package/src/ValidationsFactory.js +23 -7
- package/src/components/inspector/loop.vue +4 -4
- package/src/mixins/Json2Vue.js +4 -1
- package/src/mixins/ScreenBase.js +2 -8
- package/src/mixins/VisibilityRule.js +14 -9
package/package-lock.json
CHANGED
package/package.json
CHANGED
package/src/DataProvider.js
CHANGED
|
@@ -51,9 +51,9 @@ export default {
|
|
|
51
51
|
baseURL() {
|
|
52
52
|
return localStorage.getItem('baseURL');
|
|
53
53
|
},
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
// Methods below are used in the components
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
getTasks(params) {
|
|
58
58
|
const endpoint = _.get(window, 'PM4ConfigOverrides.getTasksEndpoint', '/tasks');
|
|
59
59
|
return this.get(endpoint + params).then(response => {
|
|
@@ -83,7 +83,8 @@ export default {
|
|
|
83
83
|
const cache = this.screensCache.find(screen => screen.id == id);
|
|
84
84
|
if (cache) {
|
|
85
85
|
resolve({data: cache});
|
|
86
|
-
}
|
|
86
|
+
}
|
|
87
|
+
if (!cache && id != undefined) {
|
|
87
88
|
const request = this.get(endpoint + `/${id}${query}`);
|
|
88
89
|
request.then(response => {
|
|
89
90
|
if (response.data.nested) {
|
|
@@ -94,7 +95,7 @@ export default {
|
|
|
94
95
|
}
|
|
95
96
|
});
|
|
96
97
|
},
|
|
97
|
-
|
|
98
|
+
|
|
98
99
|
postScript(id, params, options = {}) {
|
|
99
100
|
let endpoint = _.get(
|
|
100
101
|
window,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { validators } from './mixins/ValidationRules';
|
|
2
2
|
import DataProvider from './DataProvider';
|
|
3
3
|
import { get, set } from 'lodash';
|
|
4
|
+
import { Parser } from 'expr-eval';
|
|
4
5
|
|
|
5
6
|
let globalObject = typeof window === 'undefined'
|
|
6
7
|
? global
|
|
@@ -8,6 +9,7 @@ let globalObject = typeof window === 'undefined'
|
|
|
8
9
|
class Validations {
|
|
9
10
|
screen = null;
|
|
10
11
|
firstPage = 0;
|
|
12
|
+
data = {};
|
|
11
13
|
constructor(element, options) {
|
|
12
14
|
this.element = element;
|
|
13
15
|
Object.assign(this, options);
|
|
@@ -33,7 +35,7 @@ class Validations {
|
|
|
33
35
|
class ArrayOfFieldsValidations extends Validations {
|
|
34
36
|
async addValidations(validations) {
|
|
35
37
|
for (const item of this.element) {
|
|
36
|
-
await ValidationsFactory(item, { screen: this.screen }).addValidations(validations);
|
|
38
|
+
await ValidationsFactory(item, { screen: this.screen, data: this.data }).addValidations(validations);
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
}
|
|
@@ -46,7 +48,7 @@ class ScreenValidations extends Validations {
|
|
|
46
48
|
// add validations for page 1
|
|
47
49
|
if (this.element.config[this.firstPage]) {
|
|
48
50
|
this.element.pagesValidated = [this.firstPage];
|
|
49
|
-
const screenValidations = ValidationsFactory(this.element.config[this.firstPage].items, { screen: this.element });
|
|
51
|
+
const screenValidations = ValidationsFactory(this.element.config[this.firstPage].items, { screen: this.element, data: this.data });
|
|
50
52
|
await screenValidations.addValidations(validations);
|
|
51
53
|
delete this.element.pagesValidated;
|
|
52
54
|
}
|
|
@@ -60,7 +62,7 @@ class FormNestedScreenValidations extends Validations {
|
|
|
60
62
|
async addValidations(validations) {
|
|
61
63
|
const definition = await this.loadScreen(this.element.config.screen);
|
|
62
64
|
if (definition && definition[0] && definition[0].items) {
|
|
63
|
-
await ValidationsFactory(definition[0].items, { screen: this.screen }).addValidations(validations);
|
|
65
|
+
await ValidationsFactory(definition[0].items, { screen: this.screen, data: this.data }).addValidations(validations);
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
|
|
@@ -86,7 +88,8 @@ class FormLoopValidations extends Validations {
|
|
|
86
88
|
set(validations, this.element.config.name, {});
|
|
87
89
|
const loopField = get(validations, this.element.config.name);
|
|
88
90
|
loopField['$each'] = [];
|
|
89
|
-
|
|
91
|
+
const firstRow = this.data[0] || {};
|
|
92
|
+
await ValidationsFactory(this.element.items, { screen: this.screen, data: {_parent: this.data, ...firstRow } }).addValidations(loopField['$each']);
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
95
|
|
|
@@ -95,7 +98,7 @@ class FormLoopValidations extends Validations {
|
|
|
95
98
|
*/
|
|
96
99
|
class FormMultiColumnValidations extends Validations {
|
|
97
100
|
async addValidations(validations) {
|
|
98
|
-
await ValidationsFactory(this.element.items, { screen: this.screen }).addValidations(validations);
|
|
101
|
+
await ValidationsFactory(this.element.items, { screen: this.screen, data: this.data }).addValidations(validations);
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
|
|
@@ -107,7 +110,7 @@ class PageNavigateValidations extends Validations {
|
|
|
107
110
|
if (!this.screen.pagesValidated.includes(parseInt(this.element.config.eventData))) {
|
|
108
111
|
this.screen.pagesValidated.push(parseInt(this.element.config.eventData));
|
|
109
112
|
if (this.screen.config[this.element.config.eventData] && this.screen.config[this.element.config.eventData].items) {
|
|
110
|
-
await ValidationsFactory(this.screen.config[this.element.config.eventData].items, { screen: this.screen }).addValidations(validations);
|
|
113
|
+
await ValidationsFactory(this.screen.config[this.element.config.eventData].items, { screen: this.screen, data: this.data }).addValidations(validations);
|
|
111
114
|
}
|
|
112
115
|
}
|
|
113
116
|
}
|
|
@@ -133,6 +136,19 @@ class FormElementValidations extends Validations {
|
|
|
133
136
|
const fieldName = this.element.config.name;
|
|
134
137
|
const validationConfig = this.element.config.validation;
|
|
135
138
|
|
|
139
|
+
// Disable validations if field is hidden
|
|
140
|
+
if (this.element.config.conditionalHide) {
|
|
141
|
+
let visible = true;
|
|
142
|
+
try {
|
|
143
|
+
visible = !!Parser.evaluate(this.element.config.conditionalHide, this.data);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
visible = false;
|
|
146
|
+
}
|
|
147
|
+
if (!visible) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
136
152
|
set(validations, fieldName, get(validations, fieldName, {}));
|
|
137
153
|
const fieldValidation = get(validations, fieldName);
|
|
138
154
|
if (validationConfig instanceof Array) {
|
|
@@ -166,7 +182,7 @@ class FormElementValidations extends Validations {
|
|
|
166
182
|
fieldValidation[validationConfig] = validationFn;
|
|
167
183
|
}
|
|
168
184
|
if (this.element.items) {
|
|
169
|
-
ValidationsFactory(this.element.items, { screen: this.screen }).addValidations(validations);
|
|
185
|
+
ValidationsFactory(this.element.items, { screen: this.screen, data: this.data }).addValidations(validations);
|
|
170
186
|
}
|
|
171
187
|
}
|
|
172
188
|
camelCase(name) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<div class="form-group border-bottom pb-3">
|
|
3
|
+
<div v-if="screenType == 'form'" class="form-group border-bottom pb-3">
|
|
4
4
|
<label for="type">{{ $t('Data Source') }}</label>
|
|
5
5
|
<b-form-select id="type" v-model="settings.type" :options="options" data-cy="inspector-source"/>
|
|
6
6
|
</div>
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
</div>
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
<div v-if="settings.type === 'new'" class="form-group border-bottom">
|
|
20
|
+
<div v-if="screenType == 'form' && settings.type === 'new'" class="form-group border-bottom">
|
|
21
21
|
<FormInput
|
|
22
22
|
v-model="settings.times"
|
|
23
23
|
:label="$t('Default Loop Count')"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
/>
|
|
29
29
|
</div>
|
|
30
30
|
|
|
31
|
-
<form-checkbox name="add"
|
|
31
|
+
<form-checkbox v-if="screenType == 'form'" name="add"
|
|
32
32
|
:label="$t('Allow additional loops')"
|
|
33
33
|
v-model="settings.add"
|
|
34
34
|
:helper="$t('Check this box to allow task assignee to add additional loops')"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
import { FormInput, FormCheckbox } from '@processmaker/vue-form-elements';
|
|
42
42
|
|
|
43
43
|
export default {
|
|
44
|
-
props: ['value'],
|
|
44
|
+
props: ['value', 'screenType'],
|
|
45
45
|
inheritAttrs: false,
|
|
46
46
|
components: { FormInput, FormCheckbox },
|
|
47
47
|
data() {
|
package/src/mixins/Json2Vue.js
CHANGED
|
@@ -335,8 +335,11 @@ export default {
|
|
|
335
335
|
component.methods.loadValidationRules = function() {
|
|
336
336
|
// Asynchronous loading of validations
|
|
337
337
|
const validations = {};
|
|
338
|
-
ValidationsFactory(definition, { screen: definition, firstPage }).addValidations(validations).then(() => {
|
|
338
|
+
ValidationsFactory(definition, { screen: definition, firstPage, data: this.vdata }).addValidations(validations).then(() => {
|
|
339
339
|
this.ValidationRules__ = validations;
|
|
340
|
+
this.$nextTick(() => {
|
|
341
|
+
this.$v.$touch();
|
|
342
|
+
});
|
|
340
343
|
});
|
|
341
344
|
};
|
|
342
345
|
component.mounted.push('this.loadValidationRules()');
|
package/src/mixins/ScreenBase.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get, isEqual, set
|
|
1
|
+
import { get, isEqual, set } from 'lodash';
|
|
2
2
|
import Mustache from 'mustache';
|
|
3
3
|
import { ValidationMsg } from './ValidationRules';
|
|
4
4
|
|
|
@@ -138,12 +138,6 @@ export default {
|
|
|
138
138
|
},
|
|
139
139
|
},
|
|
140
140
|
validations() {
|
|
141
|
-
|
|
142
|
-
if (this.hiddenFields__.length) {
|
|
143
|
-
this.hiddenFields__.forEach((field) => {
|
|
144
|
-
set(defaultValidations, field, {});
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
return { vdata: defaultValidations };
|
|
141
|
+
return { vdata: this.ValidationRules__ };
|
|
148
142
|
},
|
|
149
143
|
};
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import { Parser } from 'expr-eval';
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
+
mounted() {
|
|
5
|
+
this.$root.$on('refresh-validation-rules', () => {
|
|
6
|
+
this.loadValidationRules();
|
|
7
|
+
});
|
|
8
|
+
},
|
|
4
9
|
methods: {
|
|
5
10
|
visibilityRuleIsVisible(rule, fieldName) {
|
|
6
11
|
try {
|
|
7
12
|
const data = Object.assign({ _parent: this._parent }, this.vdata);
|
|
8
13
|
const isVisible = !!Parser.evaluate(rule, Object.assign({}, this, data));
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
|
|
15
|
+
// Update the array of hidden fields
|
|
16
|
+
const fieldExists = this.hiddenFields__.indexOf(fieldName) !== -1;
|
|
17
|
+
if (isVisible && fieldExists) {
|
|
18
|
+
this.hiddenFields__ = this.hiddenFields__.filter((f) => f !== fieldName);
|
|
19
|
+
this.$root.$emit('refresh-validation-rules');
|
|
20
|
+
} else if (!isVisible && !fieldExists) {
|
|
21
|
+
this.hiddenFields__.push(fieldName);
|
|
22
|
+
this.$root.$emit('refresh-validation-rules');
|
|
18
23
|
}
|
|
19
24
|
|
|
20
25
|
return isVisible;
|