diff --git a/src/boot/constants.js b/src/boot/constants.js index d8ce93ca..d8b754fd 100644 --- a/src/boot/constants.js +++ b/src/boot/constants.js @@ -1,4 +1,3 @@ - export default ({ Vue, app }) => { Vue.prototype.$faxQualityOptions = [ { label: app.i18n.t('Normal'), value: 'normal' }, diff --git a/src/boot/routes.js b/src/boot/routes.js index 410111b6..7b4813d0 100644 --- a/src/boot/routes.js +++ b/src/boot/routes.js @@ -36,6 +36,8 @@ export default ({ app, router, store }) => { default: if (to.meta?.profileAttribute) { app.store.getters['user/hasSubscriberProfileAttribute'](to.meta.profileAttribute) ? next() : next('/') + } else if (to.meta?.profileAttributes) { + app.store.getters['user/hasSubscriberProfileAttributes'](to.meta.profileAttributes) ? next() : next('/') } else { next() } diff --git a/src/components/CscMainMenuTop.vue b/src/components/CscMainMenuTop.vue index 31383373..9a31480f 100644 --- a/src/components/CscMainMenuTop.vue +++ b/src/components/CscMainMenuTop.vue @@ -9,6 +9,8 @@ import { mapGetters } from 'vuex' import CscMainMenu from 'components/CscMainMenu' +import { PROFILE_ATTRIBUTE_MAP, PROFILE_ATTRIBUTES_MAP } from 'src/constants' + export default { name: 'CscMainMenuTop', components: { @@ -49,6 +51,7 @@ export default { 'isPbxEnabled', 'hasFaxCapability', 'hasSubscriberProfileAttribute', + 'hasSubscriberProfileAttributes', 'getCustomerId', 'isOldCSCProxyingAllowed' ]), @@ -83,13 +86,13 @@ export default { to: '/user/call-settings', icon: 'settings', label: this.$t('General'), - visible: true + visible: this.hasSubscriberProfileAttributes(PROFILE_ATTRIBUTES_MAP.callSettings) }, { to: '/user/voicebox', icon: 'voicemail', label: this.$t('Voicebox'), - visible: this.hasSubscriberProfileAttribute('voice_mail') + visible: this.hasSubscriberProfileAttribute(PROFILE_ATTRIBUTE_MAP.voiceMail) }, { to: '/user/call-forwarding', @@ -101,31 +104,31 @@ export default { to: '/user/call-blocking/incoming', icon: 'call_received', label: this.$t('Block incoming'), - visible: true + visible: this.hasSubscriberProfileAttributes(PROFILE_ATTRIBUTES_MAP.callBlockingIncoming) }, { to: '/user/call-blocking/outgoing', icon: 'call_made', label: this.$t('Block outgoing'), - visible: true + visible: this.hasSubscriberProfileAttributes(PROFILE_ATTRIBUTES_MAP.callBlockingOutgoing) }, { to: '/user/call-blocking/privacy', icon: 'fas fa-user-secret', label: this.$t('Privacy'), - visible: true + visible: this.hasSubscriberProfileAttribute(PROFILE_ATTRIBUTE_MAP.callBlockingPrivacy) }, { to: '/user/speeddial', icon: 'touch_app', label: this.$t('Speed Dial'), - visible: this.hasSubscriberProfileAttribute('speed_dial') + visible: this.hasSubscriberProfileAttribute(PROFILE_ATTRIBUTE_MAP.speedDial) }, { to: '/user/reminder', icon: 'notification_important', label: this.$t('Reminder'), - visible: this.hasSubscriberProfileAttribute('reminder') + visible: this.hasSubscriberProfileAttribute(PROFILE_ATTRIBUTE_MAP.reminder) }, { to: '/user/recordings', @@ -139,7 +142,7 @@ export default { to: '/user/fax-settings', icon: 'fas fa-fax', label: this.$t('Fax Settings'), - visible: this.hasFaxCapability && this.hasSubscriberProfileAttribute('fax_server') + visible: this.hasFaxCapability && this.hasSubscriberProfileAttribute(PROFILE_ATTRIBUTE_MAP.faxServer) }, { icon: 'miscellaneous_services', @@ -195,7 +198,7 @@ export default { to: '/user/pbx-settings', icon: 'settings', label: this.$t('PBX Settings'), - visible: this.isPbxEnabled + visible: this.isPbxEnabled && this.hasSubscriberProfileAttribute(PROFILE_ATTRIBUTE_MAP.pbxSettings) }, { to: '/user/registered-devices', diff --git a/src/constants.js b/src/constants.js index 02142166..72fb6c98 100644 --- a/src/constants.js +++ b/src/constants.js @@ -5,3 +5,18 @@ export const INTERNAL_DATE_FORMAT_SLASH = 'YYYY/MM/DD' export const INTERNAL_DATE_FORMAT_DASH = 'YYYY-MM-DD' export const INTERNAL_DATE_FORMAT_DASH_HOUR = 'YYYY-MM-DD HH:mm' + +export const PROFILE_ATTRIBUTE_MAP = { + reminder: 'reminder', + speedDial: 'speed_dial', + voiceMail: 'voice_mail', + callBlockingPrivacy: 'clir', + faxServer: 'fax_server', + pbxSettings: 'clir_intrapbx' +} + +export const PROFILE_ATTRIBUTES_MAP = { + callBlockingIncoming: ['block_in_clir', 'block_in_mode', 'block_in_list'], + callBlockingOutgoing: ['block_out_mode', 'block_out_list'], + callSettings: ['music_on_hold', 'language'] +} diff --git a/src/router/routes.js b/src/router/routes.js index 675a79ae..538bed3a 100644 --- a/src/router/routes.js +++ b/src/router/routes.js @@ -1,3 +1,4 @@ +import { PROFILE_ATTRIBUTE_MAP, PROFILE_ATTRIBUTES_MAP } from 'src/constants' import CscLayoutConference from 'src/layouts/CscLayoutConference' import CscLayoutMain from 'src/layouts/CscLayoutMain' @@ -125,7 +126,8 @@ export default function routes (app) { }, get subtitle () { return i18n.t('Incoming') - } + }, + profileAttributes: PROFILE_ATTRIBUTES_MAP.callBlockingIncoming } }, { @@ -137,7 +139,8 @@ export default function routes (app) { }, get subtitle () { return i18n.t('Outgoing') - } + }, + profileAttributes: PROFILE_ATTRIBUTES_MAP.callBlockingOutgoing } }, { @@ -149,7 +152,8 @@ export default function routes (app) { }, get subtitle () { return i18n.t('Privacy') - } + }, + profileAttribute: PROFILE_ATTRIBUTE_MAP.callBlockingPrivacy } }, { @@ -174,7 +178,7 @@ export default function routes (app) { get subtitle () { return i18n.t('Set your personal alarm') }, - profileAttribute: 'reminder' + profileAttribute: PROFILE_ATTRIBUTE_MAP.reminder } }, { @@ -187,7 +191,7 @@ export default function routes (app) { get subtitle () { return i18n.t('Set your speed dials') }, - profileAttribute: 'speed_dial' + profileAttribute: PROFILE_ATTRIBUTE_MAP.speedDial } }, { @@ -284,7 +288,7 @@ export default function routes (app) { get subtitle () { return i18n.t('Set your voicebox settings') }, - profileAttribute: 'voice_mail' + profileAttribute: PROFILE_ATTRIBUTE_MAP.voiceMail } }, { @@ -297,7 +301,7 @@ export default function routes (app) { get subtitle () { return i18n.t('Set your fax settings') }, - profileAttribute: 'fax_server' + profileAttribute: PROFILE_ATTRIBUTE_MAP.faxServer }, async beforeEnter (routeTo, routeFrom, next) { if (app.store.getters['user/hasFaxCapability']) { @@ -328,7 +332,8 @@ export default function routes (app) { }, get subtitle () { return i18n.t('Call Settings') - } + }, + profileAttributes: PROFILE_ATTRIBUTES_MAP.callSettings } }, { @@ -340,7 +345,8 @@ export default function routes (app) { }, get subtitle () { return i18n.t('Set your PBX settings') - } + }, + profileAttribute: PROFILE_ATTRIBUTE_MAP.pbxSettings } }, {