TT#79307 CF Busy group

Change-Id: Ib563a6a4eb2b8cf65da8778cb919abb298b9bb04
changes/50/39850/6
Carlo Venusino 6 years ago
parent 581e68225a
commit 9c3f1e6b3f

@ -9,7 +9,7 @@
<div <div
class="col col-xs-12 col-md-4 text-right csc-cf-group-title" class="col col-xs-12 col-md-4 text-right csc-cf-group-title"
> >
{{ !(groupsCount < 2 && (group.name.includes('timeout') || group.name.includes('unconditional'))) ? groupTitle :"" }} {{ groupTitle }}
</div> </div>
<div class="col text-left col-xs-12 col-md-2 csc-cf-dest-number-cont"> <div class="col text-left col-xs-12 col-md-2 csc-cf-dest-number-cont">
@ -36,7 +36,7 @@
:index="index" :index="index"
:groupId="group.id" :groupId="group.id"
:groupName="group.name" :groupName="group.name"
:allCallsFwd="group.name == 'csc-unconditional' && index === 0" :allCallsFwd="(['csc-unconditional', 'csc-busy', 'csc-offline'].includes(group.name) && index === 0)"
:class="{ 'cf-destination-disabled': !isEnabled }" :class="{ 'cf-destination-disabled': !isEnabled }"
/> />
@ -81,6 +81,7 @@
<csc-new-call-forward-add-destination-form <csc-new-call-forward-add-destination-form
ref="addDestinationForm" ref="addDestinationForm"
:groupName="this.group.name" :groupName="this.group.name"
:groupId="this.group.id"
/> />
</q-popover> </q-popover>
</div> </div>
@ -137,7 +138,7 @@
async mounted(){ async mounted(){
try{ try{
if(!this.inCreation){ if(!this.inCreation){
const isGroupEnabled = await this.$store.dispatch('newCallForward/isGroupEnabled', this.group.name); const isGroupEnabled = await this.$store.dispatch('newCallForward/isGroupEnabled', {groupName: this.group.name, id: this.group.id});
this.isEnabled = isGroupEnabled; this.isEnabled = isGroupEnabled;
} }
@ -172,6 +173,9 @@
case "csc-offline": case "csc-offline":
title = `${this.$t('pages.newCallForward.titles.offlineGroup')}`; title = `${this.$t('pages.newCallForward.titles.offlineGroup')}`;
break; break;
case "csc-busy":
title = `${this.$t('pages.newCallForward.titles.busyGroup')}`;
break;
} }
return title; return title;
} }
@ -231,10 +235,6 @@
width 100% width 100%
.csc-cf-group-cont .csc-cf-group-cont
position relative position relative
.csc-cf-group-title
font-weight bold
.csc-cf-group-title
text-align right
.csc-cf-destination-label .csc-cf-destination-label
text-align right text-align right
.csc-cf-destination-value .csc-cf-destination-value

@ -2,6 +2,27 @@
<csc-page <csc-page
class="csc-simple-page" class="csc-simple-page"
> >
<div
class="csc-cf-row row"
>
<div
class="col col-xs-12 col-md-4 csc-cf-group-title"
>
{{ $t('pages.newCallForward.titles.timeoutGroup') }}
</div>
<div
class="col col-xs-12 col-md-2 text-left csc-cf-self-number-cont"
>
<q-toggle
v-if="forwardGroups.length > 0"
v-model="toggleDefaultNumber"
@change="toggleChange" />
</div>
<div
class="col col-xs-12 col-md-6"
>
</div>
</div>
<div <div
class="csc-cf-row row" class="csc-cf-row row"
> >
@ -20,10 +41,6 @@
class="col col-xs-12 col-md-6" class="col col-xs-12 col-md-6"
> >
<q-toggle
v-if="forwardGroups.length > 0"
v-model="toggleDefaultNumber"
@change="toggleChange" />
</div> </div>
</div> </div>
<div <div
@ -71,6 +88,7 @@
<q-popover <q-popover
ref="destsetTypeForm" ref="destsetTypeForm"
class="cf-popover-bottom" class="cf-popover-bottom"
@open="resetSelectFwdGroup()"
@close="addForwardGroup()" @close="addForwardGroup()"
> >
@ -137,8 +155,8 @@
try{ try{
await this.$store.dispatch('newCallForward/loadMappings'); await this.$store.dispatch('newCallForward/loadMappings');
await this.$store.dispatch('newCallForward/loadForwardGroups'); await this.$store.dispatch('newCallForward/loadForwardGroups');
let unconditionalGroup = await this.$store.dispatch('newCallForward/getForwardGroupByName', 'unconditional'); let unconditionalGroups = await this.$store.dispatch('newCallForward/getForwardGroupByName', 'unconditional');
this.toggleDefaultNumber = !unconditionalGroup || unconditionalGroup.destinations.length < 1; this.toggleDefaultNumber = !unconditionalGroups; //|| unconditionalGroup.destinations.length < 1;
} }
catch(err){ catch(err){
console.log(err) console.log(err)
@ -168,14 +186,14 @@
switch(selectedDestType){ switch(selectedDestType){
case "unconditional":{ case "unconditional":{
if(this.toggleDefaultNumber){ if(this.toggleDefaultNumber){
const timeoutFwdGroup = await this.$store.dispatch('newCallForward/getForwardGroupByName', 'timeout'); const tempTimeoutFwdGroup = await this.$store.dispatch('newCallForward/getForwardGroupById', 'temp-csc-timeout');
if(!timeoutFwdGroup){ if(!tempTimeoutFwdGroup){
await this.$store.dispatch('newCallForward/addTempGroup','timeout' ); await this.$store.dispatch('newCallForward/addTempGroup','timeout' );
} }
} }
else{ else{
const unconditionalFwdGroup = await this.$store.dispatch('newCallForward/getForwardGroupByName', 'unconditional'); const tempUnconditionalFwdGroup = await this.$store.dispatch('newCallForward/getForwardGroupById', 'temp-csc-unconditional');
if(!unconditionalFwdGroup){ if(!tempUnconditionalFwdGroup){
await this.$store.dispatch('newCallForward/addTempGroup','unconditional' ); await this.$store.dispatch('newCallForward/addTempGroup','unconditional' );
} }
} }
@ -184,7 +202,10 @@
case "offline":{ case "offline":{
await this.$store.dispatch('newCallForward/addTempGroup','offline' ); await this.$store.dispatch('newCallForward/addTempGroup','offline' );
} }
break;
case "busy":{
await this.$store.dispatch('newCallForward/addTempGroup','busy' );
}
break; break;
} }
@ -198,6 +219,9 @@
this.groupInCreation = true; this.groupInCreation = true;
await this.$store.dispatch('newCallForward/forwardAllCalls', !this.toggleDefaultNumber); await this.$store.dispatch('newCallForward/forwardAllCalls', !this.toggleDefaultNumber);
this.groupInCreation = false; this.groupInCreation = false;
},
async resetSelectFwdGroup(){
await this.$store.dispatch('newCallForward/setSelectedDestType', null);
} }
} }
} }
@ -208,6 +232,9 @@
.csc-cf-flat-btn .csc-cf-flat-btn
color $primary color $primary
float right float right
.csc-cf-group-title
text-align right
font-weight bold
.csc-cf-destinations-cont .csc-cf-destinations-cont
margin-top 25px margin-top 25px
.csc-cf-field-toggle .csc-cf-field-toggle

@ -81,7 +81,8 @@
'index', 'index',
'disable', 'disable',
'loading', 'loading',
'groupName' 'groupName',
'groupId'
], ],
validations: { validations: {
number: { number: {
@ -103,8 +104,9 @@
}, },
methods: { methods: {
async save() { async save() {
const forwardGroupId = this.groupId;
const forwardGroupName = this.groupName; const forwardGroupName = this.groupName;
const forwardGroup = await this.$store.dispatch('newCallForward/getForwardGroupByName', forwardGroupName); const forwardGroup = await this.$store.dispatch('newCallForward/getForwardGroupById', forwardGroupId);
if (this.numberError || this.saveDisabled) { if (this.numberError || this.saveDisabled) {
showGlobalError(this.$t('validationErrors.generic')); showGlobalError(this.$t('validationErrors.generic'));
} }
@ -115,7 +117,7 @@
destination: this.number destination: this.number
}); });
} }
else { // new destination else { // new group
await this.$store.dispatch('newCallForward/setDestinationInCreation', true); await this.$store.dispatch('newCallForward/setDestinationInCreation', true);
if(forwardGroup.id.toString().includes('temp-')){ // unexisting group if(forwardGroup.id.toString().includes('temp-')){ // unexisting group
forwardGroup.destinations[0].simple_destination = this.number; // optimistic UI update :) forwardGroup.destinations[0].simple_destination = this.number; // optimistic UI update :)

@ -29,7 +29,7 @@
</span> </span>
{{ this.allCallsFwd {{ this.allCallsFwd
? $t('pages.newCallForward.allCallsForwardedTo') ? $t('pages.newCallForward.allCallsForwardedTo')
: isVoiceMail() : isVoiceMail() || isOfflineGroup() || isBusyGroup()
? $t('pages.newCallForward.destinationVoicemailLabel') ? $t('pages.newCallForward.destinationVoicemailLabel')
: $t('pages.newCallForward.destinationNumberLabel') : $t('pages.newCallForward.destinationNumberLabel')
}} }}
@ -68,6 +68,7 @@
:index="this.destinationIndex" :index="this.destinationIndex"
:destination="this.destinationNumber" :destination="this.destinationNumber"
:groupName="this.groupName" :groupName="this.groupName"
:groupId="this.groupId"
/> />
</q-popover> </q-popover>
</div> </div>
@ -218,6 +219,15 @@
isVoiceMail(){ isVoiceMail(){
return this.destination.destination.includes('voicebox.local') return this.destination.destination.includes('voicebox.local')
}, },
isBusyGroup(){
return this.groupName.includes('busy');
},
isOfflineGroup(){
return this.groupName.includes('offline');
},
isNotTimeoutOrUnconditional(){
return this.destination.destination.includes('voicebox.local')
},
getDestName(){ getDestName(){
return this.destination.simple_destination return this.destination.simple_destination
? this.destination.simple_destination ? this.destination.simple_destination

@ -4,20 +4,32 @@
> >
<div <div
class="csc-cf-dest-type" class="csc-cf-dest-type"
v-if="!unconditionalGroupExists && !timeoutGroupExists"
@click="addDestinationsetUnconditional()" @click="addDestinationsetUnconditional()"
> >
{{ $t('pages.newCallForward.uncoditionalLabel') }} {{ $t('pages.newCallForward.unconditionalLabel') }}
</div> </div>
<div <div
class="csc-cf-dest-type" class="csc-cf-dest-type"
v-if="!offlineGroupExists"
@click="addDestinationsetOffline()" @click="addDestinationsetOffline()"
> >
{{ $t('pages.newCallForward.offlinelLabel') }} {{ $t('pages.newCallForward.offlineLabel') }}
</div>
<div
class="csc-cf-dest-type"
v-if="!busyGroupExists"
@click="addDestinationsetBusy()"
>
{{ $t('pages.newCallForward.busyLabel') }}
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import {
mapGetters,
} from 'vuex'
import CscSpinner from '../../CscSpinner' import CscSpinner from '../../CscSpinner'
import { } from 'quasar-framework' import { } from 'quasar-framework'
@ -31,6 +43,14 @@
enabled: true enabled: true
} }
}, },
computed: {
...mapGetters('newCallForward', [
'timeoutGroupExists',
'unconditionalGroupExists',
'offlineGroupExists',
'busyGroupExists'
])
},
methods: { methods: {
async addDestinationsetUnconditional(){ async addDestinationsetUnconditional(){
await this.$store.dispatch('newCallForward/setSelectedDestType', 'unconditional'); await this.$store.dispatch('newCallForward/setSelectedDestType', 'unconditional');
@ -40,6 +60,26 @@
await this.$store.dispatch('newCallForward/setSelectedDestType', 'offline'); await this.$store.dispatch('newCallForward/setSelectedDestType', 'offline');
this.$parent.close() this.$parent.close()
}, },
async addDestinationsetBusy(){
await this.$store.dispatch('newCallForward/setSelectedDestType', 'busy');
this.$parent.close()
},
// async checkTimeoutExisting(){
// const group = await this.$store.dispatch('newCallForward/getForwardGroupByName', 'timeout');
// this.timeoutExisting = !!group;
// },
// async checkUnconditionalExisting(){
// const group = await this.$store.dispatch('newCallForward/getForwardGroupByName', 'unconditional');
// this.unconditionalExisting = !!group;
// },
// async checkOfflineExisting(){
// const group = await this.$store.dispatch('newCallForward/getForwardGroupByName', 'offline');
// this.offlineExisting = !!group;
// },
// async checkBusyExisting(){
// const group = await this.$store.dispatch('newCallForward/getForwardGroupByName', 'busy');
// this.busyExisting = !!group;
// },
cancel() { cancel() {
this.enabled = false; this.enabled = false;
}, },

@ -212,8 +212,9 @@
}, },
"newCallForward": { "newCallForward": {
"titles": { "titles": {
"timeoutGroup" : "Else", "timeoutGroup" : "If online",
"offlineGroup" : "If offline" "offlineGroup" : "If offline",
"busyGroup" : "If busy"
}, },
"primarNumberEnabled": "All calls go to the primary number", "primarNumberEnabled": "All calls go to the primary number",
"primarNumberDisabled": "No call goes to primary number", "primarNumberDisabled": "No call goes to primary number",
@ -228,8 +229,9 @@
"allCallsForwardedTo": "All calls forwarded to", "allCallsForwardedTo": "All calls forwarded to",
"cancelDialogTitle": "Delete from {groupName} forwarding", "cancelDialogTitle": "Delete from {groupName} forwarding",
"cancelDialogText": "You are about to delete {destination} from {groupName} call forwarding", "cancelDialogText": "You are about to delete {destination} from {groupName} call forwarding",
"uncoditionalLabel": "Unconditional", "unconditionalLabel": "If online",
"offlinelLabel": "If offline" "offlineLabel": "If offline",
"busyLabel": "If busy"
}, },
"callForward": { "callForward": {
"titles": { "titles": {

@ -22,6 +22,10 @@ const ForwardGroup = {
offline: { offline: {
name: 'csc-offline', name: 'csc-offline',
mapping: 'cfo' mapping: 'cfo'
},
busy: {
name: 'csc-busy',
mapping: 'cfb'
} }
}; };
@ -63,6 +67,30 @@ export default {
}, },
groupsCount(state){ groupsCount(state){
return state.forwardGroups.length; return state.forwardGroups.length;
},
timeoutGroupExists(state){
const group = state.forwardGroups.filter(($group)=>{
return $group.name === 'csc-timeout'
});
return group && group.length > 0;
},
unconditionalGroupExists(state){
const group = state.forwardGroups.filter(($group)=>{
return $group.name === 'csc-unconditional'
});
return group && group.length > 0;
},
offlineGroupExists(state){
const group = state.forwardGroups.filter(($group)=>{
return $group.name === 'csc-offline'
});
return group && group.length > 0;
},
busyGroupExists(state){
const group = state.forwardGroups.filter(($group)=>{
return $group.name === 'csc-busy'
});
return group && group.length > 0;
} }
}, },
mutations: { mutations: {
@ -96,7 +124,7 @@ export default {
for (let i = 0; i < forwardGroups.length; i++) { for (let i = 0; i < forwardGroups.length; i++) {
const group = forwardGroups[i]; const group = forwardGroups[i];
if (!group.name.includes('unconditional') && !group.name.includes('timeout')){ if (group.name.includes('unconditional') || group.name.includes('timeout')){
forwardGroups.splice(i, 1); forwardGroups.splice(i, 1);
forwardGroups.unshift(group); forwardGroups.unshift(group);
} }
@ -211,6 +239,13 @@ export default {
forwardGroups = forwardGroups.filter(($forwardGroup) => { forwardGroups = forwardGroups.filter(($forwardGroup) => {
return ForwardGroup[name] ? $forwardGroup.name === ForwardGroup[name].name : $forwardGroup.name === name; return ForwardGroup[name] ? $forwardGroup.name === ForwardGroup[name].name : $forwardGroup.name === name;
}); });
return forwardGroups.length > 0 ? forwardGroups : null;
},
getForwardGroupById(context, id){
let forwardGroups = context.getters.forwardGroups;
forwardGroups = forwardGroups.filter(($forwardGroup) => {
return $forwardGroup.id === id ;
});
return forwardGroups.length > 0 ? forwardGroups[0] : null; return forwardGroups.length > 0 ? forwardGroups[0] : null;
}, },
addTempGroup(context, groupName){ addTempGroup(context, groupName){
@ -225,7 +260,7 @@ export default {
"timeout": 5 "timeout": 5
}] }]
}; };
if(!groupName.includes('timeout') && !groupName.includes('unconditional')){ if(groupName.includes('timeout') || groupName.includes('unconditional')){
context.state.forwardGroups.unshift(data); context.state.forwardGroups.unshift(data);
} }
else{ else{
@ -365,10 +400,11 @@ export default {
}, },
async forwardAllCalls(context, noSelfNumber){ async forwardAllCalls(context, noSelfNumber){
try{ try{
let unconditionalGroup = await context.dispatch('getForwardGroupByName', 'unconditional') let unconditionalGroups = await context.dispatch('getForwardGroupByName', 'unconditional')
let timeoutGroup = await context.dispatch('getForwardGroupByName', 'timeout'); let timeoutGroups = await context.dispatch('getForwardGroupByName', 'timeout');
if(noSelfNumber){ if(noSelfNumber && timeoutGroups){
for(let timeoutGroup of timeoutGroups){
if(timeoutGroup && !timeoutGroup.id.toString().includes('temp')){ if(timeoutGroup && !timeoutGroup.id.toString().includes('temp')){
const destinations = [...timeoutGroup.destinations] const destinations = [...timeoutGroup.destinations]
await context.dispatch('addForwardGroup', { await context.dispatch('addForwardGroup', {
@ -388,8 +424,11 @@ export default {
await context.dispatch('addTempGroup', 'unconditional'); await context.dispatch('addTempGroup', 'unconditional');
} }
} }
}
else{ else{
if(unconditionalGroup && !unconditionalGroup.id.toString().includes('temp')){ if(unconditionalGroups ){
for(let unconditionalGroup of unconditionalGroups){
if(!unconditionalGroup.id.toString().includes('temp')){
const destinations = [...unconditionalGroup.destinations] const destinations = [...unconditionalGroup.destinations]
await context.dispatch('addForwardGroup', { await context.dispatch('addForwardGroup', {
name: 'timeout' name: 'timeout'
@ -407,9 +446,8 @@ export default {
await context.dispatch('loadForwardGroups'); await context.dispatch('loadForwardGroups');
await context.dispatch('addTempGroup', 'timeout'); await context.dispatch('addTempGroup', 'timeout');
} }
}
}
} }
} }
catch(err){ catch(err){
@ -426,22 +464,29 @@ export default {
} }
return mappingId; return mappingId;
}, },
async isGroupEnabled(context, groupName){ async isGroupEnabled(context, data){
const mappingId = await context.dispatch('getMappingIdByGroupName', groupName); const mappingId = await context.dispatch('getMappingIdByGroupName', data.groupName);
return mappingId if(mappingId && context.state.mappings[mappingId]){
&& context.state.mappings[mappingId] let groupProps = await context.state.mappings[mappingId].filter(($group)=>{
&& context.state.mappings[mappingId][0] // IMPROVE remove hardcoded [0] return $group.destinationset_id === data.id;
? context.state.mappings[mappingId][0].enabled });
: true; if(groupProps){
return groupProps[0].enabled;
}
}
return true;
}, },
async enableGroup(context, data){ async enableGroup(context, data){
try{ try{
if(!data.id.toString().includes('temp-')){ if(!data.id.toString().includes('temp-')){
const subscriberId = localStorage.getItem('subscriberId'); const subscriberId = localStorage.getItem('subscriberId');
const mappingId = await context.dispatch('getMappingIdByGroupName', data.groupName); const mappingId = await context.dispatch('getMappingIdByGroupName', data.groupName);
let groupMappings = context.state.mappings[mappingId]; const groupMappings = await context.state.mappings[mappingId];
groupMappings[0].enabled = data.enabled; // IMPROVE remove hardcoded [0] for(let group of groupMappings){
if(group.destinationset_id === data.id){
group.enabled = data.enabled;
}
}
await addNewMapping({ await addNewMapping({
mappings: groupMappings, mappings: groupMappings,
group: mappingId, group: mappingId,

Loading…
Cancel
Save