From a282cd29ae7631967e167b7db9b87c83a3a04d59 Mon Sep 17 00:00:00 2001 From: Carlo Venusino <cvenusino@sipwise.com> Date: Wed, 14 Jul 2021 17:34:36 +0200 Subject: [PATCH] TT#130400 SubscriberProfiles - Hide main menu item, if none of the containing parts of the page are visible due to a SubscriberProfile NOTE Affected routes/modules: - /call-blocking/incoming by 'block_in_clir', 'block_in_mode', 'block_in_list' - /call-blocking/outgoing by 'block_out_mode', 'block_out_list' - /call-blocking/privacy by 'clir' - /call-settings by 'music_on_hold', 'language' - /pbx-settings by 'clir_intrapbx' When the controlling profile attribute(s) are all unchecked, the module should disappear from CSC main menu and the route should not be reachable. For AR, in AUI you need to create a Subscriber Profile with at least one Profile, and assign the newly created profile to the subscriber via Details > Master Data. Change-Id: Idadcc096643fe58419682042814d3508c015b464 --- src/boot/constants.js | 1 - src/boot/routes.js | 2 ++ src/components/CscMainMenuTop.vue | 21 ++++++++++++--------- src/constants.js | 15 +++++++++++++++ src/router/routes.js | 24 +++++++++++++++--------- 5 files changed, 44 insertions(+), 19 deletions(-) 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 608c54f3..0b592550 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' @@ -81,7 +82,8 @@ export default function routes (app) { }, get subtitle () { return i18n.t('Incoming') - } + }, + profileAttributes: PROFILE_ATTRIBUTES_MAP.callBlockingIncoming } }, { @@ -93,7 +95,8 @@ export default function routes (app) { }, get subtitle () { return i18n.t('Outgoing') - } + }, + profileAttributes: PROFILE_ATTRIBUTES_MAP.callBlockingOutgoing } }, { @@ -105,7 +108,8 @@ export default function routes (app) { }, get subtitle () { return i18n.t('Privacy') - } + }, + profileAttribute: PROFILE_ATTRIBUTE_MAP.callBlockingPrivacy } }, { @@ -130,7 +134,7 @@ export default function routes (app) { get subtitle () { return i18n.t('Set your personal alarm') }, - profileAttribute: 'reminder' + profileAttribute: PROFILE_ATTRIBUTE_MAP.reminder } }, { @@ -143,7 +147,7 @@ export default function routes (app) { get subtitle () { return i18n.t('Set your speed dials') }, - profileAttribute: 'speed_dial' + profileAttribute: PROFILE_ATTRIBUTE_MAP.speedDial } }, { @@ -240,7 +244,7 @@ export default function routes (app) { get subtitle () { return i18n.t('Set your voicebox settings') }, - profileAttribute: 'voice_mail' + profileAttribute: PROFILE_ATTRIBUTE_MAP.voiceMail } }, { @@ -253,7 +257,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']) { @@ -284,7 +288,8 @@ export default function routes (app) { }, get subtitle () { return i18n.t('Call Settings') - } + }, + profileAttributes: PROFILE_ATTRIBUTES_MAP.callSettings } }, { @@ -296,7 +301,8 @@ export default function routes (app) { }, get subtitle () { return i18n.t('Set your PBX settings') - } + }, + profileAttribute: PROFILE_ATTRIBUTE_MAP.pbxSettings } }, {