szurubooru/client/js/views/user_delete_view.js

56 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-04-09 09:52:00 +02:00
'use strict';
const events = require('../events.js');
const views = require('../util/views.js');
2016-04-09 09:52:00 +02:00
const template = views.getTemplate('user-delete');
class UserDeleteView extends events.EventTarget {
constructor(ctx) {
super();
this._user = ctx.user;
this._hostNode = ctx.hostNode;
views.replaceContent(this._hostNode, template(ctx));
views.decorateValidator(this._formNode);
this._formNode.addEventListener('submit', e => this._evtSubmit(e));
}
clearMessages() {
views.clearMessages(this._hostNode);
}
showSuccess(message) {
views.showSuccess(this._hostNode, message);
}
showError(message) {
views.showError(this._hostNode, message);
2016-04-09 09:52:00 +02:00
}
enableForm() {
views.enableForm(this._formNode);
}
2016-04-09 09:52:00 +02:00
disableForm() {
views.disableForm(this._formNode);
}
2016-04-09 09:52:00 +02:00
_evtSubmit(e) {
e.preventDefault();
this.dispatchEvent(new CustomEvent('submit', {
detail: {
user: this._user,
},
}));
}
2016-04-09 09:52:00 +02:00
get _formNode() {
return this._hostNode.querySelector('form');
2016-04-09 09:52:00 +02:00
}
}
2016-05-11 12:17:40 +02:00
module.exports = UserDeleteView;