client/tags: add exit confirmation for edit form
This commit is contained in:
parent
d8d4654849
commit
ea947ed91e
|
@ -2,6 +2,7 @@
|
|||
|
||||
const router = require('../router.js');
|
||||
const api = require('../api.js');
|
||||
const misc = require('../util/misc.js');
|
||||
const tags = require('../tags.js');
|
||||
const Tag = require('../models/tag.js');
|
||||
const topNavigation = require('../models/top_navigation.js');
|
||||
|
@ -36,6 +37,7 @@ class TagController {
|
|||
categories: categories,
|
||||
});
|
||||
|
||||
this._view.addEventListener('change', e => this._evtChange(e));
|
||||
this._view.addEventListener('submit', e => this._evtUpdate(e));
|
||||
this._view.addEventListener('merge', e => this._evtMerge(e));
|
||||
this._view.addEventListener('delete', e => this._evtDelete(e));
|
||||
|
@ -45,7 +47,12 @@ class TagController {
|
|||
});
|
||||
}
|
||||
|
||||
_evtChange(e) {
|
||||
misc.enableExitConfirmation();
|
||||
}
|
||||
|
||||
_evtSaved(e) {
|
||||
misc.disableExitConfirmation();
|
||||
if (this._name !== e.detail.tag.names[0]) {
|
||||
router.replace('/tag/' + e.detail.tag.names[0], null, false);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,14 @@ class TagEditView extends events.EventTarget {
|
|||
new TagInputControl(this._suggestionsFieldNode);
|
||||
}
|
||||
|
||||
for (let node of this._formNode.querySelectorAll(
|
||||
'input, select, textarea')) {
|
||||
node.addEventListener(
|
||||
'change', e => {
|
||||
this.dispatchEvent(new CustomEvent('change'));
|
||||
});
|
||||
}
|
||||
|
||||
this._formNode.addEventListener('submit', e => this._evtSubmit(e));
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ class TagView extends events.EventTarget {
|
|||
this._view = new TagSummaryView(ctx);
|
||||
}
|
||||
|
||||
events.proxyEvent(this._view, this, 'change');
|
||||
views.syncScrollPosition();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue