TT#81502 CF: As a Customer, I want to delete entire forwarding groups

Change-Id: I999a0ab380d87fe8986c9f6cfc8b4e034fce152d
changes/19/40319/2
Carlo Venusino 5 years ago
parent 9966fbb960
commit a063d1ab9c

@ -81,9 +81,22 @@
@change="toggleGroupChange"
/>
</div>
<div class="col col-xs-12 col-md-5 ">
<div class="col col-xs-12 col-md-5 csc-cf-group-actions">
<q-icon
name="delete"
color="negative"
size="24px"
@click="showConfirmDialog"
/>
<csc-confirm-dialog
ref="confirmDialog"
title-icon="delete"
:title="$t('pages.newCallForward.cancelGroupDialogTitle', {groupName: this.group.name})"
:message="$t('pages.newCallForward.cancelGroupDialogText', {groupName: this.group.name})"
@confirm="confirmDeleteGroup"
/>
<q-spinner-dots
v-if="toggleGroupInProgress || destinationInCreation"
v-if="groupIsLoading"
class="csc-call-spinner"
color="primary"
:size="24"
@ -168,6 +181,7 @@
QItemSide
} from 'quasar-framework'
import CscObjectSpinner from "../../CscObjectSpinner";
import CscConfirmDialog from "../../CscConfirmationDialog";
import CscNewCallForwardDestination from './CscNewCallForwardDestination'
import CscNewCallForwardAddDestinationForm from './CscNewCallForwardAddDestinationForm'
import CscNewCallForwardEditSources from './CscNewCallForwardEditSources'
@ -188,6 +202,7 @@
QItem,
QItemMain,
QItemSide,
CscConfirmDialog,
CscObjectSpinner,
CscNewCallForwardDestination,
CscNewCallForwardAddDestinationForm,
@ -202,7 +217,7 @@
isEnabled: true,
toggleNumberForm: true,
toggleConditionFromForm: true,
toggleGroupInProgress: false,
groupIsLoading: false,
sourceSet: null,
sources: []
};
@ -222,9 +237,9 @@
computed: {
...mapGetters('newCallForward', [
'getOwnPhoneTimeout',
'destinationInCreation',
'groupsCount',
'getMappings'
'getMappings',
'getGroupsLoaders'
]),
showAddDestBtn(){
const destinations = this.group.destinations;
@ -261,9 +276,13 @@
}
},
watch: {
group: function () {
group: function () {
this.updateSourcesetNames();
},
getGroupsLoaders: function(){
const groupLoaders = this.getGroupsLoaders;
this.groupIsLoading = groupLoaders.includes(this.group.id);
}
},
methods: {
// we need to generate key because destinations have no id
@ -280,10 +299,10 @@
this.$refs.numberForm.open();
break;
case 'voicemail':
await this.$store.dispatch('newCallForward/setDestinationInCreation', true);
await this.$store.dispatch('newCallForward/addGroupLoader', this.group.id);
await this.$store.dispatch('newCallForward/addVoiceMail', this.group.id);
await this.$store.dispatch('newCallForward/loadForwardGroups');
await this.$store.dispatch('newCallForward/setDestinationInCreation', false);
await this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id);
break;
}
},
@ -310,13 +329,13 @@
return destination;
},
async toggleGroupChange(){
this.toggleGroupInProgress = true;
await this.$store.dispatch('newCallForward/addGroupLoader', this.group.id);
await this.$store.dispatch('newCallForward/enableGroup', {
groupName: this.group.name,
id: this.group.id,
enabled: this.isEnabled
});
this.toggleGroupInProgress = false;
await this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id);
},
showConditions(){
this.$refs.addCondition.add();
@ -345,6 +364,15 @@
this.sources = this.sourceSet.sources;
}
}
},
showConfirmDialog(){
this.$refs.confirmDialog.open();
},
async confirmDeleteGroup(){
await this.$store.dispatch('newCallForward/addGroupLoader', this.group.id);
await this.$store.dispatch('newCallForward/deleteForwardGroup', this.group);
await this.$store.dispatch('newCallForward/loadForwardGroups');
await this.$store.dispatch('newCallForward/removeGroupLoader', this.group.id);
}
}
}
@ -377,6 +405,8 @@
.csc-cf-from-link
color $primary
cursor pointer
.csc-cf-group-actions
cursor pointer
.csc-cf-destination-disabled
color $cf-disabled-label
.csc-cf-destination-link

@ -42,9 +42,6 @@
</template>
<script>
import {
mapGetters,
} from 'vuex'
import CscNewCallForwardInput from './CscNewCallForwardInput'
import CscSpinner from '../../CscSpinner'
import {
@ -95,9 +92,6 @@
}
},
computed: {
...mapGetters('newCallForward', [
'destinationInCreation'
]),
saveDisabled() {
return this.numberError|| this.disable || this.loading;
}
@ -107,6 +101,7 @@
const forwardGroupId = this.groupId;
const forwardGroupName = this.groupName;
const forwardGroup = await this.$store.dispatch('newCallForward/getForwardGroupById', forwardGroupId);
await this.$store.dispatch('newCallForward/addGroupLoader', this.groupId);
if (this.numberError || this.saveDisabled) {
showGlobalError(this.$t('validationErrors.generic'));
}
@ -118,7 +113,6 @@
});
}
else { // new group
await this.$store.dispatch('newCallForward/setDestinationInCreation', true);
if(forwardGroup.id.toString().includes('temp-')){ // unexisting group
forwardGroup.destinations[0].simple_destination = this.number; // optimistic UI update :)
await this.$store.dispatch('newCallForward/addForwardGroup', {
@ -134,8 +128,8 @@
});
}
await this.$store.dispatch('newCallForward/loadForwardGroups');
await this.$store.dispatch('newCallForward/setDestinationInCreation', false);
}
await this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId);
},
cancel() {
this.number = '';

@ -49,9 +49,6 @@
</template>
<script>
import {
mapGetters,
} from 'vuex'
import CscNewCallForwardInput from './CscNewCallForwardInput'
import CscNewCallForwardInputText from './CscNewCallForwardInputText'
import CscSpinner from '../../CscSpinner'
@ -103,9 +100,6 @@
}
},
computed: {
...mapGetters('newCallForward', [
'destinationInCreation'
]),
saveDisabled() {
return this.number.length < 1 || this.name.length < 1 || this.numberError|| this.nameError || this.disable || this.loading;
}
@ -115,8 +109,7 @@
let sourceSetId;
const forwardGroupId = this.groupId;
const forwardGroupName = this.groupName;
const forwardGroup = await this.$store.dispatch('newCallForward/getForwardGroupById', forwardGroupId);
if (this.numberError || this.nameError || this.saveDisabled) {
showGlobalError(this.$t('validationErrors.generic'));
}
@ -143,7 +136,6 @@
case 'edit':
break;
}
console.log(forwardGroupId, forwardGroupName, forwardGroup)
},
cancel() {
this.number = '';

@ -172,18 +172,19 @@
this.$refs.numberForm.open();
break;
case 'voicemail':
await this.$store.dispatch('newCallForward/addGroupLoader', this.groupId);
if(this.groupId.toString().includes('temp-')){ // unexisting group
this.$parent.toggleGroupInProgress = true;
await this.$store.dispatch('newCallForward/addForwardGroup', {
name: this.groupName,
destination: 'voicebox'
});
await this.$store.dispatch('newCallForward/loadForwardGroups');
this.$parent.toggleGroupInProgress = false;
}
else{
await this.$store.dispatch('newCallForward/addVoiceMail', this.groupId);
}
await this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId);
break;
}
},
@ -195,13 +196,13 @@
this.$refs.selectDestinationType.add();
},
async saveTimeout(){
this.$parent.toggleGroupInProgress = true;
await this.$store.dispatch('newCallForward/addGroupLoader', this.groupId);
await this.$store.dispatch('newCallForward/editTimeout', {
index: this.destinationIndex,
timeout: this.destinationTimeout,
forwardGroupId: this.groupId
});
this.$parent.toggleGroupInProgress = false;
await this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId);
},
showConfirmDialog(){
@ -209,10 +210,12 @@
},
async confirmDeleteDest(){
this.removeInProgress = true;
await this.$store.dispatch('newCallForward/addGroupLoader', this.groupId);
await this.$store.dispatch('newCallForward/removeDestination', {
destination: this.destination,
forwardGroupId: this.groupId
});
await this.$store.dispatch('newCallForward/removeGroupLoader', this.groupId);
},
isVoiceMail(){
return this.destination.destination.includes('voicebox.local')
@ -266,7 +269,7 @@
.csc-cf-dest-popover-bottom
margin-left 0px
.csc-cf-removed-destination
visibility hidden
visibility hidden
opacity 0
transition visibility 0s 1s, opacity 1s linear
transition visibility 0s 2s, opacity 2s linear
</style>

@ -111,7 +111,8 @@
},
computed: {
...mapGetters('newCallForward', [
'destinationInCreation'
'getSourcesets',
'getSourcesesBySourcesetId'
]),
saveDisabled() {
return this.number.length < 1 || this.numberError || this.disable || this.loading;

@ -231,7 +231,9 @@
"addDestinationLabel": "Add destination",
"allCallsForwardedTo": "All calls forwarded to",
"cancelDialogTitle": "Delete from {groupName} forwarding",
"cancelGroupDialogTitle": "Delete {groupName} forwarding group",
"cancelDialogText": "You are about to delete {destination} from {groupName} call forwarding",
"cancelGroupDialogText": "You are about to delete {groupName} call forwarding group",
"unconditionalLabel": "If online",
"fromLabel": "If call from ...",
"fromLabelShort": " and call from ",

@ -10,8 +10,8 @@ import {
updateOwnPhoneTimeout,
updateDestinationsetName,
createSourcesetWithSource,
getSourcesetById,
// getSourcesets
getSourcesets,
addSourceToSourceset
} from '../api/call-forward';
const ForwardGroup = {
@ -45,11 +45,15 @@ export default {
namespaced: true,
state: {
mappings: [],
sourceSets: [],
forwardGroups: [],
destinationInCreation: false,
groupsLoaders: [],
selectedDestType: null
},
getters: {
getGroupsLoaders(state){
return state.groupsLoaders;
},
primaryNumber(state, getters, rootState, rootGetters) {
const subscriber = rootGetters['user/getSubscriber'];
if(subscriber !== null) {
@ -71,9 +75,6 @@ export default {
tempDestinations(state){
return state.tempDestinations;
},
destinationInCreation(state){
return state.destinationInCreation;
},
selectedDestType(state){
return state.selectedDestType;
},
@ -118,6 +119,13 @@ export default {
},
getMappings(state){
return state.mappings;
},
getSourcesets(state){
return state.sourceSets;
},
getSourcesesBySourcesetId: (state) => (sourceSetId) => {
const sourceSet = state.sourceSets.filter($sourceset => $sourceset.id == sourceSetId);
return sourceSet ? sourceSet[0].sources : null;
}
},
mutations: {
@ -163,9 +171,28 @@ export default {
},
setSelectedDestType(state, destType){
state.selectedDestType = destType;
},
setSourceSets(state, sourceSets){
state.sourceSets = sourceSets;
},
addGroupLoader(state, groupId){
state.groupsLoaders.push(groupId)
},
removeGroupLoader(state, groupId){
state.groupsLoaders = state.groupsLoaders.filter($groupId => $groupId !== groupId);
}
},
actions: {
groupIsLoading(context, groupId){
const loader = context.state.groupsLoaders.filter($groupId => $groupId == groupId);
return loader && loader.length > 0;
},
addGroupLoader(context, groupId){
context.commit('addGroupLoader', groupId);
},
removeGroupLoader(context, groupId){
context.commit('removeGroupLoader', groupId);
},
async loadMappings(context) {
try{
const mappings = await getMappings(localStorage.getItem('subscriberId'));
@ -384,10 +411,6 @@ export default {
console.log(err);
}
},
removeSourceFromSourceset(context, data){
// TODO
console.log(context, data)
},
async editDestination(context, data){
let group = context.state.forwardGroups.find((group)=>{
return group.id === data.forwardGroupId;
@ -564,6 +587,11 @@ export default {
setSelectedDestType(context, destType){
context.commit('setSelectedDestType', destType);
},
async loadSourcesets(context){
const subscriberId = localStorage.getItem('subscriberId');
const sourceSets = await getSourcesets(subscriberId);
context.commit('setSourceSets', sourceSets);
},
async createSourceSet(context, data){
const sourceSetId = await createSourcesetWithSource({
sourcesetName: data.name,
@ -586,13 +614,15 @@ export default {
console.log(err)
}
},
// async getSourcesets(){
// const sourceSets = await getSourcesets(localStorage.getItem('subscriberId'));
// return sourceSet;
// },
async getSourcesetById(context, id){
const sourceSet = await getSourcesetById(id);
return sourceSet;
}
const sourceSet = context.state.sourceSets.filter($sourceset => $sourceset.id == id);
return sourceSet ? sourceSet[0] : [];
},
async addSourceToSourceset(context, data){
await addSourceToSourceset(data)
},
async removeSourceFromSourceset(context, data){
await addSourceToSourceset(data)
},
}
};

Loading…
Cancel
Save