Change-Id: Ib3be8962f17edbced21f2eebf78895ce20379afcchanges/85/24485/6
parent
26224ec89d
commit
62c65b978a
@ -0,0 +1,97 @@
|
||||
|
||||
<template>
|
||||
<q-field
|
||||
:error-label="errorMessage"
|
||||
>
|
||||
<q-input
|
||||
dark
|
||||
clearable
|
||||
type="text"
|
||||
:float-label="label"
|
||||
v-model="inputValue"
|
||||
@keyup.enter="submit"
|
||||
@keypress.space.prevent
|
||||
@keydown.space.prevent
|
||||
@keyup.space.prevent
|
||||
@input="input"
|
||||
@blur="blur"
|
||||
:error="$v.inputValue.$error"
|
||||
/>
|
||||
</q-field>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
QField,
|
||||
QInput
|
||||
} from 'quasar-framework'
|
||||
import { userInfo } from '../../helpers/validation'
|
||||
import {
|
||||
maxLength,
|
||||
required
|
||||
} from 'vuelidate/lib/validators'
|
||||
|
||||
export default {
|
||||
name: 'csc-call-input',
|
||||
props: {
|
||||
label: String
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
inputValue: '',
|
||||
error: ''
|
||||
}
|
||||
},
|
||||
validations: {
|
||||
inputValue: {
|
||||
userInfo,
|
||||
maxLength: maxLength(64),
|
||||
required
|
||||
}
|
||||
},
|
||||
components: {
|
||||
QField,
|
||||
QInput
|
||||
},
|
||||
computed: {
|
||||
errorMessage() {
|
||||
if (!this.$v.inputValue.required) {
|
||||
return this.$t('validationErrors.fieldRequired', {
|
||||
field: this.label
|
||||
});
|
||||
}
|
||||
else if (!this.$v.inputValue.maxLength) {
|
||||
return this.$t('validationErrors.maxLength', {
|
||||
field: this.label,
|
||||
maxLength: this.$v.inputValue.$params.maxLength.max
|
||||
});
|
||||
}
|
||||
else if (!this.$v.inputValue.userInfo) {
|
||||
return this.$t('validationErrors.inputValidNumber');
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
this.$emit('submit');
|
||||
},
|
||||
input() {
|
||||
this.$v.inputValue.$touch();
|
||||
this.error = this.$v.inputValue.$error;
|
||||
this.$emit('input', this.inputValue);
|
||||
},
|
||||
blur() {
|
||||
this.$v.inputValue.$touch();
|
||||
this.error = this.$v.inputValue.$error;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
error(state) {
|
||||
this.$emit('error', state);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="stylus" rel="stylesheet/stylus">
|
||||
</style>
|
@ -1,53 +0,0 @@
|
||||
|
||||
<template>
|
||||
<q-input
|
||||
dark
|
||||
clearable
|
||||
type="text"
|
||||
:float-label="label"
|
||||
:value="destination"
|
||||
@input="inputDestination"
|
||||
@keyup.enter="submit"
|
||||
@keypress.space.prevent
|
||||
@keydown.space.prevent
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
normalizeNumber,
|
||||
rawNumber
|
||||
} from '../../filters/number-format'
|
||||
import {
|
||||
QInput,
|
||||
Platform
|
||||
} from 'quasar-framework'
|
||||
|
||||
export default {
|
||||
name: 'csc-destination-input',
|
||||
props: {
|
||||
loading: Boolean,
|
||||
label: String
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
destination: ''
|
||||
}
|
||||
},
|
||||
components: {
|
||||
QInput
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
this.$emit('submit');
|
||||
},
|
||||
inputDestination(value) {
|
||||
this.destination = normalizeNumber(value, Platform.is.mobile);
|
||||
this.$emit('input', rawNumber(this.destination));
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="stylus" rel="stylesheet/stylus">
|
||||
</style>
|
Loading…
Reference in new issue