szurubooru/client/js/views/user_delete_view.js
rr- 69fe8ec31a client/general: refactor all the things
- Move controls to the "controls/" directory
- Make controls interface look similar to each other
- Prefix "private" methods and attributes with underscore
2016-05-21 00:08:43 +02:00

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;