AC: Can see the preference Music-on-hold in the new main page "Call Settings" Can toggle the preference Music-on-hold Change-Id: Id725dc65fc08b6b865c69ff035bc3e343e4a7651pull/4/head
parent
cd736c1fb5
commit
e4c421e1d9
@ -0,0 +1,93 @@
|
|||||||
|
<template>
|
||||||
|
<csc-page
|
||||||
|
id="csc-page-voicebox"
|
||||||
|
class="row q-pa-lg"
|
||||||
|
>
|
||||||
|
<q-list
|
||||||
|
class="col col-xs-12 col-md-6"
|
||||||
|
>
|
||||||
|
<q-item>
|
||||||
|
<q-item-section>
|
||||||
|
<q-toggle
|
||||||
|
:value="musicOnHold"
|
||||||
|
:disable="dataLoading"
|
||||||
|
:label="$t('callSettings.musicOnHold')"
|
||||||
|
:title="$t('callSettings.musicOnHoldHint')"
|
||||||
|
checked-icon="audiotrack"
|
||||||
|
unchecked-icon="audiotrack"
|
||||||
|
@input="toggleMusicOnHold"
|
||||||
|
/>
|
||||||
|
</q-item-section>
|
||||||
|
<q-item-section
|
||||||
|
side
|
||||||
|
>
|
||||||
|
<csc-spinner
|
||||||
|
v-if="dataLoading"
|
||||||
|
class="self-center"
|
||||||
|
/>
|
||||||
|
</q-item-section>
|
||||||
|
</q-item>
|
||||||
|
</q-list>
|
||||||
|
</csc-page>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
mapGetters,
|
||||||
|
mapState
|
||||||
|
} from 'vuex'
|
||||||
|
import {
|
||||||
|
mapWaitingActions,
|
||||||
|
mapWaitingGetters
|
||||||
|
} from 'vue-wait'
|
||||||
|
import {
|
||||||
|
showGlobalError
|
||||||
|
} from 'src/helpers/ui'
|
||||||
|
import CscPage from 'components/CscPage'
|
||||||
|
import CscSpinner from 'components/CscSpinner'
|
||||||
|
export default {
|
||||||
|
name: 'CscPageCallSettings',
|
||||||
|
components: {
|
||||||
|
CscSpinner,
|
||||||
|
CscPage
|
||||||
|
},
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState('callSettings', [
|
||||||
|
'subscriberPreferencesInitialized'
|
||||||
|
]),
|
||||||
|
...mapGetters('callSettings', [
|
||||||
|
'musicOnHold'
|
||||||
|
]),
|
||||||
|
...mapWaitingGetters({
|
||||||
|
processingSubscriberPreferences: 'processing subscriberPreferences'
|
||||||
|
}),
|
||||||
|
dataLoading () {
|
||||||
|
return !this.subscriberPreferencesInitialized || this.processingSubscriberPreferences
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
try {
|
||||||
|
this.loadSubscriberPreferencesAction()
|
||||||
|
} catch (err) {
|
||||||
|
showGlobalError(err?.message)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapWaitingActions('callSettings', {
|
||||||
|
loadSubscriberPreferencesAction: 'processing subscriberPreferences',
|
||||||
|
setMusicOnHold: 'processing subscriberPreferences'
|
||||||
|
}),
|
||||||
|
async toggleMusicOnHold () {
|
||||||
|
try {
|
||||||
|
await this.setMusicOnHold(!this.musicOnHold)
|
||||||
|
} catch (err) {
|
||||||
|
showGlobalError(err?.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -0,0 +1,45 @@
|
|||||||
|
import {
|
||||||
|
getPreferences,
|
||||||
|
setPreference
|
||||||
|
} from '../api/subscriber'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
namespaced: true,
|
||||||
|
state: {
|
||||||
|
subscriberPreferencesInitialized: false,
|
||||||
|
subscriberPreferences: {}
|
||||||
|
},
|
||||||
|
getters: {
|
||||||
|
subscriberId (state, getters, rootState, rootGetters) {
|
||||||
|
return parseInt(rootGetters['user/getSubscriberId'])
|
||||||
|
},
|
||||||
|
musicOnHold (state) {
|
||||||
|
return state.subscriberPreferences.music_on_hold
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mutations: {
|
||||||
|
subscriberPreferencesSucceeded (state, res) {
|
||||||
|
state.subscriberPreferences = res
|
||||||
|
state.subscriberPreferencesInitialized = true
|
||||||
|
},
|
||||||
|
subscriberPreferencesUpdate (state, { field, value }) {
|
||||||
|
state.subscriberPreferences[field] = value
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
async loadSubscriberPreferencesAction (context) {
|
||||||
|
const subscriberPreferences = await getPreferences(context.getters.subscriberId)
|
||||||
|
context.commit('subscriberPreferencesSucceeded', subscriberPreferences)
|
||||||
|
},
|
||||||
|
async fieldUpdateAction (context, options) {
|
||||||
|
await setPreference(context.getters.subscriberId, options.field, options.value)
|
||||||
|
context.commit('subscriberPreferencesUpdate', {
|
||||||
|
field: options.field,
|
||||||
|
value: options.value
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async setMusicOnHold (context, value) {
|
||||||
|
await context.dispatch('fieldUpdateAction', { field: 'music_on_hold', value })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue