comand-component-library 4.1.54 → 4.1.55

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.
@@ -7,6 +7,7 @@
7
7
  <!-- begin CmdForm -->
8
8
  <CmdForm
9
9
  @submit="onSubmit"
10
+ :class="{'send-success': sendSuccessfully}"
10
11
  novalidate="novalidate"
11
12
  v-bind="cmdForm"
12
13
  :legend="legend"
@@ -25,7 +26,6 @@
25
26
  :replaceInputType="configuration.salutation?.replaceInputType"
26
27
  v-model="formData.salutation.value"
27
28
  :i18n="i18n"
28
- @validate="onValidate"
29
29
  />
30
30
  <!-- end cmd-form-element -->
31
31
 
@@ -39,7 +39,6 @@
39
39
  :replaceInputType="configuration.salutation?.replaceInputType"
40
40
  v-model="formData.salutation.value"
41
41
  :i18n="i18n"
42
- @validate="onValidate"
43
42
  />
44
43
  <!-- end cmd-form-element -->
45
44
  </div>
@@ -62,7 +61,7 @@
62
61
  v-model="formData.lastName.value"
63
62
  :status="formData.lastName.error ? 'error' : ''"
64
63
  :i18n="i18n"
65
- @validate="onValidate"
64
+ :showStatusIcon="false"
66
65
  />
67
66
  <!-- end cmd-form-element -->
68
67
 
@@ -79,7 +78,6 @@
79
78
  v-model="formData.firstName.value"
80
79
  :status="formData.firstName.error ? 'error' : ''"
81
80
  :i18n="i18n"
82
- @validate="onValidate"
83
81
  />
84
82
  <!-- end cmd-form-element -->
85
83
  </div>
@@ -97,7 +95,7 @@
97
95
  v-model="formData.email.value"
98
96
  :status="formData.email.error ? 'error' : ''"
99
97
  :i18n="i18n"
100
- @validate="onValidate"
98
+ :showStatusIcon="false"
101
99
  />
102
100
  <!-- end cmd-form-element -->
103
101
 
@@ -114,7 +112,6 @@
114
112
  :name="configuration.phone?.name"
115
113
  :status="formData.phone.error ? 'error' : ''"
116
114
  :i18n="i18n"
117
- @validate="onValidate"
118
115
  />
119
116
  <!-- end cmd-form-element -->
120
117
  </div>
@@ -131,7 +128,6 @@
131
128
  v-model="formData.country.value"
132
129
  :status="formData.country.error ? 'error' : ''"
133
130
  :i18n="i18n"
134
- @validate="onValidate"
135
131
  @update:modelValue="onCountrySelect"
136
132
  />
137
133
  <!-- end cmd-form-element -->
@@ -148,7 +144,6 @@
148
144
  v-model="formData.streetNo.value"
149
145
  :status="formData.streetNo.error ? 'error' : ''"
150
146
  :i18n="i18n"
151
- @validate="onValidate"
152
147
  />
153
148
  <!-- end cmd-form-element -->
154
149
 
@@ -164,7 +159,6 @@
164
159
  v-model="formData.pobox.value"
165
160
  :status="formData.pobox.error ? 'error' : ''"
166
161
  :i18n="i18n"
167
- @validate="onValidate"
168
162
  />
169
163
  <!-- end cmd-form-element -->
170
164
 
@@ -182,7 +176,6 @@
182
176
  v-model="formData.zip.value"
183
177
  :status="formData.zip.error ? 'error' : ''"
184
178
  :i18n="i18n"
185
- @validate="onValidate"
186
179
  />
187
180
  <!-- end cmd-form-element -->
188
181
 
@@ -198,7 +191,6 @@
198
191
  v-model="formData.city.value"
199
192
  :status="formData.city.error ? 'error' : ''"
200
193
  :i18n="i18n"
201
- @validate="onValidate"
202
194
  />
203
195
  <!-- end cmd-form-element -->
204
196
  </div>
@@ -215,7 +207,6 @@
215
207
  v-model="formData.additionalAddressInfo.value"
216
208
  :status="formData.additionalAddressInfo.error ? 'error' : ''"
217
209
  :i18n="i18n"
218
- @validate="onValidate"
219
210
  />
220
211
  <!-- end cmd-form-element -->
221
212
  </div>
@@ -233,7 +224,7 @@
233
224
  v-model="formData.userMessage.value"
234
225
  :status="formData.userMessage.error ? 'error' : ''"
235
226
  :i18n="i18n"
236
- @validate="onValidate"
227
+ :showStatusIcon="false"
237
228
  />
238
229
  <!-- end cmd-form-element -->
239
230
 
@@ -252,12 +243,14 @@
252
243
  v-model="formData.acceptPrivacy.value"
253
244
  :status="formData.acceptPrivacy.error ? 'error' : ''"
254
245
  :i18n="i18n"
255
- @validate="onValidate">
246
+ >
256
247
  <template v-slot:labeltext>
257
248
  <span ref="dataPrivacy" v-html="getMessage('basic_form.labeltext.data_privacy')"></span>
258
249
  </template>
259
250
  </CmdFormElement>
260
251
  <!-- end cmd-form-element -->
252
+
253
+ <button class="button" type="button" @click="onSuccess">On Success</button>
261
254
  </CmdForm>
262
255
  <!-- end CmdForm -->
263
256
  </div>
@@ -284,6 +277,7 @@ export default {
284
277
  },
285
278
  data() {
286
279
  return {
280
+ sendSuccessfully: false,
287
281
  validator: new ContactFormValidator(label => label),
288
282
  formData: {
289
283
  salutation: {value: this.configuration.salutation.default},
@@ -481,9 +475,35 @@ export default {
481
475
  }
482
476
  },
483
477
  methods: {
478
+ onSuccess() {
479
+ this.sendSuccessfully = true
480
+ try {
481
+ // reset global validation-status
482
+ this.formData.error = false
483
+
484
+ for (let key in this.formData) {
485
+ // reset field-validation-status
486
+ if(this.formData[key].error) {
487
+ this.formData[key].error = false
488
+ }
489
+
490
+ // reset field-values
491
+ if(typeof this.formData[key].value === "string") {
492
+ if(key === "salutation") {
493
+ this.formData[key].value = this.configuration.salutation.default
494
+ } else {
495
+ this.formData[key].value = ""
496
+ }
497
+ } else if(key === "acceptPrivacy") {
498
+ this.formData[key].value = false
499
+ }
500
+ }
501
+ } catch (error) {
502
+ console.error(error)
503
+ }
504
+ },
484
505
  onSubmit(event) {
485
506
  this.onValidate()
486
-
487
507
  this.formData = Object.assign({}, this.validator.validatePrivacy(this.formData));
488
508
 
489
509
  if (this.formData.error || this.useNativeSubmit) {
@@ -523,6 +543,7 @@ export default {
523
543
 
524
544
  fetch(this.formAction, {method: this.cmdForm?.formMethod || "POST", body: customSubmitFormData}).then((response) => {
525
545
  if(response.ok) {
546
+ this.sendSuccessfully = true
526
547
  this.$refs.form.showMessage("success", this.getMessage("basic_form.system_message.success.message_sent_successfully"))
527
548
  try {
528
549
  // reset global validation-status
@@ -549,6 +570,7 @@ export default {
549
570
  console.error(error)
550
571
  }
551
572
  } else {
573
+ this.sendSuccessfully = false
552
574
  this.$refs.form.showMessage("error", this.getMessage("basic_form.system_message.error.message_could_not_be_sent"))
553
575
  }
554
576
  }).catch((error) => {
@@ -257,6 +257,20 @@ export default {
257
257
  }
258
258
  }
259
259
 
260
+ /* must be refactored */
261
+ &.send-success {
262
+ fieldset {
263
+ :is(label, .label):is(.error, .success):has(:user-invalid) :is(.label-text :is(span, a[class*="icon-"], a:has([class*="icon-"])), .place-inside[class*="icon-"], input, select, textarea) {
264
+ --status-color: var(--default-text-color) !important;
265
+ border-color: var(--default-border-color) !important;
266
+ }
267
+
268
+ sup {
269
+ --status-color: var(--primary-color) !important;
270
+ }
271
+ }
272
+ }
273
+
260
274
  legend.align-left {
261
275
  left: 0;
262
276
  right: auto;
@@ -11,12 +11,16 @@ class ContactFormValidator {
11
11
  }
12
12
 
13
13
  validate(formData) {
14
- [formData.lastName.error, formData.lastName.errorMessage] = this.validateRequired(
15
- formData.lastName.value, ContactFormValidator.PATTERN_SURNAME, this.label('form_error_invalid_surname'))
16
- [formData.email.error, formData.email.errorMessage] = this.validateRequired(
17
- formData.email.value, ContactFormValidator.PATTERN_EMAIL, this.label('form_error_invalid_email'))
18
- [formData.userMessage.error, formData.userMessage.errorMessage] = this.validateRequired(
19
- formData.userMessage.value, ContactFormValidator.PATTERN_MESSAGE, this.label('form_error_invalid_message'))
14
+ const lastNameValidationResult = this.validateRequired(formData.lastName.value, ContactFormValidator.PATTERN_SURNAME, this.label('form_error_invalid_surname'))
15
+ const emailValidationResult = this.validateRequired(formData.email.value, ContactFormValidator.PATTERN_EMAIL, this.label('form_error_invalid_email'))
16
+ const userMessageValidationResult = this.validateRequired(formData.userMessage.value, ContactFormValidator.PATTERN_MESSAGE, this.label('form_error_invalid_message'))
17
+ formData.lastName.error = lastNameValidationResult[0]
18
+ formData.lastName.errorMessage = lastNameValidationResult[1]
19
+ formData.email.error = emailValidationResult[0]
20
+ formData.email.errorMessage = emailValidationResult[1]
21
+ formData.userMessage.error = userMessageValidationResult[0]
22
+ formData.userMessage.errorMessage = userMessageValidationResult[1]
23
+ console.log("validate", formData.email)
20
24
  formData.acceptPrivacy.error = false
21
25
  formData.error = formData.lastName.error
22
26
  || formData.email.error