client/users: add exit confirmation for edit form
This commit is contained in:
parent
ea947ed91e
commit
fec31d7946
3 changed files with 15 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
const router = require('../router.js');
|
const router = require('../router.js');
|
||||||
const api = require('../api.js');
|
const api = require('../api.js');
|
||||||
|
const misc = require('../util/misc.js');
|
||||||
const config = require('../config.js');
|
const config = require('../config.js');
|
||||||
const views = require('../util/views.js');
|
const views = require('../util/views.js');
|
||||||
const User = require('../models/user.js');
|
const User = require('../models/user.js');
|
||||||
|
@ -51,6 +52,7 @@ class UserController {
|
||||||
canDelete: api.hasPrivilege(`users:delete:${infix}`),
|
canDelete: api.hasPrivilege(`users:delete:${infix}`),
|
||||||
ranks: ranks,
|
ranks: ranks,
|
||||||
});
|
});
|
||||||
|
this._view.addEventListener('change', e => this._evtChange(e));
|
||||||
this._view.addEventListener('submit', e => this._evtUpdate(e));
|
this._view.addEventListener('submit', e => this._evtUpdate(e));
|
||||||
this._view.addEventListener('delete', e => this._evtDelete(e));
|
this._view.addEventListener('delete', e => this._evtDelete(e));
|
||||||
}, errorMessage => {
|
}, errorMessage => {
|
||||||
|
@ -59,7 +61,12 @@ class UserController {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_evtChange(e) {
|
||||||
|
misc.enableExitConfirmation();
|
||||||
|
}
|
||||||
|
|
||||||
_evtSaved(e) {
|
_evtSaved(e) {
|
||||||
|
misc.disableExitConfirmation();
|
||||||
if (this._name !== e.detail.user.name) {
|
if (this._name !== e.detail.user.name) {
|
||||||
router.replace(
|
router.replace(
|
||||||
'/user/' + e.detail.user.name + '/edit', null, false);
|
'/user/' + e.detail.user.name + '/edit', null, false);
|
||||||
|
|
|
@ -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));
|
this._formNode.addEventListener('submit', e => this._evtSubmit(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ class UserView extends events.EventTarget {
|
||||||
this._view = new UserSummaryView(ctx);
|
this._view = new UserSummaryView(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
events.proxyEvent(this._view, this, 'change');
|
||||||
views.syncScrollPosition();
|
views.syncScrollPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue