TT#46176 CallForward destination input validation

Change-Id: Icdd8dd3aeccaa3056bd9a2598918f1b6b3bce7d6
changes/84/24484/3
raxelsen 7 years ago
parent 62c65b978a
commit c75e215574

@ -16,6 +16,7 @@
@input="input" @input="input"
@blur="blur" @blur="blur"
:error="$v.inputValue.$error" :error="$v.inputValue.$error"
:before="beforeButtons"
/> />
</q-field> </q-field>
</template> </template>
@ -34,7 +35,8 @@
export default { export default {
name: 'csc-call-input', name: 'csc-call-input',
props: { props: {
label: String label: String,
before: Array
}, },
data () { data () {
return { return {
@ -69,6 +71,9 @@
else if (!this.$v.inputValue.userInfo) { else if (!this.$v.inputValue.userInfo) {
return this.$t('validationErrors.inputValidNumber'); return this.$t('validationErrors.inputValidNumber');
} }
},
beforeButtons() {
return this.before ? this.before : [];
} }
}, },
methods: { methods: {

@ -28,24 +28,13 @@
</q-popover> </q-popover>
</q-btn> </q-btn>
<div v-if="isFormEnabled"> <div v-if="isFormEnabled">
<q-field <csc-call-input
:error-label="destinationInputError" :label="$t('pages.callForward.destination')"
>
<q-input
dark
:before="beforeIconDestination"
:float-label="$t('pages.callForward.destination')"
type="text"
v-model="destinationForm.destination" v-model="destinationForm.destination"
@keyup.enter="addDestination()" @submit="addDestination"
:clearable="isFormTypeNumber" @error="error"
:autofocus="isFormTypeNumber" :before="beforeIconDestination"
:disable="!isFormTypeNumber || addDestinationIsRequesting"
@input="$v.destinationForm.destination.$touch"
@blur="$v.destinationForm.destination.$touch"
:error="$v.destinationForm.destination.$error"
/> />
</q-field>
<q-field <q-field
:error-label="timeoutInputError" :error-label="timeoutInputError"
> >
@ -74,7 +63,7 @@
icon="check" icon="check"
color="primary" color="primary"
@click="addDestination()" @click="addDestination()"
:disable="$v.destinationForm.destination.$error || $v.destinationForm.timeout.$error" :disable="$v.destinationForm.timeout.$error || destinationError"
> >
{{ $t('buttons.save') }} {{ $t('buttons.save') }}
</q-btn> </q-btn>
@ -84,6 +73,7 @@
<script> <script>
import _ from 'lodash' import _ from 'lodash'
import CscCallInput from '../../form/CscCallInput'
import { import {
startLoading, startLoading,
showGlobalError showGlobalError
@ -94,7 +84,6 @@
} from 'vuex' } from 'vuex'
import { import {
required, required,
maxLength,
minValue, minValue,
numeric numeric
} from 'vuelidate/lib/validators' } from 'vuelidate/lib/validators'
@ -126,10 +115,12 @@
destinationForm: { destinationForm: {
destination: '', destination: '',
timeout: 300 timeout: 300
} },
destinationError: false
} }
}, },
components: { components: {
CscCallInput,
QSelect, QSelect,
QPopover, QPopover,
QField, QField,
@ -142,10 +133,6 @@
}, },
validations: { validations: {
destinationForm: { destinationForm: {
destination: {
required,
maxLength: maxLength(64)
},
timeout: { timeout: {
required, required,
minValue: minValue(1), minValue: minValue(1),
@ -163,19 +150,6 @@
'hasSendFaxFeature', 'hasSendFaxFeature',
'hasFaxCapability' 'hasFaxCapability'
]), ]),
destinationInputError() {
if (!this.$v.destinationForm.destination.maxLength) {
return this.$t('validationErrors.maxLength', {
field: this.$t('pages.callForward.destination'),
maxLength: this.$v.destinationForm.destination.$params.maxLength.max
});
}
else if (!this.$v.destinationForm.destination.required) {
return this.$t('validationErrors.fieldRequired', {
field: this.$t('pages.callForward.destination')
});
}
},
timeoutInputError() { timeoutInputError() {
if (!this.$v.destinationForm.timeout.required) { if (!this.$v.destinationForm.timeout.required) {
return this.$t('validationErrors.fieldRequired', { return this.$t('validationErrors.fieldRequired', {
@ -194,9 +168,6 @@
}); });
} }
}, },
isFormTypeNumber() {
return this.formType === 'number';
},
isFormEnabled() { isFormEnabled() {
return this.activeForm === this.groupName && this.formEnabled; return this.activeForm === this.groupName && this.formEnabled;
}, },
@ -252,8 +223,8 @@
this.$store.commit('callForward/resetDestinationState'); this.$store.commit('callForward/resetDestinationState');
}, },
addDestination() { addDestination() {
if (this.$v.destinationForm.destination.$error || if (this.$v.destinationForm.timeout.$error ||
this.$v.destinationForm.timeout.$error) { this.destinationError) {
showGlobalError(this.$t('validationErrors.generic')); showGlobalError(this.$t('validationErrors.generic'));
} }
else { else {
@ -266,6 +237,9 @@
sourcesetId: this.sourcesetId sourcesetId: this.sourcesetId
}); });
} }
},
error(state) {
this.destinationError = state;
} }
} }
} }

@ -71,6 +71,9 @@
import 'quasar-extras/animate/bounceInRight.css' import 'quasar-extras/animate/bounceInRight.css'
import 'quasar-extras/animate/bounceOutRight.css' import 'quasar-extras/animate/bounceOutRight.css'
import CscCallInput from '../../form/CscCallInput' import CscCallInput from '../../form/CscCallInput'
import {
showGlobalError
} from '../../../helpers/ui'
import { import {
QCard, QCard,
QCardTitle, QCardTitle,
@ -137,10 +140,15 @@
this.formEnabled = false; this.formEnabled = false;
}, },
save() { save() {
if (this.destinationError) {
showGlobalError(this.$t('validationErrors.generic'));
}
else {
this.$emit('save', { this.$emit('save', {
destination: this.destination, destination: this.destination,
slot: this.slot slot: this.slot
}); });
}
}, },
reset() { reset() {
this.destination = ''; this.destination = '';

Loading…
Cancel
Save