hedera-web/forms/cms/contact/index.js

40 lines
731 B
JavaScript
Raw Normal View History

2022-11-16 01:44:39 +00:00
import './style.scss';
2016-07-22 20:00:27 +00:00
2022-11-16 01:44:39 +00:00
export default new Class({
Extends: Hedera.Form,
Template: require('./ui.xml')
2016-07-22 20:00:27 +00:00
2022-11-16 01:46:44 +00:00
,activate() {
2022-11-28 08:51:31 +00:00
this.$.contactForm.onsubmit = () => {
this._onSubmit(); return false;
2022-10-04 13:12:16 +00:00
};
this.refreshCaptcha();
2016-07-22 20:00:27 +00:00
}
2022-11-16 01:46:44 +00:00
,refreshCaptcha() {
params = {
2022-10-04 13:12:16 +00:00
srv: 'rest:misc/captcha',
stamp: new Date().getTime()
};
2022-10-04 13:12:16 +00:00
this.$.captchaImg.src = '?'+ Vn.Url.makeUri(params);
2016-07-22 20:00:27 +00:00
}
2022-11-28 08:51:31 +00:00
,async _onSubmit() {
const form = this.$.contactForm;
try {
await this.conn.sendForm(this.$.contactForm);
} catch (err) {
2022-10-04 13:12:16 +00:00
Htk.Toast.showError(_('ErrorSendingData'));
2022-11-28 08:51:31 +00:00
return;
} finally {
form['captcha'].value = '';
this.refreshCaptcha();
}
2016-07-22 20:00:27 +00:00
2022-11-28 08:51:31 +00:00
form.reset();
Htk.Toast.showMessage(_('DataSentSuccess'));
2016-07-22 20:00:27 +00:00
}
});