From 7ae7e49233d0849b7f5d2b51e36dd2c97beeef81 Mon Sep 17 00:00:00 2001 From: Carlo Venusino Date: Wed, 12 Feb 2020 17:29:47 +0100 Subject: [PATCH] TT#39942 PBXConfig: Saving a field after editing several fields result in only the last one saved Change-Id: I98b5fd89390bff24814daf5934ba33accb188163 --- .../PbxConfiguration/CscPbxCallQueue.vue | 36 ++++--- .../pages/PbxConfiguration/CscPbxDevice.vue | 60 ++++++------ .../pages/PbxConfiguration/CscPbxGroup.vue | 94 ++++++++----------- .../pages/PbxConfiguration/CscPbxSeat.vue | 73 +++++++------- .../pages/PbxConfiguration/CscPbxSoundSet.vue | 38 ++++---- 5 files changed, 140 insertions(+), 161 deletions(-) diff --git a/src/components/pages/PbxConfiguration/CscPbxCallQueue.vue b/src/components/pages/PbxConfiguration/CscPbxCallQueue.vue index cf66635a..2a13bb49 100644 --- a/src/components/pages/PbxConfiguration/CscPbxCallQueue.vue +++ b/src/components/pages/PbxConfiguration/CscPbxCallQueue.vue @@ -52,12 +52,12 @@ v-model="changes.max_queue_length" :error="$v.changes.max_queue_length.$error" @input="$v.changes.max_queue_length.$touch" - @keyup.enter="saveMaxQueueLength" + @keyup.enter="save" /> @@ -78,12 +78,12 @@ :suffix="$t('pbxConfig.seconds')" :error="$v.changes.queue_wrap_up_time.$error" @input="$v.changes.queue_wrap_up_time.$touch" - @keyup.enter="saveQueueWrapUpTime" + @keyup.enter="save" /> @@ -252,33 +252,31 @@ this.$emit('expand'); } }, - saveMaxQueueLength() { + resetMaxQueueLength() { + this.changes.max_queue_length = this.getDefaultData().max_queue_length; + }, + resetQueueWrapUpTime() { + this.changes.queue_wrap_up_time = this.getDefaultData().queue_wrap_up_time; + }, + getDefaultData() { + return { + max_queue_length: this.callQueue.max_queue_length || this.defaultMaxQueueLength, + queue_wrap_up_time: this.callQueue.queue_wrap_up_time || this.defaultQueueWrapUpTime + } + }, + save(){ if(this.hasMaxQueueLengthChanged && !this.$v.changes.max_queue_length.$error) { this.$emit('save-max-queue-length', { callQueueId: this.callQueue.id, maxQueueLength: this.changes.max_queue_length }); } - }, - resetMaxQueueLength() { - this.changes.max_queue_length = this.getDefaultData().max_queue_length; - }, - saveQueueWrapUpTime() { if(this.hasQueueWrapUpTimeChanged && !this.$v.changes.queue_wrap_up_time.$error) { this.$emit('save-queue-wrap-up-time', { callQueueId: this.callQueue.id, queueWrapUpTime: this.changes.queue_wrap_up_time }); } - }, - resetQueueWrapUpTime() { - this.changes.queue_wrap_up_time = this.getDefaultData().queue_wrap_up_time; - }, - getDefaultData() { - return { - max_queue_length: this.callQueue.max_queue_length || this.defaultMaxQueueLength, - queue_wrap_up_time: this.callQueue.queue_wrap_up_time || this.defaultQueueWrapUpTime - } } }, watch: { diff --git a/src/components/pages/PbxConfiguration/CscPbxDevice.vue b/src/components/pages/PbxConfiguration/CscPbxDevice.vue index f6d308ee..7d6931da 100644 --- a/src/components/pages/PbxConfiguration/CscPbxDevice.vue +++ b/src/components/pages/PbxConfiguration/CscPbxDevice.vue @@ -47,12 +47,12 @@ @@ -68,12 +68,12 @@ @@ -99,7 +99,7 @@ @@ -214,39 +214,15 @@ this.$emit('expand'); } }, - saveStationName() { - this.$emit('save-station-name', { - deviceId: this.device.id, - stationName: this.changes.stationName - }); - }, resetStationName() { this.changes.stationName = this.device.station_name; }, - saveIdentifier(){ - this.$emit('save-identifier', { - deviceId: this.device.id, - identifier: this.changes.identifier - }); - }, resetIdentifier() { this.changes.identifier = this.device.identifier; }, - saveProfile() { - this.$emit('save-profile', { - deviceId: this.device.id, - profileId: this.changes.profile - }); - }, resetProfile() { this.changes.profile = this.device.profile_id; }, - saveKeys(keys) { - this.$emit('save-keys', { - deviceId: this.device.id, - keys: keys - }); - }, selectedDeviceProfile(profileId) { this.changes.profile = profileId; }, @@ -255,6 +231,32 @@ this.$refs.listItem.closePopoverMenu(); } this.$emit('remove'); + }, + saveKeys(keys) { + this.$emit('save-keys', { + deviceId: this.device.id, + keys: keys + }); + }, + save(){ + if(this.hasStationNameChanged){ + this.$emit('save-station-name', { + deviceId: this.device.id, + stationName: this.changes.stationName + }); + } + if(this.hasIdentifierChanged){ + this.$emit('save-identifier', { + deviceId: this.device.id, + identifier: this.changes.identifier + }); + } + if(this.hasProfileChanged){ + this.$emit('save-profile', { + deviceId: this.device.id, + profileId: this.changes.profile + }); + } } }, watch: { diff --git a/src/components/pages/PbxConfiguration/CscPbxGroup.vue b/src/components/pages/PbxConfiguration/CscPbxGroup.vue index b9db00ba..c02e45fa 100644 --- a/src/components/pages/PbxConfiguration/CscPbxGroup.vue +++ b/src/components/pages/PbxConfiguration/CscPbxGroup.vue @@ -69,12 +69,12 @@ @@ -91,12 +91,12 @@ @@ -129,7 +129,7 @@ @@ -146,12 +146,12 @@ @@ -174,7 +174,7 @@ @@ -197,7 +197,7 @@ @@ -219,7 +219,7 @@ @@ -380,51 +380,61 @@ this.$emit('expand'); } }, - saveName() { + resetName() { + this.changes.name = this.group.display_name; + }, + resetExtension() { + this.changes.extension = this.group.pbx_extension; + }, + resetHuntPolicy() { + this.changes.huntPolicy = this.group.pbx_hunt_policy; + }, + resetHuntTimeout() { + this.changes.huntTimeout = this.group.pbx_hunt_timeout; + }, + resetAliasNumbers() { + this.changes.aliasNumbers = this.getAliasNumberIds(); + }, + resetSeats() { + this.changes.seats = this.getSeatIds(); + }, + resetSoundSet() { + this.changes.soundSet = this.getSoundSetId(); + }, + deleteSeat() { + if(this.$refs.listItem) { + this.$refs.listItem.closePopoverMenu(); + } + this.$emit('remove'); + }, + jumpToCallQueue() { + this.$emit('jump-to-call-queue', this.group); + }, + save(){ if(this.hasNameChanged) { this.$emit('save-name', { groupId: this.group.id, groupName: this.changes.name }); } - }, - resetName() { - this.changes.name = this.group.display_name; - }, - saveExtension() { if(this.hasExtensionChanged) { this.$emit('save-extension', { groupId: this.group.id, groupExtension: this.changes.extension }); } - }, - resetExtension() { - this.changes.extension = this.group.pbx_extension; - }, - saveHuntPolicy(){ if(this.hasHuntPolicyChanged) { this.$emit('save-hunt-policy', { groupId: this.group.id, groupHuntPolicy: this.changes.huntPolicy }); } - }, - resetHuntPolicy() { - this.changes.huntPolicy = this.group.pbx_hunt_policy; - }, - saveHuntTimeout(){ if(this.hasHuntTimeoutChanged) { this.$emit('save-hunt-timeout', { groupId: this.group.id, groupHuntTimeout: this.changes.huntTimeout }); } - }, - resetHuntTimeout() { - this.changes.huntTimeout = this.group.pbx_hunt_timeout; - }, - saveAliasNumbers() { if(this.hasAliasNumbersChanged) { this.$emit('save-alias-numbers', { groupId: this.group.id, @@ -432,40 +442,18 @@ unassignedNumbers: _.difference(this.getAliasNumberIds(), this.changes.aliasNumbers) }); } - }, - resetAliasNumbers() { - this.changes.aliasNumbers = this.getAliasNumberIds(); - }, - saveSeats() { if(this.hasSeatsChanged) { this.$emit('save-seats', { groupId: this.group.id, seatIds: this.changes.seats }); } - }, - resetSeats() { - this.changes.seats = this.getSeatIds(); - }, - saveSoundSet() { if(this.hasSoundSetChanged) { this.$emit('save-sound-set', { groupId: this.group.id, soundSetId: this.changes.soundSet }); } - }, - resetSoundSet() { - this.changes.soundSet = this.getSoundSetId(); - }, - deleteSeat() { - if(this.$refs.listItem) { - this.$refs.listItem.closePopoverMenu(); - } - this.$emit('remove'); - }, - jumpToCallQueue() { - this.$emit('jump-to-call-queue', this.group); } }, watch: { diff --git a/src/components/pages/PbxConfiguration/CscPbxSeat.vue b/src/components/pages/PbxConfiguration/CscPbxSeat.vue index 4a231ea2..31be12ff 100644 --- a/src/components/pages/PbxConfiguration/CscPbxSeat.vue +++ b/src/components/pages/PbxConfiguration/CscPbxSeat.vue @@ -77,12 +77,12 @@ @@ -99,12 +99,12 @@ @@ -138,7 +138,7 @@ @@ -161,7 +161,7 @@ @@ -183,7 +183,7 @@ @@ -335,29 +335,43 @@ this.$emit('expand'); } }, - saveName() { + resetName() { + this.changes.name = this.seat.display_name; + }, + resetExtension() { + this.changes.extension = this.seat.pbx_extension; + }, + resetAliasNumbers() { + this.changes.aliasNumbers = this.getAliasNumberIds(); + }, + resetGroups() { + this.changes.groups = this.getGroupIds(); + }, + resetSoundSet() { + this.changes.soundSet = this.getSoundSetId(); + }, + deleteSeat() { + if(this.$refs.listItem) { + this.$refs.listItem.closePopoverMenu(); + } + this.$emit('remove'); + }, + jumpToCallQueue() { + this.$emit('jump-to-call-queue', this.seat); + }, + save(){ if(this.hasNameChanged) { this.$emit('save-name', { seatId: this.seat.id, seatName: this.changes.name }); } - }, - resetName() { - this.changes.name = this.seat.display_name; - }, - saveExtension() { if(this.hasExtensionChanged) { this.$emit('save-extension', { seatId: this.seat.id, seatExtension: this.changes.extension }); } - }, - resetExtension() { - this.changes.extension = this.seat.pbx_extension; - }, - saveAliasNumbers() { if(this.hasAliasNumbersChanged) { this.$emit('save-alias-numbers', { seatId: this.seat.id, @@ -365,40 +379,19 @@ unassignedNumbers: _.difference(this.getAliasNumberIds(), this.changes.aliasNumbers) }); } - }, - resetAliasNumbers() { - this.changes.aliasNumbers = this.getAliasNumberIds(); - }, - saveGroups() { if(this.hasGroupsChanged) { this.$emit('save-groups', { seatId: this.seat.id, groupIds: this.changes.groups }); } - }, - resetGroups() { - this.changes.groups = this.getGroupIds(); - }, - saveSoundSet() { if(this.hasSoundSetChanged) { this.$emit('save-sound-set', { seatId: this.seat.id, soundSetId: this.changes.soundSet }); } - }, - resetSoundSet() { - this.changes.soundSet = this.getSoundSetId(); - }, - deleteSeat() { - if(this.$refs.listItem) { - this.$refs.listItem.closePopoverMenu(); - } - this.$emit('remove'); - }, - jumpToCallQueue() { - this.$emit('jump-to-call-queue', this.seat); + } }, watch: { diff --git a/src/components/pages/PbxConfiguration/CscPbxSoundSet.vue b/src/components/pages/PbxConfiguration/CscPbxSoundSet.vue index bb279f9d..3b5ea26d 100644 --- a/src/components/pages/PbxConfiguration/CscPbxSoundSet.vue +++ b/src/components/pages/PbxConfiguration/CscPbxSoundSet.vue @@ -46,12 +46,12 @@ v-model="changes.name" :error="$v.changes.name.$error" @input="$v.changes.name.$touch" - @keyup.enter="saveName" + @keyup.enter="save" /> @@ -70,12 +70,12 @@ v-model="changes.description" :error="$v.changes.description.$error" @input="$v.changes.description.$touch" - @keyup.enter="saveDescription" + @keyup.enter="save" /> @@ -235,25 +235,9 @@ contract_default: this.soundSet.contract_default } }, - saveName() { - if(this.hasNameChanged) { - this.$emit('save-name', { - soundSetId: this.soundSet.id, - name: this.changes.name - }); - } - }, resetName() { this.changes.name = this.getDefaultData().name; }, - saveDescription() { - if(this.hasDescriptionChanged) { - this.$emit('save-description', { - soundSetId: this.soundSet.id, - description: this.changes.description - }); - } - }, resetDescription() { this.changes.description = this.getDefaultData().description; }, @@ -269,6 +253,20 @@ }, toggleLoopPlay(options) { this.$emit('toggle-loop-play', options); + }, + save(){ + if(this.hasNameChanged) { + this.$emit('save-name', { + soundSetId: this.soundSet.id, + name: this.changes.name + }); + } + if(this.hasDescriptionChanged) { + this.$emit('save-description', { + soundSetId: this.soundSet.id, + description: this.changes.description + }); + } } }, watch: {