From 6612d8a5f930b535241cd0d27e2bfe7742f71627 Mon Sep 17 00:00:00 2001 From: Zaytsev Kirill Date: Sun, 30 May 2021 14:12:58 +0300 Subject: [PATCH] refactor!: FormularioFieldGroup - isArrayItem prop no longer required, replaced with integer name value detection --- src/FormularioField.vue | 3 ++- src/FormularioFieldGroup.vue | 13 ++++++------- storybook/stories/ExampleAddressList.tale.vue | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/FormularioField.vue b/src/FormularioField.vue index 3f11259..1ed6977 100644 --- a/src/FormularioField.vue +++ b/src/FormularioField.vue @@ -149,10 +149,11 @@ export default class FormularioField extends Vue { if (!this.hasModel && !shallowEquals(newValue, oldValue)) { this.model = newValue } + if (this.validationBehavior === VALIDATION_BEHAVIOR.LIVE) { this.runValidation() } else { - this.violations = [] + this.resetValidation() } } diff --git a/src/FormularioFieldGroup.vue b/src/FormularioFieldGroup.vue index 5dd9190..c60ddc6 100644 --- a/src/FormularioFieldGroup.vue +++ b/src/FormularioFieldGroup.vue @@ -20,20 +20,19 @@ export default class FormularioFieldGroup extends Vue { @Prop({ required: true }) readonly name!: string - @Prop({ default: false }) - readonly isArrayItem!: boolean - @Provide('__Formulario_path') get fullPath (): string { - if (this.isArrayItem) { - return `${this.__Formulario_path}[${this.name}]` + const name = `${this.name}` + + if (parseInt(name).toString() === name) { + return `${this.__Formulario_path}[${name}]` } if (this.__Formulario_path === '') { - return this.name + return name } - return `${this.__Formulario_path}.${this.name}` + return `${this.__Formulario_path}.${name}` } } diff --git a/storybook/stories/ExampleAddressList.tale.vue b/storybook/stories/ExampleAddressList.tale.vue index 629207b..b5708bc 100644 --- a/storybook/stories/ExampleAddressList.tale.vue +++ b/storybook/stories/ExampleAddressList.tale.vue @@ -11,7 +11,6 @@ v-for="(address, addressIndex) in addressList.context.model" :key="'address-' + addressIndex" :name="addressIndex" - :is-array-item="true" class="row mx-n2" >