@processmaker/screen-builder 3.8.45 → 3.8.46
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.css +1 -1
- package/dist/vue-form-builder.es.js +5729 -5040
- package/dist/vue-form-builder.es.js.map +1 -1
- package/dist/vue-form-builder.umd.js +43 -42
- package/dist/vue-form-builder.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/DataProvider.js +2 -0
- package/src/ValidationsFactory.js +15 -12
- package/src/components/index.js +4 -0
- package/src/components/inspector/vueRender/EditorFieldInspector.vue +239 -0
- package/src/components/renderer/add-loop-row.vue +27 -1
- package/src/components/renderer/form-collection-record-control.vue +44 -10
- package/src/components/renderer/form-collection-view-control.vue +2 -0
- package/src/components/renderer/form-loop.vue +29 -2
- package/src/components/renderer/form-nested-screen.vue +17 -1
- package/src/components/renderer/form-record-list.vue +93 -13
- package/src/components/renderer/vueRender/VueRenderEditor.vue +99 -0
- package/src/components/renderer/vueRender/VueRenderPreview.vue +36 -0
- package/src/components/renderer/vueRender/VueRenderTemplate.js +245 -0
- package/src/components/screen-renderer.vue +5 -0
- package/src/components/task.vue +37 -5
- package/src/components/vue-form-renderer.vue +51 -8
- package/src/form-builder-controls.js +68 -1
- package/src/main.js +11 -0
- package/src/mixins/DeviceDetector.js +19 -3
- package/src/mixins/Json2Vue.js +12 -1
- package/src/mixins/ScreenBase.js +43 -16
- package/src/mixins/VisibilityRule.js +3 -3
- package/src/mixins/extensions/FormDynamicPanel.js +2 -2
- package/src/mixins/extensions/LoadFieldComponents.js +64 -39
- package/src/mixins/extensions/LoopContainer.js +2 -2
- package/src/mixins/extensions/VisibilityRule.js +8 -8
- package/src/stories/VueRender.stories.js +274 -0
package/src/components/task.vue
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
:key="refreshScreen"
|
|
33
33
|
:loop-context="loopContext"
|
|
34
34
|
:taskdraft="this.task"
|
|
35
|
+
:read-only="isFormReadOnly"
|
|
35
36
|
@update-page-task="pageUpdate"
|
|
36
37
|
@update="onUpdate"
|
|
37
38
|
@after-submit="afterSubmit"
|
|
@@ -132,6 +133,7 @@ export default {
|
|
|
132
133
|
loadingTask: false,
|
|
133
134
|
loadingListeners: this.waitLoadingListeners,
|
|
134
135
|
isSelfService: false,
|
|
136
|
+
forceFormReadOnly: false,
|
|
135
137
|
};
|
|
136
138
|
},
|
|
137
139
|
watch: {
|
|
@@ -205,6 +207,18 @@ export default {
|
|
|
205
207
|
},
|
|
206
208
|
},
|
|
207
209
|
computed: {
|
|
210
|
+
isFormReadOnly() {
|
|
211
|
+
if (this.forceFormReadOnly) {
|
|
212
|
+
return true;
|
|
213
|
+
}
|
|
214
|
+
const status = this.task?.status;
|
|
215
|
+
return Boolean(
|
|
216
|
+
this.taskPreview
|
|
217
|
+
&& status
|
|
218
|
+
&& ["CLOSED", "COMPLETED", "TRIGGERED"].includes(status)
|
|
219
|
+
&& !this.alwaysAllowEditing
|
|
220
|
+
);
|
|
221
|
+
},
|
|
208
222
|
shouldAddSubmitButton() {
|
|
209
223
|
if (!this.task) {
|
|
210
224
|
return false;
|
|
@@ -239,7 +253,11 @@ export default {
|
|
|
239
253
|
}
|
|
240
254
|
}
|
|
241
255
|
if (json.config !== undefined) {
|
|
256
|
+
// Align with nested-screen / collection controls: Record List uses
|
|
257
|
+
// `editable`, and Signature/File-like controls may check readonly.
|
|
242
258
|
json.config.disabled = true;
|
|
259
|
+
json.config.readonly = true;
|
|
260
|
+
json.config.editable = false;
|
|
243
261
|
}
|
|
244
262
|
if (json.items !== undefined) {
|
|
245
263
|
this.disableForm(json.items);
|
|
@@ -283,10 +301,7 @@ export default {
|
|
|
283
301
|
url += `&screen_version=${this.screenVersion}`;
|
|
284
302
|
}
|
|
285
303
|
|
|
286
|
-
|
|
287
|
-
if (window.ProcessMaker && window.ProcessMaker.packages && window.ProcessMaker.packages.includes('package-vocabularies')) {
|
|
288
|
-
window.ProcessMaker.VocabulariesSchemaUrl = `vocabularies/task_schema/${this.taskId}`;
|
|
289
|
-
}
|
|
304
|
+
this.setVocabulariesSchemaUrl();
|
|
290
305
|
|
|
291
306
|
return this.beforeLoadTask(this.taskId, this.nodeId).then(() => {
|
|
292
307
|
this.$dataProvider
|
|
@@ -337,9 +352,13 @@ export default {
|
|
|
337
352
|
}
|
|
338
353
|
}
|
|
339
354
|
}
|
|
340
|
-
if (
|
|
355
|
+
if (
|
|
356
|
+
this.taskPreview
|
|
357
|
+
&& ["CLOSED", "COMPLETED", "TRIGGERED"].includes(this.task.status)
|
|
358
|
+
) {
|
|
341
359
|
this.task.interstitial_screen['_interstitial'] = false;
|
|
342
360
|
if (!this.alwaysAllowEditing) {
|
|
361
|
+
this.forceFormReadOnly = true;
|
|
343
362
|
this.task.screen.config = this.disableForm(this.task.screen.config);
|
|
344
363
|
}
|
|
345
364
|
this.screen = this.task.screen;
|
|
@@ -704,6 +723,19 @@ export default {
|
|
|
704
723
|
|
|
705
724
|
return this.$dataProvider.getTasks(`?${queryString}`);
|
|
706
725
|
},
|
|
726
|
+
setVocabulariesSchemaUrl() {
|
|
727
|
+
if (
|
|
728
|
+
window.ProcessMaker
|
|
729
|
+
&& window.ProcessMaker.packages
|
|
730
|
+
&& window.ProcessMaker.packages.includes("package-vocabularies")
|
|
731
|
+
) {
|
|
732
|
+
const schemaUrl = `vocabularies/task_schema/${this.taskId}`;
|
|
733
|
+
if (window.ProcessMaker.VocabulariesSchemaUrl !== schemaUrl) {
|
|
734
|
+
window.ProcessMaker.VocabulariesSchemaCache = null;
|
|
735
|
+
}
|
|
736
|
+
window.ProcessMaker.VocabulariesSchemaUrl = schemaUrl;
|
|
737
|
+
}
|
|
738
|
+
},
|
|
707
739
|
/**
|
|
708
740
|
* Parses a JSON string and returns the result.
|
|
709
741
|
* @param {string} jsonString - The JSON string to parse.
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
:value="data"
|
|
13
13
|
:_parent="_parent || data?._parent"
|
|
14
14
|
:definition="definition"
|
|
15
|
+
:is-mobile="responsiveIsMobile"
|
|
15
16
|
:current-page="currentPage"
|
|
16
17
|
data-cy="screen-renderer"
|
|
17
18
|
:show-errors="showErrors"
|
|
@@ -64,16 +65,28 @@ export default {
|
|
|
64
65
|
"showErrors",
|
|
65
66
|
"testScreenDefinition",
|
|
66
67
|
"deviceScreen",
|
|
67
|
-
"taskdraft"
|
|
68
|
+
"taskdraft",
|
|
69
|
+
"readOnly"
|
|
68
70
|
],
|
|
71
|
+
inject: {
|
|
72
|
+
parentFormReadOnlyState: {
|
|
73
|
+
from: "formReadOnlyState",
|
|
74
|
+
default: () => ({ value: false })
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
provide() {
|
|
78
|
+
return {
|
|
79
|
+
formReadOnlyState: this.formReadOnlyState
|
|
80
|
+
};
|
|
81
|
+
},
|
|
69
82
|
data() {
|
|
70
83
|
return {
|
|
84
|
+
formReadOnlyState: { value: false },
|
|
71
85
|
definition: {
|
|
72
86
|
config: this.config,
|
|
73
87
|
computed: this.computed,
|
|
74
88
|
customCss: this.customCss,
|
|
75
|
-
watchers: this.watchers
|
|
76
|
-
isMobile: false
|
|
89
|
+
watchers: this.watchers
|
|
77
90
|
},
|
|
78
91
|
formSubmitErrorClass: "",
|
|
79
92
|
// watcher URLs
|
|
@@ -114,7 +127,8 @@ export default {
|
|
|
114
127
|
}
|
|
115
128
|
},
|
|
116
129
|
scrollable: null,
|
|
117
|
-
containerObserver: null
|
|
130
|
+
containerObserver: null,
|
|
131
|
+
containerObserverFrame: null
|
|
118
132
|
};
|
|
119
133
|
},
|
|
120
134
|
computed: {
|
|
@@ -135,6 +149,18 @@ export default {
|
|
|
135
149
|
}
|
|
136
150
|
},
|
|
137
151
|
watch: {
|
|
152
|
+
readOnly: {
|
|
153
|
+
immediate: true,
|
|
154
|
+
handler() {
|
|
155
|
+
this.syncFormReadOnly();
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
"parentFormReadOnlyState.value": {
|
|
159
|
+
immediate: true,
|
|
160
|
+
handler() {
|
|
161
|
+
this.syncFormReadOnly();
|
|
162
|
+
}
|
|
163
|
+
},
|
|
138
164
|
customCss(customCss) {
|
|
139
165
|
this.definition.customCss = customCss;
|
|
140
166
|
this.parseCss();
|
|
@@ -188,7 +214,19 @@ export default {
|
|
|
188
214
|
// Initialize the clipboard module
|
|
189
215
|
this.$store.dispatch('clipboardModule/initializeClipboard');
|
|
190
216
|
},
|
|
217
|
+
beforeDestroy() {
|
|
218
|
+
this.containerObserver.disconnect();
|
|
219
|
+
if (this.containerObserverFrame) {
|
|
220
|
+
cancelAnimationFrame(this.containerObserverFrame);
|
|
221
|
+
}
|
|
222
|
+
},
|
|
191
223
|
methods: {
|
|
224
|
+
syncFormReadOnly() {
|
|
225
|
+
const fromParent = Boolean(
|
|
226
|
+
this.parentFormReadOnlyState && this.parentFormReadOnlyState.value
|
|
227
|
+
);
|
|
228
|
+
this.formReadOnlyState.value = Boolean(this.readOnly) || fromParent;
|
|
229
|
+
},
|
|
192
230
|
...mapActions("globalErrorsModule", [
|
|
193
231
|
"validate",
|
|
194
232
|
"hasSubmitted",
|
|
@@ -367,10 +405,15 @@ export default {
|
|
|
367
405
|
this.$emit("update-page-task");
|
|
368
406
|
this.$refs.renderer.setCurrentPage(page);
|
|
369
407
|
},
|
|
370
|
-
onContainerObserver(
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
408
|
+
onContainerObserver() {
|
|
409
|
+
if (this.containerObserverFrame) {
|
|
410
|
+
cancelAnimationFrame(this.containerObserverFrame);
|
|
411
|
+
}
|
|
412
|
+
this.containerObserverFrame = requestAnimationFrame(() => {
|
|
413
|
+
this.containerObserverFrame = null;
|
|
414
|
+
this.checkIfIsMobile();
|
|
415
|
+
this.parseCss();
|
|
416
|
+
});
|
|
374
417
|
},
|
|
375
418
|
saveClipboarToLocalStorage(items){
|
|
376
419
|
localStorage.setItem("savedClipboard", JSON.stringify(items));
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
import { dataSourceValues } from '@/components/inspector/data-source-types';
|
|
30
30
|
import LinkButton from "./components/renderer/link-button.vue";
|
|
31
31
|
import CaseProgressBar from "./components/renderer/case-progress-bar.vue";
|
|
32
|
+
import EditorFieldInspector from './components/inspector/vueRender/EditorFieldInspector.vue';
|
|
32
33
|
|
|
33
34
|
import {
|
|
34
35
|
bgcolorProperty,
|
|
@@ -56,6 +57,71 @@ import {
|
|
|
56
57
|
variantStyleProperty
|
|
57
58
|
} from './form-control-common-properties';
|
|
58
59
|
|
|
60
|
+
const VueComponentEditorConfig = {
|
|
61
|
+
editorComponent: 'VueRenderEditor',
|
|
62
|
+
editorBinding: 'VueRenderEditor',
|
|
63
|
+
rendererComponent: 'VueRenderPreview',
|
|
64
|
+
rendererBinding: 'VueRenderPreview',
|
|
65
|
+
control: {
|
|
66
|
+
popoverContent: 'Use a Rich Text Editor to add HTML-formatted',
|
|
67
|
+
order: 2.0,
|
|
68
|
+
group: 'Content Fields',
|
|
69
|
+
label: 'Vue component Editor',
|
|
70
|
+
component: 'VueRenderPreview',
|
|
71
|
+
'editor-component': 'VueRenderEditor',
|
|
72
|
+
'editor-control': 'VueRenderPreview',
|
|
73
|
+
config: {
|
|
74
|
+
icon: 'fas fa-pencil-ruler',
|
|
75
|
+
interactive: true,
|
|
76
|
+
templateVue: '<p>Vue component editor</p>',
|
|
77
|
+
handlerVue: 'return {}',
|
|
78
|
+
renderVarHtml: null,
|
|
79
|
+
ignoreMustache: true,
|
|
80
|
+
},
|
|
81
|
+
inspector: [
|
|
82
|
+
{
|
|
83
|
+
type: 'FormInput',
|
|
84
|
+
field: 'componentName',
|
|
85
|
+
config: {
|
|
86
|
+
label: 'Component Name',
|
|
87
|
+
helper: 'Name of the component',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: EditorFieldInspector,
|
|
92
|
+
field: 'templateVue',
|
|
93
|
+
config: {
|
|
94
|
+
rows: 5,
|
|
95
|
+
label: 'Template Vue',
|
|
96
|
+
helper: 'The template vue component to display',
|
|
97
|
+
value: '<p>Vue component editor</p>',
|
|
98
|
+
language: 'html',
|
|
99
|
+
enablePopup: true,
|
|
100
|
+
openPopupLabel: 'Open in popup',
|
|
101
|
+
popupTitle: 'Edit template',
|
|
102
|
+
cancelPopupLabel: 'Cancel',
|
|
103
|
+
savePopupLabel: 'Save',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: EditorFieldInspector,
|
|
108
|
+
field: 'handlerVue',
|
|
109
|
+
config: {
|
|
110
|
+
label: 'Handler Vue',
|
|
111
|
+
helper: 'The code vue component to display',
|
|
112
|
+
value: 'return {}',
|
|
113
|
+
language: 'javascript',
|
|
114
|
+
enablePopup: true,
|
|
115
|
+
openPopupLabel: 'Open in popup',
|
|
116
|
+
popupTitle: 'Edit script',
|
|
117
|
+
cancelPopupLabel: 'Cancel',
|
|
118
|
+
savePopupLabel: 'Save',
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
|
|
59
125
|
export default [
|
|
60
126
|
{
|
|
61
127
|
editorComponent: FormHtmlEditor,
|
|
@@ -1292,5 +1358,6 @@ export default [
|
|
|
1292
1358
|
},
|
|
1293
1359
|
inspector: [],
|
|
1294
1360
|
}
|
|
1295
|
-
}
|
|
1361
|
+
},
|
|
1362
|
+
VueComponentEditorConfig
|
|
1296
1363
|
];
|
package/src/main.js
CHANGED
|
@@ -203,6 +203,17 @@ window.ProcessMaker = {
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
});
|
|
206
|
+
} else if (url === "/requests/data_sources/1/resources/list/data") {
|
|
207
|
+
resolve({
|
|
208
|
+
data: {
|
|
209
|
+
response: [
|
|
210
|
+
{ value: 1, content: "James" },
|
|
211
|
+
{ value: 2, content: "John" },
|
|
212
|
+
{ value: 3, content: "Mary" },
|
|
213
|
+
{ value: 4, content: "Patricia" }
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
});
|
|
206
217
|
} else if (url === "/data_sources") {
|
|
207
218
|
resolve({
|
|
208
219
|
data: {
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
export const MAX_MOBILE_WIDTH = 480;
|
|
2
2
|
export const originalDevicePixelRatio = window.devicePixelRatio;
|
|
3
3
|
export default {
|
|
4
|
+
props: {
|
|
5
|
+
isMobile: {
|
|
6
|
+
type: Boolean,
|
|
7
|
+
default: false
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
data() {
|
|
11
|
+
return {
|
|
12
|
+
detectedIsMobile: false
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
computed: {
|
|
16
|
+
responsiveIsMobile() {
|
|
17
|
+
return this.isMobile || this.detectedIsMobile;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
4
20
|
created() {
|
|
5
21
|
window.addEventListener("resize", this.resizeHandler);
|
|
6
22
|
},
|
|
@@ -17,10 +33,10 @@ export default {
|
|
|
17
33
|
this.checkIfIsMobile();
|
|
18
34
|
},
|
|
19
35
|
checkIfIsMobile() {
|
|
20
|
-
const renderer =
|
|
36
|
+
const renderer = this.$refs.formRendererContainer;
|
|
21
37
|
const isModelerInspector = this.data && this.data.$type && this.data.$type.startsWith("bpmn:");
|
|
22
|
-
if (
|
|
23
|
-
this.
|
|
38
|
+
if (!isModelerInspector) {
|
|
39
|
+
this.detectedIsMobile =
|
|
24
40
|
renderer &&
|
|
25
41
|
renderer.offsetWidth <= MAX_MOBILE_WIDTH &&
|
|
26
42
|
originalDevicePixelRatio === window.devicePixelRatio;
|
package/src/mixins/Json2Vue.js
CHANGED
|
@@ -163,9 +163,19 @@ export default {
|
|
|
163
163
|
properties = this.mergeUpdatedConfig(nodeName, this.setDefaultPropertyValues(properties));
|
|
164
164
|
nodeName = this.snakeCase(nodeName);
|
|
165
165
|
const node = this.ownerDocument.createElement(nodeName);
|
|
166
|
+
// Keep false for editability flags so closed/completed forms can disable Record List / Loop.
|
|
167
|
+
const allowFalseProperties = [
|
|
168
|
+
"editable",
|
|
169
|
+
"disabled",
|
|
170
|
+
"readonly",
|
|
171
|
+
":editable",
|
|
172
|
+
":disabled",
|
|
173
|
+
":readonly"
|
|
174
|
+
];
|
|
166
175
|
for (let property in properties) {
|
|
167
176
|
const value = properties[property];
|
|
168
|
-
|
|
177
|
+
const allowFalse = allowFalseProperties.includes(property);
|
|
178
|
+
if ((allowFalse || value !== false) && value !== null && value !== undefined) {
|
|
169
179
|
if (property.substr(0,1) === ':' || (typeof value === 'string' && value.indexOf('{{') === -1)) {
|
|
170
180
|
node.setAttribute(this.escapeVuePropertyName(property), value);
|
|
171
181
|
} else if (typeof value === 'string' && value.indexOf('{{') !== -1 && !properties.ignoreMustache) {
|
|
@@ -448,6 +458,7 @@ export default {
|
|
|
448
458
|
await ValidationsFactory(definition, {
|
|
449
459
|
screen: definition,
|
|
450
460
|
firstPage,
|
|
461
|
+
isMobile: this.isMobile,
|
|
451
462
|
data: {
|
|
452
463
|
_parent: this._parent,
|
|
453
464
|
...this.vdata
|
package/src/mixins/ScreenBase.js
CHANGED
|
@@ -10,25 +10,52 @@ import { findRootScreen } from "./DataReference";
|
|
|
10
10
|
const stringFormats = ['string', 'datetime', 'date', 'password'];
|
|
11
11
|
const parentReference = [];
|
|
12
12
|
|
|
13
|
+
const getVocabulariesSchema = () => {
|
|
14
|
+
if (window.ProcessMaker?.packages?.includes("package-vocabularies")) {
|
|
15
|
+
if (window.ProcessMaker.VocabulariesSchemaUrl) {
|
|
16
|
+
const schemaUrl = window.ProcessMaker.VocabulariesSchemaUrl;
|
|
17
|
+
const cache = window.ProcessMaker.VocabulariesSchemaCache;
|
|
18
|
+
|
|
19
|
+
if (cache && cache.url === schemaUrl) {
|
|
20
|
+
return cache.promise || cache.data;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const promise = window.ProcessMaker.apiClient
|
|
24
|
+
.get(schemaUrl)
|
|
25
|
+
.then((response) => {
|
|
26
|
+
if (window.ProcessMaker.VocabulariesSchemaUrl === schemaUrl) {
|
|
27
|
+
window.ProcessMaker.VocabulariesSchemaCache = {
|
|
28
|
+
url: schemaUrl,
|
|
29
|
+
data: response.data
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return response.data;
|
|
33
|
+
})
|
|
34
|
+
.catch((error) => {
|
|
35
|
+
if (window.ProcessMaker.VocabulariesSchemaCache?.url === schemaUrl) {
|
|
36
|
+
window.ProcessMaker.VocabulariesSchemaCache = null;
|
|
37
|
+
}
|
|
38
|
+
throw error;
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
window.ProcessMaker.VocabulariesSchemaCache = {
|
|
42
|
+
url: schemaUrl,
|
|
43
|
+
promise
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return promise;
|
|
47
|
+
}
|
|
48
|
+
if (window.ProcessMaker.VocabulariesPreview) {
|
|
49
|
+
return window.ProcessMaker.VocabulariesPreview;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return {};
|
|
53
|
+
};
|
|
54
|
+
|
|
13
55
|
export default {
|
|
14
56
|
name: "ScreenContent",
|
|
15
57
|
mixins: [DataReference, computedFields, VariablesToSubmitFilter],
|
|
16
|
-
schema: [
|
|
17
|
-
function() {
|
|
18
|
-
if (window.ProcessMaker && window.ProcessMaker.packages && window.ProcessMaker.packages.includes('package-vocabularies')) {
|
|
19
|
-
if (window.ProcessMaker.VocabulariesSchemaUrl) {
|
|
20
|
-
let response = window.ProcessMaker.apiClient.get(window.ProcessMaker.VocabulariesSchemaUrl);
|
|
21
|
-
return response.then(response => {
|
|
22
|
-
return response.data;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
if (window.ProcessMaker.VocabulariesPreview) {
|
|
26
|
-
return window.ProcessMaker.VocabulariesPreview;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return {};
|
|
30
|
-
},
|
|
31
|
-
],
|
|
58
|
+
schema: [getVocabulariesSchema],
|
|
32
59
|
data() {
|
|
33
60
|
return {
|
|
34
61
|
ValidationRules__: {},
|
|
@@ -2,10 +2,10 @@ import { Parser } from 'expr-eval';
|
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
methods: {
|
|
5
|
-
visibilityRuleIsVisible(rule, name, deviceVisibility) {
|
|
6
|
-
const visibility = deviceVisibility || { showForDesktop: true, showForMobile: true
|
|
5
|
+
visibilityRuleIsVisible(rule, name, deviceVisibility, isMobile = false) {
|
|
6
|
+
const visibility = deviceVisibility || { showForDesktop: true, showForMobile: true };
|
|
7
7
|
const visibleInDevice =
|
|
8
|
-
(
|
|
8
|
+
(isMobile && visibility.showForMobile) || (!isMobile && visibility.showForDesktop);
|
|
9
9
|
|
|
10
10
|
try {
|
|
11
11
|
if (rule && rule.trim().length > 0) {
|
|
@@ -20,8 +20,7 @@ export default {
|
|
|
20
20
|
items: element.items,
|
|
21
21
|
}
|
|
22
22
|
],
|
|
23
|
-
watchers: []
|
|
24
|
-
isMobile: false
|
|
23
|
+
watchers: []
|
|
25
24
|
};
|
|
26
25
|
},
|
|
27
26
|
|
|
@@ -57,6 +56,7 @@ export default {
|
|
|
57
56
|
return this.createComponent("ScreenRenderer", {
|
|
58
57
|
":definition": this.byRef(nested),
|
|
59
58
|
":value": valueExpression,
|
|
59
|
+
":is-mobile": "isMobile",
|
|
60
60
|
":loop-context": loopContextExpression,
|
|
61
61
|
":_parent": "getValidationData()",
|
|
62
62
|
":components": this.byRef(this.components),
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
/* eslint-disable no-param-reassign */
|
|
2
|
+
const RESPONSIVE_COMPONENTS = new Set([
|
|
3
|
+
"FormLoop",
|
|
4
|
+
"FormRecordList",
|
|
5
|
+
"FormNestedScreen",
|
|
6
|
+
"FormCollectionRecordControl",
|
|
7
|
+
"FormCollectionViewControl"
|
|
8
|
+
]);
|
|
9
|
+
|
|
2
10
|
export default {
|
|
3
11
|
data() {
|
|
4
12
|
return {
|
|
@@ -6,6 +14,11 @@ export default {
|
|
|
6
14
|
};
|
|
7
15
|
},
|
|
8
16
|
methods: {
|
|
17
|
+
addResponsiveProperties(properties, componentName) {
|
|
18
|
+
if (RESPONSIVE_COMPONENTS.has(componentName)) {
|
|
19
|
+
properties[":is-mobile"] = "isMobile";
|
|
20
|
+
}
|
|
21
|
+
},
|
|
9
22
|
searchForRecordList(items) {
|
|
10
23
|
items.forEach((item) => {
|
|
11
24
|
if (item instanceof Array) {
|
|
@@ -27,56 +40,58 @@ export default {
|
|
|
27
40
|
}
|
|
28
41
|
});
|
|
29
42
|
},
|
|
43
|
+
bindFieldVariable(properties, element, componentName) {
|
|
44
|
+
if (componentName === "FormImage") {
|
|
45
|
+
this.registerVariable(element.config.variableName, element);
|
|
46
|
+
delete properties.image;
|
|
47
|
+
properties[":image"] = this.byRef(element.config.image);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!this.validVariableName(element.config.name)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
this.registerVariable(element.config.name, element);
|
|
54
|
+
// v-model are not assigned directly to the field name, to prevent invalid references like:
|
|
55
|
+
// `person.content` when `person`=null
|
|
56
|
+
const safeDotName = this.safeDotName(element.config.name);
|
|
57
|
+
properties["v-model"] = safeDotName;
|
|
58
|
+
// Debounce input from FormTextArea and FormInput.
|
|
59
|
+
// Pass $event on @input so vdata is updated with the emitted value even
|
|
60
|
+
// if this handler runs before the v-model assignment (listener order race).
|
|
61
|
+
// Keep @change without $event: change payloads are not always the field value.
|
|
62
|
+
if (componentName === "FormTextArea" || componentName === "FormInput") {
|
|
63
|
+
properties[
|
|
64
|
+
"@input"
|
|
65
|
+
] = `updateScreenData('${safeDotName}', '${element.config.name}', $event)`;
|
|
66
|
+
properties[
|
|
67
|
+
"@change"
|
|
68
|
+
] = `updateScreenDataNow('${safeDotName}', '${element.config.name}')`;
|
|
69
|
+
} else {
|
|
70
|
+
properties[
|
|
71
|
+
"@input"
|
|
72
|
+
] = `updateScreenDataNow('${safeDotName}', '${element.config.name}', true, $event)`;
|
|
73
|
+
properties[
|
|
74
|
+
"@change"
|
|
75
|
+
] = `updateScreenDataNow('${safeDotName}', '${element.config.name}')`;
|
|
76
|
+
}
|
|
77
|
+
// Process the FormSelectList@reset event
|
|
78
|
+
properties[
|
|
79
|
+
"@reset"
|
|
80
|
+
] = `resetValue('${safeDotName}', '${element.config.name}')`;
|
|
81
|
+
},
|
|
30
82
|
loadFieldProperties({
|
|
31
83
|
properties,
|
|
32
84
|
element,
|
|
33
85
|
componentName,
|
|
34
86
|
definition,
|
|
35
|
-
formIndex
|
|
36
|
-
screen
|
|
87
|
+
formIndex
|
|
37
88
|
}) {
|
|
38
89
|
properties.class = this.elementCssClass(element);
|
|
39
90
|
properties[":validation-data"] = "getValidationData()";
|
|
40
91
|
|
|
41
92
|
// verify if component is defined in popup
|
|
42
93
|
if (!this.popups.includes(formIndex)) {
|
|
43
|
-
|
|
44
|
-
this.registerVariable(element.config.variableName, element);
|
|
45
|
-
delete properties.image;
|
|
46
|
-
properties[":image"] = this.byRef(element.config.image);
|
|
47
|
-
} else if (this.validVariableName(element.config.name)) {
|
|
48
|
-
this.registerVariable(element.config.name, element);
|
|
49
|
-
// v-model are not assigned directly to the field name, to prevent invalid references like:
|
|
50
|
-
// `person.content` when `person`=null
|
|
51
|
-
const safeDotName = this.safeDotName(element.config.name);
|
|
52
|
-
properties["v-model"] = safeDotName;
|
|
53
|
-
// Debounce input from FormTextArea and FormInput.
|
|
54
|
-
// Pass $event on @input so vdata is updated with the emitted value even
|
|
55
|
-
// if this handler runs before the v-model assignment (listener order race).
|
|
56
|
-
// Keep @change without $event: change payloads are not always the field value.
|
|
57
|
-
if (
|
|
58
|
-
componentName === "FormTextArea" ||
|
|
59
|
-
componentName === "FormInput"
|
|
60
|
-
) {
|
|
61
|
-
properties[
|
|
62
|
-
"@input"
|
|
63
|
-
] = `updateScreenData('${safeDotName}', '${element.config.name}', $event)`;
|
|
64
|
-
properties[
|
|
65
|
-
"@change"
|
|
66
|
-
] = `updateScreenDataNow('${safeDotName}', '${element.config.name}')`;
|
|
67
|
-
} else {
|
|
68
|
-
properties[
|
|
69
|
-
"@input"
|
|
70
|
-
] = `updateScreenDataNow('${safeDotName}', '${element.config.name}', true, $event)`;
|
|
71
|
-
properties[
|
|
72
|
-
"@change"
|
|
73
|
-
] = `updateScreenDataNow('${safeDotName}', '${element.config.name}')`;
|
|
74
|
-
}
|
|
75
|
-
// Process the FormSelectList@reset event
|
|
76
|
-
properties[
|
|
77
|
-
"@reset"
|
|
78
|
-
] = `resetValue('${safeDotName}', '${element.config.name}')`;
|
|
79
|
-
}
|
|
94
|
+
this.bindFieldVariable(properties, element, componentName);
|
|
80
95
|
}
|
|
81
96
|
// Do not replace mustache in RichText control, it is replaced by the control
|
|
82
97
|
if (
|
|
@@ -89,6 +104,7 @@ export default {
|
|
|
89
104
|
if (componentName === "FormNestedScreen") {
|
|
90
105
|
properties[":_parent"] = "_parent";
|
|
91
106
|
}
|
|
107
|
+
this.addResponsiveProperties(properties, componentName);
|
|
92
108
|
// Add cypress testing tags
|
|
93
109
|
if (element.config.name) {
|
|
94
110
|
properties["data-cy"] = `screen-field-${element.config.name}`;
|
|
@@ -110,6 +126,15 @@ export default {
|
|
|
110
126
|
);
|
|
111
127
|
properties[":readonly"] = isCalcProp || element.config.readonly;
|
|
112
128
|
properties[":disabled"] = isCalcProp || element.config.disabled;
|
|
129
|
+
// Record List must read editability from the live config object so
|
|
130
|
+
// disableForm() mutations (completed/closed preview) take effect.
|
|
131
|
+
if (componentName === "FormRecordList") {
|
|
132
|
+
const configRef = this.byRef(element.config);
|
|
133
|
+
delete properties.editable;
|
|
134
|
+
// Avoid "&&" in attribute expressions: owner.innerHTML escapes & to &.
|
|
135
|
+
properties[":editable"] =
|
|
136
|
+
`(${configRef}.editable)?!(${configRef}.disabled||${configRef}.readonly):false`;
|
|
137
|
+
}
|
|
113
138
|
// Events
|
|
114
139
|
properties["@submit"] = "submitForm";
|
|
115
140
|
// Add handler event if Button
|
|
@@ -28,8 +28,7 @@ export default {
|
|
|
28
28
|
items: element.items
|
|
29
29
|
}
|
|
30
30
|
],
|
|
31
|
-
watchers: definition.watchers
|
|
32
|
-
isMobile: definition.isMobile
|
|
31
|
+
watchers: definition.watchers
|
|
33
32
|
};
|
|
34
33
|
|
|
35
34
|
let loopContext = "";
|
|
@@ -42,6 +41,7 @@ export default {
|
|
|
42
41
|
const child = this.createComponent("ScreenRenderer", {
|
|
43
42
|
":definition": this.byRef(nested),
|
|
44
43
|
":value": "loopRow",
|
|
44
|
+
":is-mobile": "isMobile",
|
|
45
45
|
":loop-context": `'${loopContext}.' + index`,
|
|
46
46
|
":_parent": "getValidationData()",
|
|
47
47
|
":components": this.byRef(this.components),
|
|
@@ -3,25 +3,25 @@ import VisibilityRule from '../VisibilityRule';
|
|
|
3
3
|
export default {
|
|
4
4
|
mounted() {
|
|
5
5
|
this.extensions.push({
|
|
6
|
-
onloaditems({ element, wrapper
|
|
6
|
+
onloaditems({ element, wrapper }) {
|
|
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
|
-
|
|
15
10
|
if (element.config.conditionalHide || restrictDeviceVisibility) {
|
|
16
|
-
const deviceVisibility = JSON.stringify(
|
|
11
|
+
const deviceVisibility = JSON.stringify(visibility);
|
|
17
12
|
wrapper.setAttribute(
|
|
18
13
|
'v-show',
|
|
19
14
|
`visibilityRuleIsVisible(${JSON.stringify(element.config.conditionalHide)},
|
|
20
|
-
${JSON.stringify(element.config.name)}, ${deviceVisibility})`
|
|
15
|
+
${JSON.stringify(element.config.name)}, ${deviceVisibility}, isMobile)`
|
|
21
16
|
);
|
|
22
17
|
}
|
|
23
18
|
},
|
|
24
19
|
onbuild({ screen }) {
|
|
20
|
+
this.addProp(screen, "isMobile", {
|
|
21
|
+
type: Boolean,
|
|
22
|
+
default: false,
|
|
23
|
+
});
|
|
24
|
+
this.addWatch(screen, "isMobile", "this.loadValidationRules();");
|
|
25
25
|
screen.mixins.push(VisibilityRule);
|
|
26
26
|
},
|
|
27
27
|
});
|