From 48007762908a59d742b25680e3f103719052f1c7 Mon Sep 17 00:00:00 2001 From: Hans-Peter Herzog Date: Tue, 23 Jul 2019 11:50:14 +0200 Subject: [PATCH] TT#63409 SoundSets: As PBXAdmin I want to unset a SoundSet as contract default Change-Id: I7c164c80757bfd5b63d01fa80fd1a6f58ff1ece2 --- src/api/pbx-soundsets.js | 4 ++++ .../pages/PbxConfiguration/CscPbxSoundSet.vue | 7 ++++--- .../pages/PbxConfiguration/CscPbxSoundSets.vue | 2 +- src/store/pbx-soundsets.js | 12 ++++++++---- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/api/pbx-soundsets.js b/src/api/pbx-soundsets.js index 62609ee5..92e1ab60 100644 --- a/src/api/pbx-soundsets.js +++ b/src/api/pbx-soundsets.js @@ -91,6 +91,10 @@ export function setAsDefault(soundSetId) { return setSoundSetProperty(soundSetId, 'contract_default', true); } +export function unsetAsDefault(soundSetId) { + return setSoundSetProperty(soundSetId, 'contract_default', false); +} + export function setSoundSetName(soundSetId, name) { return setSoundSetProperty(soundSetId, 'name', name); } diff --git a/src/components/pages/PbxConfiguration/CscPbxSoundSet.vue b/src/components/pages/PbxConfiguration/CscPbxSoundSet.vue index f68b853b..bb279f9d 100644 --- a/src/components/pages/PbxConfiguration/CscPbxSoundSet.vue +++ b/src/components/pages/PbxConfiguration/CscPbxSoundSet.vue @@ -209,9 +209,10 @@ }, methods: { saveAsDefault() { - if(!this.soundSet.contract_default) { - this.$emit('save-as-default'); - } + this.$emit('save-as-default', { + soundSetId: this.soundSet.id, + contractDefault: !this.soundSet.contract_default + }); }, remove() { if(this.$refs.listItem) { diff --git a/src/components/pages/PbxConfiguration/CscPbxSoundSets.vue b/src/components/pages/PbxConfiguration/CscPbxSoundSets.vue index dff51df4..ac6275ec 100644 --- a/src/components/pages/PbxConfiguration/CscPbxSoundSets.vue +++ b/src/components/pages/PbxConfiguration/CscPbxSoundSets.vue @@ -61,7 +61,7 @@ :sound-file-update-state="soundFileUpdateState" @require-sound-handles="loadSoundSetResources(soundSet.id)" @remove="openSoundSetRemovalDialog(soundSet.id)" - @save-as-default="setAsDefaultSoundSet(soundSet.id)" + @save-as-default="setAsDefaultSoundSet" @save-name="setSoundSetName" @save-description="setSoundSetDescription" @expand="expandSoundSet(soundSet.id)" diff --git a/src/store/pbx-soundsets.js b/src/store/pbx-soundsets.js index 41b93847..79463502 100644 --- a/src/store/pbx-soundsets.js +++ b/src/store/pbx-soundsets.js @@ -16,7 +16,7 @@ import { getAllSoundFilesBySoundSetId, getSoundFile, uploadSoundFile, - setLoopPlay + setLoopPlay, unsetAsDefault } from "../api/pbx-soundsets"; import _ from "lodash"; import { @@ -324,9 +324,13 @@ export default { context.commit('soundSetRemovalFailed', err.message); }); }, - setAsDefaultSoundSet(context, soundSetId) { - context.commit('soundSetUpdateRequesting', soundSetId); - setAsDefault(soundSetId).then(()=>{ + setAsDefaultSoundSet(context, options) { + context.commit('soundSetUpdateRequesting', options.soundSetId); + let func = setAsDefault; + if(options.contractDefault !== true) { + func = unsetAsDefault; + } + func(options.soundSetId).then(()=>{ return context.dispatch('loadSoundSetList', { listVisible: true, page: context.state.soundSetListCurrentPage