TT#104197 CF Custom Announcement basic functionalities

Change-Id: I8364368fcb9f6880c3ce34d64ab3ffacc5e00aff
mr9.3
Carlo Venusino 5 years ago
parent 5c79fc75f2
commit 4387646c9a

@ -132,6 +132,32 @@
/>
{{ $t('Conference') }}
</span>
<span
v-else-if="destination.announcement_id"
class="q-pl-xs text-primary text-weight-bold cursor-pointer"
style="white-space: nowrap"
>
<q-icon
name="app"
/>
{{ announcement }}
<q-popup-edit
v-model="announcement"
buttons
@before-show="$store.commit('callForwarding/popupShow', null)"
@save="updateAnnouncementEvent({
destinationIndex: destinationIndex,
destinationSetId: destinationSet.id
})">
<q-select
v-model="announcement"
:clearable="false"
:options="announcements"
:label="$t('Custom Announcements')"
:disable="loading"
/>
</q-popup-edit>
</span>
<span
v-else-if="destination.destination.endsWith('app.local')"
class="q-pl-xs text-weight-bold"
@ -250,12 +276,14 @@ export default {
data () {
return {
changedDestination: this.destination.simple_destination,
changedDestinationTimeout: 0
changedDestinationTimeout: 0,
announcement: null
}
},
computed: {
...mapGetters('callForwarding', [
'ringTimeout'
'ringTimeout',
'announcements'
]),
waitIdentifier () {
return 'csc-cf-group-item-' + this.destinationSet.id + '-' + this.destinationIndex
@ -265,13 +293,17 @@ export default {
destination () {
this.changedDestination = this.destination.simple_destination
}
},
mounted () {
async mounted () {
if (this.mapping.type === 'cft' && this.destinationIndex === 0) {
this.changedDestinationTimeout = this.ringTimeout
} else if (this.destinationPrevious) {
this.changedDestinationTimeout = this.destinationPrevious.timeout
}
if (this.destination.announcement_id) {
this.announcement = await this.getAnnouncementById(this.destination.announcement_id)
}
},
methods: {
...mapActions('callForwarding', [
@ -279,7 +311,9 @@ export default {
'removeDestination',
'updateDestinationTimeout',
'updateRingTimeout',
'rewriteDestination'
'rewriteDestination',
'getAnnouncementById',
'updateAnnouncement'
]),
async updateDestinationEvent (payload) {
this.$wait.start(this.waitIdentifier)
@ -318,6 +352,16 @@ export default {
this.$wait.start('csc-cf-mappings-full')
await this.updateRingTimeout(this.changedDestinationTimeout)
this.$wait.end('csc-cf-mappings-full')
},
async updateAnnouncementEvent (payload) {
this.$wait.start(this.waitIdentifier)
try {
await this.updateAnnouncement({ ...payload, announcementId: this.announcement })
} catch (err) {
showGlobalError(err.message)
} finally {
this.$wait.end(this.waitIdentifier)
}
}
}
}

@ -241,6 +241,15 @@
destinationSetId: destinationSet.id
})"
/>
<csc-popup-menu-item
icon="announcement"
:label="$t('Custom Announcement')"
:disable="hasTermination"
@click="addDestinationEvent({
destination: 'customhours',
destinationSetId: destinationSet.id
})"
/>
<csc-popup-menu-item
:icon="(mapping.enabled)?'toggle_on':'toggle_off'"
:label="(mapping.enabled)?$t('Disable'):$t('Enable')"

@ -115,11 +115,13 @@ export default {
},
mounted () {
this.loadMappingsFull()
this.loadAnnouncements()
},
methods: {
...mapActions('callForwarding', [
'loadMappingsFull',
'createMapping'
'createMapping',
'loadAnnouncements'
])
}
}

@ -22,24 +22,25 @@ import {
import {
patchReplace,
patchReplaceFull,
post, put
post, put, get, getList
} from 'src/api/common'
import _ from 'lodash'
const DEFAULT_RING_TIMEOUT = 60
const DEFAULT_PRIORITY = 0
const WAIT_IDENTIFIER = 'csc-cf-mappings-full'
const DEFAULT_CUSTOM_ANNOUNCEMENT_ID = 255 // TODO get from endpoint
function createDefaultDestination (destination) {
let finalDestination = 'Number'
if (destination) {
finalDestination = destination
}
return {
destination: finalDestination,
const payload = {
destination: destination || 'Number',
priority: DEFAULT_PRIORITY,
timeout: DEFAULT_RING_TIMEOUT
}
if (destination === 'customhours') {
payload.announcement_id = DEFAULT_CUSTOM_ANNOUNCEMENT_ID
}
return payload
}
export async function loadMappingsFull ({ dispatch, commit, rootGetters }) {
@ -539,3 +540,36 @@ export async function updateOfficeHoursSameTimes ({ dispatch, commit, rootGetter
})
dispatch('wait/end', 'csc-cf-time-set-create', { root: true })
}
export async function loadAnnouncements ({ dispatch, commit }) {
try {
const announcements = await getList({
resource: 'soundhandles',
all: true,
params: {
group: 'custom_announcements'
}
})
commit('setAnnouncements', announcements.items.length > 0 ? announcements.items.map(item => item.handle) : ['custom_announcement_0', 'custom_announcement_1', 'custom_announcement_2']) // TODO remove dummy data
} catch (err) {
commit('setAnnouncements', {
announcements: []
})
}
}
export async function getAnnouncementById ({ dispatch, commit, rootGetters, state }, announcementId) {
try {
const announcement = await get({
resource: 'soundhandles',
resourceId: announcementId
})
return announcement.handle
} catch (err) {
return 'custom_announcement_0' // TODO remove
}
}
export async function updateAnnouncement ({ dispatch, commit, rootGetters, state }, announcementId) {
// TODO
}

@ -17,3 +17,7 @@ export function groups (state) {
export function ringTimeout (state) {
return state.mappings.cft_ringtimeout
}
export function announcements (state) {
return state.announcements
}

@ -31,3 +31,7 @@ export function dataSucceeded (state, res) {
export function popupShow (state, popupId) {
state.popupCurrent = popupId
}
export function setAnnouncements (state, announcements) {
state.announcements = announcements
}

@ -16,6 +16,7 @@ export default function () {
sourceSetMap: {},
timeSets: null,
timeSetMap: {},
popupCurrent: null
popupCurrent: null,
announcements: []
}
}

Loading…
Cancel
Save