diff --git a/ghost/admin/app/controllers/tag.js b/ghost/admin/app/controllers/tag.js
index fddc15253f..03af43dfeb 100644
--- a/ghost/admin/app/controllers/tag.js
+++ b/ghost/admin/app/controllers/tag.js
@@ -126,24 +126,10 @@ export default Controller.extend({
}),
_deleteTag() {
- let tag = this.tag;
-
- return tag.destroyRecord().then(() => {
- this._deleteTagSuccess();
+ return this.tag.destroyRecord().then(() => {
+ return this.transitionToRoute('tags');
}, (error) => {
- this._deleteTagFailure(error);
+ return this.notifications.showAPIError(error, {key: 'tag.delete'});
});
- },
-
- _deleteTagSuccess() {
- let currentRoute = this.router.currentRouteName || '';
-
- if (currentRoute.match(/^tags/)) {
- this.transitionToRoute('tags');
- }
- },
-
- _deleteTagFailure(error) {
- this.notifications.showAPIError(error, {key: 'tag.delete'});
}
});
diff --git a/ghost/admin/app/routes/tag.js b/ghost/admin/app/routes/tag.js
index ee958e84ce..dba03dc7b4 100644
--- a/ghost/admin/app/routes/tag.js
+++ b/ghost/admin/app/routes/tag.js
@@ -38,15 +38,15 @@ export default AuthenticatedRoute.extend(CurrentUserSettings, {
},
showUnsavedChangesModal(transition) {
- if (transition.from && transition.from.name.match(/^tag$|^tag\.new$/) && transition.targetName) {
+ if (transition.from && transition.from.name === this.routeName && transition.targetName) {
let {controller} = this;
- if (!controller.tag.isDeleted && controller.tag.hasDirtyAttributes) {
+ // tag.changedAttributes is always true for new tags but number of changed attrs is reliable
+ if (!controller.tag.isDeleted && Object.keys(controller.tag.changedAttributes()).length > 0) {
transition.abort();
controller.send('toggleUnsavedChangesModal', transition);
return;
}
}
}
-
});
diff --git a/ghost/admin/app/templates/tag.hbs b/ghost/admin/app/templates/tag.hbs
index 1a63c6d346..8e21a17b95 100644
--- a/ghost/admin/app/templates/tag.hbs
+++ b/ghost/admin/app/templates/tag.hbs
@@ -14,9 +14,12 @@
setProperty=(action "setProperty")
showDeleteTagModal=(action "toggleDeleteTagModal")}}
-
+
+ {{#unless this.tag.isNew}}
+
+ {{/unless}}
{{#if showUnsavedChangesModal}}