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