|
6 | 6 | </label>
|
7 | 7 |
|
8 | 8 | <div class="field-wrap">
|
9 |
| - <component ref="child" :is="fieldType" :model="model" :schema="field" :formOptions="options" :eventBus="eventBus" :fieldID="fieldID" @errors-updated="onChildValidated"></component> |
| 9 | + <component ref="child" :is="fieldType" :model="model" :schema="field" :formOptions="options" :eventBus="eventBus" :fieldID="fieldID" @field-touched="onFieldTouched" @errors-updated="onChildValidated"></component> |
10 | 10 | <div v-if="buttonsAreVisible" class="buttons">
|
11 | 11 | <button v-for="(btn, index) in field.buttons" @click="buttonClickHandler(btn, field, $event)" :class="btn.classes" :key="index" v-text="btn.label"></button>
|
12 | 12 | </div>
|
@@ -51,7 +51,8 @@ export default {
|
51 | 51 | },
|
52 | 52 | data() {
|
53 | 53 | return {
|
54 |
| - childErrors: [] |
| 54 | + childErrors: [], |
| 55 | + childTouched: false |
55 | 56 | };
|
56 | 57 | },
|
57 | 58 | computed: {
|
@@ -93,7 +94,8 @@ export default {
|
93 | 94 | fieldRowClasses() {
|
94 | 95 | let baseClasses = {
|
95 | 96 | [objGet(this.options, "validationErrorClass", "error")]: this.fieldHasErrors,
|
96 |
| - [objGet(this.options, "validationSuccessClass", "valid")]: !this.fieldHasErrors, |
| 97 | + [objGet(this.options, "validationSuccessClass", "valid")]: !this.fieldHasErrors && this.childTouched, |
| 98 | + [objGet(this.options, "validationCleanClass", "clean")]: !this.fieldHasErrors && !this.childTouched, |
97 | 99 | disabled: this.getValueFromOption(this.field, "disabled"),
|
98 | 100 | readonly: this.getValueFromOption(this.field, "readonly"),
|
99 | 101 | featured: this.getValueFromOption(this.field, "featured"),
|
@@ -128,6 +130,9 @@ export default {
|
128 | 130 | buttonClickHandler(btn, field, event) {
|
129 | 131 | return btn.onclick.call(this, this.model, field, event, this);
|
130 | 132 | },
|
| 133 | + onFieldTouched() { |
| 134 | + this.childTouched = true; |
| 135 | + }, |
131 | 136 | onChildValidated(errors) {
|
132 | 137 | this.childErrors = errors;
|
133 | 138 | }
|
|
0 commit comments