diff --git a/core/client/controllers/settings/tags.js b/core/client/controllers/settings/tags.js new file mode 100644 index 00000000000..210453c6c68 --- /dev/null +++ b/core/client/controllers/settings/tags.js @@ -0,0 +1,50 @@ +import PaginationMixin from 'ghost/mixins/pagination-controller'; + +var TagsController = Ember.ArrayController.extend(PaginationMixin, { + tags: Ember.computed.alias('model'), + activeTag: null, + init: function (options) { + options = options || {}; + options.modelType = 'tag'; + this._super(options); + }, + actions: { + // Clear any unsaved changes until autosave is implemented + closeTagEditor: function () { + this.get('activeTag').rollback(); + this.send('closeSettingsMenu'); + }, + newTag: function () { + this.set('activeTag', this.store.createRecord('tag')); + this.send('openSettingsMenu'); + }, + editTag: function (tag) { + this.set('activeTag', tag); + this.send('openSettingsMenu'); + }, + deleteTag: function (tag) { + var name = tag.get('name'), + self = this; + + this.send('closeSettingsMenu'); + + tag.destroyRecord().then(function () { + self.notifications.showSuccess('Deleted ' + name); + }).catch(function (error) { + self.notifications.showAPIError(error); + }); + }, + saveTag: function (tag) { + var name = tag.get('name'), + self = this; + + tag.save().then(function () { + self.notifications.showSuccess('Saved ' + name); + }).catch(function (error) { + self.notifications.showAPIError(error); + }); + } + } +}); + +export default TagsController; diff --git a/core/client/mixins/pagination-controller.js b/core/client/mixins/pagination-controller.js index 40c812e10d4..b4f910cb2ea 100644 --- a/core/client/mixins/pagination-controller.js +++ b/core/client/mixins/pagination-controller.js @@ -17,7 +17,7 @@ var PaginationControllerMixin = Ember.Mixin.create({ * } */ init: function (options) { - this._super(); + this._super(options); var metadata = this.store.metadataFor(options.modelType); diff --git a/core/client/routes/application.js b/core/client/routes/application.js index fd1ec7203a9..c6b8c353a98 100644 --- a/core/client/routes/application.js +++ b/core/client/routes/application.js @@ -31,12 +31,15 @@ var ApplicationRoute = Ember.Route.extend(SimpleAuth.ApplicationRouteMixin, Shor this.toggleProperty('controller.showGlobalMobileNav'); }, - toggleSettingsMenu: function () { - this.toggleProperty('controller.showSettingsMenu'); + openSettingsMenu: function () { + this.set('controller.showSettingsMenu', true); }, closeSettingsMenu: function () { this.set('controller.showSettingsMenu', false); }, + toggleSettingsMenu: function () { + this.toggleProperty('controller.showSettingsMenu'); + }, closePopups: function () { this.get('dropdown').closeDropdowns(); diff --git a/core/client/routes/settings/tags.js b/core/client/routes/settings/tags.js index 17e6dc5fa60..b59aa2bdefc 100644 --- a/core/client/routes/settings/tags.js +++ b/core/client/routes/settings/tags.js @@ -1,7 +1,8 @@ import AuthenticatedRoute from 'ghost/routes/authenticated'; import CurrentUserSettings from 'ghost/mixins/current-user-settings'; +import PaginationRouteMixin from 'ghost/mixins/pagination-route'; -var TagsRoute = AuthenticatedRoute.extend(CurrentUserSettings, { +var TagsRoute = AuthenticatedRoute.extend(CurrentUserSettings, PaginationRouteMixin, { beforeModel: function () { if (!this.get('config.tagsUI')) { @@ -14,6 +15,20 @@ var TagsRoute = AuthenticatedRoute.extend(CurrentUserSettings, { model: function () { return this.store.find('tag'); + }, + + setupController: function (controller, model) { + this._super(controller, model); + this.setupPagination(); + }, + + renderTemplate: function (controller, model) { + this._super(controller, model); + this.render('settings/tags/settings-menu', { + into: 'application', + outlet: 'settings-menu', + view: 'settings/tags/settings-menu' + }); } }); diff --git a/core/client/templates/-publish-bar.hbs b/core/client/templates/-publish-bar.hbs index 79a0407a92d..10c6ce02092 100644 --- a/core/client/templates/-publish-bar.hbs +++ b/core/client/templates/-publish-bar.hbs @@ -3,7 +3,7 @@ {{render 'post-tags-input'}}
diff --git a/core/client/templates/settings/tags.hbs b/core/client/templates/settings/tags.hbs index 1d9e1790749..1161e4896a2 100644 --- a/core/client/templates/settings/tags.hbs +++ b/core/client/templates/settings/tags.hbs @@ -2,84 +2,17 @@ Back