TT#46172 Impl PIN validation in Voicebox settings

Change-Id: Ia469efec8e5c63950e3f800c52c0cc489c92b801
changes/25/24425/7
raxelsen 7 years ago committed by Hans-Peter Herzog
parent 5a152e3967
commit 02137b1b48

@ -53,7 +53,6 @@
dark
:before="beforeIconTimeout"
:float-label="$t('pages.callForward.timeout')"
type="number"
v-model="destinationForm.timeout"
suffix="seconds"
clearable
@ -96,7 +95,8 @@
import {
required,
maxLength,
minValue
minValue,
numeric
} from 'vuelidate/lib/validators'
import {
QItem,
@ -148,7 +148,8 @@
},
timeout: {
required,
minValue: minValue(1)
minValue: minValue(1),
numeric
}
}
},
@ -176,15 +177,20 @@
}
},
timeoutInputError() {
if (!this.$v.destinationForm.timeout.minValue) {
return this.$t('validationErrors.minValueSecond', {
if (!this.$v.destinationForm.timeout.required) {
return this.$t('validationErrors.fieldRequired', {
field: this.$t('pages.callForward.timeout')
});
}
else if (!this.$v.destinationForm.timeout.numeric) {
return this.$t('validationErrors.numeric', {
field: this.$t('pages.callForward.timeout'),
minValue: this.$v.destinationForm.timeout.$params.minValue.min
});
}
else if (!this.$v.destinationForm.timeout.required) {
return this.$t('validationErrors.fieldRequired', {
field: this.$t('pages.callForward.timeout')
else if (!this.$v.destinationForm.timeout.minValue) {
return this.$t('validationErrors.minValueSecond', {
field: this.$t('pages.callForward.timeout'),
minValue: this.$v.destinationForm.timeout.$params.minValue.min
});
}
},

@ -168,7 +168,6 @@
dark
v-if="ownPhone"
v-model="editTimeout"
type="number"
suffix="seconds"
:before="[{ icon: 'schedule' }]"
:float-label="$t('pages.callForward.timeout')"
@ -216,7 +215,8 @@
import CscAddDestinationForm from './CscAddDestinationForm'
import {
required,
minValue
minValue,
numeric
} from 'vuelidate/lib/validators'
import {
QList,
@ -273,7 +273,8 @@
validations: {
editTimeout: {
required,
minValue: minValue(1)
minValue: minValue(1),
numeric
}
},
computed: {
@ -281,17 +282,22 @@
return this.ownPhone ? 'fa-toggle-off' : 'fa-toggle-on';
},
errorMessage() {
if (!this.$v.editTimeout.minValue) {
return this.$t('validationErrors.minValueSecond', {
field: this.$t('pages.callForward.timeout'),
minValue: this.$v.editTimeout.$params.minValue.min
});
}
else if (!this.$v.editTimeout.required) {
if (!this.$v.editTimeout.required) {
return this.$t('validationErrors.fieldRequired', {
field: this.$t('pages.callForward.timeout')
});
}
else if (!this.$v.editTimeout.numeric) {
return this.$t('validationErrors.numeric', {
field: this.$t('pages.callForward.timeout'),
});
}
else if (!this.$v.editTimeout.minValue) {
return this.$t('validationErrors.minValueSecond', {
field: this.$t('pages.callForward.timeout'),
minValue: this.$v.editTimeout.$params.minValue.min
});
}
},
editTimeout: {
get() {

@ -48,12 +48,12 @@
>
<q-input
dark
v-model="device.identifier"
v-model="changes.identifier"
:after="identifierButtons"
@keyup.enter="saveIdentifier"
@input="$v.device.identifier.$touch"
@blur="$v.device.identifier.$touch"
:error="$v.device.identifier.$error"
@input="$v.changes.identifier.$touch"
@blur="$v.changes.identifier.$touch"
:error="$v.changes.identifier.$error"
/>
</q-field>
<q-field
@ -186,7 +186,7 @@
}
},
validations: {
device: {
changes: {
identifier: {
required,
customMacAddress
@ -247,6 +247,9 @@
stationName() {
return this.device.station_name;
},
identifier() {
return this.device.station_name;
},
deviceModel() {
return {
id: this.changes.id,
@ -263,7 +266,18 @@
identifierButtons() {
let buttons = [];
let self = this;
if(this.identifierHasChanges) {
if (this.identifierHasChanges && this.$v.changes.identifier.$error) {
buttons.push({
icon: 'clear',
error: true,
handler (event) {
event.stopPropagation();
self.resetIdentifier();
}
}
);
}
else if (this.identifierHasChanges) {
buttons.push({
icon: 'check',
error: false,
@ -287,12 +301,12 @@
return _.get(this.device, 'profile.id', null);
},
identifierErrorMessage() {
if (!this.$v.device.identifier.required) {
if (!this.$v.changes.identifier.required) {
return this.$t('validationErrors.fieldRequired', {
field: this.$t('pbxConfig.deviceIdentifier')
});
}
else if (!this.$v.device.identifier.customMacAddress) {
else if (!this.$v.changes.identifier.customMacAddress) {
return this.$t('validationErrors.macAddress');
}
}
@ -333,7 +347,7 @@
this.changes.identifier = this.device.identifier;
},
saveIdentifier() {
if (!this.$v.device.identifier.$error) {
if (!this.$v.changes.identifier.$error) {
this.$emit('save-identifier', this.deviceModel);
}
else {

@ -45,7 +45,6 @@
:error="$v.data.huntTimeout.$error"
:disabled="loading"
:readonly="loading"
type="number"
v-model="data.huntTimeout"
clearable
:float-label="$t('pbxConfig.huntTimeout')"
@ -165,6 +164,7 @@
},
huntTimeout: {
required,
numeric,
minValue: minValue(1),
maxValue: maxValue(3600)
}
@ -202,7 +202,7 @@
});
}
else if (!this.$v.data.extension.numeric) {
return this.$t('validationErrors.alphaNum', {
return this.$t('validationErrors.numeric', {
field: this.$t('pbxConfig.extension'),
});
}
@ -213,6 +213,11 @@
field: this.$t('pbxConfig.huntTimeoutSentence')
});
}
else if (!this.$v.data.huntTimeout.numeric) {
return this.$t('validationErrors.numeric', {
field: this.$t('pbxConfig.huntTimeoutSentence'),
});
}
else if (!this.$v.data.huntTimeout.minValue) {
return this.$t('validationErrors.minValueSecond', {
field: this.$t('pbxConfig.huntTimeoutSentence'),

@ -18,17 +18,20 @@
no-border
class="csc-pbx-model-list"
highlight
inset-separator
>
<q-item
v-for="(profile, index) in profiles"
v-for="profile in profiles"
:key="profile.id"
@click="selectProfile(profile)"
class="cursor-pointer"
>
<q-item-side>
<q-item-tile avatar>
<img :src="frontImageUrl(profile.device_id)" />
<q-item-tile
avatar
>
<img
:src="frontImageUrl(profile.device_id)"
/>
</q-item-tile>
</q-item-side>
<q-item-main>

@ -167,7 +167,7 @@
});
}
else if (!this.$v.data.extension.numeric) {
return this.$t('validationErrors.alphaNum', {
return this.$t('validationErrors.numeric', {
field: this.$t('pbxConfig.extension'),
});
}

@ -85,8 +85,10 @@
</template>
<script>
import { showGlobalError } from '../../../helpers/ui'
import {
maxLength,
numeric,
email
} from 'vuelidate/lib/validators'
import {
@ -125,7 +127,8 @@
validations: {
changes: {
pin: {
maxLength: maxLength(64)
maxLength: maxLength(64),
numeric
},
email: {
email
@ -134,10 +137,17 @@
},
computed: {
pinErrorMessage() {
return this.$t('validationErrors.maxLength', {
field: this.$t('voicebox.pin'),
maxLength: this.$v.changes.pin.$params.maxLength.max
});
if (!this.$v.changes.pin.maxLength) {
return this.$t('validationErrors.maxLength', {
field: this.$t('voicebox.pin'),
maxLength: this.$v.changes.pin.$params.maxLength.max
});
}
else if (!this.$v.changes.pin.numeric) {
return this.$t('validationErrors.numeric', {
field: this.$t('voicebox.pin')
});
}
},
emailErrorMessage() {
return this.$t('validationErrors.email');
@ -154,7 +164,18 @@
pinButtons() {
let buttons = [];
let self = this;
if (this.pinHasChanged) {
if (this.pinHasChanged && this.$v.changes.pin.$error) {
buttons.push({
icon: 'clear',
error: true,
handler (event) {
event.stopPropagation();
self.resetFields();
}
}
);
}
else if (this.pinHasChanged) {
buttons.push({
icon: 'check',
error: false,
@ -177,7 +198,18 @@
emailButtons() {
let buttons = [];
let self = this;
if (this.emailHasChanged) {
if (this.emailHasChanged && this.$v.changes.email.$error) {
buttons.push({
icon: 'clear',
error: true,
handler (event) {
event.stopPropagation();
self.resetFields();
}
}
);
}
else if (this.emailHasChanged) {
buttons.push({
icon: 'check',
error: false,
@ -237,14 +269,20 @@
this.$store.dispatch('voicebox/toggleAttach');
},
updatePin() {
if(this.pinHasChanged) {
if (this.pinHasChanged && !this.$v.changes.pin.$error) {
this.$store.dispatch('voicebox/updatePin', this.changes.pin);
}
else {
showGlobalError(this.$t('validationErrors.pin'));
}
},
updateEmail() {
if(this.emailHasChanged) {
if (this.emailHasChanged && !this.$v.changes.email.$error) {
this.$store.dispatch('voicebox/updateEmail', this.changes.email);
}
else {
showGlobalError(this.$t('validationErrors.email'));
}
}
},
watch: {

@ -35,12 +35,13 @@
"fieldRequired": "{field} is required",
"minValueSecond": "{field} must be at least {minValue} second",
"maxValueSecond": "{field} must be maximum of {maxValue} seconds",
"alphaNum": "{field} must consist of numeric characters only",
"numeric": "{field} must consist of numeric characters only",
"inputNumber": "Input a phone number",
"inputValidNumber": "Input a valid phone number",
"fieldRequiredXor": "{fieldOne} or {fieldTwo} is required",
"email": "Input a valid email address",
"macAddress": "Input a valid mac address",
"pin": "Input a valid PIN",
"userInfoAndEmpty": "Input contains invalid characters"
},
"navigation": {
@ -325,7 +326,6 @@
"removeGroup": "Remove group",
"removeGroupTitle": "Remove group",
"removeGroupText": "You are about to remove group {group}",
"groupName": "Group name",
"name": "Name",
"seatName": "Seat name",
"addSeat": "Add Seat",

@ -69,7 +69,7 @@
.csc-no-entities
margin 15px
color $secondary
color $body-color
.csc-important
font-weight bold
@ -161,3 +161,6 @@
bottom 0
.csc-list-message
text-align center
.q-inner-loading
background $main-menu-background

@ -75,10 +75,11 @@ $csc-subtitle-line-height = 2rem
$item-stripe-color = alpha(white, 0.06)
$item-highlight-color = alpha(white, 0.1)
$item-content-secondary-text-color = alpha($white, 70%)
$typography-font-family = 'Muli', '-apple-system', 'Helvetica Neue', Helvetica, Arial, sans-serif
$popover-background = $main-menu-background
$popover-background = alpha($dark, 90%)
$modal-background = $body-background
$modal-body-color = $body-color
@ -89,3 +90,5 @@ $call-footer-action-margin = 27px
$call-footer-height-mobile = $call-footer-height * 1.4
$popover-box-shadow = $shadow-1
$loading-background = $main-menu-background

Loading…
Cancel
Save