client/tags: add exit confirmation for edit form

This commit is contained in:
rr- 2016-08-22 21:35:20 +02:00
parent d8d4654849
commit ea947ed91e
3 changed files with 16 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 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);
}

View file

@ -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));
}

View file

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