@ -7,7 +7,7 @@
class = "col col-xs-12 col-md-4"
>
< q -item
v - if = " hasSubscriberProfileAttribute('clir') "
v - if = " showClir "
>
< q -item -section >
< q -toggle
@ -29,21 +29,46 @@
/ >
< / q - i t e m - s e c t i o n >
< / q - i t e m >
< q -item
v - if = "showClirIntrapbx"
>
< q -item -section >
< q -toggle
v - model = "clirIntrapbx"
: disabled = "isLoading"
: label = "$t('Hide number to the callee within own PBX')"
checked - icon = "visibility_off"
unchecked - icon = "visibility"
@ input = "changeIntraPbx"
/ >
< / q - i t e m - s e c t i o n >
< q -item -section
side
>
< csc -spinner
v - if = "isLoading"
/ >
< / q - i t e m - s e c t i o n >
< / q - i t e m >
< / q - l i s t >
< / c s c - p a g e >
< / template >
< script >
import { mapGetters , mapActions , mapState } from 'vuex'
import {
mapGetters ,
mapState
} from 'vuex'
import {
showGlobalError ,
showToast
} from 'src/helpers/ui'
import {
RequestState
} from 'src/store/common'
import CscPage from 'components/CscPage'
import CscSpinner from 'components/CscSpinner'
import { getSubscriberId } from 'src/auth'
import { PROFILE _ATTRIBUTE _MAP } from 'src/constants'
export default {
name : 'CscPageCallBlockingPrivacy' ,
components : {
@ -51,7 +76,10 @@ export default {
CscPage
} ,
data ( ) {
return { }
return {
clirIntrapbx : false ,
isLoading : false
}
} ,
computed : {
fieldIcon ( ) {
@ -64,6 +92,9 @@ export default {
... mapState ( 'callBlocking' , [
'privacy'
] ) ,
... mapGetters ( 'pbxSeats' , [
'getIntraPbx'
] ) ,
... mapGetters ( 'callBlocking' , [
'privacy' ,
'privacyError' ,
@ -73,7 +104,17 @@ export default {
] ) ,
... mapGetters ( 'user' , [
'hasSubscriberProfileAttribute'
] )
] ) ,
... mapState ( 'pbxSeats' , [
'seatUpdateState' ,
'seatUpdateError'
] ) ,
showClir ( ) {
return this . hasSubscriberProfileAttribute ( PROFILE _ATTRIBUTE _MAP . clir )
} ,
showClirIntrapbx ( ) {
return this . hasSubscriberProfileAttribute ( PROFILE _ATTRIBUTE _MAP . clir _intrapbx )
} ,
} ,
watch : {
privacyUpdated ( updated ) {
@ -82,12 +123,46 @@ export default {
} else if ( updated && ! this . privacy ) {
showToast ( this . $t ( 'Your number is visible to the callee' ) )
}
} ,
seatUpdateState ( state ) {
switch ( state ) {
case RequestState . requesting :
this . requestInProgress ( true )
break
case RequestState . succeeded :
showToast ( this . clirIntrapbx ? this . $t ( 'Your number is hidden to the callee within own PBX' ) : this . $t ( 'Your number is visible to the callee within own PBX' ) )
this . requestInProgress ( false )
break
case RequestState . failed :
showGlobalError ( this . seatUpdateError , 5000 )
this . requestInProgress ( false )
break
}
}
} ,
mounted ( ) {
async mounted ( ) {
this . requestInProgress ( true )
const preferences = await this . loadPreferences ( getSubscriberId ( ) )
this . clirIntrapbx = preferences . clir _intrapbx
this . requestInProgress ( false )
this . $store . dispatch ( 'callBlocking/loadPrivacy' )
} ,
methods : {
... mapActions ( 'pbxSeats' , [
'setIntraPbx' ,
'loadPreferences'
] ) ,
changeIntraPbx ( ) {
const msg = this . clirIntrapbx ? this . $t ( 'Your number is hidden to the callee within own PBX' ) : this . $t ( 'Your number is visible to the callee within own PBX' )
this . setIntraPbx ( {
seatId : getSubscriberId ( ) ,
intraPbx : this . clirIntrapbx ,
message : msg
} )
} ,
requestInProgress ( loading ) {
this . isLoading = loading
} ,
toggle ( ) {
this . $store . dispatch ( 'callBlocking/updatePrivacy' , ! this . privacy )
}