From b691f24498102106a7d54eb3b13d2e4b41a221b9 Mon Sep 17 00:00:00 2001 From: Robert Axelsen Date: Tue, 26 Mar 2019 17:35:09 +0100 Subject: [PATCH] TT#47517 Change sound item loop flag Change-Id: Idca3bb1c14f7785b29de0cf961e5a78c6dec4714 --- src/api/pbx-config.js | 9 +++ .../PbxConfiguration/CscPbxSoundGroup.vue | 9 ++- .../PbxConfiguration/CscPbxSoundItem.vue | 8 ++- .../pages/PbxConfiguration/CscPbxSoundSet.vue | 9 +++ .../PbxConfiguration/CscPbxSoundSets.vue | 4 ++ src/store/pbx-config/actions.js | 59 +++++++++++-------- src/store/pbx-config/getters.js | 7 ++- 7 files changed, 77 insertions(+), 28 deletions(-) diff --git a/src/api/pbx-config.js b/src/api/pbx-config.js index 4c522ad5..0ccfe9aa 100644 --- a/src/api/pbx-config.js +++ b/src/api/pbx-config.js @@ -843,3 +843,12 @@ export function abortPreviousSoundFileUpload(handle) { resolve(); }); } + +export function setSoundSetItemLoopplay(id, loopplay) { + let loopflag = !loopplay ? 'true' : 'false'; + return patchReplace({ + path: 'api/soundfiles/' + id, + fieldPath: 'loopplay', + value: loopflag + }); +} diff --git a/src/components/pages/PbxConfiguration/CscPbxSoundGroup.vue b/src/components/pages/PbxConfiguration/CscPbxSoundGroup.vue index 15bd4ae8..be57bc76 100644 --- a/src/components/pages/PbxConfiguration/CscPbxSoundGroup.vue +++ b/src/components/pages/PbxConfiguration/CscPbxSoundGroup.vue @@ -13,9 +13,10 @@ :key="item.id" :item="item" :group="groupLabel" - :updating="isRemoveFileRequesting(item.id)" :set-id="setId" + :updating="isRemoveFileRequesting(item.id) || isToggleLoopplayRequesting(item.id)" @remove-file="removeFile" + @toggle-loop="toggleLoop" /> @@ -63,7 +64,8 @@ }, computed: { ...mapGetters('pbxConfig', [ - 'isRemoveFileRequesting' + 'isRemoveFileRequesting', + 'isToggleLoopplayRequesting' ]), groupLabelClasses() { let classes = []; @@ -76,6 +78,9 @@ methods: { removeFile(item) { this.$emit('remove-file', item); + }, + toggleLoop(item) { + this.$emit('toggle-loop', item) } }, watch: { diff --git a/src/components/pages/PbxConfiguration/CscPbxSoundItem.vue b/src/components/pages/PbxConfiguration/CscPbxSoundItem.vue index efec4d18..0fdee978 100644 --- a/src/components/pages/PbxConfiguration/CscPbxSoundItem.vue +++ b/src/components/pages/PbxConfiguration/CscPbxSoundItem.vue @@ -28,12 +28,13 @@ slot="additional" > {{ loopTooltipLabel }} @@ -167,6 +168,9 @@ resetFile() { this.$refs.uploadSoundFile.reset(); this.$store.commit('pbxConfig/resetSoundFileProgress', this.item.handle); + }, + toggleLoop() { + this.$emit('toggle-loop', this.item) } }, watch: { diff --git a/src/components/pages/PbxConfiguration/CscPbxSoundSet.vue b/src/components/pages/PbxConfiguration/CscPbxSoundSet.vue index ef8e675a..fc296d74 100644 --- a/src/components/pages/PbxConfiguration/CscPbxSoundSet.vue +++ b/src/components/pages/PbxConfiguration/CscPbxSoundSet.vue @@ -109,6 +109,7 @@ :set-id="set.id" :key="index" @remove-file="removeFile" + @toggle-loop="toggleLoop" /> @@ -453,6 +454,14 @@ soundSet: this.setModel }; this.$emit('remove-file', options); + }, + toggleLoop(item) { + let options = { + id: item.id, + loopplay: item.loopplay, + soundSet: this.setModel + }; + this.$emit('toggle-loop', options); } }, watch: { diff --git a/src/components/pages/PbxConfiguration/CscPbxSoundSets.vue b/src/components/pages/PbxConfiguration/CscPbxSoundSets.vue index 107d224c..3d8cefbe 100644 --- a/src/components/pages/PbxConfiguration/CscPbxSoundSets.vue +++ b/src/components/pages/PbxConfiguration/CscPbxSoundSets.vue @@ -55,6 +55,7 @@ @save-description="saveSoundSetDescription" @save-contract-default="saveContractDefault" @remove-file="removeSoundFileDialog" + @toggle-loop="toggleLoop" />
{ - sets.items.forEach((set) => { - context.dispatch('loadFilesForSoundSet', set.id); + sets.items.forEach((soundSet) => { + context.dispatch('loadFilesForSoundSet', soundSet.id); }); }).catch((err) => { context.commit('listSoundSetsFailed', err.message) @@ -603,48 +604,48 @@ export default { context.commit('removeItemFailed', err.message); }); }, - saveSoundSetName(context, set) { - context.commit('updateItemRequesting', set); - context.commit('lastUpdatedField', {name: set.name, type: 'sound set name'}); - setSoundSetName(set.id, set.name).then(() => { - return context.dispatch('reloadSoundSet', set); + saveSoundSetName(context, soundSet) { + context.commit('updateItemRequesting', soundSet); + context.commit('lastUpdatedField', {name: soundSet.name, type: 'sound set name'}); + setSoundSetName(soundSet.id, soundSet.name).then(() => { + return context.dispatch('reloadSoundSet', soundSet); }).then(() => { context.commit('updateItemSucceeded'); }).catch((err) => { context.commit('updateItemFailed', err.message); }); }, - saveSoundSetDescription(context, set) { - context.commit('updateItemRequesting', set); - context.commit('lastUpdatedField', {name: set.description, type: 'sound set description'}); - setSoundSetDescription(set.id, set.description).then(() => { - return context.dispatch('reloadSoundSet', set); + saveSoundSetDescription(context, soundSet) { + context.commit('updateItemRequesting', soundSet); + context.commit('lastUpdatedField', {name: soundSet.description, type: 'sound set description'}); + setSoundSetDescription(soundSet.id, soundSet.description).then(() => { + return context.dispatch('reloadSoundSet', soundSet); }).then(() => { context.commit('updateItemSucceeded'); }).catch((err) => { context.commit('updateItemFailed', err.message); }); }, - saveContractDefault(context, set) { - let defaultName = set.contract_default ? 'on' : 'off'; - context.commit('updateItemRequesting', set); + saveContractDefault(context, soundSet) { + let defaultName = soundSet.contract_default ? 'on' : 'off'; + context.commit('updateItemRequesting', soundSet); context.commit('lastUpdatedField', {name: defaultName, type: 'default for subscribers'}); - setSoundSetContractDefault(set.id, set.contract_default).then(() => { - return context.dispatch('reloadSoundSet', set); + setSoundSetContractDefault(soundSet.id, soundSet.contract_default).then(() => { + return context.dispatch('reloadSoundSet', soundSet); }).then(() => { context.commit('updateItemSucceeded'); }).catch((err) => { context.commit('updateItemFailed', err.message); }); }, - reloadSoundSet(context, set) { + reloadSoundSet(context, soundSet) { return new Promise((resolve, reject) => { - context.commit('soundSetReloading', set); - getSoundSetWithFiles(set.id).then(($set) => { - context.commit('soundSetReloaded', $set); + context.commit('soundSetReloading', soundSet); + getSoundSetWithFiles(soundSet.id).then(($soundSet) => { + context.commit('soundSetReloaded', $soundSet); }).catch((err)=>{ context.commit('soundSetReloadingFailed', { - set: set, + set: soundSet, error: err.message }); }).then(() => { @@ -702,5 +703,17 @@ export default { }, abortPreviousSoundFileUpload(state, handle) { abortPreviousSoundFileUpload(handle); + }, + setLoopplay(context, options) { + let loopName = options.loopplay ? 'off' : 'on'; + context.commit('updateItemRequesting', options.id); + context.commit('lastUpdatedField', {name: loopName, type: 'playing in loop'}); + setSoundSetItemLoopplay(options.id, options.loopplay).then(() => { + return context.dispatch('reloadSoundSet', options.soundSet); + }).then(() => { + context.commit('updateItemSucceeded'); + }).catch((err) => { + context.commit('updateItemFailed', err.message); + }); } } diff --git a/src/store/pbx-config/getters.js b/src/store/pbx-config/getters.js index 4269e05a..50b372e5 100644 --- a/src/store/pbx-config/getters.js +++ b/src/store/pbx-config/getters.js @@ -390,7 +390,12 @@ export default { }, isRemoveFileRequesting(state) { return (id) => { - return id ? state.removeItem === id : false; + return state.removeState === 'requesting' && id ? state.removeItem === id : false; + } + }, + isToggleLoopplayRequesting(state) { + return (id) => { + return state.updateState === 'requesting' && id ? state.updateItem === id : false; } }, uploadSoundFileRequesting(state) {