client/users: add exit confirmation for edit form

This commit is contained in:
rr- 2016-08-22 21:38:21 +02:00
parent ea947ed91e
commit fec31d7946
3 changed files with 15 additions and 0 deletions

View file

@ -2,6 +2,7 @@
const router = require('../router.js');
const api = require('../api.js');
const misc = require('../util/misc.js');
const config = require('../config.js');
const views = require('../util/views.js');
const User = require('../models/user.js');
@ -51,6 +52,7 @@ class UserController {
canDelete: api.hasPrivilege(`users:delete:${infix}`),
ranks: ranks,
});
this._view.addEventListener('change', e => this._evtChange(e));
this._view.addEventListener('submit', e => this._evtUpdate(e));
this._view.addEventListener('delete', e => this._evtDelete(e));
}, errorMessage => {
@ -59,7 +61,12 @@ class UserController {
});
}
_evtChange(e) {
misc.enableExitConfirmation();
}
_evtSaved(e) {
misc.disableExitConfirmation();
if (this._name !== e.detail.user.name) {
router.replace(
'/user/' + e.detail.user.name + '/edit', null, false);

View file

@ -30,6 +30,13 @@ class UserEditView extends events.EventTarget {
});
}
for (let node of this._formNode.querySelectorAll('input, select')) {
node.addEventListener(
'change', e => {
this.dispatchEvent(new CustomEvent('change'));
});
}
this._formNode.addEventListener('submit', e => this._evtSubmit(e));
}

View file

@ -48,6 +48,7 @@ class UserView extends events.EventTarget {
this._view = new UserSummaryView(ctx);
}
events.proxyEvent(this._view, this, 'change');
views.syncScrollPosition();
}