TT#79307 CF Busy group

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

@ -9,7 +9,7 @@
<div
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 class="col text-left col-xs-12 col-md-2 csc-cf-dest-number-cont">
@ -36,7 +36,7 @@
:index="index"
:groupId="group.id"
: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 }"
/>
@ -81,6 +81,7 @@
<csc-new-call-forward-add-destination-form
ref="addDestinationForm"
:groupName="this.group.name"
:groupId="this.group.id"
/>
</q-popover>
</div>
@ -137,7 +138,7 @@
async mounted(){
try{
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;
}
@ -172,6 +173,9 @@
case "csc-offline":
title = `${this.$t('pages.newCallForward.titles.offlineGroup')}`;
break;
case "csc-busy":
title = `${this.$t('pages.newCallForward.titles.busyGroup')}`;
break;
}
return title;
}
@ -231,10 +235,6 @@
width 100%
.csc-cf-group-cont
position relative
.csc-cf-group-title
font-weight bold
.csc-cf-group-title
text-align right
.csc-cf-destination-label
text-align right
.csc-cf-destination-value

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

@ -81,7 +81,8 @@
'index',
'disable',
'loading',
'groupName'
'groupName',
'groupId'
],
validations: {
number: {
@ -103,8 +104,9 @@
},
methods: {
async save() {
const forwardGroupId = this.groupId;
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) {
showGlobalError(this.$t('validationErrors.generic'));
}
@ -115,7 +117,7 @@
destination: this.number
});
}
else { // new destination
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 :)

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

@ -4,20 +4,32 @@
>
<div
class="csc-cf-dest-type"
v-if="!unconditionalGroupExists && !timeoutGroupExists"
@click="addDestinationsetUnconditional()"
>
{{ $t('pages.newCallForward.uncoditionalLabel') }}
{{ $t('pages.newCallForward.unconditionalLabel') }}
</div>
<div
class="csc-cf-dest-type"
v-if="!offlineGroupExists"
@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>
</template>
<script>
import {
mapGetters,
} from 'vuex'
import CscSpinner from '../../CscSpinner'
import { } from 'quasar-framework'
@ -31,6 +43,14 @@
enabled: true
}
},
computed: {
...mapGetters('newCallForward', [
'timeoutGroupExists',
'unconditionalGroupExists',
'offlineGroupExists',
'busyGroupExists'
])
},
methods: {
async addDestinationsetUnconditional(){
await this.$store.dispatch('newCallForward/setSelectedDestType', 'unconditional');
@ -40,6 +60,26 @@
await this.$store.dispatch('newCallForward/setSelectedDestType', 'offline');
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() {
this.enabled = false;
},

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

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

Loading…
Cancel
Save