2020-10-18 20:11:20 +03:00
|
|
|
<template>
|
2020-11-02 18:55:03 +03:00
|
|
|
<div>
|
|
|
|
<div
|
|
|
|
v-for="(item, groupIndex) in groups"
|
|
|
|
:key="groupIndex"
|
2020-11-02 11:54:50 +03:00
|
|
|
>
|
2020-11-02 18:55:03 +03:00
|
|
|
<FormularioGrouping :name="`groups[${groupIndex}]`">
|
|
|
|
<FormularioInput
|
|
|
|
v-slot="{ context }"
|
|
|
|
class="mb-3"
|
|
|
|
name="text"
|
|
|
|
validation="number|required"
|
|
|
|
validation-behavior="live"
|
|
|
|
>
|
|
|
|
<label for="text-field">Text field (number|required)</label>
|
|
|
|
<input
|
|
|
|
id="text-field"
|
|
|
|
v-model="context.model"
|
|
|
|
type="text"
|
|
|
|
class="form-control"
|
|
|
|
style="max-width: 250px;"
|
|
|
|
>
|
|
|
|
|
|
|
|
<div
|
|
|
|
v-for="(error, index) in context.allErrors"
|
|
|
|
:key="index"
|
|
|
|
class="text-danger"
|
|
|
|
>
|
|
|
|
{{ error }}
|
|
|
|
</div>
|
|
|
|
</FormularioInput>
|
|
|
|
|
|
|
|
<FormularioInput
|
|
|
|
v-slot="{ context }"
|
|
|
|
:validation-messages="{ in: 'The value was different than expected' }"
|
|
|
|
class="mb-3"
|
|
|
|
name="abcdef-field"
|
|
|
|
validation="in:abcdef"
|
|
|
|
validation-behavior="live"
|
|
|
|
>
|
|
|
|
<label for="abcdef-field">Text field (in:abcdef)</label>
|
|
|
|
<input
|
|
|
|
id="abcdef-field"
|
|
|
|
v-model="context.model"
|
|
|
|
type="text"
|
|
|
|
class="form-control"
|
|
|
|
style="max-width: 250px;"
|
|
|
|
>
|
|
|
|
|
|
|
|
<div
|
|
|
|
v-for="(error, index) in context.allErrors"
|
|
|
|
:key="index"
|
|
|
|
class="text-danger"
|
|
|
|
>
|
|
|
|
{{ error }}
|
|
|
|
</div>
|
|
|
|
</FormularioInput>
|
|
|
|
</FormularioGrouping>
|
|
|
|
|
|
|
|
<button @click="onRemoveGroup(groupIndex)">
|
|
|
|
Remove Group
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button @click="onAddGroup">
|
|
|
|
Add Group
|
|
|
|
</button>
|
|
|
|
</div>
|
2020-10-18 20:11:20 +03:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-11-02 18:55:03 +03:00
|
|
|
import FormularioGrouping from '@/FormularioGrouping'
|
|
|
|
import FormularioInput from '@/FormularioInput'
|
2020-10-18 20:11:20 +03:00
|
|
|
|
|
|
|
export default {
|
2020-11-02 18:55:03 +03:00
|
|
|
name: 'FormularioGroupingGroupTale',
|
2020-10-18 20:11:20 +03:00
|
|
|
|
|
|
|
components: {
|
2020-11-02 18:55:03 +03:00
|
|
|
FormularioGrouping,
|
|
|
|
FormularioInput,
|
|
|
|
},
|
|
|
|
|
|
|
|
model: {
|
|
|
|
prop: 'groups',
|
|
|
|
event: 'change'
|
|
|
|
},
|
|
|
|
|
|
|
|
props: {
|
|
|
|
groups: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
2020-10-18 20:11:20 +03:00
|
|
|
},
|
|
|
|
|
2020-11-02 18:55:03 +03:00
|
|
|
methods: {
|
|
|
|
onAddGroup () {
|
|
|
|
this.$emit('change', this.groups.concat([{}]))
|
|
|
|
},
|
|
|
|
onRemoveGroup (removedIndex) {
|
|
|
|
this.$emit('change', this.groups.filter((item, index) => {
|
|
|
|
return index !== removedIndex
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
}
|
2020-10-18 20:11:20 +03:00
|
|
|
}
|
|
|
|
</script>
|