@ -53,7 +53,8 @@
v - if = "expanded"
>
< q -field
: label = "$t('pbxConfig.queueExtensionName')" >
: label = "$t('pbxConfig.queueExtensionName')"
>
< q -input
dark
readonly
@ -61,21 +62,33 @@
/ >
< / q - f i e l d >
< q -field
: label = "$t('pbxConfig.queueLength')" >
: label = "$t('pbxConfig.queueLength')"
: error - label = "queueLengthErrorMessage"
>
< q -input
dark
readonly
: value = "subscriber.max_queue_length"
suffix = "callers"
v - model = "changes.max_queue_length"
: after = "queueLengthButtons"
@ keyup . enter = "saveQueueLength"
@ input = "$v.changes.max_queue_length.$touch"
@ blur = "$v.changes.max_queue_length.$touch"
: error = "$v.changes.max_queue_length.$error"
/ >
< / q - f i e l d >
< q -field
: label = "$t('pbxConfig.wrapUpTime')" >
: label = "$t('pbxConfig.wrapUpTime')"
: error - label = "wrapUpTimeErrorMessage"
>
< q -input
dark
readonly
: value= "subscriber.queue_wrap_up_time "
v- model = "changes.queue_wrap_up_time"
: after= "wrapUpTimeButtons "
suffix = "seconds"
@ keyup . enter = "saveWrapUpTime"
@ input = "$v.changes.queue_wrap_up_time.$touch"
@ blur = "$v.changes.queue_wrap_up_time.$touch"
: error = "$v.changes.queue_wrap_up_time.$error"
/ >
< / q - f i e l d >
< / q - i t e m - t i l e >
@ -94,10 +107,22 @@
/ >
< / q - i t e m - t i l e >
< / q - i t e m - s i d e >
< q -inner -loading :visible ="isLoading" >
< q -spinner -mat
size = "60px"
color = "primary"
/ >
< / q - i n n e r - l o a d i n g >
< / q - i t e m >
< / template >
< script >
import { showGlobalError } from '../../../helpers/ui'
import {
minValue ,
maxValue ,
numeric
} from 'vuelidate/lib/validators'
import {
QField ,
QInput ,
@ -107,16 +132,20 @@
QItem ,
QItemSide ,
QItemMain ,
QItemTile
QItemTile ,
QInnerLoading ,
QSpinnerMat
} from 'quasar-framework'
export default {
name : 'csc-pbx-call-queue' ,
props : [
'subscriber'
'subscriber' ,
'loading'
] ,
data ( ) {
return {
expanded : false
expanded : false ,
changes : this . getConfig ( )
}
} ,
components : {
@ -127,9 +156,63 @@
QItem ,
QItemSide ,
QItemMain ,
QItemTile
QItemTile ,
QInnerLoading ,
QSpinnerMat
} ,
validations : {
changes : {
max _queue _length : {
numeric ,
minValue : minValue ( 1 ) ,
maxValue : maxValue ( 99999 )
} ,
queue _wrap _up _time : {
numeric ,
minValue : minValue ( 1 ) ,
maxValue : maxValue ( 99999 )
}
}
} ,
computed : {
queueLengthErrorMessage ( ) {
if ( ! this . $v . changes . max _queue _length . numeric ) {
return this . $t ( 'validationErrors.numeric' , {
field : this . $t ( 'pbxConfig.queueLength' ) ,
} ) ;
}
else if ( ! this . $v . changes . max _queue _length . minValue ) {
return this . $t ( 'validationErrors.minValueSecond' , {
field : this . $t ( 'pbxConfig.queueLength' ) ,
minValue : this . $v . changes . max _queue _length . $params . minValue . min
} ) ;
}
else if ( ! this . $v . changes . max _queue _length . maxValue ) {
return this . $t ( 'validationErrors.maxValueSecond' , {
field : this . $t ( 'pbxConfig.queueLength' ) ,
maxValue : this . $v . changes . max _queue _length . $params . maxValue . max
} ) ;
}
} ,
wrapUpTimeErrorMessage ( ) {
if ( ! this . $v . changes . queue _wrap _up _time . numeric ) {
return this . $t ( 'validationErrors.numeric' , {
field : this . $t ( 'pbxConfig.wrapUpTime' ) ,
} ) ;
}
else if ( ! this . $v . changes . queue _wrap _up _time . minValue ) {
return this . $t ( 'validationErrors.minValueSecond' , {
field : this . $t ( 'pbxConfig.wrapUpTime' ) ,
minValue : this . $v . changes . queue _wrap _up _time . $params . minValue . min
} ) ;
}
else if ( ! this . $v . changes . queue _wrap _up _time . maxValue ) {
return this . $t ( 'validationErrors.maxValueSecond' , {
field : this . $t ( 'pbxConfig.wrapUpTime' ) ,
maxValue : this . $v . changes . queue _wrap _up _time . $params . maxValue . max
} ) ;
}
} ,
itemClasses ( ) {
let classes = [ 'csc-list-item' , 'csc-pbx-call-queue' ] ;
if ( this . expanded ) {
@ -150,11 +233,129 @@
else {
return 'keyboard arrow up' ;
}
} ,
wrapUpTimeButtons ( ) {
let buttons = [ ] ;
let self = this ;
if ( this . wrapUpTimeHasChanged && this . $v . changes . queue _wrap _up _time . $error ) {
buttons . push ( {
icon : 'clear' ,
error : true ,
handler ( event ) {
event . stopPropagation ( ) ;
self . resetWrapUpTime ( ) ;
}
}
) ;
}
else if ( this . wrapUpTimeHasChanged ) {
buttons . push ( {
icon : 'check' ,
error : false ,
handler ( event ) {
event . stopPropagation ( ) ;
self . saveWrapUpTime ( ) ;
}
} , {
icon : 'clear' ,
error : false ,
handler ( event ) {
event . stopPropagation ( ) ;
self . resetWrapUpTime ( ) ;
}
}
) ;
}
return buttons ;
} ,
wrapUpTime ( ) {
return this . subscriber . queue _wrap _up _time ;
} ,
wrapUpTimeHasChanged ( ) {
return this . wrapUpTime + "" !== this . changes . queue _wrap _up _time + "" ;
} ,
queueLengthButtons ( ) {
let buttons = [ ] ;
let self = this ;
if ( this . queueLengthHasChanged && this . $v . changes . max _queue _length . $error ) {
buttons . push ( {
icon : 'clear' ,
error : true ,
handler ( event ) {
event . stopPropagation ( ) ;
self . resetQueueLength ( ) ;
}
}
) ;
}
else if ( this . queueLengthHasChanged ) {
buttons . push ( {
icon : 'check' ,
error : false ,
handler ( event ) {
event . stopPropagation ( ) ;
self . saveQueueLength ( ) ;
}
} , {
icon : 'clear' ,
error : false ,
handler ( event ) {
event . stopPropagation ( ) ;
self . resetQueueLength ( ) ;
}
}
) ;
}
return buttons ;
} ,
queueLength ( ) {
return this . subscriber . max _queue _length ;
} ,
queueLengthHasChanged ( ) {
return this . queueLength + "" !== this . changes . max _queue _length + "" ;
} ,
configModel ( ) {
return {
id : this . subscriber . id ,
max _queue _length : this . changes . max _queue _length ,
queue _wrap _up _time : this . changes . queue _wrap _up _time
}
} ,
isLoading ( ) {
return this . loading ;
}
} ,
methods : {
toggleMain ( ) {
this . expanded = ! this . expanded ;
} ,
getConfig ( ) {
return {
max _queue _length : this . subscriber . max _queue _length ,
queue _wrap _up _time : this . subscriber . queue _wrap _up _time
}
} ,
resetWrapUpTime ( ) {
this . changes . queue _wrap _up _time = this . subscriber . queue _wrap _up _time ;
} ,
saveWrapUpTime ( ) {
if ( this . $v . changes . $invalid ) {
showGlobalError ( this . $t ( 'validationErrors.generic' ) ) ;
}
else {
this . $emit ( 'save-wrap-up-time' , this . configModel ) ;
}
} ,
resetQueueLength ( ) {
this . changes . max _queue _length = this . subscriber . max _queue _length ;
} ,
saveQueueLength ( ) {
if ( this . $v . changes . $invalid ) {
showGlobalError ( this . $t ( 'validationErrors.generic' ) ) ;
}
else {
this . $emit ( 'save-queue-length' , this . configModel ) ;
}
}
} ,
watch : {