TT#56394 Implemented toasts for section PBXConfiguration/SoundSets

Change-Id: I870797a54db8363d20c882e7cda63a5d9f190f0f
changes/22/32022/1
Hans-Peter Herzog 6 years ago
parent 164406557c
commit 06488aee57

@ -83,6 +83,14 @@
</template> </template>
<script> <script>
import {
showGlobalError,
showToast
} from '../../../helpers/ui'
import {
CreationState,
RequestState
} from "../../../store/common"
import CscPage from '../../CscPage' import CscPage from '../../CscPage'
import CscList from "../../CscList" import CscList from "../../CscList"
import CscFade from "../../transitions/CscFade" import CscFade from "../../transitions/CscFade"
@ -134,7 +142,13 @@
'soundFileUrlMap', 'soundFileUrlMap',
'soundFileUploadState', 'soundFileUploadState',
'soundFileUploadProgress', 'soundFileUploadProgress',
'soundFileUpdateState' 'soundFileUpdateState',
'soundSetCreationState',
'soundSetCreationError',
'soundSetUpdateState',
'soundSetUpdateError',
'soundSetRemovalState',
'soundSetRemovalError'
]), ]),
...mapGetters('pbxSoundSets', [ ...mapGetters('pbxSoundSets', [
'isSoundSetListRequesting', 'isSoundSetListRequesting',
@ -146,7 +160,10 @@
'isSoundSetExpanded', 'isSoundSetExpanded',
'getSoundSetRemoveDialogMessage', 'getSoundSetRemoveDialogMessage',
'isSoundHandleListRequesting', 'isSoundHandleListRequesting',
'isSoundFileListRequesting' 'isSoundFileListRequesting',
'getSoundSetCreationToastMessage',
'getSoundSetUpdateToastMessage',
'getSoundSetRemovalToastMessage'
]) ])
}, },
methods: { methods: {
@ -186,6 +203,32 @@
} }
}, },
watch: { watch: {
soundSetCreationState(state) {
if(state === CreationState.created) {
this.$scrollTo(this.$parent.$el);
showToast(this.getSoundSetCreationToastMessage);
}
else if(state === CreationState.error) {
showGlobalError(this.soundSetCreationError);
}
},
soundSetUpdateState(state) {
if(state === RequestState.succeeded) {
showToast(this.getSoundSetUpdateToastMessage);
}
else if(state === RequestState.failed) {
showGlobalError(this.soundSetUpdateError);
}
},
soundSetRemovalState(state) {
if(state === RequestState.succeeded) {
this.$scrollTo(this.$parent.$el);
showToast(this.getSoundSetRemovalToastMessage);
}
else if(state === RequestState.failed) {
showGlobalError(this.soundSetRemovalError);
}
}
} }
} }
</script> </script>

@ -484,6 +484,12 @@
"soundSetPlayAllLoop": "Play all files in loop", "soundSetPlayAllLoop": "Play all files in loop",
"soundSetRemovalDialogTitle": "Remove sound set", "soundSetRemovalDialogTitle": "Remove sound set",
"soundSetRemovalDialogText": "You are about to remove sound set {soundSetName}", "soundSetRemovalDialogText": "You are about to remove sound set {soundSetName}",
"soundSetCreationToast": "Created sound set {soundSet} successfully",
"soundSetUpdateToast": "Updated {field} for sound set {soundSet} successfully",
"soundSetRemovalToast": "Removed sound set {soundSet} successfully",
"soundSetDefaultLabel": "default option",
"soundSetNameLabel": "name",
"soundSetDescriptionLabel": "description",
"deviceCreationToast": "Created device {device} successfully", "deviceCreationToast": "Created device {device} successfully",
"deviceUpdateToast": "Updated {field} for device {device} successfully", "deviceUpdateToast": "Updated {field} for device {device} successfully",
"deviceRemovalToast": "Removed device {device} successfully", "deviceRemovalToast": "Removed device {device} successfully",

@ -42,10 +42,15 @@ export default {
soundSetListCurrentPage: 1, soundSetListCurrentPage: 1,
soundSetListLastPage: null, soundSetListLastPage: null,
soundSetCreationState: CreationState.initiated, soundSetCreationState: CreationState.initiated,
soundSetCreationData: null,
soundSetCreationError: null,
soundSetRemovalState: CreationState.initiated, soundSetRemovalState: CreationState.initiated,
soundSetRemoving: null, soundSetRemoving: null,
soundSetRemovalError: null,
soundSetUpdateState: CreationState.initiated, soundSetUpdateState: CreationState.initiated,
soundSetUpdateError: null,
soundSetUpdating: null, soundSetUpdating: null,
soundSetUpdatingField: null,
soundSetSelected: null, soundSetSelected: null,
soundHandleList: [], soundHandleList: [],
soundHandleListState: RequestState.initiated, soundHandleListState: RequestState.initiated,
@ -105,6 +110,34 @@ export default {
} }
return ''; return '';
}, },
getSoundSetRemovingName(state) {
return _.get(state.soundSetRemoving, 'name', '');
},
getSoundSetCreatingName(state) {
return _.get(state.soundSetCreationData, 'name', '');
},
getSoundSetUpdatingName(state) {
return _.get(state.soundSetUpdating, 'name', '');
},
getSoundSetUpdatingField(state) {
return state.soundSetUpdatingField;
},
getSoundSetCreationToastMessage(state, getters) {
return i18n.t('pbxConfig.soundSetCreationToast', {
soundSet: getters.getSoundSetCreatingName
});
},
getSoundSetUpdateToastMessage(state, getters) {
return i18n.t('pbxConfig.soundSetUpdateToast', {
soundSet: getters.getSoundSetUpdatingName,
field: getters.getSoundSetUpdatingField
});
},
getSoundSetRemovalToastMessage(state, getters) {
return i18n.t('pbxConfig.soundSetRemovalToast', {
soundSet: getters.getSoundSetRemovingName
});
},
isSoundHandleListRequesting(state) { isSoundHandleListRequesting(state) {
return state.soundHandleListState === RequestState.requesting; return state.soundHandleListState === RequestState.requesting;
}, },
@ -134,24 +167,28 @@ export default {
Vue.set(state.soundSetMap, soundSet.id, soundSet); Vue.set(state.soundSetMap, soundSet.id, soundSet);
}); });
}, },
soundSetCreationRequesting(state) { soundSetCreationRequesting(state, options) {
state.soundSetCreationState = CreationState.creating; state.soundSetCreationState = CreationState.creating;
state.soundSetCreationData = options;
}, },
soundSetCreationSucceeded(state) { soundSetCreationSucceeded(state) {
state.soundSetCreationState = CreationState.created; state.soundSetCreationState = CreationState.created;
}, },
soundSetCreationFailed(state) { soundSetCreationFailed(state, err) {
state.soundSetCreationState = CreationState.error; state.soundSetCreationState = CreationState.error;
state.soundSetCreationError = err;
}, },
soundSetUpdateRequesting(state, soundSetId) { soundSetUpdateRequesting(state, options) {
state.soundSetUpdateState = RequestState.requesting; state.soundSetUpdateState = RequestState.requesting;
state.soundSetUpdating = state.soundSetMap[soundSetId]; state.soundSetUpdating = state.soundSetMap[options.soundSetId];
state.soundSetUpdatingField = options.field;
}, },
soundSetUpdateSucceeded(state) { soundSetUpdateSucceeded(state) {
state.soundSetUpdateState = RequestState.succeeded; state.soundSetUpdateState = RequestState.succeeded;
}, },
soundSetUpdateFailed(state) { soundSetUpdateFailed(state, err) {
state.soundSetUpdateState = RequestState.failed; state.soundSetUpdateState = RequestState.failed;
state.soundSetUpdateError = err;
}, },
soundSetRemovalRequesting(state, soundSetId) { soundSetRemovalRequesting(state, soundSetId) {
state.soundSetRemovalState = RequestState.requesting; state.soundSetRemovalState = RequestState.requesting;
@ -166,8 +203,9 @@ export default {
soundSetRemovalSucceeded(state) { soundSetRemovalSucceeded(state) {
state.soundSetRemovalState = RequestState.succeeded; state.soundSetRemovalState = RequestState.succeeded;
}, },
soundSetRemovalFailed(state) { soundSetRemovalFailed(state, err) {
state.soundSetRemovalState = RequestState.failed; state.soundSetRemovalState = RequestState.failed;
state.soundSetRemovalError = err;
}, },
enableSoundSetAddForm(state) { enableSoundSetAddForm(state) {
state.soundSetCreationState = CreationState.input; state.soundSetCreationState = CreationState.input;
@ -299,7 +337,7 @@ export default {
}); });
}, },
createSoundSet(context, options) { createSoundSet(context, options) {
context.commit('soundSetCreationRequesting'); context.commit('soundSetCreationRequesting', options);
createSoundSet(options).then(()=>{ createSoundSet(options).then(()=>{
return context.dispatch('loadSoundSetList', { return context.dispatch('loadSoundSetList', {
listVisible: true, listVisible: true,
@ -325,7 +363,10 @@ export default {
}); });
}, },
setAsDefaultSoundSet(context, options) { setAsDefaultSoundSet(context, options) {
context.commit('soundSetUpdateRequesting', options.soundSetId); context.commit('soundSetUpdateRequesting', {
soundSetId: options.soundSetId,
field: i18n.t('pbxConfig.soundSetDefaultLabel')
});
let func = setAsDefault; let func = setAsDefault;
if(options.contractDefault !== true) { if(options.contractDefault !== true) {
func = unsetAsDefault; func = unsetAsDefault;
@ -342,7 +383,10 @@ export default {
}); });
}, },
setSoundSetName(context, options) { setSoundSetName(context, options) {
context.commit('soundSetUpdateRequesting', options.soundSetId); context.commit('soundSetUpdateRequesting', {
soundSetId: options.soundSetId,
field: i18n.t('pbxConfig.soundSetNameLabel')
});
setSoundSetName(options.soundSetId, options.name).then(()=>{ setSoundSetName(options.soundSetId, options.name).then(()=>{
return context.dispatch('loadSoundSetList', { return context.dispatch('loadSoundSetList', {
listVisible: true, listVisible: true,
@ -355,7 +399,10 @@ export default {
}); });
}, },
setSoundSetDescription(context, options) { setSoundSetDescription(context, options) {
context.commit('soundSetUpdateRequesting', options.soundSetId); context.commit('soundSetUpdateRequesting', {
soundSetId: options.soundSetId,
field: i18n.t('pbxConfig.soundSetDescriptionLabel')
});
setSoundSetDescription(options.soundSetId, options.description).then(()=>{ setSoundSetDescription(options.soundSetId, options.description).then(()=>{
return context.dispatch('loadSoundSetList', { return context.dispatch('loadSoundSetList', {
listVisible: true, listVisible: true,

Loading…
Cancel
Save