diff --git a/client/js/controllers/tag_controller.js b/client/js/controllers/tag_controller.js index 9eeff35..9071593 100644 --- a/client/js/controllers/tag_controller.js +++ b/client/js/controllers/tag_controller.js @@ -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); } diff --git a/client/js/views/tag_edit_view.js b/client/js/views/tag_edit_view.js index 515b4ad..600cebc 100644 --- a/client/js/views/tag_edit_view.js +++ b/client/js/views/tag_edit_view.js @@ -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)); } diff --git a/client/js/views/tag_view.js b/client/js/views/tag_view.js index 26f0491..4421db1 100644 --- a/client/js/views/tag_view.js +++ b/client/js/views/tag_view.js @@ -53,6 +53,7 @@ class TagView extends events.EventTarget { this._view = new TagSummaryView(ctx); } + events.proxyEvent(this._view, this, 'change'); views.syncScrollPosition(); }