69fe8ec31a
- Move controls to the "controls/" directory - Make controls interface look similar to each other - Prefix "private" methods and attributes with underscore
31 lines
734 B
JavaScript
31 lines
734 B
JavaScript
'use strict';
|
|
|
|
const views = require('../util/views.js');
|
|
|
|
class UserDeleteView {
|
|
constructor() {
|
|
this._template = views.getTemplate('user-delete');
|
|
}
|
|
|
|
render(ctx) {
|
|
const target = ctx.target;
|
|
const source = this._template(ctx);
|
|
|
|
const form = source.querySelector('form');
|
|
|
|
views.decorateValidator(form);
|
|
|
|
form.addEventListener('submit', e => {
|
|
e.preventDefault();
|
|
views.clearMessages(target);
|
|
views.disableForm(form);
|
|
ctx.delete()
|
|
.catch(() => { views.enableForm(form); });
|
|
});
|
|
|
|
views.listenToMessages(source);
|
|
views.showView(target, source);
|
|
}
|
|
}
|
|
|
|
module.exports = UserDeleteView;
|