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>
<script>
import {
showGlobalError,
showToast
} from '../../../helpers/ui'
import {
CreationState,
RequestState
} from "../../../store/common"
import CscPage from '../../CscPage'
import CscList from "../../CscList"
import CscFade from "../../transitions/CscFade"
@ -134,7 +142,13 @@
'soundFileUrlMap',
'soundFileUploadState',
'soundFileUploadProgress',
'soundFileUpdateState'
'soundFileUpdateState',
'soundSetCreationState',
'soundSetCreationError',
'soundSetUpdateState',
'soundSetUpdateError',
'soundSetRemovalState',
'soundSetRemovalError'
]),
...mapGetters('pbxSoundSets', [
'isSoundSetListRequesting',
@ -146,7 +160,10 @@
'isSoundSetExpanded',
'getSoundSetRemoveDialogMessage',
'isSoundHandleListRequesting',
'isSoundFileListRequesting'
'isSoundFileListRequesting',
'getSoundSetCreationToastMessage',
'getSoundSetUpdateToastMessage',
'getSoundSetRemovalToastMessage'
])
},
methods: {
@ -186,6 +203,32 @@
}
},
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>

@ -484,6 +484,12 @@
"soundSetPlayAllLoop": "Play all files in loop",
"soundSetRemovalDialogTitle": "Remove sound set",
"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",
"deviceUpdateToast": "Updated {field} for device {device} successfully",
"deviceRemovalToast": "Removed device {device} successfully",

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

Loading…
Cancel
Save