forked from verdnatura/hedera-web
40 lines
731 B
JavaScript
40 lines
731 B
JavaScript
import './style.scss';
|
|
|
|
export default new Class({
|
|
Extends: Hedera.Form,
|
|
Template: require('./ui.xml')
|
|
|
|
,activate() {
|
|
this.$.contactForm.onsubmit = () => {
|
|
this._onSubmit(); return false;
|
|
};
|
|
this.refreshCaptcha();
|
|
}
|
|
|
|
,refreshCaptcha() {
|
|
params = {
|
|
srv: 'rest:misc/captcha',
|
|
stamp: new Date().getTime()
|
|
};
|
|
this.$.captchaImg.src = '?'+ Vn.Url.makeUri(params);
|
|
}
|
|
|
|
,async _onSubmit() {
|
|
const form = this.$.contactForm;
|
|
|
|
try {
|
|
await this.conn.sendForm(this.$.contactForm);
|
|
} catch (err) {
|
|
Htk.Toast.showError(_('ErrorSendingData'));
|
|
return;
|
|
} finally {
|
|
form['captcha'].value = '';
|
|
this.refreshCaptcha();
|
|
}
|
|
|
|
form.reset();
|
|
Htk.Toast.showMessage(_('DataSentSuccess'));
|
|
}
|
|
});
|
|
|