diff --git a/core/client/controllers/modals/delete-tag.js b/core/client/controllers/modals/delete-tag.js index 60b4fb8648..b0977c0352 100644 --- a/core/client/controllers/modals/delete-tag.js +++ b/core/client/controllers/modals/delete-tag.js @@ -1,4 +1,8 @@ var DeleteTagController = Ember.Controller.extend({ + inflection: function () { + return this.get('model').get('post_count') > 1 ? 'posts' : 'post'; + }.property('model'), + actions: { confirmAccept: function () { var tag = this.get('model'), diff --git a/core/client/models/tag.js b/core/client/models/tag.js index 1163e8c9e0..41203459bb 100644 --- a/core/client/models/tag.js +++ b/core/client/models/tag.js @@ -16,7 +16,8 @@ var Tag = DS.Model.extend(NProgressSaveMixin, ValidationEngine, { created_at: DS.attr('moment-date'), updated_at: DS.attr('moment-date'), created_by: DS.attr(), - updated_by: DS.attr() + updated_by: DS.attr(), + post_count: DS.attr('number') }); export default Tag; diff --git a/core/client/routes/settings/tags.js b/core/client/routes/settings/tags.js index 3bc3470585..927fc80a25 100644 --- a/core/client/routes/settings/tags.js +++ b/core/client/routes/settings/tags.js @@ -22,7 +22,7 @@ var TagsRoute = AuthenticatedRoute.extend(CurrentUserSettings, PaginationRouteMi }, model: function () { - return this.store.find('tag'); + return this.store.find('tag', {include: 'post_count'}); }, setupController: function (controller, model) { diff --git a/core/client/serializers/tag.js b/core/client/serializers/tag.js new file mode 100644 index 0000000000..60792e81c4 --- /dev/null +++ b/core/client/serializers/tag.js @@ -0,0 +1,21 @@ +import ApplicationSerializer from 'ghost/serializers/application'; + +var TagSerializer = ApplicationSerializer.extend(DS.EmbeddedRecordsMixin, { + + serializeIntoHash: function (hash, type, record, options) { + options = options || {}; + + // We have a plural root in the API + var root = Ember.String.pluralize(type.typeKey), + data = this.serialize(record, options); + + // Properties that exist on the model but we don't want sent in the payload + + delete data.post_count; + delete data.uuid; + + hash[root] = [data]; + } +}); + +export default TagSerializer; diff --git a/core/client/templates/modals/delete-tag.hbs b/core/client/templates/modals/delete-tag.hbs index 240cb0516c..467ace9a29 100644 --- a/core/client/templates/modals/delete-tag.hbs +++ b/core/client/templates/modals/delete-tag.hbs @@ -1,6 +1,10 @@ {{#gh-modal-dialog action="closeModal" showClose=true type="action" style="wide,centered" animation="fade" title="Are you sure you want to delete this tag?" confirm=confirm}} -
You're about to delete "{{model.name}}".
This is permanent! No backups, no restores, no magic undo button.
We warned you, ok?
You're about to delete "{{model.name}}".
+ {{#if model.post_count}}
+ This tag will be removed from {{model.post_count}} {{inflection}}.
+ {{/if}}
+ This is permanent! No backups, no restores, no magic undo button.
We warned you, ok?
{{tag.description}}
- + {{/each}}