unclean SPARC
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
class TemplatesMailTestDialog extends EICDialogContent {
|
||||
|
||||
actions = [
|
||||
{
|
||||
label: 'Cancel',
|
||||
onclick: this.cancel.bind(this),
|
||||
severity: 'secondary',
|
||||
role: 'cancel'
|
||||
},
|
||||
{
|
||||
label: 'Send test',
|
||||
onclick: this.add.bind(this),
|
||||
severity: 'primary',
|
||||
role: 'add',
|
||||
disabled: true
|
||||
}
|
||||
]
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
Object.assign(this, app.helpers.validators)
|
||||
}
|
||||
|
||||
DOMContentLoaded() {
|
||||
this.form = new Form(this.find('.test-mail-dialog'))
|
||||
this.mailInput = this.find('.mail-address')
|
||||
this.mailInput.addEventListener('keyup', this.checkEmail.bind(this))
|
||||
|
||||
// Use user email by default
|
||||
this.mailInput.value = app.User.identity.email || ''
|
||||
|
||||
// force validation on init
|
||||
setTimeout(() => this.checkEmail(), 0)
|
||||
}
|
||||
|
||||
checkEmail(event = null){
|
||||
if(event){
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
}
|
||||
|
||||
const addAction = this.actions.find(o => o.role === 'add')
|
||||
if (!addAction || !addAction.button) {
|
||||
return
|
||||
}
|
||||
|
||||
const isValid = this.validators.isValidEmail(this.mailInput.value)
|
||||
addAction.button.disabled = !isValid
|
||||
}
|
||||
|
||||
add() {
|
||||
if(!this.validators.isValidEmail(this.mailInput.value)) return
|
||||
let data = { email: this.mailInput.value }
|
||||
this.commit(data)
|
||||
}
|
||||
|
||||
onFailed() {
|
||||
this.abort()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
app.registerClass('TemplatesMailTestDialog', TemplatesMailTestDialog)
|
||||
Reference in New Issue
Block a user