2016-04-09 09:52:00 +02:00
|
|
|
'use strict';
|
|
|
|
|
2016-04-09 18:54:23 +02:00
|
|
|
const views = require('../util/views.js');
|
2016-04-09 09:52:00 +02:00
|
|
|
|
2016-05-11 12:17:40 +02:00
|
|
|
class UserDeleteView {
|
2016-04-09 09:52:00 +02:00
|
|
|
constructor() {
|
2016-05-20 21:35:12 +02:00
|
|
|
this._template = views.getTemplate('user-delete');
|
2016-04-09 09:52:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render(ctx) {
|
|
|
|
const target = ctx.target;
|
2016-05-20 21:35:12 +02:00
|
|
|
const source = this._template(ctx);
|
2016-04-09 09:52:00 +02:00
|
|
|
|
|
|
|
const form = source.querySelector('form');
|
|
|
|
|
2016-04-09 18:54:23 +02:00
|
|
|
views.decorateValidator(form);
|
2016-04-09 09:52:00 +02:00
|
|
|
|
|
|
|
form.addEventListener('submit', e => {
|
|
|
|
e.preventDefault();
|
2016-04-09 18:54:23 +02:00
|
|
|
views.clearMessages(target);
|
|
|
|
views.disableForm(form);
|
2016-05-11 21:29:57 +02:00
|
|
|
ctx.delete()
|
|
|
|
.catch(() => { views.enableForm(form); });
|
2016-04-09 09:52:00 +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-09 09:52:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-11 12:17:40 +02:00
|
|
|
module.exports = UserDeleteView;
|