-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #505 Title and Description Validation
- Loading branch information
1 parent
28a1066
commit ba223b6
Showing
2 changed files
with
577 additions
and
567 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,81 @@ | ||
<template> | ||
<v-form ref="form"> | ||
<v-row justify="space-around" class="pa-2"> | ||
<v-col cols="12" md="5"> | ||
<v-text-field | ||
v-model="test.testTitle" | ||
:autofocus="lock ? false : true" | ||
:label="$t('common.title')" | ||
:rules="titleRequired" | ||
counter="100" | ||
outlined | ||
dense | ||
@input="$store.commit('SET_LOCAL_CHANGES', true)" | ||
/> | ||
<v-select | ||
v-model="test.testType" | ||
:disabled="lock" | ||
:items="types" | ||
:label="$t('common.type')" | ||
:rules="typeRequired" | ||
dense | ||
outlined | ||
/> | ||
</v-col> | ||
<v-col cols="12" md="5"> | ||
<v-textarea | ||
v-model="test.testDescription" | ||
:label="$t('common.description')" | ||
outlined | ||
dense | ||
@input="$store.commit('SET_LOCAL_CHANGES', true)" | ||
/> | ||
<v-checkbox | ||
v-model="test.isPublic" | ||
:label="$t('pages.createTest.public')" | ||
color="#F9A826" | ||
@change="$store.commit('SET_LOCAL_CHANGES', true)" | ||
/> | ||
</v-col> | ||
</v-row> | ||
</v-form> | ||
</template> | ||
|
||
<script> | ||
import i18n from '@/i18n' | ||
export default { | ||
props: { | ||
test: { | ||
type: Object, | ||
required: true, | ||
}, | ||
lock: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}, | ||
data: () => ({ | ||
titleRequired: [ | ||
(v) => !!v || i18n.t('errors.fieldRequired'), | ||
(v) => (v && v.length <= 100) || 'Max 100 characters', | ||
], | ||
typeRequired: [(v) => !!v || i18n.t('errors.fieldRequired')], | ||
types: [ | ||
{ text: 'Usability User Test', value: 'User' }, | ||
{ text: i18n.t('titles.heuristic'), value: 'HEURISTICS' }, | ||
], | ||
}), | ||
methods: { | ||
valida() { | ||
const valid = this.$refs.form.validate() | ||
this.$emit('valForm', valid, 0) | ||
return valid | ||
}, | ||
resetVal() { | ||
this.$refs.form.resetValidation() //used on emits | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style></style> | ||
<template> | ||
<v-form ref="form"> | ||
<v-row justify="space-around" class="pa-2"> | ||
<v-col cols="12" md="5"> | ||
<v-text-field | ||
v-model="test.testTitle" | ||
:autofocus="lock ? false : true" | ||
:label="$t('common.title')" | ||
:rules="titleRequired" | ||
counter="200" | ||
outlined | ||
dense | ||
@input="$store.commit('SET_LOCAL_CHANGES', true)" | ||
/> | ||
<v-select | ||
v-model="test.testType" | ||
:disabled="lock" | ||
:items="types" | ||
:label="$t('common.type')" | ||
:rules="typeRequired" | ||
dense | ||
outlined | ||
/> | ||
</v-col> | ||
<v-col cols="12" md="5"> | ||
<v-textarea | ||
v-model="test.testDescription" | ||
:label="$t('common.description')" | ||
outlined | ||
dense | ||
@input="$store.commit('SET_LOCAL_CHANGES', true)" | ||
/> | ||
<v-checkbox | ||
v-model="test.isPublic" | ||
:label="$t('pages.createTest.public')" | ||
color="#F9A826" | ||
@change="$store.commit('SET_LOCAL_CHANGES', true)" | ||
/> | ||
</v-col> | ||
</v-row> | ||
</v-form> | ||
</template> | ||
|
||
<script> | ||
import i18n from '@/i18n' | ||
export default { | ||
props: { | ||
test: { | ||
type: Object, | ||
required: true, | ||
}, | ||
lock: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}, | ||
data: () => ({ | ||
titleRequired: [ | ||
(v) => !!v || i18n.t('errors.fieldRequired'), | ||
(v) => (v && v.length <= 200) || 'Max 200 characters', | ||
], | ||
typeRequired: [(v) => !!v || i18n.t('errors.fieldRequired')], | ||
types: [ | ||
{ text: 'Usability User Test', value: 'User' }, | ||
{ text: i18n.t('titles.heuristic'), value: 'HEURISTICS' }, | ||
], | ||
}), | ||
methods: { | ||
valida() { | ||
const valid = this.$refs.form.validate() | ||
this.$emit('valForm', valid, 0) | ||
return valid | ||
}, | ||
resetVal() { | ||
this.$refs.form.resetValidation() //used on emits | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style></style> |
Oops, something went wrong.