@ -7,55 +7,139 @@
< div class = "title" >
{ { $t ( 'communication.sendFax' ) } }
< / div >
< q -field >
< q -field :error-label ="destinationErrorMessage" >
< q -input
clearable
type = "text"
v - model = "form.destination"
: float - label = "$t('communication.label.destination')" / >
: float - label = "$t('communication.label.destination')"
@ input = "$v.form.destination.$touch"
@ blur = "$v.form.destination.$touch"
: error = "$v.form.destination.$error"
/ >
< / q - f i e l d >
< q -field >
< q -select
v - model = "form.quality"
: options = "qualityOptions"
: float - label = "$t('communication.label.quality')" / >
: float - label = "$t('communication.label.quality')"
/ >
< / q - f i e l d >
< q -field >
< q -field :error-label ="pageHeaderErrorMessage" >
< q -input
clearable
type = "text"
v - model = "form.pageheader"
: float - label = "$t('communication.label.pageHeader')" / >
v - model = "form.pageHeader"
: float - label = "$t('communication.label.pageHeader')"
@ input = "$v.form.pageHeader.$touch"
@ blur = "$v.form.pageHeader.$touch"
: error = "$v.form.pageHeader.$error"
/ >
< / q - f i e l d >
< q -field >
< q -field :error-label ="dataErrorMessage" >
< q -input
clearable
type = "textarea"
: max - height = "100"
: min - rows = "10"
v - model = "form.data"
: float - label = "$t('communication.label.content')" / >
: float - label = "$t('communication.label.content')"
@ input = "$v.form.data.$touch"
@ blur = "$v.form.data.$touch"
: error = "$v.form.data.$error"
/ >
< / q - f i e l d >
< q -field class = "upload-field" >
< label
for = "file-upload"
class = "upload-label"
>
< div class = "upload-label" >
{ { $t ( 'communication.label.faxFile' ) } }
< / div >
< q -btn
class = "upload-button"
flat
dark
@ click = "$refs.upload.click()"
icon - right = "cloud_upload"
>
{ { $t ( 'communication.label.uploadFile' ) } }
< / q - b t n >
< span class = "upload-filename" >
{ { selectedFile } }
< / span >
< q -btn
class = "reset-button"
v - if = "selectedFile.length > 0"
flat
dark
@ click = "resetFile"
icon - right = "cancel"
/ >
< / label >
< input
ref = "upload"
id = "file-upload"
type = "file"
accept = ".pdf,.tiff,.txt,.ps"
@ change = "processFile($event)"
@ input = "$v.form.file.$touch"
@ blur = "$v.form.file.$touch"
: error = "$v.form.file.$error"
/ >
< / q - f i e l d >
< q -btn flat dark @click ="hideModal" > {{ $ t ( ' communication.cancel ' ) }} < / q -btn >
< q -btn flat color = "primary" @click ="sendFax" icon -right = " insert drive file " :disable ="formDisabled" > { { $t ( 'communication.send' ) } } < / q - b t n >
< div
v - if = "$v.form.file.$error"
id = "csc-error-label"
>
{ { fileErrorMessage } }
< / div >
< q -btn
flat
dark
@ click = "hideModal"
>
{ { $t ( 'communication.cancel' ) } }
< / q - b t n >
< q -btn
flat
color = "primary"
@ click = "sendFax"
icon - right = "insert drive file"
: disable = "formDisabled"
>
{ { $t ( 'communication.send' ) } }
< / q - b t n >
< / q - m o d a l >
< / template >
< script >
import {
required ,
requiredUnless ,
maxLength
} from 'vuelidate/lib/validators'
import {
QModal ,
QBtn ,
QField ,
QSelect ,
QInput ,
QIcon
} from 'quasar-framework'
export default {
name : 'csc-send-fax' ,
data ( ) {
return {
showFaxModal : false ,
selectedFile : '' ,
form : {
destination : null ,
pageheader : null ,
page H eader: null ,
data : null ,
quality : 'normal'
quality : 'normal' ,
file : null
} ,
qualityOptions : [
{ label : this . $t ( 'communication.quality.normal' ) , value : 'normal' } ,
@ -70,26 +154,114 @@
QBtn ,
QField ,
QSelect ,
QInput
QInput ,
QIcon
} ,
validations : {
form : {
destination : {
required ,
maxLength : maxLength ( 64 )
} ,
data : {
required : requiredUnless ( function ( ) {
return this . hasContentToSend ;
} ) ,
maxLength : maxLength ( 3600 )
} ,
file : {
required : requiredUnless ( function ( ) {
return this . hasContentToSend ;
} )
} ,
pageHeader : {
maxLength : maxLength ( 64 )
}
}
} ,
computed : {
hasContentToSend ( ) {
return ( ! ! this . form . data || ! ! this . form . file ) || ! this . $v . form . $anyDirty ;
} ,
formDisabled ( ) {
return ! ( this . form . destination &&
this . form . data && this . form . quality ) ? true : false ;
return ! this . $v . form . $anyDirty ||
this . $v . form . destination . $error ||
this . $v . form . pageHeader . $error ||
! this . hasContentToSend ;
} ,
destinationErrorMessage ( ) {
if ( ! this . $v . form . destination . required ) {
return this . $t ( 'validationErrors.fieldRequired' , {
field : this . $t ( 'communication.label.destination' )
} ) ;
}
else if ( ! this . $v . form . destination . maxLength ) {
return this . $t ( 'validationErrors.maxLength' , {
field : this . $t ( 'communication.label.destination' ) ,
maxLength : this . $v . form . destination . $params . maxLength . max
} ) ;
}
} ,
pageHeaderErrorMessage ( ) {
return this . $t ( 'validationErrors.maxLength' , {
field : this . $t ( 'communication.label.pageHeader' ) ,
maxLength : this . $v . form . pageHeader . $params . maxLength . max
} ) ;
} ,
dataErrorMessage ( ) {
if ( ! this . $v . form . data . required ) {
return this . $t ( 'validationErrors.fieldRequiredXor' , {
fieldOne : this . $t ( 'communication.label.content' ) ,
fieldTwo : this . $t ( 'communication.label.file' )
} ) ;
}
else if ( ! this . $v . form . data . maxLength ) {
return this . $t ( 'validationErrors.maxLength' , {
field : this . $t ( 'communication.label.content' ) ,
maxLength : this . $v . form . data . $params . maxLength . max
} ) ;
}
} ,
fileErrorMessage ( ) {
return this . $t ( 'validationErrors.fieldRequiredXor' , {
fieldOne : this . $t ( 'communication.label.file' ) ,
fieldTwo : this . $t ( 'communication.label.content' )
} ) ;
}
} ,
methods : {
resetFile ( ) {
this . form . file = null ;
this . selectedFile = '' ;
} ,
processFile ( event ) {
let file = event . target . files [ 0 ] ;
let fileName = file ? file . name : '' ;
let fileNameSplit = fileName . split ( '.' ) ;
let extension = fileNameSplit [ 1 ] ? fileNameSplit [ 1 ] : null ;
if ( fileName . length > 22 && extension ) {
fileName = ` ${ fileName . substring ( 0 , 14 ) } ... ${ extension } ` ;
}
else if ( fileName . length > 22 && ! extension ) {
fileName = ` ${ fileName . substring ( 0 , 17 ) } ... ` ;
}
this . form . file = file ;
this . selectedFile = fileName ;
} ,
sendFax ( ) {
this . $store . dispatch ( 'communication/createFax' , this . form ) ;
} ,
showModal ( ) {
this . form = {
destination : null ,
pageheader : null ,
page H eader: null ,
data : null ,
quality : 'normal'
quality : 'normal' ,
file : null
} ;
this . selectedFile = '' ;
this . showFaxModal = true ;
this . $v . $reset ( ) ;
} ,
hideModal ( ) {
this . showFaxModal = false ;
@ -112,4 +284,34 @@
line - height $csc - subtitle - line - height
font - size $csc - subtitle - font - size
font - weight $csc - subtitle - font - weight
. upload - field
margin - bottom 10 px
. upload - label
display block
color $csc - label
font - size 16 px
margin - bottom 5 px
. upload - button
color black
. reset - button
padding 0
. q - icon
margin 0
. upload - filename
color black
# file - upload
display none
# csc - error - label
font - size 12 px
color $negative
margin - 15 px 0 10 px 0
< / style >