diff --git a/src/api/pbx-config.js b/src/api/pbx-config.js index 3368485b..d961edf0 100644 --- a/src/api/pbx-config.js +++ b/src/api/pbx-config.js @@ -20,7 +20,8 @@ import { addNewCallQueueConfig, setQueueLength, setWrapUpTime, - getPreferences + getPreferences, + removeCallQueueConfig } from './subscriber'; import uuid from 'uuid'; import { getList, get, patchReplace } from './common' @@ -549,7 +550,7 @@ export function getCallQueueConfigurations() { } export function addCallQueueConfig(id, config) { - return new Promise((resolve, reject)=>{ + return new Promise((resolve, reject) => { addNewCallQueueConfig(id, config).then(() => { resolve(); }).catch((err)=>{ @@ -559,9 +560,9 @@ export function addCallQueueConfig(id, config) { } export function getConfig(id) { - return new Promise((resolve, reject)=>{ + return new Promise((resolve, reject) => { let $subscriber = {}; - Promise.resolve().then(()=>{ + Promise.resolve().then(() => { return getSubscriber(id); }).then((subscriber) => { $subscriber = subscriber; @@ -580,6 +581,16 @@ export function getConfig(id) { }); } +export function removeCallQueue(subscriberId) { + return new Promise((resolve, reject) => { + removeCallQueueConfig(subscriberId).then(() => { + resolve(); + }).catch((err)=>{ + reject(err); + }); + }); +} + export function setQueueLengthConfig(id, queueLength) { return setQueueLength(id, queueLength); } diff --git a/src/api/subscriber.js b/src/api/subscriber.js index d909c0b7..cc27b3dc 100644 --- a/src/api/subscriber.js +++ b/src/api/subscriber.js @@ -361,3 +361,8 @@ export function setQueueLength(id, queueLength) { export function setWrapUpTime(id, wrapUpTime) { return editCallQueuePreference(id, { queue_wrap_up_time: wrapUpTime }); } + +export function removeCallQueueConfig(subscriberId) { + let param = { cloud_pbx_callqueue: false }; + return Vue.http.put('api/subscriberpreferences/' + subscriberId, param); +} diff --git a/src/components/pages/PbxConfiguration/CscPbxCallQueue.vue b/src/components/pages/PbxConfiguration/CscPbxCallQueue.vue index a7940d01..e95c8fbf 100644 --- a/src/components/pages/PbxConfiguration/CscPbxCallQueue.vue +++ b/src/components/pages/PbxConfiguration/CscPbxCallQueue.vue @@ -98,6 +98,14 @@ class="csc-list-actions-pinned" > + diff --git a/src/components/pages/PbxConfiguration/CscPbxCallQueues.vue b/src/components/pages/PbxConfiguration/CscPbxCallQueues.vue index d5390974..7b856c15 100644 --- a/src/components/pages/PbxConfiguration/CscPbxCallQueues.vue +++ b/src/components/pages/PbxConfiguration/CscPbxCallQueues.vue @@ -52,6 +52,7 @@ :loading="isItemLoading(subscriber.id)" @save-queue-length="setQueueLength" @save-wrap-up-time="setWrapUpTime" + @remove="removeConfigDialog" /> @@ -61,6 +62,12 @@ > {{ $t('pbxConfig.noCallQueues') }} + @@ -68,6 +75,7 @@ import CscPage from '../../CscPage' import CscPbxCallQueue from './CscPbxCallQueue' import CscPbxCallQueueAddForm from './CscPbxCallQueueAddForm' + import CscRemoveDialog from '../../CscRemoveDialog' import { mapGetters } from 'vuex' import { QField, @@ -89,6 +97,7 @@ CscPage, CscPbxCallQueue, CscPbxCallQueueAddForm, + CscRemoveDialog, QField, QInput, QIcon, @@ -104,7 +113,8 @@ }, data () { return { - addFormEnabled: false + addFormEnabled: false, + currentRemovingSubscriber: null } }, mounted() { @@ -120,10 +130,19 @@ 'isAdding', 'addState', 'isUpdating', - 'updateItemId' + 'updateItemId', + 'removeState', + 'isRemoving' ]), isMobile() { return Platform.is.mobile; + }, + removeDialogMessage() { + if (this.currentRemovingSubscriber !== null) { + return this.$t('pbxConfig.removeConfigText', { + subscriber: this.currentRemovingSubscriber.display_name + }); + } } }, methods: { @@ -155,7 +174,15 @@ this.$store.dispatch('pbxConfig/setWrapUpTime', subscriber); }, isItemLoading(subscriberId) { - return (this.isUpdating && this.updateItemId + "" === subscriberId + ""); + return (this.isUpdating && this.updateItemId + "" === subscriberId + "") || + (this.isRemoving && this.currentRemovingSubscriber.id + "" === subscriberId + ""); + }, + removeConfigDialog(subscriber) { + this.currentRemovingSubscriber = subscriber; + this.$refs.removeDialog.open(); + }, + removeConfig() { + this.$store.dispatch('pbxConfig/removeCallQueue', this.currentRemovingSubscriber) } }, watch: { diff --git a/src/components/pages/PbxConfiguration/CscPbxDevices.vue b/src/components/pages/PbxConfiguration/CscPbxDevices.vue index 982e748c..f7880fdf 100644 --- a/src/components/pages/PbxConfiguration/CscPbxDevices.vue +++ b/src/components/pages/PbxConfiguration/CscPbxDevices.vue @@ -126,7 +126,7 @@ :profiles="profiles" :modelImages="modelImages" :loading="createDeviceRequesting" - @remove="removeDevice" + @remove="removeDeviceDialog" @modelSelectOpened="modelSelectOpened()" @save="saveDevice" @cancelForm="cancelForm" @@ -170,7 +170,7 @@ :subscribers="getGroupOrSeatById" :profiles="profiles" :modelImages="modelImages" - @remove="removeDevice" + @remove="removeDeviceDialog" @loadGroupsAndSeats="loadGroupsAndSeats()" @deviceKeysChanged="deviceKeysChanged" @save-station-name="setStationName" @@ -184,6 +184,12 @@ > {{ noDeviceMessage }} + @@ -194,12 +200,12 @@ import CscPbxDevice from './CscPbxDevice' import CscPbxDeviceAddForm from './CscPbxDeviceAddForm' import CscPbxModelSelect from './CscPbxModelSelect' + import CscRemoveDialog from '../../CscRemoveDialog' import { showToast, showGlobalError } from '../../../helpers/ui' import { QSpinnerDots, QPagination, QList, - Dialog, QItem, QItemMain, QBtn, @@ -217,7 +223,8 @@ formEnabled: false, filterEnabled: false, filterStationNameInput: '', - filterMacAddressInput: '' + filterMacAddressInput: '', + currentRemovingDevice: null } }, mounted() { @@ -229,6 +236,7 @@ CscPbxDevice, CscPbxDeviceAddForm, CscPbxModelSelect, + CscRemoveDialog, QSpinnerDots, QPagination, QList, @@ -363,6 +371,13 @@ } } ]; + }, + removeDialogMessage() { + if (this.currentRemovingDevice !== null) { + return this.$t('pbxConfig.removeDeviceText', { + device: this.currentRemovingDevice.station_name + }); + } } }, methods: { @@ -378,23 +393,8 @@ saveDevice(device) { this.$store.dispatch('pbxConfig/createDevice', device); }, - removeDevice(device) { - var store = this.$store; - var i18n = this.$i18n; - Dialog.create({ - title: i18n.t('pbxConfig.removeDeviceTitle'), - message: i18n.t('pbxConfig.removeDeviceText', { device: device.station_name }), - buttons: [ - 'Cancel', - { - label: i18n.t('pbxConfig.removeDevice'), - color: 'negative', - handler () { - store.dispatch('pbxConfig/removeDevice', device); - } - } - ] - }); + removeDevice() { + this.$store.dispatch('pbxConfig/removeDevice', this.currentRemovingDevice); }, loadGroupsAndSeats() { this.$store.dispatch('pbxConfig/getAllGroupsAndSeats'); @@ -466,6 +466,10 @@ }, resetFilters() { this.$store.dispatch('pbxConfig/resetDeviceFilters'); + }, + removeDeviceDialog(device) { + this.currentRemovingDevice = device; + this.$refs.removeDialog.open(); } }, watch: { diff --git a/src/components/pages/PbxConfiguration/CscPbxGroups.vue b/src/components/pages/PbxConfiguration/CscPbxGroups.vue index b0211c09..2abd26c3 100644 --- a/src/components/pages/PbxConfiguration/CscPbxGroups.vue +++ b/src/components/pages/PbxConfiguration/CscPbxGroups.vue @@ -62,7 +62,7 @@ :alias-number-options="aliasNumberOptions" :seat-options="seatOptions" :hunt-policy-options="huntPolicyOptions" - @remove="removeGroup" + @remove="removeGroupDialog" :loading="isItemLoading(group.id)" @save-name="setGroupName" @save-extension="setGroupExtension" @@ -78,6 +78,12 @@ > {{ $t('pbxConfig.noGroups') }} + @@ -86,6 +92,7 @@ import CscPage from '../../CscPage' import CscPbxGroup from './CscPbxGroup' import CscPbxGroupAddForm from './CscPbxGroupAddForm' + import CscRemoveDialog from '../../CscRemoveDialog' import aliasNumberOptions from '../../../mixins/alias-number-options' import itemError from '../../../mixins/item-error' import { showToast } from '../../../helpers/ui' @@ -108,7 +115,6 @@ QInnerLoading, QSpinnerDots, QSpinnerMat, - Dialog, QPagination, Platform } from 'quasar-framework' @@ -119,6 +125,7 @@ CscPage, CscPbxGroup, CscPbxGroupAddForm, + CscRemoveDialog, QChip, QCard, QCardSeparator, @@ -147,7 +154,8 @@ data () { return { addFormEnabled: false, - page: 1 + page: 1, + currentRemovingGroup: null } }, computed: { @@ -213,6 +221,13 @@ isMobile() { return Platform.is.mobile; }, + removeDialogMessage() { + if (this.currentRemovingGroup !== null) { + return this.$t('pbxConfig.removeGroupText', { + group: this.currentRemovingGroup.name + }); + } + } }, watch: { addState(state) { @@ -263,23 +278,8 @@ addGroup(group) { this.$store.dispatch('pbxConfig/addGroup', group); }, - removeGroup(group) { - var store = this.$store; - var i18n = this.$i18n; - Dialog.create({ - title: i18n.t('pbxConfig.removeGroupTitle'), - message: i18n.t('pbxConfig.removeGroupText', { group: group.name }), - buttons: [ - 'Cancel', - { - label: i18n.t('pbxConfig.removeGroup'), - color: 'negative', - handler () { - store.dispatch('pbxConfig/removeGroup', group); - } - } - ] - }); + removeGroup() { + this.$store.dispatch('pbxConfig/removeGroup', this.currentRemovingGroup); }, setGroupName(group) { this.$store.dispatch('pbxConfig/setGroupName', group); @@ -303,6 +303,10 @@ this.$store.dispatch('pbxConfig/listGroups', { page: page }); + }, + removeGroupDialog(subscriber) { + this.currentRemovingGroup = subscriber; + this.$refs.removeDialog.open(); } } } diff --git a/src/components/pages/PbxConfiguration/CscPbxSeat.vue b/src/components/pages/PbxConfiguration/CscPbxSeat.vue index c188b1ce..c377cc89 100644 --- a/src/components/pages/PbxConfiguration/CscPbxSeat.vue +++ b/src/components/pages/PbxConfiguration/CscPbxSeat.vue @@ -410,7 +410,7 @@ }, saveGroups() { this.$emit('save-groups', this.seatModel); - }, + } }, watch: { seat() { diff --git a/src/components/pages/PbxConfiguration/CscPbxSeats.vue b/src/components/pages/PbxConfiguration/CscPbxSeats.vue index 8b5ad81a..ede19ef7 100644 --- a/src/components/pages/PbxConfiguration/CscPbxSeats.vue +++ b/src/components/pages/PbxConfiguration/CscPbxSeats.vue @@ -61,7 +61,7 @@ :seat="seat" :alias-number-options="aliasNumberOptions" :group-options="groupOptions" - @remove="removeSeat" + @remove="removeSeatDialog" :loading="isItemLoading(seat.id)" @save-name="setSeatName" @save-extension="setSeatExtension" @@ -76,13 +76,20 @@ > {{ $t('pbxConfig.noSeats') }} +