Browse Source

Add a validation to label mapping creation form

pull/1206/head
Hironsan 4 years ago
parent
commit
2454fb2c17
1 changed files with 37 additions and 26 deletions
  1. 63
      frontend/components/containers/settings/LabelMapping.vue

63
frontend/components/containers/settings/LabelMapping.vue

@ -26,31 +26,38 @@
<v-card-text> <v-card-text>
<v-container> <v-container>
<v-row>
<v-col
cols="12"
sm="12"
class="pa-0"
>
<v-text-field
v-model="editedItem.from"
label="From"
outlined
/>
</v-col>
<v-col
cols="12"
sm="12"
class="pa-0"
>
<v-select
v-model="editedItem.to"
:items="items"
label="To"
outlined
/>
</v-col>
</v-row>
<v-form
ref="form"
v-model="valid"
>
<v-row>
<v-col
cols="12"
sm="12"
class="pa-0"
>
<v-text-field
v-model="editedItem.from"
label="From"
:rules="labelNameRules($t('rules.labelNameRules'))"
outlined
/>
</v-col>
<v-col
cols="12"
sm="12"
class="pa-0"
>
<v-select
v-model="editedItem.to"
:items="items"
:rules="labelNameRules($t('rules.labelNameRules'))"
label="To"
outlined
/>
</v-col>
</v-row>
</v-form>
</v-container> </v-container>
</v-card-text> </v-card-text>
@ -65,6 +72,7 @@
Cancel Cancel
</v-btn> </v-btn>
<v-btn <v-btn
:disabled="!valid"
color="blue darken-1" color="blue darken-1"
class="text-capitalize" class="text-capitalize"
text text
@ -99,12 +107,14 @@ import Vue from 'vue'
import { headers } from '@/models/config/config-template' import { headers } from '@/models/config/config-template'
import { FromApiLabelItemListRepository } from '@/repositories/label/api' import { FromApiLabelItemListRepository } from '@/repositories/label/api'
import { LabelApplicationService } from '@/services/application/label.service' import { LabelApplicationService } from '@/services/application/label.service'
import { labelNameRules } from '@/rules/index'
export default Vue.extend({ export default Vue.extend({
data() { data() {
return { return {
headers, headers,
dialog: false, dialog: false,
valid: false,
editedIndex: -1, editedIndex: -1,
editedItem: { editedItem: {
'from': '', 'from': '',
@ -114,7 +124,8 @@ export default Vue.extend({
'from': '', 'from': '',
'to': '' 'to': ''
}, },
items: [] as string[]
items: [] as string[],
labelNameRules
} }
}, },

Loading…
Cancel
Save