szurubooru/client/js/views/user_delete_view.js

32 lines
734 B
JavaScript
Raw Normal View History

2016-04-09 09:52:00 +02:00
'use strict';
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() {
this._template = views.getTemplate('user-delete');
2016-04-09 09:52:00 +02:00
}
render(ctx) {
const target = ctx.target;
const source = this._template(ctx);
2016-04-09 09:52:00 +02:00
const form = source.querySelector('form');
views.decorateValidator(form);
2016-04-09 09:52:00 +02:00
form.addEventListener('submit', e => {
e.preventDefault();
views.clearMessages(target);
views.disableForm(form);
ctx.delete()
.catch(() => { views.enableForm(form); });
2016-04-09 09:52:00 +02:00
});
views.listenToMessages(source);
views.showView(target, source);
2016-04-09 09:52:00 +02:00
}
}
2016-05-11 12:17:40 +02:00
module.exports = UserDeleteView;