2016-04-06 17:56:34 +02:00
|
|
|
'use strict';
|
|
|
|
|
2016-04-09 18:54:23 +02:00
|
|
|
const views = require('../util/views.js');
|
2016-04-06 17:56:34 +02:00
|
|
|
|
2016-04-09 18:54:23 +02:00
|
|
|
class PasswordResetView {
|
2016-04-06 17:56:34 +02:00
|
|
|
constructor() {
|
2016-04-09 18:54:23 +02:00
|
|
|
this.template = views.getTemplate('password-reset');
|
2016-04-06 17:56:34 +02:00
|
|
|
}
|
|
|
|
|
2016-04-08 10:35:38 +02:00
|
|
|
render(ctx) {
|
2016-04-09 18:54:23 +02:00
|
|
|
const target = document.getElementById('content-holder');
|
2016-04-08 10:35:38 +02:00
|
|
|
const source = this.template();
|
|
|
|
|
|
|
|
const form = source.querySelector('form');
|
|
|
|
const userNameOrEmailField = source.querySelector('#user-name');
|
2016-04-06 17:56:34 +02:00
|
|
|
|
2016-04-09 18:54:23 +02:00
|
|
|
views.decorateValidator(form);
|
2016-04-06 17:56:34 +02:00
|
|
|
|
|
|
|
form.addEventListener('submit', e => {
|
|
|
|
e.preventDefault();
|
2016-04-09 18:54:23 +02:00
|
|
|
views.clearMessages(target);
|
|
|
|
views.disableForm(form);
|
2016-04-08 10:35:38 +02:00
|
|
|
ctx.proceed(userNameOrEmailField.value)
|
2016-04-09 18:54:23 +02:00
|
|
|
.catch(() => { views.enableForm(form); });
|
2016-04-06 17:56:34 +02:00
|
|
|
});
|
2016-04-08 10:35:38 +02:00
|
|
|
|
2016-05-11 21:29:57 +02:00
|
|
|
views.listenToMessages(source);
|
2016-04-09 18:54:23 +02:00
|
|
|
views.showView(target, source);
|
2016-04-06 17:56:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = PasswordResetView;
|