diff --git a/src/components/pages/PbxConfiguration/CscPbxGroupAddForm.vue b/src/components/pages/PbxConfiguration/CscPbxGroupAddForm.vue index c1efabb6..eb7b1da3 100644 --- a/src/components/pages/PbxConfiguration/CscPbxGroupAddForm.vue +++ b/src/components/pages/PbxConfiguration/CscPbxGroupAddForm.vue @@ -154,8 +154,7 @@ import { minValue, maxValue, maxLength, - numeric, - between + numeric } from '@vuelidate/validators' import { inRange } from 'src/helpers/validation' import CscObjectSpinner from '../../CscObjectSpinner' @@ -203,7 +202,7 @@ export default { maxLength: maxLength(64), numeric, isInRange: function (value) { - return inRange(value, this.getMinAllowedExtension, this.getMaxAllowedExtension, between) + return inRange(value, this.getMinAllowedExtension, this.getMaxAllowedExtension) } }, huntTimeout: { diff --git a/src/components/pages/PbxConfiguration/CscPbxSeatAddForm.vue b/src/components/pages/PbxConfiguration/CscPbxSeatAddForm.vue index e6f31079..a020e213 100644 --- a/src/components/pages/PbxConfiguration/CscPbxSeatAddForm.vue +++ b/src/components/pages/PbxConfiguration/CscPbxSeatAddForm.vue @@ -32,7 +32,6 @@ clearable dense hide-bottom-space - hide-hint :error="v$.data.extension.$errors.length > 0" :error-message="extensionErrorMessage" :disable="loading" @@ -201,8 +200,7 @@ import { import { required, maxLength, - numeric, - between + numeric } from '@vuelidate/validators' import { inRange } from 'src/helpers/validation' import CscInput from 'components/form/CscInput' @@ -256,7 +254,7 @@ export default { numeric, maxLength: maxLength(64), isInRange: function (value) { - return inRange(value, this.getMinAllowedExtension, this.getMaxAllowedExtension, between) + return inRange(value, this.getMinAllowedExtension, this.getMaxAllowedExtension) } }, password: { diff --git a/src/helpers/validation.js b/src/helpers/validation.js index 866e66cc..d67a1e7c 100644 --- a/src/helpers/validation.js +++ b/src/helpers/validation.js @@ -22,14 +22,14 @@ export function isPhone (value) { return /^\+[0-9]?()[0-9](\s|\S)(\d[0-9]{9})$/.test(value) } -export function inRange (value, min, max, between) { +export function inRange (value, min, max) { value = Number(value) - if (min && max == null) { + if (min >= 0 && max == null) { return min <= value - } else if (min == null && max) { + } else if (min < 0 && max) { return max >= value - } else if (min && max) { - return between(min, max)(value) + } else if (min >= 0 && max) { + return min <= value && max >= value } else { return true } diff --git a/src/pages/CscPagePbxGroupDetails.vue b/src/pages/CscPagePbxGroupDetails.vue index 272f0906..19bb5dd0 100644 --- a/src/pages/CscPagePbxGroupDetails.vue +++ b/src/pages/CscPagePbxGroupDetails.vue @@ -242,7 +242,6 @@ <script> import _ from 'lodash' -import { between } from '@vuelidate/validators' import { inRange } from 'src/helpers/validation' import { mapState, @@ -391,7 +390,7 @@ export default { changes: { extension: { isInRange: function (value) { - return inRange(value, this.getMinAllowedExtension, this.getMaxAllowedExtension, between) + return inRange(value, this.getMinAllowedExtension, this.getMaxAllowedExtension) } } } diff --git a/src/pages/CscPagePbxSeatDetails.vue b/src/pages/CscPagePbxSeatDetails.vue index c1225022..c81b2ae5 100644 --- a/src/pages/CscPagePbxSeatDetails.vue +++ b/src/pages/CscPagePbxSeatDetails.vue @@ -326,8 +326,7 @@ import numberFilter from '../filters/number' import useValidate from '@vuelidate/core' import { required, - maxLength, - between + maxLength } from '@vuelidate/validators' export default { name: 'CscPagePbxSeatDetails', @@ -533,7 +532,7 @@ export default { changes: { extension: { isInRange: function (value) { - return inRange(value, this.getMinAllowedExtension, this.getMaxAllowedExtension, between) + return inRange(value, this.getMinAllowedExtension, this.getMaxAllowedExtension) } }, displayName: { diff --git a/src/store/pbx.js b/src/store/pbx.js index f1f0124f..649239f7 100644 --- a/src/store/pbx.js +++ b/src/store/pbx.js @@ -160,24 +160,24 @@ export default { }, getMinAllowedExtension (state, getters, rootState, rootGetters) { const subscriber = rootGetters['user/getSubscriber'] - return subscriber.ext_range_min + return subscriber.ext_range_min && subscriber.ext_range_min >= 0 ? +subscriber.ext_range_min : -1 }, getMaxAllowedExtension (state, getters, rootState, rootGetters) { const subscriber = rootGetters['user/getSubscriber'] - return subscriber.ext_range_max + return subscriber.ext_range_max && subscriber.ext_range_max >= 1 ? +subscriber.ext_range_max : null }, getExtensionHint (state, getters, rootState, rootGetters) { const min = getters.getMinAllowedExtension const max = getters.getMaxAllowedExtension - if (min && max == null) { + if (min >= 0 && max == null) { return i18n.global.tc('Minimum allowed extension is {min}', { min: min }) - } else if (min == null && max) { + } else if (min < 0 && max) { return i18n.global.tc('Maximum allowed extension is {max}', { max: max }) - } else if (min && max) { + } else if (min >= 0 && max) { return i18n.global.tc('Allowed extensions are between {min} and {max}', { min: min, max: max