@processmaker/screen-builder 3.8.44 → 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 +3 -3
- 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
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
function isPlainObject(value) {
|
|
2
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function sanitizeHandlerPart(value, kind) {
|
|
6
|
+
if (!isPlainObject(value)) {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const sanitized = {};
|
|
11
|
+
Object.keys(value).forEach((key) => {
|
|
12
|
+
const entry = value[key];
|
|
13
|
+
if (entry === null || entry === undefined) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (kind === 'methods' || kind === 'computed') {
|
|
17
|
+
if (typeof entry === 'function') {
|
|
18
|
+
sanitized[key] = entry;
|
|
19
|
+
}
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (kind === 'watch') {
|
|
23
|
+
sanitized[key] = entry;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (kind === 'components') {
|
|
27
|
+
if (typeof entry === 'object' || typeof entry === 'function') {
|
|
28
|
+
sanitized[key] = entry;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
return sanitized;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default {
|
|
36
|
+
name: 'RenderTemplate',
|
|
37
|
+
inheritAttrs: false,
|
|
38
|
+
props: [
|
|
39
|
+
'error',
|
|
40
|
+
'name',
|
|
41
|
+
'value',
|
|
42
|
+
'helper',
|
|
43
|
+
'controlClass',
|
|
44
|
+
'templateVue',
|
|
45
|
+
'handlerVue',
|
|
46
|
+
'validationData',
|
|
47
|
+
'label',
|
|
48
|
+
'renderVarHtml',
|
|
49
|
+
'components',
|
|
50
|
+
],
|
|
51
|
+
methods: {
|
|
52
|
+
/**
|
|
53
|
+
* Screen Builder binds v-model on this renderer when `config.name` is set.
|
|
54
|
+
* Forward nested data writes so `$v.vdata.<name>` stays in sync.
|
|
55
|
+
*/
|
|
56
|
+
emitInput(nextValue) {
|
|
57
|
+
this.$emit('input', nextValue);
|
|
58
|
+
this.$emit('change', nextValue);
|
|
59
|
+
},
|
|
60
|
+
resolveTransientData() {
|
|
61
|
+
return this.$attrs['transient-data']
|
|
62
|
+
|| this.$attrs.transientData
|
|
63
|
+
|| this.validationData
|
|
64
|
+
|| {};
|
|
65
|
+
},
|
|
66
|
+
resolveTemplateSource() {
|
|
67
|
+
const template = this.templateVue && String(this.templateVue).trim();
|
|
68
|
+
return template || '<div></div>';
|
|
69
|
+
},
|
|
70
|
+
resolveHandlerOptions() {
|
|
71
|
+
const empty = {
|
|
72
|
+
methods: {},
|
|
73
|
+
computed: {},
|
|
74
|
+
watch: {},
|
|
75
|
+
components: {},
|
|
76
|
+
dataFn: null,
|
|
77
|
+
error: null,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
if (!this.handlerVue || !String(this.handlerVue).trim()) {
|
|
81
|
+
return empty;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
// eslint-disable-next-line no-new-func -- handlerVue is screen-authored in Screen Builder
|
|
86
|
+
const evaluated = new Function(this.handlerVue)(); // NOSONAR. Intentional: handlerVue is JS configured by authorized screen authors; result must be a plain object and only methods/computed/watch/components/data are used after sanitization.
|
|
87
|
+
if (!isPlainObject(evaluated)) {
|
|
88
|
+
return {
|
|
89
|
+
...empty,
|
|
90
|
+
error:
|
|
91
|
+
'handlerVue must return a plain object (Vue mixin). Example: return { methods: { ... } }',
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let dataFn = null;
|
|
96
|
+
if (typeof evaluated.data === 'function') {
|
|
97
|
+
dataFn = evaluated.data;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
methods: sanitizeHandlerPart(evaluated.methods, 'methods'),
|
|
102
|
+
computed: sanitizeHandlerPart(evaluated.computed, 'computed'),
|
|
103
|
+
watch: sanitizeHandlerPart(evaluated.watch, 'watch'),
|
|
104
|
+
components: sanitizeHandlerPart(evaluated.components, 'components'),
|
|
105
|
+
dataFn,
|
|
106
|
+
error: null,
|
|
107
|
+
};
|
|
108
|
+
} catch (err) {
|
|
109
|
+
return {
|
|
110
|
+
...empty,
|
|
111
|
+
error: err?.message || String(err),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
render(createElement) {
|
|
117
|
+
const handlerOptions = this.resolveHandlerOptions();
|
|
118
|
+
const templateSource = this.resolveTemplateSource();
|
|
119
|
+
const getTransientData = () => this.resolveTransientData();
|
|
120
|
+
const emitSubmit = () => this.$emit('submit');
|
|
121
|
+
|
|
122
|
+
let component;
|
|
123
|
+
try {
|
|
124
|
+
component = createElement({
|
|
125
|
+
components: {
|
|
126
|
+
...this.components,
|
|
127
|
+
...handlerOptions.components,
|
|
128
|
+
},
|
|
129
|
+
template: templateSource,
|
|
130
|
+
data() {
|
|
131
|
+
const base = {
|
|
132
|
+
data: getTransientData(),
|
|
133
|
+
};
|
|
134
|
+
if (!handlerOptions.dataFn) {
|
|
135
|
+
return base;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
const handlerData = handlerOptions.dataFn.call(this);
|
|
139
|
+
if (isPlainObject(handlerData)) {
|
|
140
|
+
return { ...base, ...handlerData };
|
|
141
|
+
}
|
|
142
|
+
} catch (dataError) {
|
|
143
|
+
// eslint-disable-next-line no-console
|
|
144
|
+
console.warn('[VueRenderTemplate] handlerVue.data() failed', dataError);
|
|
145
|
+
}
|
|
146
|
+
return base;
|
|
147
|
+
},
|
|
148
|
+
computed: {
|
|
149
|
+
...handlerOptions.computed,
|
|
150
|
+
transientData: {
|
|
151
|
+
get: () => getTransientData(),
|
|
152
|
+
set(value) {
|
|
153
|
+
const target = getTransientData();
|
|
154
|
+
if (target && typeof target === 'object') {
|
|
155
|
+
Object.assign(target, value);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
watch: {
|
|
161
|
+
...handlerOptions.watch,
|
|
162
|
+
data(value) {
|
|
163
|
+
const target = getTransientData();
|
|
164
|
+
if (!target || !value || typeof value !== 'object' || value === target) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
Object.assign(target, value);
|
|
168
|
+
this.data = target;
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
methods: {
|
|
172
|
+
...handlerOptions.methods,
|
|
173
|
+
submit: () => emitSubmit(),
|
|
174
|
+
getData: () => getTransientData() || {},
|
|
175
|
+
updateTransientData(value) {
|
|
176
|
+
this.transientData = value;
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
} catch (compileError) {
|
|
181
|
+
component = createElement(
|
|
182
|
+
'div',
|
|
183
|
+
{ class: 'invalid-feedback d-block', attrs: { role: 'alert' } },
|
|
184
|
+
compileError?.message || String(compileError),
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const children = [component];
|
|
189
|
+
|
|
190
|
+
const displayError = this.error || handlerOptions.error;
|
|
191
|
+
if (displayError) {
|
|
192
|
+
children.push(createElement(
|
|
193
|
+
'div',
|
|
194
|
+
{
|
|
195
|
+
class: 'invalid-feedback d-block',
|
|
196
|
+
attrs: { role: 'alert' },
|
|
197
|
+
},
|
|
198
|
+
displayError,
|
|
199
|
+
));
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (this.helper) {
|
|
203
|
+
children.push(createElement(
|
|
204
|
+
'small',
|
|
205
|
+
{ class: 'form-text text-muted' },
|
|
206
|
+
this.helper,
|
|
207
|
+
));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return createElement(
|
|
211
|
+
'div',
|
|
212
|
+
{
|
|
213
|
+
class: {
|
|
214
|
+
'form-group': true,
|
|
215
|
+
'form-group--error': Boolean(displayError),
|
|
216
|
+
[this.controlClass]: Boolean(this.controlClass),
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
children,
|
|
220
|
+
);
|
|
221
|
+
},
|
|
222
|
+
mounted() {
|
|
223
|
+
if (!this.name) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const data = this.resolveTransientData();
|
|
227
|
+
if (!data || typeof data !== 'object') {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
this.sbDataUnwatch = this.$watch(
|
|
231
|
+
() => data[this.name],
|
|
232
|
+
(nextValue) => {
|
|
233
|
+
if (nextValue !== this.value) {
|
|
234
|
+
this.emitInput(nextValue === undefined ? null : nextValue);
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
{ immediate: true },
|
|
238
|
+
);
|
|
239
|
+
},
|
|
240
|
+
beforeDestroy() {
|
|
241
|
+
if (typeof this.sbDataUnwatch === 'function') {
|
|
242
|
+
this.sbDataUnwatch();
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
};
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
:vdata="value"
|
|
40
40
|
:_parent="_parent || value?._parent"
|
|
41
41
|
:_initial-page="currentPage"
|
|
42
|
+
:is-mobile="isMobile"
|
|
42
43
|
:taskdraft="taskdraft"
|
|
43
44
|
@after-submit="afterSubmit"
|
|
44
45
|
@submit="submit"
|
|
@@ -71,6 +72,10 @@ export default {
|
|
|
71
72
|
type: String,
|
|
72
73
|
default: ""
|
|
73
74
|
},
|
|
75
|
+
isMobile: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
default: false
|
|
78
|
+
},
|
|
74
79
|
taskdraft: Object
|
|
75
80
|
},
|
|
76
81
|
data() {
|
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__: {},
|