comand-component-library 4.3.27 → 5.0.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/comand-component-library.css +1 -1
- package/dist/comand-component-library.js +7568 -7448
- package/dist/styles/demopage-only.css +35 -1
- package/package.json +47 -46
- package/src/ComponentLibrary.vue +2697 -2688
- package/src/assets/data/component-structure.json +1 -1
- package/src/assets/data/form-elements.json +224 -224
- package/src/assets/data/social-networks-page-by-json.json +43 -43
- package/src/assets/styles/component-library-global-styles.scss +296 -295
- package/src/componentSettingsDataAndControls.vue +1 -18
- package/src/components/CmdAccordion.vue +1 -1
- package/src/components/CmdAddressData.vue +6 -1
- package/src/components/CmdAddressDataItem.vue +6 -1
- package/src/components/CmdBasicForm.vue +2 -2
- package/src/components/CmdBox.vue +1103 -1086
- package/src/components/CmdBoxWrapper.vue +11 -1
- package/src/components/CmdBreadcrumbs.vue +2 -2
- package/src/components/CmdCodeOutput.vue +1 -1
- package/src/components/CmdContainer.vue +13 -1
- package/src/components/CmdCookieDisclaimer.vue +480 -480
- package/src/components/CmdFakeSelect.vue +930 -917
- package/src/components/CmdFlexibleScrollContainer.vue +42 -42
- package/src/components/CmdForm.vue +481 -481
- package/src/components/CmdFormElement.vue +1110 -1091
- package/src/components/CmdFormFilters.vue +146 -146
- package/src/components/CmdGoogleMaps.vue +1 -1
- package/src/components/CmdHeadline.vue +21 -4
- package/src/components/CmdIcon.vue +8 -2
- package/src/components/CmdImage.vue +27 -21
- package/src/components/CmdImageZoom.vue +9 -8
- package/src/components/CmdInputGroup.vue +436 -435
- package/src/components/CmdLink.vue +1 -1
- package/src/components/CmdList.vue +3 -3
- package/src/components/CmdListOfRequirements.vue +192 -192
- package/src/components/CmdLoginForm.vue +618 -618
- package/src/components/CmdMailToolFilter.vue +217 -217
- package/src/components/CmdMainNavigation.vue +581 -572
- package/src/components/CmdMultistepFormProgressBar.vue +9 -9
- package/src/components/CmdNewsletterSubscription.vue +199 -199
- package/src/components/CmdPagination.vue +4 -2
- package/src/components/CmdParagraph.vue +10 -4
- package/src/components/CmdProgressBar.vue +72 -72
- package/src/components/CmdSiteHeader.vue +382 -389
- package/src/components/CmdSiteSearch.vue +420 -420
- package/src/components/CmdSiteWrapper.vue +12 -5
- package/src/components/CmdSlideshow.vue +519 -519
- package/src/components/CmdSmartSearch.vue +291 -291
- package/src/components/CmdSystemMessage.vue +3 -2
- package/src/components/CmdTable.vue +401 -401
- package/src/components/CmdTabs.vue +262 -262
- package/src/components/CmdTag.vue +2 -2
- package/src/components/CmdTextImageBlock.vue +8 -2
- package/src/components/CmdThumbnailScroller.vue +0 -7
- package/src/components/CmdToast.vue +1 -1
- package/src/components/CmdToggleDarkMode.vue +13 -11
- package/src/components/CmdTooltip.vue +305 -301
- package/src/components/CmdUploadForm.vue +1299 -1305
- package/src/components/CmdWidthLimitationWrapper.vue +1 -1
- package/src/components/EditComponentWrapper.vue +5 -5
- package/src/index.js +5 -0
- package/src/main.js +4 -3
- package/src/utils/template.js +57 -0
- package/dist/styles/templates/casual.css +0 -3
- package/src/assets/styles/template.css +0 -1
|
@@ -1,481 +1,481 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- begin CmdForm ---------------------------------------------------------------------------------------- -->
|
|
3
|
-
<form :class="['cmd-form', { error: errorOccurred }]" :action="formAction" :data-use-validation="useValidation"
|
|
4
|
-
@submit="onSubmit" :novalidate="novalidate" :method="formMethod">
|
|
5
|
-
<template v-if="useFieldset">
|
|
6
|
-
<fieldset class="flex-container flex-direction-column">
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<!--
|
|
16
|
-
|
|
17
|
-
<CmdHeadline v-if="cmdHeadlineProperties.show && cmdHeadlineProperties?.headlineText"
|
|
18
|
-
v-bind="cmdHeadlineProperties" />
|
|
19
|
-
|
|
20
|
-
<CmdSystemMessage v-if="systemMessage.show && systemMessage.message"
|
|
21
|
-
:validationStatus="systemMessage.validationStatus" :systemMessage="systemMessage.message" />
|
|
22
|
-
<!-- begin loop for formElements -->
|
|
23
|
-
<template v-else v-for="(item, index) in formElements" :key="index">
|
|
24
|
-
<CmdFormElement v-if="!item.component || item.component === 'CmdFormElement'" :key="index"
|
|
25
|
-
:class="item.htmlClass" v-bind="item" v-model="formValues[item.name]"
|
|
26
|
-
@validation-status-change="formElementHasError($event, item.name)" />
|
|
27
|
-
<CmdFakeSelect v-if="item.component === 'CmdFakeSelect'" :class="item.htmlClass" v-bind="item"
|
|
28
|
-
v-model="formValues[item.name]" />
|
|
29
|
-
<CmdInputGroup v-else-if="item.component === 'CmdInputGroup'" :class="item.htmlClass"
|
|
30
|
-
v-bind="item" v-model="formValues[item.name]" />
|
|
31
|
-
<div v-else-if="item.component === 'flexContainer' || item.component === 'inputWrapper'"
|
|
32
|
-
:class="item.component === 'flexContainer' ? 'flex-container' : 'input-wrapper'">
|
|
33
|
-
<!-- begin inner loop for formElements inside flex-container/input-wrapper -->
|
|
34
|
-
<template v-for="(item, index) in item.formElements" :key="index">
|
|
35
|
-
<CmdFormElement v-if="!item.component || item.component === 'CmdFormElement'"
|
|
36
|
-
:key="index" :class="item.htmlClass" v-bind="item" v-model="formValues[item.name]"
|
|
37
|
-
@validation-status-change="formElementHasError($event, item.name)" />
|
|
38
|
-
<CmdFakeSelect v-else-if="item.component === 'CmdFakeSelect'" :class="item.htmlClass"
|
|
39
|
-
v-bind="item" v-model="formValues[item.name]" />
|
|
40
|
-
<CmdInputGroup v-else-if="item.component === 'CmdInputGroup'"
|
|
41
|
-
v-model="formValues[item.name]" v-bind="item" />
|
|
42
|
-
</template>
|
|
43
|
-
<!-- end inner loop for formElements inside flex-container/input-wrapper -->
|
|
44
|
-
</div>
|
|
45
|
-
</template>
|
|
46
|
-
<!-- end loop for formElements -->
|
|
47
|
-
|
|
48
|
-
<!-- begin submit- and cancel-button inside fieldset -->
|
|
49
|
-
<div v-if="cmdLinkSubmitButtonProperties.show && (cmdLinkSubmitButtonProperties.position === 'insideFieldset' || cmdLinkSubmitButtonProperties.position === null)"
|
|
50
|
-
class="flex-container no-wrap-on-small-devices">
|
|
51
|
-
<small v-if="mandatoryText" class="mandatory-text"><sup>*</sup>{{ mandatoryText }}</small>
|
|
52
|
-
|
|
53
|
-
<!-- begin cancel-button -->
|
|
54
|
-
<CmdLink v-if="cmdLinkCancelButtonProperties.show" v-bind="cmdLinkCancelButtonProperties"
|
|
55
|
-
:class="{ 'stretch-on-small-devices': cmdLinkCancelButtonProperties.stretchOnSmallDevices, disabled: cmdLinkCancelButtonProperties.disabled }"
|
|
56
|
-
@click="cancelFormSubmit" />
|
|
57
|
-
<!-- end cancel-button -->
|
|
58
|
-
|
|
59
|
-
<!-- begin submit-button -->
|
|
60
|
-
<CmdLink v-if="cmdLinkSubmitButtonProperties.show" v-bind="cmdLinkSubmitButtonProperties"
|
|
61
|
-
:class="{ 'stretch-on-small-devices': cmdLinkSubmitButtonProperties.stretchOnSmallDevices, disabled: cmdLinkSubmitButtonProperties.disabled }"
|
|
62
|
-
@click.prevent="onSubmit" />
|
|
63
|
-
<!-- end submit-button -->
|
|
64
|
-
</div>
|
|
65
|
-
</slot>
|
|
66
|
-
<!-- end submit- and cancel-button inside fieldset -->
|
|
67
|
-
</fieldset>
|
|
68
|
-
|
|
69
|
-
<!-- begin submit- and cancel-button outside/below fieldset -->
|
|
70
|
-
<div v-if="cmdLinkCancelButtonProperties.show && cmdLinkCancelButtonProperties.position === 'belowFieldset'"
|
|
71
|
-
class="flex-container no-wrap-on-small-devices">
|
|
72
|
-
<small v-if="mandatoryText" class="mandatory-text"><sup>*</sup>{{ mandatoryText }}</small>
|
|
73
|
-
<!-- begin cancel-button -->
|
|
74
|
-
<CmdLink v-if="cmdLinkCancelButtonProperties.show" v-bind="cmdLinkCancelButtonProperties"
|
|
75
|
-
:class="{ 'stretch-on-small-devices': cmdLinkCancelButtonProperties.stretchOnSmallDevices, disabled: cmdLinkCancelButtonProperties.disabled }"
|
|
76
|
-
@click="cancelFormSubmit" />
|
|
77
|
-
<!-- end cancel-button -->
|
|
78
|
-
|
|
79
|
-
<!-- begin submit-button -->
|
|
80
|
-
<CmdLink v-if="cmdLinkSubmitButtonProperties.show" v-bind="cmdLinkSubmitButtonProperties"
|
|
81
|
-
:class="{ 'stretch-on-small-devices': cmdLinkSubmitButtonProperties.stretchOnSmallDevices, disabled: cmdLinkSubmitButtonProperties.disabled }"
|
|
82
|
-
@click.prevent="onSubmit" />
|
|
83
|
-
<!-- end submit-button -->
|
|
84
|
-
</div>
|
|
85
|
-
<!-- end submit- and cancel-button outside/below fieldset -->
|
|
86
|
-
|
|
87
|
-
<!-- begin button-row-slot-content -->
|
|
88
|
-
<slot name="button-row"></slot>
|
|
89
|
-
<!-- end button-row-slot-content -->
|
|
90
|
-
</template>
|
|
91
|
-
|
|
92
|
-
<!-- begin default-slot-content -->
|
|
93
|
-
<slot v-else></slot>
|
|
94
|
-
<!-- end default-slot-content -->
|
|
95
|
-
</form>
|
|
96
|
-
<!-- end CmdForm ---------------------------------------------------------------------------------------- -->
|
|
97
|
-
</template>
|
|
98
|
-
|
|
99
|
-
<script>
|
|
100
|
-
import { createHtmlId } from "@"
|
|
101
|
-
import CmdSystemMessage from "@/components/CmdSystemMessage.vue"
|
|
102
|
-
|
|
103
|
-
export default {
|
|
104
|
-
name: "CmdForm",
|
|
105
|
-
components: { CmdSystemMessage },
|
|
106
|
-
emits: ["validation-status-change", "cancel-form-submit", "submit", "update:modelValue"],
|
|
107
|
-
data() {
|
|
108
|
-
return {
|
|
109
|
-
errorOccurred: false,
|
|
110
|
-
formValues: {},
|
|
111
|
-
showSystemMessage: false,
|
|
112
|
-
systemMessage: {
|
|
113
|
-
show: false,
|
|
114
|
-
validationStatus: "",
|
|
115
|
-
message: ""
|
|
116
|
-
},
|
|
117
|
-
formElementsWithError: []
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
props: {
|
|
121
|
-
/**
|
|
122
|
-
* model-value for entire form
|
|
123
|
-
*/
|
|
124
|
-
modelValue: {
|
|
125
|
-
type: Object
|
|
126
|
-
},
|
|
127
|
-
/**
|
|
128
|
-
* set url for form-action
|
|
129
|
-
*/
|
|
130
|
-
formAction: {
|
|
131
|
-
type: String,
|
|
132
|
-
required: false
|
|
133
|
-
},
|
|
134
|
-
/**
|
|
135
|
-
* define method to send form
|
|
136
|
-
*/
|
|
137
|
-
formMethod: {
|
|
138
|
-
type: String,
|
|
139
|
-
default: "POST",
|
|
140
|
-
validator(value) {
|
|
141
|
-
return value === "POST" || value === "GET"
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
/**
|
|
145
|
-
* legend for form
|
|
146
|
-
*
|
|
147
|
-
* useFieldset-property must be activated
|
|
148
|
-
*
|
|
149
|
-
* @requiredForAccessiblity: true
|
|
150
|
-
*/
|
|
151
|
-
legend: {
|
|
152
|
-
type: Object,
|
|
153
|
-
required: false
|
|
154
|
-
},
|
|
155
|
-
/**
|
|
156
|
-
* activate if form-elements should be given by slot
|
|
157
|
-
*/
|
|
158
|
-
useSlot: {
|
|
159
|
-
type: Boolean,
|
|
160
|
-
default: true
|
|
161
|
-
},
|
|
162
|
-
/**
|
|
163
|
-
* define form-elements by given array
|
|
164
|
-
*/
|
|
165
|
-
formElements: {
|
|
166
|
-
type: Array,
|
|
167
|
-
required: false
|
|
168
|
-
},
|
|
169
|
-
/**
|
|
170
|
-
* deactivate if browser-validation should be used
|
|
171
|
-
*/
|
|
172
|
-
novalidate: {
|
|
173
|
-
type: Boolean,
|
|
174
|
-
default: true
|
|
175
|
-
},
|
|
176
|
-
/**
|
|
177
|
-
* if activated the entire form will be validated by pre-coded validation
|
|
178
|
-
*
|
|
179
|
-
* @affectsStyling: true
|
|
180
|
-
*/
|
|
181
|
-
useValidation: {
|
|
182
|
-
type: Boolean,
|
|
183
|
-
default: true
|
|
184
|
-
},
|
|
185
|
-
/**
|
|
186
|
-
* activate if you want to use a fieldset
|
|
187
|
-
*
|
|
188
|
-
* @requiredForAccessibility: true
|
|
189
|
-
*/
|
|
190
|
-
useFieldset: {
|
|
191
|
-
type: Boolean,
|
|
192
|
-
default: true
|
|
193
|
-
},
|
|
194
|
-
/**
|
|
195
|
-
* text to clarify which inputs are mandatory
|
|
196
|
-
*/
|
|
197
|
-
mandatoryText: {
|
|
198
|
-
type: String,
|
|
199
|
-
default: "mandatory inputs"
|
|
200
|
-
},
|
|
201
|
-
/**
|
|
202
|
-
* properties for CmdLink-component for cancel-button
|
|
203
|
-
*/
|
|
204
|
-
cmdLinkCancelButton: {
|
|
205
|
-
type: Object,
|
|
206
|
-
required: false
|
|
207
|
-
},
|
|
208
|
-
/**
|
|
209
|
-
* properties for CmdLink-component for submit-button
|
|
210
|
-
*/
|
|
211
|
-
cmdLinkSubmitButton: {
|
|
212
|
-
type: Object,
|
|
213
|
-
required: false
|
|
214
|
-
},
|
|
215
|
-
/**
|
|
216
|
-
* properties for CmdHeadline-component
|
|
217
|
-
*/
|
|
218
|
-
cmdHeadline: {
|
|
219
|
-
type: Object,
|
|
220
|
-
required: false
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
mounted() {
|
|
224
|
-
// get the names of all elements that match the phrase and push to data-property to initially collect all required field to set correct validationStatus for form
|
|
225
|
-
const requiredElementNames = this.formElements?.filter(element => element.required === true).map(element => element.name)
|
|
226
|
-
|
|
227
|
-
requiredElementNames?.forEach((name) => {
|
|
228
|
-
this.formElementsWithError.push(name)
|
|
229
|
-
})
|
|
230
|
-
},
|
|
231
|
-
computed: {
|
|
232
|
-
cmdHeadlineProperties() {
|
|
233
|
-
return {
|
|
234
|
-
show: true,
|
|
235
|
-
headlineLevel: 3,
|
|
236
|
-
...this.cmdHeadline
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
legendProperties() {
|
|
240
|
-
return {
|
|
241
|
-
show: false,
|
|
242
|
-
align: "left",
|
|
243
|
-
text: "Legend",
|
|
244
|
-
...this.legend
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
cmdLinkCancelButtonProperties() {
|
|
248
|
-
return {
|
|
249
|
-
show: true,
|
|
250
|
-
linkType: "button",
|
|
251
|
-
highlightLevel: null,
|
|
252
|
-
icon: {
|
|
253
|
-
iconClass: "icon-cancel-circle"
|
|
254
|
-
},
|
|
255
|
-
text: "Cancel",
|
|
256
|
-
stretchOnSmallDevices: false,
|
|
257
|
-
position: "insideFieldset",
|
|
258
|
-
...this.cmdLinkCancelButton
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
cmdLinkSubmitButtonProperties() {
|
|
262
|
-
return {
|
|
263
|
-
show: true,
|
|
264
|
-
linkType: "button",
|
|
265
|
-
icon: {
|
|
266
|
-
iconClass: "icon-check-circle"
|
|
267
|
-
},
|
|
268
|
-
text: "Submit",
|
|
269
|
-
type: "submit",
|
|
270
|
-
position: "insideFieldset",
|
|
271
|
-
primary: true,
|
|
272
|
-
...this.cmdLinkSubmitButton
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
},
|
|
276
|
-
methods: {
|
|
277
|
-
createHtmlId,
|
|
278
|
-
formElementHasError(event, itemName) {
|
|
279
|
-
if (event === "error" && !this.formElementsWithError.some(entry => entry.name === itemName)) {
|
|
280
|
-
this.formElementsWithError.push(itemName)
|
|
281
|
-
} else if (event === "success" && this.formElementsWithError.includes(itemName)) {
|
|
282
|
-
this.formElementsWithError = this.formElementsWithError.filter((element) => element !== itemName)
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
this.$emit("validation-status-change", this.formElementsWithError.length ? "error" : "success")
|
|
286
|
-
},
|
|
287
|
-
showMessage(validationStatus, message) {
|
|
288
|
-
this.systemMessage.show = true
|
|
289
|
-
this.systemMessage.validationStatus = validationStatus
|
|
290
|
-
this.systemMessage.message = message
|
|
291
|
-
},
|
|
292
|
-
cancelFormSubmit(event) {
|
|
293
|
-
const isConfirmed = window.confirm("Are you sure you want to cancel the form submit (all entered data will be lost)?");
|
|
294
|
-
|
|
295
|
-
if (isConfirmed) {
|
|
296
|
-
this.$emit("cancel-form-submit", event)
|
|
297
|
-
}
|
|
298
|
-
},
|
|
299
|
-
submitFormData(event) {
|
|
300
|
-
// fill form-data with names and value
|
|
301
|
-
let formdata = {}
|
|
302
|
-
if (this.formElements) {
|
|
303
|
-
// iterate form-elements in flex-containers and input-wrappers to get their names and values
|
|
304
|
-
this.formElements.forEach((element) => {
|
|
305
|
-
if (element.component === 'flexContainer' || element.component === 'inputWrapper') {
|
|
306
|
-
element.formElements.forEach(innerElement => {
|
|
307
|
-
formdata[innerElement.name] = this.formValues[innerElement.name]
|
|
308
|
-
})
|
|
309
|
-
return
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
formdata[element.name] = this.formValues[element.name]
|
|
313
|
-
})
|
|
314
|
-
}
|
|
315
|
-
this.$emit("submit", { originalEvent: event, formdata: formdata })
|
|
316
|
-
},
|
|
317
|
-
onSubmit(event) {
|
|
318
|
-
if (this.useValidation) {
|
|
319
|
-
if (event.target.checkValidity()) {
|
|
320
|
-
this.errorOccurred = false
|
|
321
|
-
this.submitFormData(event)
|
|
322
|
-
} else {
|
|
323
|
-
event.preventDefault()
|
|
324
|
-
this.errorOccurred = true
|
|
325
|
-
}
|
|
326
|
-
} else {
|
|
327
|
-
this.submitFormData(event)
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
},
|
|
331
|
-
watch: {
|
|
332
|
-
modelValue: {
|
|
333
|
-
handler() {
|
|
334
|
-
if (!this.modelValue) {
|
|
335
|
-
return
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// assign values in loop, because entire object cannot be assigned
|
|
339
|
-
for (const key in this.modelValue) {
|
|
340
|
-
this.formValues[key] = this.modelValue[key]
|
|
341
|
-
}
|
|
342
|
-
},
|
|
343
|
-
immediate: true
|
|
344
|
-
},
|
|
345
|
-
formValues: {
|
|
346
|
-
handler() {
|
|
347
|
-
this.$emit("update:modelValue", this.formValues)
|
|
348
|
-
},
|
|
349
|
-
deep: true
|
|
350
|
-
},
|
|
351
|
-
/*
|
|
352
|
-
formValues: {
|
|
353
|
-
handler() {
|
|
354
|
-
if(!this.formElements) {
|
|
355
|
-
return
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
const numberRequiredFormElements = this.formElements.filter((element) => {
|
|
359
|
-
return element.required
|
|
360
|
-
}).length
|
|
361
|
-
|
|
362
|
-
const numberEmptyRequiredFormElements = this.formElements.filter((element) => {
|
|
363
|
-
return element.required && !this.formValues[element.name]
|
|
364
|
-
}).length
|
|
365
|
-
|
|
366
|
-
const allRequiredFormElementsEmpty = numberRequiredFormElements > 0 && numberRequiredFormElements === numberEmptyRequiredFormElements
|
|
367
|
-
const emptyRequiredFormElementExists = numberRequiredFormElements > 0 && numberEmptyRequiredFormElements > 0
|
|
368
|
-
|
|
369
|
-
this.$emit("empty-required-form-elements", { allRequiredFormElementsEmpty, emptyRequiredFormElementExists })
|
|
370
|
-
},
|
|
371
|
-
immediate: true,
|
|
372
|
-
deep: true
|
|
373
|
-
}, */
|
|
374
|
-
formElements: {
|
|
375
|
-
handler() {
|
|
376
|
-
this.formElements?.forEach(element => {
|
|
377
|
-
// iterate form-elements inside flex-containers and input-wrappers
|
|
378
|
-
if (element.component === 'flexContainer' || element.component === 'inputWrapper') {
|
|
379
|
-
element.formElements.forEach(innerElement => {
|
|
380
|
-
if (innerElement.type === "checkbox") {
|
|
381
|
-
// create array if element is a checkbox (to contain several values)
|
|
382
|
-
if (!this.formValues[innerElement.name]) {
|
|
383
|
-
this.formValues[innerElement.name] = []
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
if (innerElement.value != null) {
|
|
387
|
-
this.formValues[innerElement.name].push(innerElement.value)
|
|
388
|
-
}
|
|
389
|
-
} else {
|
|
390
|
-
this.formValues[innerElement.name] = innerElement.value ?? ""
|
|
391
|
-
}
|
|
392
|
-
})
|
|
393
|
-
return
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
// iterate form-elements on main-level
|
|
397
|
-
if (element.type === "checkbox") {
|
|
398
|
-
// create array if element is a checkbox (to contain several values)
|
|
399
|
-
if (!this.formValues[element.name]) {
|
|
400
|
-
this.formValues[element.name] = []
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
if (element.value != null) {
|
|
404
|
-
this.formValues[element.name].push(element.value)
|
|
405
|
-
}
|
|
406
|
-
} else {
|
|
407
|
-
this.formValues[element.name] = element.value ?? ""
|
|
408
|
-
}
|
|
409
|
-
})
|
|
410
|
-
},
|
|
411
|
-
immediate: true,
|
|
412
|
-
deep: true
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
</script>
|
|
417
|
-
|
|
418
|
-
<style>
|
|
419
|
-
/* begin cmd-form ---------------------------------------------------------------------------------------- */
|
|
420
|
-
.cmd-form {
|
|
421
|
-
&:not([data-use-validation="true"]) {
|
|
422
|
-
|
|
423
|
-
label.error :where(::placeholder, select option:first-child),
|
|
424
|
-
:where(input, select, textarea):invalid:focus {
|
|
425
|
-
color: var(--error-color);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
:where(input, select, textarea):user-valid:focus[required],
|
|
429
|
-
select:user-invalid:focus[required] option:not(:first-child) {
|
|
430
|
-
color: var(--success-color);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/* must be refactored */
|
|
435
|
-
&.send-success {
|
|
436
|
-
fieldset {
|
|
437
|
-
border-color: var(--default-border-color) !important;
|
|
438
|
-
|
|
439
|
-
:is(label, .label) :is(.label-text :is(span, a[class*="icon-"], a:has([class*="icon-"])), .place-inside[class*="icon-"], input, select, textarea) {
|
|
440
|
-
--status-color: var(--default-text-color) !important;
|
|
441
|
-
border-color: var(--default-border-color) !important;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
sup {
|
|
445
|
-
--status-color: var(--primary-color) !important;
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
legend.align-left {
|
|
451
|
-
left: 0;
|
|
452
|
-
right: auto;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
&.error {
|
|
456
|
-
|
|
457
|
-
fieldset,
|
|
458
|
-
*:invalid {
|
|
459
|
-
border-color: var(--error-color);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
.mandatory-text {
|
|
464
|
-
sup {
|
|
465
|
-
color: var(--primary-color);
|
|
466
|
-
font-size: 1.5rem;
|
|
467
|
-
top: 0;
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
[type="submit"].button {
|
|
472
|
-
margin-left: auto;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
fieldset+.button-wrapper {
|
|
476
|
-
margin-top: var(--default-margin);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
/* end cmd-form ---------------------------------------------------------------------------------------- */
|
|
481
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<!-- begin CmdForm ---------------------------------------------------------------------------------------- -->
|
|
3
|
+
<form :class="['cmd-form', { error: errorOccurred }]" :action="formAction" :data-use-validation="useValidation"
|
|
4
|
+
@submit="onSubmit" :novalidate="novalidate" :method="formMethod">
|
|
5
|
+
<template v-if="useFieldset">
|
|
6
|
+
<fieldset class="flex-container flex-direction-column">
|
|
7
|
+
<!-- begin (mandatory) legend (outside the slot: a fieldset needs it as first child; visually-hidden stays available for screen readers) -->
|
|
8
|
+
<legend
|
|
9
|
+
:class="{ 'visually-hidden': !legendProperties.show, 'align-left': legendProperties.align === 'left' }">{{
|
|
10
|
+
legendProperties.text
|
|
11
|
+
}}
|
|
12
|
+
</legend>
|
|
13
|
+
<!-- end (mandatory) legend-->
|
|
14
|
+
<slot>
|
|
15
|
+
<!-- do not remove .flex-direction-column to keep specificity -->
|
|
16
|
+
|
|
17
|
+
<CmdHeadline v-if="cmdHeadlineProperties.show && cmdHeadlineProperties?.headlineText"
|
|
18
|
+
v-bind="cmdHeadlineProperties" />
|
|
19
|
+
|
|
20
|
+
<CmdSystemMessage v-if="systemMessage.show && systemMessage.message"
|
|
21
|
+
:validationStatus="systemMessage.validationStatus" :systemMessage="systemMessage.message" />
|
|
22
|
+
<!-- begin loop for formElements -->
|
|
23
|
+
<template v-else v-for="(item, index) in formElements" :key="index">
|
|
24
|
+
<CmdFormElement v-if="!item.component || item.component === 'CmdFormElement'" :key="index"
|
|
25
|
+
:class="item.htmlClass" v-bind="item" v-model="formValues[item.name]"
|
|
26
|
+
@validation-status-change="formElementHasError($event, item.name)" />
|
|
27
|
+
<CmdFakeSelect v-if="item.component === 'CmdFakeSelect'" :class="item.htmlClass" v-bind="item"
|
|
28
|
+
v-model="formValues[item.name]" />
|
|
29
|
+
<CmdInputGroup v-else-if="item.component === 'CmdInputGroup'" :class="item.htmlClass"
|
|
30
|
+
v-bind="item" v-model="formValues[item.name]" />
|
|
31
|
+
<div v-else-if="item.component === 'flexContainer' || item.component === 'inputWrapper'"
|
|
32
|
+
:class="item.component === 'flexContainer' ? 'flex-container' : 'input-wrapper'">
|
|
33
|
+
<!-- begin inner loop for formElements inside flex-container/input-wrapper -->
|
|
34
|
+
<template v-for="(item, index) in item.formElements" :key="index">
|
|
35
|
+
<CmdFormElement v-if="!item.component || item.component === 'CmdFormElement'"
|
|
36
|
+
:key="index" :class="item.htmlClass" v-bind="item" v-model="formValues[item.name]"
|
|
37
|
+
@validation-status-change="formElementHasError($event, item.name)" />
|
|
38
|
+
<CmdFakeSelect v-else-if="item.component === 'CmdFakeSelect'" :class="item.htmlClass"
|
|
39
|
+
v-bind="item" v-model="formValues[item.name]" />
|
|
40
|
+
<CmdInputGroup v-else-if="item.component === 'CmdInputGroup'"
|
|
41
|
+
v-model="formValues[item.name]" v-bind="item" />
|
|
42
|
+
</template>
|
|
43
|
+
<!-- end inner loop for formElements inside flex-container/input-wrapper -->
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
46
|
+
<!-- end loop for formElements -->
|
|
47
|
+
|
|
48
|
+
<!-- begin submit- and cancel-button inside fieldset -->
|
|
49
|
+
<div v-if="cmdLinkSubmitButtonProperties.show && (cmdLinkSubmitButtonProperties.position === 'insideFieldset' || cmdLinkSubmitButtonProperties.position === null)"
|
|
50
|
+
class="flex-container no-wrap-on-small-devices">
|
|
51
|
+
<small v-if="mandatoryText" class="mandatory-text"><sup>*</sup>{{ mandatoryText }}</small>
|
|
52
|
+
|
|
53
|
+
<!-- begin cancel-button -->
|
|
54
|
+
<CmdLink v-if="cmdLinkCancelButtonProperties.show" v-bind="cmdLinkCancelButtonProperties"
|
|
55
|
+
:class="{ 'stretch-on-small-devices': cmdLinkCancelButtonProperties.stretchOnSmallDevices, disabled: cmdLinkCancelButtonProperties.disabled }"
|
|
56
|
+
@click="cancelFormSubmit" />
|
|
57
|
+
<!-- end cancel-button -->
|
|
58
|
+
|
|
59
|
+
<!-- begin submit-button -->
|
|
60
|
+
<CmdLink v-if="cmdLinkSubmitButtonProperties.show" v-bind="cmdLinkSubmitButtonProperties"
|
|
61
|
+
:class="{ 'stretch-on-small-devices': cmdLinkSubmitButtonProperties.stretchOnSmallDevices, disabled: cmdLinkSubmitButtonProperties.disabled }"
|
|
62
|
+
@click.prevent="onSubmit" />
|
|
63
|
+
<!-- end submit-button -->
|
|
64
|
+
</div>
|
|
65
|
+
</slot>
|
|
66
|
+
<!-- end submit- and cancel-button inside fieldset -->
|
|
67
|
+
</fieldset>
|
|
68
|
+
|
|
69
|
+
<!-- begin submit- and cancel-button outside/below fieldset -->
|
|
70
|
+
<div v-if="cmdLinkCancelButtonProperties.show && cmdLinkCancelButtonProperties.position === 'belowFieldset'"
|
|
71
|
+
class="flex-container no-wrap-on-small-devices">
|
|
72
|
+
<small v-if="mandatoryText" class="mandatory-text"><sup>*</sup>{{ mandatoryText }}</small>
|
|
73
|
+
<!-- begin cancel-button -->
|
|
74
|
+
<CmdLink v-if="cmdLinkCancelButtonProperties.show" v-bind="cmdLinkCancelButtonProperties"
|
|
75
|
+
:class="{ 'stretch-on-small-devices': cmdLinkCancelButtonProperties.stretchOnSmallDevices, disabled: cmdLinkCancelButtonProperties.disabled }"
|
|
76
|
+
@click="cancelFormSubmit" />
|
|
77
|
+
<!-- end cancel-button -->
|
|
78
|
+
|
|
79
|
+
<!-- begin submit-button -->
|
|
80
|
+
<CmdLink v-if="cmdLinkSubmitButtonProperties.show" v-bind="cmdLinkSubmitButtonProperties"
|
|
81
|
+
:class="{ 'stretch-on-small-devices': cmdLinkSubmitButtonProperties.stretchOnSmallDevices, disabled: cmdLinkSubmitButtonProperties.disabled }"
|
|
82
|
+
@click.prevent="onSubmit" />
|
|
83
|
+
<!-- end submit-button -->
|
|
84
|
+
</div>
|
|
85
|
+
<!-- end submit- and cancel-button outside/below fieldset -->
|
|
86
|
+
|
|
87
|
+
<!-- begin button-row-slot-content -->
|
|
88
|
+
<slot name="button-row"></slot>
|
|
89
|
+
<!-- end button-row-slot-content -->
|
|
90
|
+
</template>
|
|
91
|
+
|
|
92
|
+
<!-- begin default-slot-content -->
|
|
93
|
+
<slot v-else></slot>
|
|
94
|
+
<!-- end default-slot-content -->
|
|
95
|
+
</form>
|
|
96
|
+
<!-- end CmdForm ---------------------------------------------------------------------------------------- -->
|
|
97
|
+
</template>
|
|
98
|
+
|
|
99
|
+
<script>
|
|
100
|
+
import { createHtmlId } from "@"
|
|
101
|
+
import CmdSystemMessage from "@/components/CmdSystemMessage.vue"
|
|
102
|
+
|
|
103
|
+
export default {
|
|
104
|
+
name: "CmdForm",
|
|
105
|
+
components: { CmdSystemMessage },
|
|
106
|
+
emits: ["validation-status-change", "cancel-form-submit", "submit", "update:modelValue"],
|
|
107
|
+
data() {
|
|
108
|
+
return {
|
|
109
|
+
errorOccurred: false,
|
|
110
|
+
formValues: {},
|
|
111
|
+
showSystemMessage: false,
|
|
112
|
+
systemMessage: {
|
|
113
|
+
show: false,
|
|
114
|
+
validationStatus: "",
|
|
115
|
+
message: ""
|
|
116
|
+
},
|
|
117
|
+
formElementsWithError: []
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
props: {
|
|
121
|
+
/**
|
|
122
|
+
* model-value for entire form
|
|
123
|
+
*/
|
|
124
|
+
modelValue: {
|
|
125
|
+
type: Object
|
|
126
|
+
},
|
|
127
|
+
/**
|
|
128
|
+
* set url for form-action
|
|
129
|
+
*/
|
|
130
|
+
formAction: {
|
|
131
|
+
type: String,
|
|
132
|
+
required: false
|
|
133
|
+
},
|
|
134
|
+
/**
|
|
135
|
+
* define method to send form
|
|
136
|
+
*/
|
|
137
|
+
formMethod: {
|
|
138
|
+
type: String,
|
|
139
|
+
default: "POST",
|
|
140
|
+
validator(value) {
|
|
141
|
+
return value === "POST" || value === "GET"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
/**
|
|
145
|
+
* legend for form
|
|
146
|
+
*
|
|
147
|
+
* useFieldset-property must be activated
|
|
148
|
+
*
|
|
149
|
+
* @requiredForAccessiblity: true
|
|
150
|
+
*/
|
|
151
|
+
legend: {
|
|
152
|
+
type: Object,
|
|
153
|
+
required: false
|
|
154
|
+
},
|
|
155
|
+
/**
|
|
156
|
+
* activate if form-elements should be given by slot
|
|
157
|
+
*/
|
|
158
|
+
useSlot: {
|
|
159
|
+
type: Boolean,
|
|
160
|
+
default: true
|
|
161
|
+
},
|
|
162
|
+
/**
|
|
163
|
+
* define form-elements by given array
|
|
164
|
+
*/
|
|
165
|
+
formElements: {
|
|
166
|
+
type: Array,
|
|
167
|
+
required: false
|
|
168
|
+
},
|
|
169
|
+
/**
|
|
170
|
+
* deactivate if browser-validation should be used
|
|
171
|
+
*/
|
|
172
|
+
novalidate: {
|
|
173
|
+
type: Boolean,
|
|
174
|
+
default: true
|
|
175
|
+
},
|
|
176
|
+
/**
|
|
177
|
+
* if activated the entire form will be validated by pre-coded validation
|
|
178
|
+
*
|
|
179
|
+
* @affectsStyling: true
|
|
180
|
+
*/
|
|
181
|
+
useValidation: {
|
|
182
|
+
type: Boolean,
|
|
183
|
+
default: true
|
|
184
|
+
},
|
|
185
|
+
/**
|
|
186
|
+
* activate if you want to use a fieldset
|
|
187
|
+
*
|
|
188
|
+
* @requiredForAccessibility: true
|
|
189
|
+
*/
|
|
190
|
+
useFieldset: {
|
|
191
|
+
type: Boolean,
|
|
192
|
+
default: true
|
|
193
|
+
},
|
|
194
|
+
/**
|
|
195
|
+
* text to clarify which inputs are mandatory
|
|
196
|
+
*/
|
|
197
|
+
mandatoryText: {
|
|
198
|
+
type: String,
|
|
199
|
+
default: "mandatory inputs"
|
|
200
|
+
},
|
|
201
|
+
/**
|
|
202
|
+
* properties for CmdLink-component for cancel-button
|
|
203
|
+
*/
|
|
204
|
+
cmdLinkCancelButton: {
|
|
205
|
+
type: Object,
|
|
206
|
+
required: false
|
|
207
|
+
},
|
|
208
|
+
/**
|
|
209
|
+
* properties for CmdLink-component for submit-button
|
|
210
|
+
*/
|
|
211
|
+
cmdLinkSubmitButton: {
|
|
212
|
+
type: Object,
|
|
213
|
+
required: false
|
|
214
|
+
},
|
|
215
|
+
/**
|
|
216
|
+
* properties for CmdHeadline-component
|
|
217
|
+
*/
|
|
218
|
+
cmdHeadline: {
|
|
219
|
+
type: Object,
|
|
220
|
+
required: false
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
mounted() {
|
|
224
|
+
// get the names of all elements that match the phrase and push to data-property to initially collect all required field to set correct validationStatus for form
|
|
225
|
+
const requiredElementNames = this.formElements?.filter(element => element.required === true).map(element => element.name)
|
|
226
|
+
|
|
227
|
+
requiredElementNames?.forEach((name) => {
|
|
228
|
+
this.formElementsWithError.push(name)
|
|
229
|
+
})
|
|
230
|
+
},
|
|
231
|
+
computed: {
|
|
232
|
+
cmdHeadlineProperties() {
|
|
233
|
+
return {
|
|
234
|
+
show: true,
|
|
235
|
+
headlineLevel: 3,
|
|
236
|
+
...this.cmdHeadline
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
legendProperties() {
|
|
240
|
+
return {
|
|
241
|
+
show: false,
|
|
242
|
+
align: "left",
|
|
243
|
+
text: "Legend",
|
|
244
|
+
...this.legend
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
cmdLinkCancelButtonProperties() {
|
|
248
|
+
return {
|
|
249
|
+
show: true,
|
|
250
|
+
linkType: "button",
|
|
251
|
+
highlightLevel: null,
|
|
252
|
+
icon: {
|
|
253
|
+
iconClass: "icon-cancel-circle"
|
|
254
|
+
},
|
|
255
|
+
text: "Cancel",
|
|
256
|
+
stretchOnSmallDevices: false,
|
|
257
|
+
position: "insideFieldset",
|
|
258
|
+
...this.cmdLinkCancelButton
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
cmdLinkSubmitButtonProperties() {
|
|
262
|
+
return {
|
|
263
|
+
show: true,
|
|
264
|
+
linkType: "button",
|
|
265
|
+
icon: {
|
|
266
|
+
iconClass: "icon-check-circle"
|
|
267
|
+
},
|
|
268
|
+
text: "Submit",
|
|
269
|
+
type: "submit",
|
|
270
|
+
position: "insideFieldset",
|
|
271
|
+
primary: true,
|
|
272
|
+
...this.cmdLinkSubmitButton
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
methods: {
|
|
277
|
+
createHtmlId,
|
|
278
|
+
formElementHasError(event, itemName) {
|
|
279
|
+
if (event === "error" && !this.formElementsWithError.some(entry => entry.name === itemName)) {
|
|
280
|
+
this.formElementsWithError.push(itemName)
|
|
281
|
+
} else if (event === "success" && this.formElementsWithError.includes(itemName)) {
|
|
282
|
+
this.formElementsWithError = this.formElementsWithError.filter((element) => element !== itemName)
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
this.$emit("validation-status-change", this.formElementsWithError.length ? "error" : "success")
|
|
286
|
+
},
|
|
287
|
+
showMessage(validationStatus, message) {
|
|
288
|
+
this.systemMessage.show = true
|
|
289
|
+
this.systemMessage.validationStatus = validationStatus
|
|
290
|
+
this.systemMessage.message = message
|
|
291
|
+
},
|
|
292
|
+
cancelFormSubmit(event) {
|
|
293
|
+
const isConfirmed = window.confirm("Are you sure you want to cancel the form submit (all entered data will be lost)?");
|
|
294
|
+
|
|
295
|
+
if (isConfirmed) {
|
|
296
|
+
this.$emit("cancel-form-submit", event)
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
submitFormData(event) {
|
|
300
|
+
// fill form-data with names and value
|
|
301
|
+
let formdata = {}
|
|
302
|
+
if (this.formElements) {
|
|
303
|
+
// iterate form-elements in flex-containers and input-wrappers to get their names and values
|
|
304
|
+
this.formElements.forEach((element) => {
|
|
305
|
+
if (element.component === 'flexContainer' || element.component === 'inputWrapper') {
|
|
306
|
+
element.formElements.forEach(innerElement => {
|
|
307
|
+
formdata[innerElement.name] = this.formValues[innerElement.name]
|
|
308
|
+
})
|
|
309
|
+
return
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
formdata[element.name] = this.formValues[element.name]
|
|
313
|
+
})
|
|
314
|
+
}
|
|
315
|
+
this.$emit("submit", { originalEvent: event, formdata: formdata })
|
|
316
|
+
},
|
|
317
|
+
onSubmit(event) {
|
|
318
|
+
if (this.useValidation) {
|
|
319
|
+
if (event.target.checkValidity()) {
|
|
320
|
+
this.errorOccurred = false
|
|
321
|
+
this.submitFormData(event)
|
|
322
|
+
} else {
|
|
323
|
+
event.preventDefault()
|
|
324
|
+
this.errorOccurred = true
|
|
325
|
+
}
|
|
326
|
+
} else {
|
|
327
|
+
this.submitFormData(event)
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
watch: {
|
|
332
|
+
modelValue: {
|
|
333
|
+
handler() {
|
|
334
|
+
if (!this.modelValue) {
|
|
335
|
+
return
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// assign values in loop, because entire object cannot be assigned
|
|
339
|
+
for (const key in this.modelValue) {
|
|
340
|
+
this.formValues[key] = this.modelValue[key]
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
immediate: true
|
|
344
|
+
},
|
|
345
|
+
formValues: {
|
|
346
|
+
handler() {
|
|
347
|
+
this.$emit("update:modelValue", this.formValues)
|
|
348
|
+
},
|
|
349
|
+
deep: true
|
|
350
|
+
},
|
|
351
|
+
/*
|
|
352
|
+
formValues: {
|
|
353
|
+
handler() {
|
|
354
|
+
if(!this.formElements) {
|
|
355
|
+
return
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
const numberRequiredFormElements = this.formElements.filter((element) => {
|
|
359
|
+
return element.required
|
|
360
|
+
}).length
|
|
361
|
+
|
|
362
|
+
const numberEmptyRequiredFormElements = this.formElements.filter((element) => {
|
|
363
|
+
return element.required && !this.formValues[element.name]
|
|
364
|
+
}).length
|
|
365
|
+
|
|
366
|
+
const allRequiredFormElementsEmpty = numberRequiredFormElements > 0 && numberRequiredFormElements === numberEmptyRequiredFormElements
|
|
367
|
+
const emptyRequiredFormElementExists = numberRequiredFormElements > 0 && numberEmptyRequiredFormElements > 0
|
|
368
|
+
|
|
369
|
+
this.$emit("empty-required-form-elements", { allRequiredFormElementsEmpty, emptyRequiredFormElementExists })
|
|
370
|
+
},
|
|
371
|
+
immediate: true,
|
|
372
|
+
deep: true
|
|
373
|
+
}, */
|
|
374
|
+
formElements: {
|
|
375
|
+
handler() {
|
|
376
|
+
this.formElements?.forEach(element => {
|
|
377
|
+
// iterate form-elements inside flex-containers and input-wrappers
|
|
378
|
+
if (element.component === 'flexContainer' || element.component === 'inputWrapper') {
|
|
379
|
+
element.formElements.forEach(innerElement => {
|
|
380
|
+
if (innerElement.type === "checkbox") {
|
|
381
|
+
// create array if element is a checkbox (to contain several values)
|
|
382
|
+
if (!this.formValues[innerElement.name]) {
|
|
383
|
+
this.formValues[innerElement.name] = []
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (innerElement.value != null) {
|
|
387
|
+
this.formValues[innerElement.name].push(innerElement.value)
|
|
388
|
+
}
|
|
389
|
+
} else {
|
|
390
|
+
this.formValues[innerElement.name] = innerElement.value ?? ""
|
|
391
|
+
}
|
|
392
|
+
})
|
|
393
|
+
return
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// iterate form-elements on main-level
|
|
397
|
+
if (element.type === "checkbox") {
|
|
398
|
+
// create array if element is a checkbox (to contain several values)
|
|
399
|
+
if (!this.formValues[element.name]) {
|
|
400
|
+
this.formValues[element.name] = []
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
if (element.value != null) {
|
|
404
|
+
this.formValues[element.name].push(element.value)
|
|
405
|
+
}
|
|
406
|
+
} else {
|
|
407
|
+
this.formValues[element.name] = element.value ?? ""
|
|
408
|
+
}
|
|
409
|
+
})
|
|
410
|
+
},
|
|
411
|
+
immediate: true,
|
|
412
|
+
deep: true
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
</script>
|
|
417
|
+
|
|
418
|
+
<style>
|
|
419
|
+
/* begin cmd-form ---------------------------------------------------------------------------------------- */
|
|
420
|
+
.cmd-form {
|
|
421
|
+
&:not([data-use-validation="true"]) {
|
|
422
|
+
|
|
423
|
+
label.error :where(::placeholder, select option:first-child),
|
|
424
|
+
:where(input, select, textarea):invalid:focus {
|
|
425
|
+
color: var(--error-color-text);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
:where(input, select, textarea):user-valid:focus[required],
|
|
429
|
+
select:user-invalid:focus[required] option:not(:first-child) {
|
|
430
|
+
color: var(--success-color-text);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/* must be refactored */
|
|
435
|
+
&.send-success {
|
|
436
|
+
fieldset {
|
|
437
|
+
border-color: var(--default-border-color) !important;
|
|
438
|
+
|
|
439
|
+
:is(label, .label) :is(.label-text :is(span, a[class*="icon-"], a:has([class*="icon-"])), .place-inside[class*="icon-"], input, select, textarea) {
|
|
440
|
+
--status-color: var(--default-text-color) !important;
|
|
441
|
+
border-color: var(--default-border-color) !important;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
sup {
|
|
445
|
+
--status-color: var(--primary-color-text) !important;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
legend.align-left {
|
|
451
|
+
left: 0;
|
|
452
|
+
right: auto;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
&.error {
|
|
456
|
+
|
|
457
|
+
fieldset,
|
|
458
|
+
*:invalid {
|
|
459
|
+
border-color: var(--error-color-text);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
.mandatory-text {
|
|
464
|
+
sup {
|
|
465
|
+
color: var(--primary-color);
|
|
466
|
+
font-size: 1.5rem;
|
|
467
|
+
top: 0;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
[type="submit"].button {
|
|
472
|
+
margin-left: auto;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
fieldset+.button-wrapper {
|
|
476
|
+
margin-top: var(--default-margin);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/* end cmd-form ---------------------------------------------------------------------------------------- */
|
|
481
|
+
</style>
|