@processmaker/screen-builder 2.68.0 → 2.70.0
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 +4288 -3968
- package/dist/vue-form-builder.common.js.map +1 -1
- package/dist/vue-form-builder.css +1 -1
- package/dist/vue-form-builder.umd.js +4288 -3968
- package/dist/vue-form-builder.umd.js.map +1 -1
- package/dist/vue-form-builder.umd.min.js +14 -14
- package/dist/vue-form-builder.umd.min.js.map +1 -1
- package/package.json +3 -3
- package/src/components/inspector/color-select.vue +36 -26
- package/src/components/vue-form-builder.vue +448 -283
- package/src/mixins/ScreenBase.js +5 -3
- package/src/store/modules/undoRedoModule.js +8 -0
|
@@ -2,17 +2,22 @@
|
|
|
2
2
|
<b-row class="h-100 m-0">
|
|
3
3
|
<!-- Controls -->
|
|
4
4
|
<b-col class="overflow-hidden h-100 p-0 controls-column">
|
|
5
|
-
<b-card
|
|
5
|
+
<b-card
|
|
6
|
+
no-body
|
|
7
|
+
class="h-100 rounded-0 border-top-0 border-bottom-0 border-left-0"
|
|
8
|
+
>
|
|
6
9
|
<b-input-group size="sm">
|
|
7
10
|
<b-input-group-prepend>
|
|
8
|
-
<b-input-group-text
|
|
9
|
-
|
|
11
|
+
<b-input-group-text
|
|
12
|
+
class="filter-icon border-left-0 border-top-0 rounded-0"
|
|
13
|
+
>
|
|
14
|
+
<i class="fas fa-filter" />
|
|
10
15
|
</b-input-group-text>
|
|
11
16
|
</b-input-group-prepend>
|
|
12
17
|
|
|
13
18
|
<b-form-input
|
|
14
|
-
class="border-top-0 border-right-0 rounded-0"
|
|
15
19
|
v-model="filterQuery"
|
|
20
|
+
class="border-top-0 border-right-0 rounded-0"
|
|
16
21
|
type="text"
|
|
17
22
|
:placeholder="$t('Filter Controls')"
|
|
18
23
|
/>
|
|
@@ -24,17 +29,24 @@
|
|
|
24
29
|
id="controls"
|
|
25
30
|
v-model="filteredControls"
|
|
26
31
|
data-cy="controls"
|
|
27
|
-
v-bind="{
|
|
32
|
+
v-bind="{
|
|
33
|
+
sort: false,
|
|
34
|
+
group: { name: 'controls', pull: 'clone', put: false }
|
|
35
|
+
}"
|
|
28
36
|
:clone="cloneControl"
|
|
29
37
|
class="controls list-group w-auto list-group-flush"
|
|
30
38
|
>
|
|
31
|
-
<b-list-group-item
|
|
32
|
-
|
|
39
|
+
<b-list-group-item
|
|
40
|
+
v-for="(element, index) in filteredControls"
|
|
41
|
+
:key="index"
|
|
42
|
+
:data-cy="'controls-' + element.component"
|
|
43
|
+
>
|
|
44
|
+
<i v-if="element.config.icon" :class="element.config.icon" />
|
|
33
45
|
{{ $t(element.label) }}
|
|
34
46
|
</b-list-group-item>
|
|
35
47
|
|
|
36
48
|
<li v-if="!filteredControls.length" class="list-group-item">
|
|
37
|
-
<slot/>
|
|
49
|
+
<slot />
|
|
38
50
|
</li>
|
|
39
51
|
</draggable>
|
|
40
52
|
</b-card-body>
|
|
@@ -42,10 +54,20 @@
|
|
|
42
54
|
</b-col>
|
|
43
55
|
|
|
44
56
|
<!-- Renderer -->
|
|
45
|
-
<b-col
|
|
57
|
+
<b-col
|
|
58
|
+
id="screen-container"
|
|
59
|
+
class="overflow-auto mh-100 ml-4 mr-4 p-0 d-flex flex-column position-relative pt-2"
|
|
60
|
+
>
|
|
46
61
|
<b-input-group size="sm" class="bg-white mt-3">
|
|
47
|
-
<b-form-select
|
|
48
|
-
|
|
62
|
+
<b-form-select
|
|
63
|
+
v-if="showToolbar"
|
|
64
|
+
v-model="currentPage"
|
|
65
|
+
class="form-control"
|
|
66
|
+
data-cy="toolbar-page"
|
|
67
|
+
>
|
|
68
|
+
<option v-for="(data, page) in config" :key="page" :value="page">
|
|
69
|
+
{{ data.name }}
|
|
70
|
+
</option>
|
|
49
71
|
</b-form-select>
|
|
50
72
|
|
|
51
73
|
<div v-if="showToolbar">
|
|
@@ -54,10 +76,10 @@
|
|
|
54
76
|
variant="secondary"
|
|
55
77
|
class="ml-1"
|
|
56
78
|
:title="$t('Edit Page Title')"
|
|
57
|
-
@click="openEditPageModal(currentPage)"
|
|
58
79
|
data-cy="toolbar-edit"
|
|
80
|
+
@click="openEditPageModal(currentPage)"
|
|
59
81
|
>
|
|
60
|
-
<i class="far fa-edit"/>
|
|
82
|
+
<i class="far fa-edit" />
|
|
61
83
|
</b-button>
|
|
62
84
|
|
|
63
85
|
<b-button
|
|
@@ -65,95 +87,114 @@
|
|
|
65
87
|
variant="danger"
|
|
66
88
|
class="ml-1"
|
|
67
89
|
:title="$t('Delete Page')"
|
|
68
|
-
@click="confirmDelete()"
|
|
69
90
|
:disabled="!displayDelete"
|
|
70
91
|
data-cy="toolbar-remove"
|
|
92
|
+
@click="confirmDelete()"
|
|
71
93
|
>
|
|
72
|
-
<i class="far fa-trash-alt"/>
|
|
94
|
+
<i class="far fa-trash-alt" />
|
|
73
95
|
</b-button>
|
|
74
96
|
|
|
75
97
|
<b-button
|
|
98
|
+
v-b-modal.addPageModal
|
|
76
99
|
size="sm"
|
|
77
100
|
variant="secondary"
|
|
78
101
|
class="ml-1 mr-1"
|
|
79
|
-
@click="originalPageName=null"
|
|
80
102
|
:title="$t('Add New Page')"
|
|
81
|
-
v-b-modal.addPageModal
|
|
82
103
|
data-cy="toolbar-add"
|
|
104
|
+
@click="originalPageName = null"
|
|
83
105
|
>
|
|
84
|
-
<i class="fas fa-plus"/>
|
|
106
|
+
<i class="fas fa-plus" />
|
|
85
107
|
</b-button>
|
|
86
108
|
</div>
|
|
87
109
|
|
|
88
110
|
<b-button-group size="sm" class="ml-1 ml-auto">
|
|
89
|
-
<b-button
|
|
90
|
-
|
|
111
|
+
<b-button :disabled="!canUndo" data-cy="toolbar-undo" @click="undo">{{
|
|
112
|
+
$t("Undo")
|
|
113
|
+
}}</b-button>
|
|
114
|
+
<b-button :disabled="!canRedo" data-cy="toolbar-redo" @click="redo">{{
|
|
115
|
+
$t("Redo")
|
|
116
|
+
}}</b-button>
|
|
91
117
|
</b-button-group>
|
|
92
118
|
|
|
93
|
-
<hr class="w-100"
|
|
119
|
+
<hr class="w-100" />
|
|
94
120
|
</b-input-group>
|
|
95
121
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
122
|
+
<div
|
|
123
|
+
v-if="isCurrentPageEmpty"
|
|
124
|
+
data-cy="screen-drop-zone"
|
|
125
|
+
class="w-100 d-flex justify-content-center align-items-center drag-placeholder text-center position-absolute rounded mt-4"
|
|
126
|
+
>
|
|
127
|
+
{{ $t("Drag an element here") }}
|
|
99
128
|
</div>
|
|
100
129
|
|
|
101
130
|
<draggable
|
|
102
131
|
v-if="renderControls"
|
|
132
|
+
:key="editorContentKey"
|
|
103
133
|
data-cy="editor-content"
|
|
104
134
|
class="h-100"
|
|
105
135
|
ghost-class="form-control-ghost"
|
|
106
136
|
:value="config[currentPage].items"
|
|
107
|
-
:key="editorContentKey"
|
|
108
|
-
@input="updateConfig"
|
|
109
137
|
v-bind="{
|
|
110
|
-
group: {name: 'controls'},
|
|
138
|
+
group: { name: 'controls' },
|
|
111
139
|
swapThreshold: 0.5
|
|
112
140
|
}"
|
|
141
|
+
@input="updateConfig"
|
|
113
142
|
>
|
|
114
143
|
<div
|
|
115
|
-
|
|
116
|
-
:class="{selected: selected === element, hasError: hasError(element)}"
|
|
117
|
-
v-for="(element,index) in config[currentPage].items"
|
|
144
|
+
v-for="(element, index) in config[currentPage].items"
|
|
118
145
|
:key="index"
|
|
119
|
-
|
|
146
|
+
class="control-item mt-4 mb-4"
|
|
147
|
+
:class="{
|
|
148
|
+
selected: selected === element,
|
|
149
|
+
hasError: hasError(element)
|
|
150
|
+
}"
|
|
120
151
|
:selector="element.config.customCssSelector"
|
|
152
|
+
@click="inspect(element)"
|
|
121
153
|
>
|
|
122
|
-
<div
|
|
154
|
+
<div
|
|
155
|
+
v-if="element.container"
|
|
156
|
+
class="card"
|
|
157
|
+
data-cy="screen-element-container"
|
|
158
|
+
@click="inspect(element)"
|
|
159
|
+
>
|
|
123
160
|
<div
|
|
124
161
|
v-if="selected === element"
|
|
125
162
|
class="card-header form-element-header d-flex align-items-center"
|
|
126
163
|
>
|
|
127
|
-
<i class="fas fa-arrows-alt-v mr-1 text-muted"/>
|
|
128
|
-
<i
|
|
129
|
-
|
|
164
|
+
<i class="fas fa-arrows-alt-v mr-1 text-muted" />
|
|
165
|
+
<i
|
|
166
|
+
v-if="element.config.icon"
|
|
167
|
+
:class="element.config.icon"
|
|
168
|
+
class="mr-2 ml-1"
|
|
169
|
+
/>
|
|
170
|
+
{{ element.config.name || element.label || $t("Field Name") }}
|
|
130
171
|
<div class="ml-auto">
|
|
131
172
|
<button
|
|
132
173
|
class="btn btn-sm btn-secondary mr-2"
|
|
133
174
|
:title="$t('Copy Control')"
|
|
134
175
|
@click="duplicateItem(index)"
|
|
135
176
|
>
|
|
136
|
-
<i class="fas fa-copy text-light"/>
|
|
177
|
+
<i class="fas fa-copy text-light" />
|
|
137
178
|
</button>
|
|
138
179
|
<button
|
|
139
180
|
class="btn btn-sm btn-danger"
|
|
140
181
|
:title="$t('Delete Control')"
|
|
141
182
|
@click="deleteItem(index)"
|
|
142
183
|
>
|
|
143
|
-
<i class="far fa-trash-alt text-light"/>
|
|
184
|
+
<i class="far fa-trash-alt text-light" />
|
|
144
185
|
</button>
|
|
145
186
|
</div>
|
|
146
187
|
</div>
|
|
147
188
|
<component
|
|
148
|
-
:
|
|
189
|
+
:is="element['editor-component']"
|
|
190
|
+
v-model="element.items"
|
|
191
|
+
:validation-errors="validationErrors"
|
|
149
192
|
class="card-body"
|
|
150
193
|
:class="elementCssClass(element)"
|
|
151
|
-
@inspect="inspect"
|
|
152
|
-
@update-state="updateState"
|
|
153
194
|
:selected="selected"
|
|
154
|
-
v-model="element.items"
|
|
155
195
|
:config="element.config"
|
|
156
|
-
|
|
196
|
+
@inspect="inspect"
|
|
197
|
+
@update-state="updateState"
|
|
157
198
|
/>
|
|
158
199
|
</div>
|
|
159
200
|
|
|
@@ -162,33 +203,44 @@
|
|
|
162
203
|
v-if="selected === element"
|
|
163
204
|
class="card-header form-element-header d-flex align-items-center"
|
|
164
205
|
>
|
|
165
|
-
<i class="fas fa-arrows-alt-v mr-1 text-muted"/>
|
|
166
|
-
<i
|
|
167
|
-
|
|
206
|
+
<i class="fas fa-arrows-alt-v mr-1 text-muted" />
|
|
207
|
+
<i
|
|
208
|
+
v-if="element.config.icon"
|
|
209
|
+
:class="element.config.icon"
|
|
210
|
+
class="mr-2 ml-1"
|
|
211
|
+
/>
|
|
212
|
+
{{ element.config.name || $t("Variable Name") }}
|
|
168
213
|
<div class="ml-auto">
|
|
169
214
|
<button
|
|
170
215
|
class="btn btn-sm btn-secondary mr-2"
|
|
171
216
|
:title="$t('Copy Control')"
|
|
172
217
|
@click="duplicateItem(index)"
|
|
173
218
|
>
|
|
174
|
-
<i class="fas fa-copy text-light"/>
|
|
219
|
+
<i class="fas fa-copy text-light" />
|
|
175
220
|
</button>
|
|
176
221
|
<button
|
|
177
222
|
class="btn btn-sm btn-danger"
|
|
178
223
|
:title="$t('Delete Control')"
|
|
179
224
|
@click="deleteItem(index)"
|
|
180
225
|
>
|
|
181
|
-
<i class="far fa-trash-alt text-light"/>
|
|
226
|
+
<i class="far fa-trash-alt text-light" />
|
|
182
227
|
</button>
|
|
183
228
|
</div>
|
|
184
229
|
</div>
|
|
185
230
|
<component
|
|
186
|
-
:tabindex="element.config.interactive ? 0 : -1"
|
|
187
|
-
class="card-body m-0 pb-4 pt-4"
|
|
188
|
-
:class="[elementCssClass(element), { 'prevent-interaction': !element.config.interactive }]"
|
|
189
231
|
v-bind="element.config"
|
|
190
232
|
:is="element['editor-component']"
|
|
191
|
-
|
|
233
|
+
:tabindex="element.config.interactive ? 0 : -1"
|
|
234
|
+
class="card-body m-0 pb-4 pt-4"
|
|
235
|
+
:class="[
|
|
236
|
+
elementCssClass(element),
|
|
237
|
+
{ 'prevent-interaction': !element.config.interactive }
|
|
238
|
+
]"
|
|
239
|
+
@input="
|
|
240
|
+
element.config.interactive
|
|
241
|
+
? (element.config.content = $event)
|
|
242
|
+
: null
|
|
243
|
+
"
|
|
192
244
|
@focusout.native="updateState"
|
|
193
245
|
/>
|
|
194
246
|
</div>
|
|
@@ -201,43 +253,60 @@
|
|
|
201
253
|
v-if="renderControls"
|
|
202
254
|
class="overflow-hidden h-100 p-0 inspector-column"
|
|
203
255
|
>
|
|
204
|
-
<b-card
|
|
256
|
+
<b-card
|
|
257
|
+
no-body
|
|
258
|
+
class="p-0 h-100 border-top-0 border-bottom-0 border-right-0 rounded-0"
|
|
259
|
+
>
|
|
205
260
|
<b-card-body class="p-0 h-100 overflow-auto">
|
|
206
261
|
<template v-for="accordion in accordions">
|
|
207
262
|
<b-button
|
|
208
|
-
:key="`${accordionName(accordion)}-button`"
|
|
209
263
|
v-if="getInspectorFields(accordion).length > 0"
|
|
264
|
+
:key="`${accordionName(accordion)}-button`"
|
|
210
265
|
variant="outline"
|
|
211
266
|
class="text-left card-header d-flex align-items-center w-100 outline-0 text-capitalize shadow-none"
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
267
|
+
:data-cy="`accordion-${accordionName(accordion).replace(
|
|
268
|
+
' ',
|
|
269
|
+
''
|
|
270
|
+
)}`"
|
|
271
|
+
:accordion-name="`accordion-${accordionName(accordion).replace(
|
|
272
|
+
' ',
|
|
273
|
+
''
|
|
274
|
+
)}`"
|
|
215
275
|
:is-open="accordion.open ? '1' : '0'"
|
|
276
|
+
@click="toggleAccordion(accordion)"
|
|
216
277
|
>
|
|
217
|
-
<i class="fas fa-cog mr-2"/>
|
|
278
|
+
<i class="fas fa-cog mr-2" />
|
|
218
279
|
{{ $t(accordionName(accordion)) }}
|
|
219
280
|
<i
|
|
220
281
|
class="fas fa-angle-down ml-auto"
|
|
221
|
-
:class="{ 'fas fa-angle-right'
|
|
282
|
+
:class="{ 'fas fa-angle-right': !accordion.open }"
|
|
222
283
|
/>
|
|
223
284
|
</b-button>
|
|
224
|
-
<b-collapse
|
|
285
|
+
<b-collapse
|
|
286
|
+
:id="accordionName(accordion)"
|
|
287
|
+
:key="`${accordionName(accordion)}-collapse`"
|
|
288
|
+
v-model="accordion.open"
|
|
289
|
+
>
|
|
225
290
|
<component
|
|
291
|
+
:is="item.type"
|
|
226
292
|
v-for="(item, index) in getInspectorFields(accordion)"
|
|
293
|
+
:key="index"
|
|
294
|
+
v-model="inspection.config[item.field]"
|
|
227
295
|
:data-cy="'inspector-' + (item.field || item.config.name)"
|
|
296
|
+
v-bind="item.config"
|
|
228
297
|
:field-name="item.field"
|
|
229
|
-
:field-accordion="`accordion-${
|
|
298
|
+
:field-accordion="`accordion-${accordionName(accordion).replace(
|
|
299
|
+
' ',
|
|
300
|
+
''
|
|
301
|
+
)}`"
|
|
230
302
|
:builder="builder"
|
|
231
|
-
:
|
|
232
|
-
:
|
|
233
|
-
:
|
|
234
|
-
:
|
|
235
|
-
:is="item.type"
|
|
236
|
-
:selectedControl="selected"
|
|
303
|
+
:form-config="config"
|
|
304
|
+
:screen-type="screenType"
|
|
305
|
+
:current-page="currentPage"
|
|
306
|
+
:selected-control="selected"
|
|
237
307
|
class="border-bottom m-0 p-4"
|
|
238
|
-
v-bind="item.config"
|
|
239
|
-
v-model="inspection.config[item.field]"
|
|
240
308
|
@focusout.native="updateState"
|
|
309
|
+
@update-state="updateState"
|
|
241
310
|
@setName="inspection.config.name = $event"
|
|
242
311
|
/>
|
|
243
312
|
</b-collapse>
|
|
@@ -247,8 +316,8 @@
|
|
|
247
316
|
</b-col>
|
|
248
317
|
|
|
249
318
|
<!-- Modals -->
|
|
250
|
-
<b-modal
|
|
251
|
-
|
|
319
|
+
<b-modal
|
|
320
|
+
id="addPageModal"
|
|
252
321
|
:ok-title="$t('Save')"
|
|
253
322
|
:cancel-title="$t('Cancel')"
|
|
254
323
|
cancel-variant="btn btn-outline-secondary"
|
|
@@ -256,75 +325,96 @@
|
|
|
256
325
|
:title="$t('Add New Page')"
|
|
257
326
|
header-close-content="×"
|
|
258
327
|
data-cy="add-page-modal"
|
|
328
|
+
@ok="addPage"
|
|
259
329
|
>
|
|
260
330
|
<required />
|
|
261
|
-
<form-input
|
|
331
|
+
<form-input
|
|
332
|
+
ref="addPageInput"
|
|
333
|
+
v-model="addPageName"
|
|
262
334
|
:name="$t('Page Name')"
|
|
263
335
|
:label="$t('Page Name') + ' *'"
|
|
264
336
|
:helper="$t('The name of the new page to add')"
|
|
265
337
|
validation="unique-page-name|required"
|
|
266
|
-
ref="addPageInput"
|
|
267
338
|
data-cy="add-page-name"
|
|
268
339
|
required
|
|
269
340
|
aria-required="true"
|
|
270
341
|
/>
|
|
271
342
|
</b-modal>
|
|
272
343
|
|
|
273
|
-
<b-modal
|
|
274
|
-
|
|
344
|
+
<b-modal
|
|
345
|
+
ref="editPageModal"
|
|
275
346
|
:title="$t('Edit Page Title')"
|
|
276
347
|
:ok-title="$t('Save')"
|
|
277
348
|
:cancel-title="$t('Cancel')"
|
|
278
349
|
cancel-variant="btn btn-outline-secondary"
|
|
279
350
|
ok-variant="btn btn-secondary ml-2"
|
|
280
351
|
header-close-content="×"
|
|
352
|
+
@ok="editPage"
|
|
281
353
|
>
|
|
282
354
|
<required />
|
|
283
|
-
<form-input
|
|
355
|
+
<form-input
|
|
356
|
+
ref="editPageInput"
|
|
357
|
+
v-model="editPageName"
|
|
284
358
|
:name="$t('Page Name')"
|
|
285
359
|
:label="$t('Page Name') + ' *'"
|
|
286
360
|
:helper="$t('The new name of the page')"
|
|
287
361
|
validation="unique-page-name|required"
|
|
288
|
-
ref="editPageInput"
|
|
289
362
|
required
|
|
290
363
|
aria-required="true"
|
|
291
364
|
/>
|
|
292
365
|
</b-modal>
|
|
293
366
|
|
|
294
|
-
<b-modal
|
|
367
|
+
<b-modal
|
|
368
|
+
ref="confirm"
|
|
295
369
|
:title="$t('Caution!')"
|
|
296
370
|
:ok-title="$t('Delete')"
|
|
297
371
|
:cancel-title="$t('Cancel')"
|
|
298
|
-
@ok="deletePage"
|
|
299
|
-
@cancel="hideConfirmModal"
|
|
300
372
|
cancel-variant="btn btn-outline-secondary"
|
|
301
373
|
ok-variant="btn btn-secondary ml-2"
|
|
302
374
|
header-close-content="×"
|
|
375
|
+
@ok="deletePage"
|
|
376
|
+
@cancel="hideConfirmModal"
|
|
303
377
|
>
|
|
304
378
|
<p>{{ confirmMessage }}</p>
|
|
305
|
-
<div slot="modal-ok">{{ $t(
|
|
379
|
+
<div slot="modal-ok">{{ $t("Delete") }}</div>
|
|
306
380
|
</b-modal>
|
|
307
381
|
</b-row>
|
|
308
382
|
</template>
|
|
309
383
|
|
|
310
384
|
<script>
|
|
311
|
-
import draggable from
|
|
312
|
-
import
|
|
313
|
-
import
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
385
|
+
import draggable from "vuedraggable";
|
|
386
|
+
import _ from "lodash";
|
|
387
|
+
import {
|
|
388
|
+
FormInput,
|
|
389
|
+
FormSelectList,
|
|
390
|
+
FormTextArea,
|
|
391
|
+
FormCheckbox,
|
|
392
|
+
FormDatePicker,
|
|
393
|
+
FormHtmlEditor,
|
|
394
|
+
FormHtmlViewer
|
|
395
|
+
} from "@processmaker/vue-form-elements";
|
|
396
|
+
import HasColorProperty from "../mixins/HasColorProperty";
|
|
397
|
+
import * as renderer from "./renderer";
|
|
398
|
+
import * as inspector from "./inspector";
|
|
399
|
+
import "@processmaker/vue-form-elements/dist/vue-form-elements.css";
|
|
400
|
+
import accordions from "./accordions";
|
|
401
|
+
import { keyNameProperty } from "../form-control-common-properties";
|
|
402
|
+
import VariableNameGenerator from "@/components/VariableNameGenerator";
|
|
403
|
+
import testing from "@/mixins/testing";
|
|
404
|
+
import defaultValueEditor from "./inspector/default-value-editor";
|
|
405
|
+
import RequiredCheckbox from "./utils/required-checkbox";
|
|
406
|
+
import MultipleUploadsCheckbox from "./utils/multiple-uploads-checkbox";
|
|
407
|
+
import { formTypes } from "@/global-properties";
|
|
408
|
+
|
|
409
|
+
const Validator = require("validatorjs");
|
|
322
410
|
// To include another language in the Validator with variable processmaker
|
|
323
|
-
|
|
324
|
-
? global
|
|
325
|
-
: window;
|
|
411
|
+
const globalObject = typeof window === "undefined" ? global : window;
|
|
326
412
|
|
|
327
|
-
if (
|
|
413
|
+
if (
|
|
414
|
+
globalObject.ProcessMaker &&
|
|
415
|
+
globalObject.ProcessMaker.user &&
|
|
416
|
+
globalObject.ProcessMaker.user.lang
|
|
417
|
+
) {
|
|
328
418
|
Validator.useLang(globalObject.ProcessMaker.user.lang);
|
|
329
419
|
}
|
|
330
420
|
|
|
@@ -333,10 +423,10 @@ if (globalObject.ProcessMaker && globalObject.ProcessMaker.user && globalObject.
|
|
|
333
423
|
// Should also probably be converted to a mixin. These changes would then
|
|
334
424
|
// require modifications to to App.vue and PM4 Core implementations
|
|
335
425
|
Validator.register(
|
|
336
|
-
|
|
337
|
-
value => {
|
|
426
|
+
"columns-adds-to-12",
|
|
427
|
+
(value) => {
|
|
338
428
|
const sum = value.reduce((total, options) => {
|
|
339
|
-
return total + parseInt(options
|
|
429
|
+
return total + parseInt(options.content);
|
|
340
430
|
}, 0);
|
|
341
431
|
|
|
342
432
|
if (sum === 12) {
|
|
@@ -344,108 +434,92 @@ Validator.register(
|
|
|
344
434
|
}
|
|
345
435
|
return false;
|
|
346
436
|
},
|
|
347
|
-
|
|
437
|
+
"Columns must add to 12"
|
|
348
438
|
);
|
|
349
439
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
FormHtmlEditor,
|
|
357
|
-
FormHtmlViewer,
|
|
358
|
-
} from '@processmaker/vue-form-elements';
|
|
359
|
-
import defaultValueEditor from "./inspector/default-value-editor";
|
|
360
|
-
|
|
361
|
-
import RequiredCheckbox from './utils/required-checkbox';
|
|
362
|
-
import MultipleUploadsCheckbox from './utils/multiple-uploads-checkbox';
|
|
363
|
-
|
|
364
|
-
import '@processmaker/vue-form-elements/dist/vue-form-elements.css';
|
|
365
|
-
import { formTypes } from '@/global-properties';
|
|
366
|
-
import _ from 'lodash';
|
|
367
|
-
|
|
368
|
-
const defaultConfig = [{
|
|
369
|
-
name: 'Default',
|
|
370
|
-
items: [],
|
|
371
|
-
}];
|
|
440
|
+
const defaultConfig = [
|
|
441
|
+
{
|
|
442
|
+
name: "Default",
|
|
443
|
+
items: []
|
|
444
|
+
}
|
|
445
|
+
];
|
|
372
446
|
|
|
373
447
|
export default {
|
|
448
|
+
components: {
|
|
449
|
+
draggable,
|
|
450
|
+
FormInput,
|
|
451
|
+
FormSelectList,
|
|
452
|
+
FormCheckbox,
|
|
453
|
+
FormTextArea,
|
|
454
|
+
FormDatePicker,
|
|
455
|
+
FormHtmlEditor,
|
|
456
|
+
FormHtmlViewer,
|
|
457
|
+
RequiredCheckbox,
|
|
458
|
+
MultipleUploadsCheckbox,
|
|
459
|
+
defaultValueEditor,
|
|
460
|
+
...inspector,
|
|
461
|
+
...renderer
|
|
462
|
+
},
|
|
463
|
+
mixins: [HasColorProperty, testing],
|
|
374
464
|
props: {
|
|
375
465
|
renderControls: {
|
|
376
466
|
type: Boolean,
|
|
377
467
|
default: true
|
|
378
468
|
},
|
|
379
469
|
validationErrors: {
|
|
380
|
-
type: Array
|
|
470
|
+
type: Array
|
|
381
471
|
},
|
|
382
472
|
initialConfig: {
|
|
383
|
-
type: Array
|
|
473
|
+
type: Array
|
|
384
474
|
},
|
|
385
475
|
title: {
|
|
386
|
-
type: String
|
|
476
|
+
type: String
|
|
387
477
|
},
|
|
388
478
|
screenType: {
|
|
389
479
|
type: String,
|
|
390
|
-
default: formTypes.form
|
|
480
|
+
default: formTypes.form
|
|
391
481
|
},
|
|
392
482
|
screen: {
|
|
393
|
-
type: Object
|
|
394
|
-
}
|
|
395
|
-
},
|
|
396
|
-
mixins: [HasColorProperty, testing],
|
|
397
|
-
components: {
|
|
398
|
-
draggable,
|
|
399
|
-
FormInput,
|
|
400
|
-
FormSelectList,
|
|
401
|
-
FormCheckbox,
|
|
402
|
-
FormTextArea,
|
|
403
|
-
FormDatePicker,
|
|
404
|
-
FormHtmlEditor,
|
|
405
|
-
FormHtmlViewer,
|
|
406
|
-
RequiredCheckbox,
|
|
407
|
-
MultipleUploadsCheckbox,
|
|
408
|
-
defaultValueEditor,
|
|
409
|
-
...inspector,
|
|
410
|
-
...renderer,
|
|
483
|
+
type: Object
|
|
484
|
+
}
|
|
411
485
|
},
|
|
412
486
|
data() {
|
|
413
487
|
const config = this.initialConfig || defaultConfig;
|
|
414
488
|
this.migrateConfig(config);
|
|
415
489
|
const generator = new VariableNameGenerator();
|
|
416
|
-
|
|
490
|
+
const variables = generator.GetVariableNames(config);
|
|
417
491
|
|
|
418
|
-
if (this.title && config[0].name ===
|
|
492
|
+
if (this.title && config[0].name === "Default") {
|
|
419
493
|
config[0].name = this.title;
|
|
420
494
|
}
|
|
421
495
|
|
|
422
496
|
return {
|
|
423
497
|
currentPage: 0,
|
|
424
498
|
selected: null,
|
|
425
|
-
display:
|
|
499
|
+
display: "editor",
|
|
426
500
|
inspection: {},
|
|
427
501
|
// Blank at start, assume the parent component will call addControl for each control
|
|
428
502
|
controls: [],
|
|
429
503
|
pageAddModal: false,
|
|
430
|
-
addPageName:
|
|
504
|
+
addPageName: "",
|
|
431
505
|
editPageIndex: null,
|
|
432
|
-
editPageName:
|
|
506
|
+
editPageName: "",
|
|
433
507
|
originalPageName: null,
|
|
434
508
|
config,
|
|
435
|
-
confirmMessage:
|
|
509
|
+
confirmMessage: "",
|
|
436
510
|
pageDelete: 0,
|
|
437
511
|
translated: [],
|
|
438
512
|
showAssignment: false,
|
|
439
513
|
showVariable: false,
|
|
440
514
|
showDesign: false,
|
|
441
|
-
filterQuery:
|
|
515
|
+
filterQuery: "",
|
|
442
516
|
accordions,
|
|
443
517
|
variables,
|
|
444
518
|
generator,
|
|
445
519
|
variablesTree: [],
|
|
446
|
-
language:
|
|
520
|
+
language: "en",
|
|
447
521
|
collator: null,
|
|
448
|
-
editorContentKey: 0
|
|
522
|
+
editorContentKey: 0
|
|
449
523
|
};
|
|
450
524
|
},
|
|
451
525
|
computed: {
|
|
@@ -453,37 +527,39 @@ export default {
|
|
|
453
527
|
return this;
|
|
454
528
|
},
|
|
455
529
|
canUndo() {
|
|
456
|
-
return this.$store.getters[
|
|
530
|
+
return this.$store.getters["undoRedoModule/canUndo"];
|
|
457
531
|
},
|
|
458
532
|
canRedo() {
|
|
459
|
-
return this.$store.getters[
|
|
533
|
+
return this.$store.getters["undoRedoModule/canRedo"];
|
|
460
534
|
},
|
|
461
535
|
displayDelete() {
|
|
462
536
|
return this.config.length > 1;
|
|
463
537
|
},
|
|
464
538
|
filteredControls() {
|
|
465
|
-
return this.controls
|
|
466
|
-
|
|
467
|
-
.
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
539
|
+
return this.controls
|
|
540
|
+
.filter((control) => {
|
|
541
|
+
return control.label
|
|
542
|
+
.toLowerCase()
|
|
543
|
+
.includes(this.filterQuery.toLowerCase());
|
|
544
|
+
})
|
|
545
|
+
.sort((a, b) => {
|
|
546
|
+
return this.collator.compare(a.label, b.label);
|
|
547
|
+
});
|
|
472
548
|
},
|
|
473
549
|
isCurrentPageEmpty() {
|
|
474
550
|
return this.config[this.currentPage].items.length === 0;
|
|
475
551
|
},
|
|
476
552
|
showToolbar() {
|
|
477
553
|
return this.screenType === formTypes.form;
|
|
478
|
-
}
|
|
554
|
+
}
|
|
479
555
|
},
|
|
480
556
|
watch: {
|
|
481
557
|
config: {
|
|
482
558
|
handler() {
|
|
483
559
|
this.checkForCaptchaInLoops();
|
|
484
|
-
this.$emit(
|
|
560
|
+
this.$emit("change", this.config);
|
|
485
561
|
},
|
|
486
|
-
deep: true
|
|
562
|
+
deep: true
|
|
487
563
|
},
|
|
488
564
|
currentPage() {
|
|
489
565
|
this.inspect();
|
|
@@ -493,11 +569,11 @@ export default {
|
|
|
493
569
|
// already translated, don't translate again!
|
|
494
570
|
return;
|
|
495
571
|
}
|
|
496
|
-
for (
|
|
572
|
+
for (const i in e.inspector) {
|
|
497
573
|
e.inspector[i].config.label = this.$t(e.inspector[i].config.label);
|
|
498
574
|
e.inspector[i].config.helper = this.$t(e.inspector[i].config.helper);
|
|
499
575
|
if (e.inspector[i].config.options) {
|
|
500
|
-
for (
|
|
576
|
+
for (const io in e.inspector[i].config.options) {
|
|
501
577
|
e.inspector[i].config.options[io].content = this.$t(
|
|
502
578
|
e.inspector[i].config.options[io].content
|
|
503
579
|
);
|
|
@@ -505,36 +581,75 @@ export default {
|
|
|
505
581
|
}
|
|
506
582
|
}
|
|
507
583
|
this.translated.push(e);
|
|
508
|
-
}
|
|
584
|
+
}
|
|
585
|
+
},
|
|
586
|
+
created() {
|
|
587
|
+
Validator.register(
|
|
588
|
+
"unique-page-name",
|
|
589
|
+
(value) => {
|
|
590
|
+
const pageNames = this.config
|
|
591
|
+
.map((config) => config.name)
|
|
592
|
+
.filter((name) => name !== this.originalPageName);
|
|
593
|
+
return !pageNames.includes(value);
|
|
594
|
+
},
|
|
595
|
+
this.$t("Must be unique")
|
|
596
|
+
);
|
|
597
|
+
this.$store.dispatch("undoRedoModule/pushState", {
|
|
598
|
+
config: JSON.stringify(this.config),
|
|
599
|
+
currentPage: this.currentPage
|
|
600
|
+
});
|
|
601
|
+
this.initiateLanguageSupport();
|
|
602
|
+
},
|
|
603
|
+
mounted() {
|
|
604
|
+
this.checkForCaptchaInLoops();
|
|
605
|
+
this.$root.$on("nested-screen-updated", () => {
|
|
606
|
+
this.checkForCaptchaInLoops();
|
|
607
|
+
});
|
|
509
608
|
},
|
|
510
609
|
methods: {
|
|
511
610
|
refreshContent() {
|
|
512
611
|
this.editorContentKey++;
|
|
513
612
|
},
|
|
514
613
|
checkForCaptchaInLoops() {
|
|
515
|
-
this.config.forEach(page => {
|
|
614
|
+
this.config.forEach((page) => {
|
|
516
615
|
this.checkForCaptcha(page.items);
|
|
517
616
|
});
|
|
518
617
|
},
|
|
519
618
|
checkForCaptcha(items, insideLoop = false, nestedScreen = null) {
|
|
520
|
-
items.forEach(item => {
|
|
521
|
-
if (!item.items && item.component ==
|
|
619
|
+
items.forEach((item) => {
|
|
620
|
+
if (!item.items && item.component == "Captcha" && insideLoop) {
|
|
522
621
|
if (nestedScreen && nestedScreen.config.screen) {
|
|
523
|
-
this.$root.$emit(
|
|
622
|
+
this.$root.$emit("remove-nested", nestedScreen.config.screen);
|
|
524
623
|
nestedScreen.config.screen = null;
|
|
525
|
-
globalObject.ProcessMaker.alert(
|
|
624
|
+
globalObject.ProcessMaker.alert(
|
|
625
|
+
this.$t(
|
|
626
|
+
// eslint-disable-next-line max-len
|
|
627
|
+
"You are trying to place a nested screen within CAPTCHA elements inside a loop. CAPTCHA controls cannot be placed within a Loop control."
|
|
628
|
+
),
|
|
629
|
+
"danger"
|
|
630
|
+
);
|
|
526
631
|
} else {
|
|
527
632
|
items.splice(items.indexOf(item), 1);
|
|
528
|
-
globalObject.ProcessMaker.alert(
|
|
633
|
+
globalObject.ProcessMaker.alert(
|
|
634
|
+
this.$t(
|
|
635
|
+
"CAPTCHA controls cannot be placed within a Loop control."
|
|
636
|
+
),
|
|
637
|
+
"danger"
|
|
638
|
+
);
|
|
529
639
|
}
|
|
530
640
|
}
|
|
531
641
|
if (item.items) {
|
|
532
642
|
this.checkForCaptcha(item.items, true, nestedScreen);
|
|
533
643
|
}
|
|
534
|
-
if (
|
|
535
|
-
|
|
644
|
+
if (
|
|
645
|
+
item.component === "FormNestedScreen" &&
|
|
646
|
+
item.config.screen &&
|
|
647
|
+
window.nestedScreens
|
|
648
|
+
) {
|
|
649
|
+
const nestedScreenItems =
|
|
650
|
+
window.nestedScreens[`id_${item.config.screen}`];
|
|
536
651
|
if (nestedScreenItems) {
|
|
537
|
-
nestedScreenItems.forEach(nestedScreenPage => {
|
|
652
|
+
nestedScreenItems.forEach((nestedScreenPage) => {
|
|
538
653
|
this.checkForCaptcha(nestedScreenPage.items, insideLoop, item);
|
|
539
654
|
});
|
|
540
655
|
}
|
|
@@ -543,36 +658,53 @@ export default {
|
|
|
543
658
|
},
|
|
544
659
|
loadVariablesTree() {
|
|
545
660
|
const definition = {
|
|
546
|
-
config
|
|
547
|
-
computed
|
|
548
|
-
customCSS
|
|
549
|
-
watchers
|
|
661
|
+
config: this.$parent.config,
|
|
662
|
+
computed: this.$parent.computed,
|
|
663
|
+
customCSS: this.$parent.customCSS,
|
|
664
|
+
watchers: this.$parent.watchers
|
|
550
665
|
};
|
|
551
|
-
this.variablesTree =
|
|
552
|
-
|
|
666
|
+
this.variablesTree =
|
|
667
|
+
this.$refs.treeOfVariables.getVariablesTree(definition);
|
|
668
|
+
this.$refs.treeOfVariables.getVariablesTree({ config: [] });
|
|
553
669
|
},
|
|
554
670
|
accordionName(accordion) {
|
|
555
|
-
return accordion.name instanceof Function
|
|
671
|
+
return accordion.name instanceof Function
|
|
672
|
+
? accordion.name(this.inspection)
|
|
673
|
+
: accordion.name;
|
|
556
674
|
},
|
|
557
675
|
toggleAccordion(accordion) {
|
|
558
|
-
this.accordions.forEach(panel =>
|
|
676
|
+
this.accordions.forEach((panel) => {
|
|
677
|
+
if (panel !== accordion) {
|
|
678
|
+
panel.open = false;
|
|
679
|
+
}
|
|
680
|
+
});
|
|
559
681
|
accordion.open = !accordion.open;
|
|
560
682
|
},
|
|
561
683
|
openAccordion(accordion) {
|
|
562
|
-
this.accordions.forEach(panel =>
|
|
684
|
+
this.accordions.forEach((panel) => {
|
|
685
|
+
panel.open = false;
|
|
686
|
+
});
|
|
563
687
|
accordion.open = true;
|
|
564
688
|
},
|
|
565
689
|
migrateConfig(config = this.config) {
|
|
566
|
-
config.forEach(page => this.replaceFormText(page.items));
|
|
567
|
-
config.forEach(page => this.migrateFormSubmit(page.items));
|
|
568
|
-
config.forEach(page => this.updateFieldNameValidation(page.items));
|
|
569
|
-
config.forEach(page =>
|
|
690
|
+
config.forEach((page) => this.replaceFormText(page.items));
|
|
691
|
+
config.forEach((page) => this.migrateFormSubmit(page.items));
|
|
692
|
+
config.forEach((page) => this.updateFieldNameValidation(page.items));
|
|
693
|
+
config.forEach((page) =>
|
|
694
|
+
this.removeDataVariableFromNestedScreens(page.items)
|
|
695
|
+
);
|
|
570
696
|
},
|
|
571
697
|
updateFieldNameValidation(items) {
|
|
572
|
-
items.forEach(item => {
|
|
698
|
+
items.forEach((item) => {
|
|
573
699
|
if (item.inspector) {
|
|
574
700
|
item.inspector.forEach((inspector) => {
|
|
575
|
-
if (
|
|
701
|
+
if (
|
|
702
|
+
inspector.field === "name" &&
|
|
703
|
+
"validation" in inspector.config &&
|
|
704
|
+
inspector.config.name !== "DataVariable" &&
|
|
705
|
+
item.component !== "FileUpload" &&
|
|
706
|
+
item.component !== "FormButton"
|
|
707
|
+
) {
|
|
576
708
|
inspector.config.validation = keyNameProperty.config.validation;
|
|
577
709
|
}
|
|
578
710
|
});
|
|
@@ -583,10 +715,14 @@ export default {
|
|
|
583
715
|
});
|
|
584
716
|
},
|
|
585
717
|
removeDataVariableFromNestedScreens(items) {
|
|
586
|
-
items.forEach(item => {
|
|
718
|
+
items.forEach((item) => {
|
|
587
719
|
if (item.inspector) {
|
|
588
|
-
const hasDataVariable = item.inspector.find(
|
|
589
|
-
|
|
720
|
+
const hasDataVariable = item.inspector.find(
|
|
721
|
+
(inspector) => inspector.config.name === "DataVariable"
|
|
722
|
+
);
|
|
723
|
+
item.inspector = item.inspector.filter(
|
|
724
|
+
(inspector) => inspector.config.name !== "DataVariable"
|
|
725
|
+
);
|
|
590
726
|
if (hasDataVariable) {
|
|
591
727
|
delete item.config.name;
|
|
592
728
|
}
|
|
@@ -594,17 +730,24 @@ export default {
|
|
|
594
730
|
});
|
|
595
731
|
},
|
|
596
732
|
replaceFormText(items) {
|
|
597
|
-
items.forEach(item => {
|
|
598
|
-
if (item.component ===
|
|
599
|
-
item.component =
|
|
600
|
-
item[
|
|
733
|
+
items.forEach((item) => {
|
|
734
|
+
if (item.component === "FormText") {
|
|
735
|
+
item.component = "FormHtmlEditor";
|
|
736
|
+
item["editor-component"] = "FormHtmlEditor";
|
|
601
737
|
const style =
|
|
602
|
-
(item.config.fontSize
|
|
603
|
-
|
|
604
|
-
|
|
738
|
+
(item.config.fontSize
|
|
739
|
+
? `font-size: ${item.config.fontSize};`
|
|
740
|
+
: "") +
|
|
741
|
+
(item.config.fontWeight
|
|
742
|
+
? `font-weight: ${item.config.fontWeight};`
|
|
743
|
+
: "") +
|
|
744
|
+
(item.config.textAlign
|
|
745
|
+
? `text-align: ${item.config.textAlign};`
|
|
746
|
+
: "");
|
|
605
747
|
item.config = {
|
|
606
|
-
content:
|
|
607
|
-
|
|
748
|
+
content:
|
|
749
|
+
"<div style=\"" + style + "\">" + item.config.label + "</div>",
|
|
750
|
+
interactive: true
|
|
608
751
|
};
|
|
609
752
|
}
|
|
610
753
|
if (item.items instanceof Array) {
|
|
@@ -613,30 +756,31 @@ export default {
|
|
|
613
756
|
});
|
|
614
757
|
},
|
|
615
758
|
migrateFormSubmit(items) {
|
|
616
|
-
items.forEach(item => {
|
|
617
|
-
if (item[
|
|
618
|
-
item[
|
|
759
|
+
items.forEach((item) => {
|
|
760
|
+
if (item["editor-control"] !== "FormSubmit") {
|
|
761
|
+
item["editor-control"] = item["editor-component"];
|
|
619
762
|
}
|
|
620
763
|
|
|
621
|
-
if (item.config.event ===
|
|
622
|
-
if (item[
|
|
764
|
+
if (item.config.event === "submit") {
|
|
765
|
+
if (item["editor-component"] === "FormNestedScreen") {
|
|
623
766
|
// Old nested screens erroneously had an event key. Remove it here
|
|
624
767
|
// and set the editor-control back to FormNestedScreen.
|
|
625
768
|
delete item.config.event;
|
|
626
|
-
item[
|
|
627
|
-
item.config.name =
|
|
628
|
-
} else {
|
|
629
|
-
|
|
630
|
-
item['editor-control'] = 'FormSubmit';
|
|
631
|
-
}
|
|
769
|
+
item["editor-control"] = "FormNestedScreen";
|
|
770
|
+
item.config.name = "Nested Screen";
|
|
771
|
+
} else if (item["editor-control"] !== "FormImage") {
|
|
772
|
+
item["editor-control"] = "FormSubmit";
|
|
632
773
|
}
|
|
633
774
|
}
|
|
634
|
-
if (item.config.event ===
|
|
635
|
-
item[
|
|
775
|
+
if (item.config.event === "pageNavigate") {
|
|
776
|
+
item["editor-control"] = "PageNavigation";
|
|
636
777
|
}
|
|
637
|
-
if (
|
|
638
|
-
item
|
|
639
|
-
item.
|
|
778
|
+
if (
|
|
779
|
+
item.items instanceof Array &&
|
|
780
|
+
item.component === "FormMultiColumn"
|
|
781
|
+
) {
|
|
782
|
+
item["editor-control"] = "FormMultiColumn";
|
|
783
|
+
item.items.forEach((column) => this.migrateFormSubmit(column));
|
|
640
784
|
}
|
|
641
785
|
});
|
|
642
786
|
},
|
|
@@ -644,9 +788,9 @@ export default {
|
|
|
644
788
|
if (this._allAccordionizedFields) {
|
|
645
789
|
return this._allAccordionizedFields;
|
|
646
790
|
}
|
|
647
|
-
this._allAccordionizedFields = this.accordions.flatMap(accordion => {
|
|
648
|
-
return accordion.fields.map(fieldName => {
|
|
649
|
-
if (typeof fieldName ===
|
|
791
|
+
this._allAccordionizedFields = this.accordions.flatMap((accordion) => {
|
|
792
|
+
return accordion.fields.map((fieldName) => {
|
|
793
|
+
if (typeof fieldName === "string") {
|
|
650
794
|
return fieldName;
|
|
651
795
|
}
|
|
652
796
|
return fieldName.name;
|
|
@@ -663,9 +807,9 @@ export default {
|
|
|
663
807
|
}
|
|
664
808
|
|
|
665
809
|
const accordionFields = accordion.fields
|
|
666
|
-
.filter(field => {
|
|
667
|
-
if (typeof field !==
|
|
668
|
-
const component = this.inspection
|
|
810
|
+
.filter((field) => {
|
|
811
|
+
if (typeof field !== "string") {
|
|
812
|
+
const { component } = this.inspection;
|
|
669
813
|
const { showFor, hideFor } = field;
|
|
670
814
|
|
|
671
815
|
if (showFor) {
|
|
@@ -679,20 +823,28 @@ export default {
|
|
|
679
823
|
|
|
680
824
|
return true;
|
|
681
825
|
})
|
|
682
|
-
.map(field => {
|
|
683
|
-
if (typeof field !==
|
|
826
|
+
.map((field) => {
|
|
827
|
+
if (typeof field !== "string") {
|
|
684
828
|
return field.name;
|
|
685
829
|
}
|
|
686
830
|
|
|
687
831
|
return field;
|
|
688
832
|
});
|
|
689
|
-
const control = this.controls.find(
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
833
|
+
const control = this.controls.find(
|
|
834
|
+
(control) =>
|
|
835
|
+
control["editor-control"] === this.inspection["editor-control"]
|
|
836
|
+
) ||
|
|
837
|
+
this.controls.find(
|
|
838
|
+
(control) => control.component === this.inspection.component
|
|
839
|
+
) || { inspector: [] };
|
|
840
|
+
return control.inspector.filter((input) => {
|
|
693
841
|
if (accordionFields.includes(input.field)) {
|
|
694
842
|
return true;
|
|
695
|
-
}
|
|
843
|
+
}
|
|
844
|
+
if (
|
|
845
|
+
!this.knownField(input.field) &&
|
|
846
|
+
accordion.name === "Configuration"
|
|
847
|
+
) {
|
|
696
848
|
// If it's not a known inspector field from accordion.js and this is the
|
|
697
849
|
// configuration accordion, then add it here
|
|
698
850
|
return true;
|
|
@@ -701,20 +853,30 @@ export default {
|
|
|
701
853
|
});
|
|
702
854
|
},
|
|
703
855
|
updateState() {
|
|
704
|
-
this.$store.dispatch(
|
|
705
|
-
|
|
856
|
+
this.$store.dispatch("undoRedoModule/pushState", {
|
|
857
|
+
config: JSON.stringify(this.config),
|
|
858
|
+
currentPage: this.currentPage
|
|
859
|
+
});
|
|
706
860
|
},
|
|
707
861
|
undo() {
|
|
708
862
|
this.inspect();
|
|
709
|
-
this.$store.dispatch(
|
|
710
|
-
this.config = JSON.parse(
|
|
711
|
-
|
|
863
|
+
this.$store.dispatch("undoRedoModule/undo");
|
|
864
|
+
this.config = JSON.parse(
|
|
865
|
+
this.$store.getters["undoRedoModule/currentState"].config
|
|
866
|
+
);
|
|
867
|
+
this.currentPage = JSON.parse(
|
|
868
|
+
this.$store.getters["undoRedoModule/currentState"].currentPage
|
|
869
|
+
);
|
|
712
870
|
},
|
|
713
871
|
redo() {
|
|
714
872
|
this.inspect();
|
|
715
|
-
this.$store.dispatch(
|
|
716
|
-
this.config = JSON.parse(
|
|
717
|
-
|
|
873
|
+
this.$store.dispatch("undoRedoModule/redo");
|
|
874
|
+
this.config = JSON.parse(
|
|
875
|
+
this.$store.getters["undoRedoModule/currentState"].config
|
|
876
|
+
);
|
|
877
|
+
this.currentPage = JSON.parse(
|
|
878
|
+
this.$store.getters["undoRedoModule/currentState"].currentPage
|
|
879
|
+
);
|
|
718
880
|
},
|
|
719
881
|
updateConfig(items) {
|
|
720
882
|
this.config[this.currentPage].items = items;
|
|
@@ -729,17 +891,26 @@ export default {
|
|
|
729
891
|
this.$nextTick(() => {
|
|
730
892
|
this.inspect(validation.item);
|
|
731
893
|
this.$nextTick(() => {
|
|
732
|
-
const field = this.$el.querySelector(
|
|
894
|
+
const field = this.$el.querySelector(
|
|
895
|
+
`[field-name="${validation.field}"]`
|
|
896
|
+
);
|
|
733
897
|
if (field) {
|
|
734
|
-
const accordion = this.$el.querySelector(
|
|
735
|
-
|
|
898
|
+
const accordion = this.$el.querySelector(
|
|
899
|
+
`[accordion-name="${field.getAttribute("field-accordion")}"]`
|
|
900
|
+
);
|
|
901
|
+
accordion &&
|
|
902
|
+
accordion.getAttribute("is-open") === "0" &&
|
|
903
|
+
accordion.click();
|
|
736
904
|
field.focus instanceof Function && field.focus();
|
|
737
905
|
}
|
|
738
906
|
});
|
|
739
907
|
});
|
|
740
908
|
},
|
|
741
909
|
confirmDelete() {
|
|
742
|
-
this.confirmMessage = this.$t(
|
|
910
|
+
this.confirmMessage = this.$t(
|
|
911
|
+
"Are you sure you want to delete {{item}}?",
|
|
912
|
+
{ item: this.config[this.currentPage].name }
|
|
913
|
+
);
|
|
743
914
|
this.pageDelete = this.currentPage;
|
|
744
915
|
this.$refs.confirm.show();
|
|
745
916
|
},
|
|
@@ -761,7 +932,9 @@ export default {
|
|
|
761
932
|
},
|
|
762
933
|
openEditPageModal(index) {
|
|
763
934
|
this.editPageIndex = index;
|
|
764
|
-
|
|
935
|
+
const pageName = this.config[index].name;
|
|
936
|
+
this.originalPageName = pageName;
|
|
937
|
+
this.editPageName = pageName;
|
|
765
938
|
this.$refs.editPageModal.show();
|
|
766
939
|
},
|
|
767
940
|
editPage(e) {
|
|
@@ -770,6 +943,7 @@ export default {
|
|
|
770
943
|
return;
|
|
771
944
|
}
|
|
772
945
|
this.config[this.editPageIndex].name = this.editPageName;
|
|
946
|
+
this.updateState();
|
|
773
947
|
},
|
|
774
948
|
addPage(e) {
|
|
775
949
|
if (this.$refs.addPageInput.validator.errorCount) {
|
|
@@ -778,18 +952,24 @@ export default {
|
|
|
778
952
|
}
|
|
779
953
|
this.config.push({ name: this.addPageName, items: [] });
|
|
780
954
|
this.currentPage = this.config.length - 1;
|
|
781
|
-
this.addPageName =
|
|
955
|
+
this.addPageName = "";
|
|
782
956
|
this.updateState();
|
|
783
957
|
},
|
|
784
958
|
deletePage() {
|
|
785
959
|
this.config.splice(this.pageDelete, 1);
|
|
786
|
-
this.currentPage =
|
|
787
|
-
this.$store.dispatch(
|
|
960
|
+
this.currentPage = this.pageDelete - 1 >= 0 ? this.pageDelete - 1 : 0;
|
|
961
|
+
this.$store.dispatch("undoRedoModule/pushState", {
|
|
962
|
+
config: JSON.stringify(this.config),
|
|
963
|
+
currentPage: this.currentPage,
|
|
964
|
+
deletedPage: true
|
|
965
|
+
});
|
|
788
966
|
},
|
|
789
967
|
inspect(element = {}) {
|
|
790
968
|
this.inspection = element;
|
|
791
969
|
this.selected = element;
|
|
792
|
-
const defaultAccordion = this.accordions.find(
|
|
970
|
+
const defaultAccordion = this.accordions.find(
|
|
971
|
+
(accordion) => this.getInspectorFields(accordion).length > 0
|
|
972
|
+
);
|
|
793
973
|
if (defaultAccordion) {
|
|
794
974
|
this.openAccordion(defaultAccordion);
|
|
795
975
|
}
|
|
@@ -797,22 +977,22 @@ export default {
|
|
|
797
977
|
// Cloning the control will ensure the config is not a copy of the observable but a plain javascript object
|
|
798
978
|
// This will ensure each control in the editor has it's own config and it's not shared
|
|
799
979
|
cloneControl(control) {
|
|
800
|
-
|
|
980
|
+
const copy = {
|
|
801
981
|
config: JSON.parse(JSON.stringify(control.config)),
|
|
802
982
|
inspector: JSON.parse(JSON.stringify(control.inspector)),
|
|
803
983
|
component: control.component,
|
|
804
|
-
|
|
805
|
-
|
|
984
|
+
"editor-component": control["editor-component"],
|
|
985
|
+
"editor-control": control["editor-control"],
|
|
806
986
|
label: control.label,
|
|
807
|
-
value: control.value
|
|
987
|
+
value: control.value
|
|
808
988
|
};
|
|
809
|
-
if (control.component ===
|
|
989
|
+
if (control.component === "FormDatePicker" && copy.config.phrases) {
|
|
810
990
|
copy.config.phrases.ok = this.$t(copy.config.phrases.ok);
|
|
811
991
|
copy.config.phrases.cancel = this.$t(copy.config.phrases.cancel);
|
|
812
992
|
}
|
|
813
993
|
copy.config.label = this.$t(copy.config.label);
|
|
814
994
|
if (Array.isArray(copy.config.options)) {
|
|
815
|
-
for (
|
|
995
|
+
for (const io in copy.config.options) {
|
|
816
996
|
copy.config.options[io].content = this.$t(
|
|
817
997
|
copy.config.options[io].content
|
|
818
998
|
);
|
|
@@ -821,14 +1001,20 @@ export default {
|
|
|
821
1001
|
|
|
822
1002
|
// If it's a container, let's add an items property, with the default of items in the control
|
|
823
1003
|
if (control.container) {
|
|
824
|
-
copy
|
|
1004
|
+
copy.items = JSON.parse(JSON.stringify(control.items));
|
|
825
1005
|
copy.container = true;
|
|
826
1006
|
}
|
|
827
1007
|
|
|
828
|
-
//Generate Variable Name
|
|
829
|
-
if (
|
|
830
|
-
|
|
831
|
-
|
|
1008
|
+
// Generate Variable Name
|
|
1009
|
+
if (
|
|
1010
|
+
control.inspector.indexOf(keyNameProperty) !== -1 ||
|
|
1011
|
+
control.component === "FormLoop"
|
|
1012
|
+
) {
|
|
1013
|
+
[this.variables, copy.config.name] = this.generator.generate(
|
|
1014
|
+
this.config,
|
|
1015
|
+
copy["editor-control"] ? copy["editor-control"] : copy.component
|
|
1016
|
+
);
|
|
1017
|
+
if (_.has(copy, "config.settings.varname")) {
|
|
832
1018
|
copy.config.settings.varname = copy.config.name;
|
|
833
1019
|
}
|
|
834
1020
|
}
|
|
@@ -840,28 +1026,8 @@ export default {
|
|
|
840
1026
|
this.language = document.documentElement.lang;
|
|
841
1027
|
}
|
|
842
1028
|
this.collator = Intl.Collator(this.language);
|
|
843
|
-
}
|
|
844
|
-
}
|
|
845
|
-
created() {
|
|
846
|
-
Validator.register(
|
|
847
|
-
'unique-page-name',
|
|
848
|
-
value => {
|
|
849
|
-
const pageNames = this.config
|
|
850
|
-
.map(config => config.name)
|
|
851
|
-
.filter(name => name !== this.originalPageName);
|
|
852
|
-
return !pageNames.includes(value);
|
|
853
|
-
},
|
|
854
|
-
this.$t('Must be unique')
|
|
855
|
-
);
|
|
856
|
-
this.$store.dispatch('undoRedoModule/pushState', {'config': JSON.stringify(this.config), 'currentPage': this.currentPage});
|
|
857
|
-
this.initiateLanguageSupport();
|
|
858
|
-
},
|
|
859
|
-
mounted() {
|
|
860
|
-
this.checkForCaptchaInLoops();
|
|
861
|
-
this.$root.$on('nested-screen-updated', () => {
|
|
862
|
-
this.checkForCaptchaInLoops();
|
|
863
|
-
});
|
|
864
|
-
},
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
865
1031
|
};
|
|
866
1032
|
</script>
|
|
867
1033
|
|
|
@@ -871,7 +1037,6 @@ export default {
|
|
|
871
1037
|
}
|
|
872
1038
|
</style>
|
|
873
1039
|
|
|
874
|
-
|
|
875
1040
|
<style lang="scss" scoped>
|
|
876
1041
|
$header-bg: #f7f7f7;
|
|
877
1042
|
$side-bar-font-size: 0.875rem;
|