TT#75404 CF: As a Customer, I want to add phone numbers in order to forward calls to these numbers

Change-Id: Ibc557c446156c55db229043c18b345066c32a867
changes/25/38625/3
Carlo Venusino 6 years ago
parent baf1383b89
commit 8554bf10cc

@ -64,15 +64,11 @@
<style lang="stylus" rel="stylesheet/stylus"> <style lang="stylus" rel="stylesheet/stylus">
@import '../themes/quasar.variables.styl'; @import '../themes/quasar.variables.styl';
.csc-page .csc-page
min-height 100vh
position relative position relative
margin 0 margin 0
padding 0 padding 0
.csc-page-content .csc-page-content
min-height 100vh padding 0
padding $flex-gutter-lg
padding-top 24px
padding-bottom $call-footer-height
.csc-page.csc-page-mobile .csc-page.csc-page-mobile
.csc-page-content .csc-page-content
padding-left $flex-gutter-sm * 1.4 padding-left $flex-gutter-sm * 1.4
@ -81,4 +77,6 @@
.csc-page-content .csc-page-content
padding-left 0 padding-left 0
padding-right 0 padding-right 0
.csc-page.csc-simple-page
padding $flex-gutter-lg
</style> </style>

@ -0,0 +1,187 @@
<template>
<div
class="csc-cf-group"
>
<div
v-if="group.id !== 'unconditional'"
class="csc-cf-group-title"
>
{{ group.title }}
</div>
<div
v-for="(destination, index) in group.destinations"
:key="genKey()"
>
<csc-new-call-forward-destination
:destination="destination"
:index="index"
:groupId="group.id"
/>
</div>
<div class="row csc-cf-destination-cont">
<div class="col col-xs-12 col-md-4 text-right"></div>
<div
class="col col-xs-12 col-md-2 text-left"
v-if="showAddDestBtn"
>
<div
class='csc-cf-destination-add-destination'
@click="addDestination"
>
<q-icon
name="add"
color="primary"
size="24px"
/>
{{ $t('pages.newCallForward.addDestinationLabel') }}
<q-spinner-dots
v-if="destinationInCreation"
class="csc-call-spinner"
color="primary"
:size="24"
/>
</div>
</div>
<div class="col col-xs-12 col-md-6 "></div>
</div>
<!-- <div
class="row"
>
<div
class="csc-cf-destination-label col col-4"
>
{{ $t('pages.newCallForward.allCallsForwardedTo') }}
</div>
<div
class="csc-cf-destination-value col col-2"
>
<span
class="csc-text-action"
>
{{ $t('pages.newCallForward.addDestinationLabel') }}
<q-popover
ref="groupMenu"
:disable="true"
>
<q-list
link
no-border
>
<q-item
>
<q-item-side
icon="number"
/>
<q-item-main>
Number
</q-item-main>
</q-item>
</q-list>
</q-popover>
</span>
</div>
<div
class="csc-cf-destination-actions col col-6"
>
<q-icon
name="delete"
color="negative"
size="24px"
/>
</div>
</div> -->
</div>
</template>
<script>
import {
QSpinnerDots,
QIcon,
QPopover,
QList,
QItem,
QItemMain,
QItemSide
} from 'quasar-framework'
import CscNewCallForwardDestination from './CscNewCallForwardDestination'
export default {
name: 'csc-cf-group',
props: [
'group'
],
components: {
QSpinnerDots,
QIcon,
QPopover,
QList,
QItem,
QItemMain,
QItemSide,
CscNewCallForwardDestination
},
data () {
return {
destinationInCreation: false
};
},
computed: {
showAddDestBtn(){
const destinations = this.group.destinations;
for(let dest of destinations){
if(dest && dest.simple_destination && dest.simple_destination.length < 2){
return false;
}
}
return true;
}
},
methods: {
// we need to generate key because destinations have no id
genKey(){
return Math.random();
},
async addDestination(){
this.destinationInCreation = true;
await this.$store.dispatch('newCallForward/addDestination', {
forwardGroupId: this.group.id,
destination: " "
});
await this.$store.dispatch('newCallForward/loadForwardGroups');
this.destinationInCreation = false;
}
}
}
</script>
<style lang="stylus" rel="stylesheet/stylus">
@import '../../../themes/app.common.styl'
.csc-cf-group
width 100%
.csc-cf-group-title
text-align right
.csc-cf-destination-label
text-align right
.csc-cf-destination-value
text-align center
.csc-cf-destination-actions
text-align left
.csc-cf-destination-add-destination
padding-left 25px
width 250px
white-space nowrap
overflow hidden
text-overflow ellipsis
color $primary
cursor pointer
</style>

@ -3,113 +3,103 @@
class="csc-simple-page" class="csc-simple-page"
> >
<div <div
class="row" class="csc-cf-row row"
> >
<div <div
class="col col-xs-12 col-md-4" class="col col-xs-12 col-md-4 text-right"
> >
{{ toggleLabel }} {{ toggleLabel }}
</div> </div>
<div <div
class="col col-xs-12 col-md-2" class="col col-xs-12 col-md-2 text-left csc-cf-self-number-cont"
> >
{{subscriberDisplayName}} {{ primaryNumber | number }}
</div> </div>
<div <div
class="col col-xs-12 col-md-6" class="col col-xs-12 col-md-6"
> ></div>
<q-field class="csc-cf-field-toggle">
<q-toggle
:value="primaryNumberEnabled"
:left-label="true"
@input="togglePrimaryNumber()"
/>
</q-field>
</div>
</div> </div>
<div class="row"> <div class="csc-cf-row row">
<div <div
class="col col-xs-12 col-md-4" class="column col col-xs-12 col-md-4 items-end"
> >
<q-btn flat class="csc-cf-flat-btn">
+ {{ $t('pages.newCallForward.forwardBtnLabel') }} <div
</q-btn> class="csc-text-action"
<q-popover @click="addForward"
ref="destinationType"
anchor="center right"
>
<q-list
link
class="no-border"
> >
<q-item> <q-icon
<q-item-main name="add"
:label="this.$t('pages.newCallForward.numberLabel')" color="primary"
@click="showForm()" size="24px"
/> />
</q-item> {{ $t('pages.newCallForward.forwardBtnLabel') }}
<q-item>
<q-item-main <q-spinner-dots
:label="this.$t('pages.newCallForward.voiceMailLabel')" v-if="groupInCreation"
@click="addVoicemail()" color="primary"
:size="24"
/> />
</q-item> </div>
</q-list>
</q-popover>
</div> </div>
</div> </div>
<div <div
class="row csc-cf-destinations-cont" class="csc-cf-row row"
> v-for="(forwardGroup, item) in forwardGroups"
<div :key="forwardGroup.id"
class="col col-xs-12 col-md-12"
> >
<csc-new-call-forward-destination <csc-cf-group
v-for="(destination, index) in destinations" :group="forwardGroup"
:key="index"
:index="index"
:destination="destination"
/> />
</div> </div>
</div>
<div <div class="csc-cf-row row">
class="row"
>
<div <div
class="col col-xs-12 col-md-6" class="column col col-xs-12 col-md-4"
> >
<q-spinner-dots
<csc-new-call-forward-add-destination-form v-if="groupsLoading"
class="csc-list-form col-xs-12 col-md-4 col-lg-6" class="csc-call-spinner"
ref="addDestinationForm" color="primary"
:size="24"
/> />
</div> </div>
</div> </div>
</csc-page> </csc-page>
</template> </template>
<script> <script>
import { mapState, mapGetters } from 'vuex'
import { import {
// mapState,
mapGetters,
// mapMutations
} from 'vuex'
import {
QSpinnerDots,
QField, QField,
QToggle, QToggle,
QBtn, QBtn,
QPopover, QPopover,
QList, QList,
QItem, QItem,
QItemMain QItemMain,
QIcon
} from 'quasar-framework' } from 'quasar-framework'
import CscPage from '../../CscPage' import CscPage from '../../CscPage'
import CscNewCallForwardDestination from './CscNewCallForwardDestination' import CscNewCallForwardDestination from './CscNewCallForwardDestination'
import CscNewCallForwardAddDestinationForm from './CscNewCallForwardAddDestinationForm' import CscNewCallForwardAddDestinationForm from './CscNewCallForwardAddDestinationForm'
import CscCfGroup from "./CscCallForwardGroup";
export default { export default {
components: { components: {
CscCfGroup,
CscPage, CscPage,
CscNewCallForwardDestination, CscNewCallForwardDestination,
CscNewCallForwardAddDestinationForm, CscNewCallForwardAddDestinationForm,
QSpinnerDots,
QField, QField,
QToggle, QToggle,
QBtn, QBtn,
@ -117,23 +107,28 @@
QList, QList,
QItem, QItem,
QItemMain, QItemMain,
QIcon
}, },
data () { data () {
return {}; return {
groupInCreation: false,
groupsLoading: false
};
}, },
async mounted(){ async mounted(){
await this.$store.dispatch('newCallForward/loadDestinationsets'); this.groupsLoading = true;
const unconditionalDestSet = await this.$store.dispatch('newCallForward/getDestinationSetByName', 'csc-unconditional'); await this.$store.dispatch('newCallForward/loadForwardGroups');
if(unconditionalDestSet){ this.groupsLoading = false;
this.$store.dispatch('newCallForward/loadDestinations', unconditionalDestSet.destinations);
}
}, },
computed: { computed: {
...mapState('newCallForward', []), // ...mapState('newCallForward', [
// 'forwardGroups'
// ]),
...mapGetters('newCallForward', [ ...mapGetters('newCallForward', [
'primaryNumber',
'subscriberDisplayName', 'subscriberDisplayName',
'destinations' 'forwardGroups'
]), ]),
primaryNumberEnabled(){ primaryNumberEnabled(){
return true; return true;
@ -143,12 +138,21 @@
} }
}, },
methods: { methods: {
async addForward(){
this.groupInCreation = true;
const unconditionalFwdGroup = await this.$store.dispatch('newCallForward/getForwardGroupByName', 'unconditional');
if(!unconditionalFwdGroup){
await this.$store.dispatch('newCallForward/addForwardGroup', 'unconditional');
await this.$store.dispatch('newCallForward/loadForwardGroups');
}
this.groupInCreation = false;
},
togglePrimaryNumber(){}, togglePrimaryNumber(){},
showForm(){ showForm(){
this.$refs.destinationType.close(); this.$refs.destinationType.close();
this.$refs.addDestinationForm.add(); this.$refs.addDestinationForm.add();
}, },
addVoicemail(){} addVoicemail(){},
} }
} }
</script> </script>
@ -162,4 +166,13 @@
margin-top 25px margin-top 25px
.csc-cf-field-toggle .csc-cf-field-toggle
margin-top 0px; margin-top 0px;
.csc-call-spinner
margin-left auto
.csc-cf-self-number-cont
padding-left 30px
width 150px
white-space nowrap
overflow hidden
text-overflow ellipsis
</style> </style>

@ -96,8 +96,8 @@
}, },
methods: { methods: {
async save() { async save() {
const destinationSetName = 'csc-unconditional'; // gonna be dynamic const forwardGroupName = 'unconditional'; // gonna be dynamic
const getDestinationSetByName = await this.$store.dispatch('newCallForward/getDestinationSetByName', destinationSetName); const forwardGroup = await this.$store.dispatch('newCallForward/getForwardGroupByName', forwardGroupName);
if (this.numberError || this.saveDisabled) { if (this.numberError || this.saveDisabled) {
showGlobalError(this.$t('validationErrors.generic')); showGlobalError(this.$t('validationErrors.generic'));
@ -105,22 +105,22 @@
else if(Number.isInteger(this.destinationIndex)){ // edit mode else if(Number.isInteger(this.destinationIndex)){ // edit mode
this.$store.dispatch('newCallForward/editDestination',{ this.$store.dispatch('newCallForward/editDestination',{
index: this.destinationIndex, index: this.destinationIndex,
destinationSetId: getDestinationSetByName.id, forwardGroupId: forwardGroup.id,
destination: this.number destination: this.number
}); });
} }
else { // new destination else { // new destination
let destinationSetId; let forwardGroupId;
if(!getDestinationSetByName){ if(!forwardGroup){
destinationSetId = await this.$store.dispatch('newCallForward/addDestinationSet', destinationSetName); forwardGroupId = await this.$store.dispatch('newCallForward/addForwardGroup', forwardGroupName);
await this.$store.dispatch('newCallForward/loadDestinationsets'); // keeps local data updated await this.$store.dispatch('newCallForward/loadForwardGroups'); // keeps local data updated
} }
else{ else{
destinationSetId = getDestinationSetByName.id; forwardGroupId = forwardGroup.id;
} }
this.$store.dispatch('newCallForward/addDestination', { this.$store.dispatch('newCallForward/addDestination', {
destinationSetId: destinationSetId, forwardGroupId: forwardGroupId,
destination: this.number destination: this.number
}); });
} }

@ -1,6 +1,6 @@
<template> <template>
<div class="row csc-cf-destination-cont"> <div class="row csc-cf-destination-cont">
<div class="col col-xs-12 col-md-4 "> <div class="col col-xs-12 col-md-4 text-right">
{{ $t('pages.newCallForward.destinationTimeoutLabel') }} {{ $t('pages.newCallForward.destinationTimeoutLabel') }}
<span class='csc-cf-timeout'> <span class='csc-cf-timeout'>
{{this.destinationTimeout}} {{this.destinationTimeout}}
@ -8,6 +8,7 @@
ref="timeoutForm" ref="timeoutForm"
self="top left" self="top left"
class="csc-cf-timeout-form" class="csc-cf-timeout-form"
@close="saveTimeout()"
> >
<q-slider <q-slider
v-model="destinationTimeout" v-model="destinationTimeout"
@ -15,17 +16,19 @@
label-always label-always
:step="5" :step="5"
:min="0" :min="0"
:max="120" :max="300"
@change="saveTimeout()" snap
/> />
</q-popover> </q-popover>
</span> </span>
{{ $t('pages.newCallForward.destinationNumberLabel') }} {{ $t('pages.newCallForward.destinationNumberLabel') }}
</div> </div>
<div class="col col-xs-12 col-md-2 "> <div class="col text-left csc-cf-dest-number-cont">
<span class='csc-cf-destination'> <div class='csc-cf-destination'>
{{this.destinationNumber}} {{ !this.destinationNumber || this.destinationNumber.length < 2
? $t('pages.newCallForward.destinationLabel')
: this.destinationNumber}}
<q-popover <q-popover
ref="numberForm" ref="numberForm"
anchor="top right" anchor="top right"
@ -38,18 +41,20 @@
:destination="this.destinationNumber" :destination="this.destinationNumber"
/> />
</q-popover> </q-popover>
</span>
</div> </div>
<div class="col col-xs-12 col-md-2 "> </div>
<div class="col col-xs-12 col-md-5 ">
<!-- TODO add remove btn --> <!-- TODO add remove btn -->
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { import {
// QField, // QField,
// QToggle, // QToggle,
QIcon,
QBtn, QBtn,
QPopover, QPopover,
QSlider, QSlider,
@ -57,11 +62,12 @@
QItem, QItem,
QItemMain QItemMain
} from 'quasar-framework' } from 'quasar-framework'
import { mapGetters } from 'vuex' // import { mapGetters } from 'vuex'
import CscNewCallForwardAddDestinationForm from './CscNewCallForwardAddDestinationForm' import CscNewCallForwardAddDestinationForm from './CscNewCallForwardAddDestinationForm'
export default { export default {
name: 'csc-new-call-forward-destination', name: 'csc-new-call-forward-destination',
components: { components: {
QIcon,
QBtn, QBtn,
QPopover, QPopover,
QSlider, QSlider,
@ -71,6 +77,7 @@
CscNewCallForwardAddDestinationForm CscNewCallForwardAddDestinationForm
}, },
props: [ props: [
'groupId',
'destination', 'destination',
'index' 'index'
], ],
@ -84,11 +91,6 @@
destinationIndex: null destinationIndex: null
} }
}, },
computed: {
...mapGetters('newCallForward', [
'destinations'
])
},
methods: { methods: {
updateValues(destination){ updateValues(destination){
this.destinationTimeout = destination.timeout; this.destinationTimeout = destination.timeout;
@ -99,22 +101,12 @@
this.$refs.addDestinationForm.add(); this.$refs.addDestinationForm.add();
}, },
async saveTimeout(){ async saveTimeout(){
const destinationSetName = 'csc-unconditional'; // gonna be dynamic
const getDestinationSetByName = await this.$store.dispatch('newCallForward/getDestinationSetByName', destinationSetName);
this.$store.dispatch('newCallForward/editTimeout', { this.$store.dispatch('newCallForward/editTimeout', {
index: this.destinationIndex, index: this.destinationIndex,
timeout: this.destinationTimeout, timeout: this.destinationTimeout,
destinationSetId: getDestinationSetByName.id forwardGroupId: this.groupId
}); });
} }
},
watch: {
destinations(){
if(Number.isInteger(this.destinationIndex)){
this.updateValues(this.destinations[this.destinationIndex])
}
}
} }
} }
</script> </script>
@ -122,15 +114,23 @@
<style lang="stylus" rel="stylesheet/stylus"> <style lang="stylus" rel="stylesheet/stylus">
@import '../../../themes/app.common.styl' @import '../../../themes/app.common.styl'
.csc-cf-destination-cont .csc-cf-destination-cont
width 100%
padding 5px padding 5px
.csc-cf-timeout, .csc-cf-timeout,
.csc-cf-destination .csc-cf-destination
width 100px
white-space nowrap
overflow hidden
text-overflow ellipsis
color $primary color $primary
cursor pointer cursor pointer
.csc-cf-timeout-form, .csc-cf-timeout-form,
.csc-cf-number-form .csc-cf-number-form
min-width 120px min-width 120px
padding 0 15px 0 15px padding 0 20px 0 20px
.csc-cf-dest-number-cont
padding-left 30px
</style> </style>

@ -26,7 +26,9 @@
QField, QField,
QInput QInput
} from 'quasar-framework' } from 'quasar-framework'
import { isPhone } from '../../../helpers/validation' import {
userInfoAndEmpty
} from '../../../helpers/validation'
import { import {
maxLength, maxLength,
required required
@ -41,7 +43,7 @@
}, },
mounted(){ mounted(){
if(this.prefilled){ if(this.prefilled){
this.inputValue = this.prefilled; this.inputValue = this.prefilled === " " ? "" : this.prefilled;
} }
}, },
@ -53,7 +55,7 @@
}, },
validations: { validations: {
inputValue: { inputValue: {
isPhone, userInfoAndEmpty,
maxLength: maxLength(64), maxLength: maxLength(64),
required required
} }
@ -75,7 +77,7 @@
maxLength: this.$v.inputValue.$params.maxLength.max maxLength: this.$v.inputValue.$params.maxLength.max
}); });
} }
else if (!this.$v.inputValue.isPhone) { else if (!this.$v.inputValue.userInfoAndEmpty) {
return this.$t('validationErrors.inputValidNumber'); return this.$t('validationErrors.inputValidNumber');
} }
}, },

@ -1,6 +1,12 @@
export default function(number, extension) { export default function(number, extension) {
let constructedNumber = "" + number.cc + number.ac + number.sn; let constructedNumber = "";
if(number !== null && number.is_devid && number.is_devid === true) {
constructedNumber = "" + number.devid_alias;
}
else if (number !== null) {
constructedNumber = "" + number.cc + number.ac + number.sn;
}
if (extension) { if (extension) {
return constructedNumber.replace(new RegExp(extension + '$'), ''); return constructedNumber.replace(new RegExp(extension + '$'), '');
} }

@ -216,7 +216,10 @@
"numberLabel": "Number", "numberLabel": "Number",
"voiceMailLabel": "Voicemail", "voiceMailLabel": "Voicemail",
"destinationTimeoutLabel": "Then after ", "destinationTimeoutLabel": "Then after ",
"destinationNumberLabel": "seconds forwarded to" "destinationNumberLabel": "seconds forwarded to",
"destinationLabel": "Destination",
"addDestinationLabel": "Add destination",
"allCallsForwardedTo": "All calls forwarded to"
}, },
"callForward": { "callForward": {
"titles": { "titles": {

@ -4,6 +4,7 @@ import Vue from 'vue'
// import _ from 'lodash'; // import _ from 'lodash';
// import { RequestState } from './common' // import { RequestState } from './common'
// import { i18n } from '../i18n'; // import { i18n } from '../i18n';
import { import {
// getSourcesets, // getSourcesets,
getDestinationsets, getDestinationsets,
@ -31,111 +32,156 @@ import {
// updateOwnPhoneTimeout // updateOwnPhoneTimeout
} from '../api/call-forward'; } from '../api/call-forward';
const ForwardGroup = {
unconditional: 'unconditional'
};
export default { export default {
namespaced: true, namespaced: true,
state: { state: {
destinationsets:[], forwardGroups: []
destinations: [],
}, },
getters: { getters: {
primaryNumber(state, getters, rootState, rootGetters) {
let subscriber = rootGetters['user/getSubscriber'];
if(subscriber !== null) {
return subscriber.primary_number;
}
else {
return null;
}
},
subscriberDisplayName(state, getters, rootState, rootGetters) { subscriberDisplayName(state, getters, rootState, rootGetters) {
return rootGetters['user/getUsername']; return rootGetters['user/getUsername'];
}, },
destinations(state) { // destinations(state) {
return state.destinations; // return state.destinations;
}, // },
destinationsets(state){ forwardGroups(state){
return state.destinationsets; return state.forwardGroups;
} }
}, },
mutations: { mutations: {
addDestination(state, destination){ addDestination(state, forwardGroupId, destination){
state.destinations.push(destination); let group = state.forwardGroups.find((group)=>{
return group.id === forwardGroupId;
});
group.destinations.push(destination);
}, },
editDestination(state, data){ editDestination(state, data){
let destination = state.destinations.slice(data.index, data.index+1)[0]; let group = state.forwardGroups.find((group)=>{
return group.id === data.forwardGroupId;
});
let destination = group.destinations.slice(data.index, data.index+1)[0];
destination.simple_destination = data.destination; destination.simple_destination = data.destination;
destination.destination = data.destination; destination.destination = data.destination;
Vue.set(state.destinations, data.index, destination) Vue.set(group.destinations, data.index, destination)
}, },
editTimeout(state, data){ editTimeout(state, data){
let destination = state.destinations.slice(data.index, data.index+1)[0]; let group = state.forwardGroups.find((group)=>{
return group.id === data.forwardGroupId;
});
let destination = group.destinations.slice(data.index, data.index+1)[0];
destination.timeout = data.timeout; destination.timeout = data.timeout;
Vue.set(state.destinations, data.index, destination) Vue.set(group.destinations, data.index, destination)
}, },
loadDestinationsets(state, destinationsets){ // loadDestinationsets(state, destinationsets){
state.destinationsets = destinationsets; // state.destinationsets = destinationsets;
// },
loadForwardGroups(state, forwardGroups){
state.forwardGroups = forwardGroups;
}, },
loadDestinations(state, destinations){ // loadDestinations(state, destinations){
state.destinations = destinations; // state.destinations = destinations;
} // },
}, },
actions: { actions: {
async loadDestinationsets(context) { async loadForwardGroups(context) {
try{ try{
const destinationsets = await getDestinationsets(localStorage.getItem('subscriberId')); const forwardGroups = await getDestinationsets(localStorage.getItem('subscriberId'));
context.commit('loadDestinationsets', destinationsets); context.commit('loadForwardGroups', forwardGroups);
} }
catch(err){ catch(err){
console.log(err) console.log(err)
} }
}, },
loadDestinations(context, destinations){ // loadDestinations(context, destinations){
context.commit('loadDestinations', destinations); // context.commit('loadDestinations', destinations);
}, // },
async addDestinationSet(context, name) { async addForwardGroup(context, name) {
try{ try{
const newDestinationset = await addNewDestinationsetWithName(name); const destination = {
return newDestinationset; "announcement_id": null,
"simple_destination": " ",
"destination": " ",
"priority": 1,
"timeout": 20
};
const newForwardGroupId = await addNewDestinationsetWithName(ForwardGroup[name]);
await addDestinationToDestinationset({
id: newForwardGroupId,
data: [destination]
});
return newForwardGroupId;
} }
catch(err){ catch(err){
console.log(err) console.log(err)
} }
}, },
getDestinationSetByName(context, name){ getForwardGroupByName(context, name){
let destinationsets = context.getters.destinationsets; let forwardGroups = context.getters.forwardGroups;
destinationsets = destinationsets.filter(($destinationset) => { forwardGroups = forwardGroups.filter(($forwardGroup) => {
return $destinationset.name === name; return $forwardGroup.name === name;
}); });
return destinationsets.length > 0 ? destinationsets[0] : null; return forwardGroups.length > 0 ? forwardGroups[0] : null;
}, },
async addDestination(context, data){ async addDestination(context, data){
try{ try{
let group = context.state.forwardGroups.find((group)=>{
return group.id === data.forwardGroupId;
});
const destination = { const destination = {
"announcement_id": null, "announcement_id": null,
"simple_destination": data.destination, "simple_destination": data.destination,
"destination": data.destination, "destination": data.destination,
"priority": 1, "priority": 1,
"timeout": 10 "timeout": 20
}; };
await addDestinationToDestinationset({ await addDestinationToDestinationset({
id: data.destinationSetId, id: data.forwardGroupId,
data: [...context.state.destinations, destination] data: [...group.destinations, destination]
}); });
context.commit('addDestination', destination); // context.commit('addDestination', group.id, destination);
} }
catch(err){ catch(err){
console.log(err); console.log(err);
} }
}, },
async editDestination(context, data){ async editDestination(context, data){
let destination = context.state.destinations.slice(data.index, data.index+1)[0]; let group = context.state.forwardGroups.find((group)=>{
return group.id === data.forwardGroupId;
});
let destination = group.destinations.slice(data.index, data.index+1)[0];
destination.simple_destination = data.destination; destination.simple_destination = data.destination;
destination.destination = data.destination; destination.destination = data.destination;
context.commit('editDestination', data); context.commit('editDestination', data);
await addDestinationToDestinationset({ await addDestinationToDestinationset({
id: data.destinationSetId, id: data.forwardGroupId,
data: context.state.destinations data: group.destinations
}); });
}, },
async editTimeout(context, data){ async editTimeout(context, data){
let destination = context.state.destinations.slice(data.index, data.index+1)[0]; let group = context.state.forwardGroups.find((group)=>{
return group.id === data.forwardGroupId;
});
let destination = group.destinations.slice(data.index, data.index+1)[0];
destination.timeout = data.timeout; destination.timeout = data.timeout;
context.commit('editTimeout', data); context.commit('editTimeout', data);
await addDestinationToDestinationset({ await addDestinationToDestinationset({
id: data.destinationSetId, id: group.id,
data: context.state.destinations data: group.destinations
}); });
} }
} }

@ -308,3 +308,11 @@ input.q-input-target
position relative position relative
left 50% !important left 50% !important
transform translateX(-50%) transform translateX(-50%)
.csc-text-action
color $primary
cursor pointer
font-weight bold
.csc-cf-row
margin-bottom $flex-gutter-sm

Loading…
Cancel
Save