Skip to content

Commit

Permalink
Merge pull request #4689 from ekulabuhov/4683_TagPostCountUI
Browse files Browse the repository at this point in the history
Updated tag management UI with the post counts
  • Loading branch information
jaswilli committed Dec 22, 2014
2 parents a4bcc02 + f1da5f8 commit 15ebc5d
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 4 deletions.
4 changes: 4 additions & 0 deletions core/client/controllers/modals/delete-tag.js
Original file line number Diff line number Diff line change
@@ -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'),
Expand Down
3 changes: 2 additions & 1 deletion core/client/models/tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion core/client/routes/settings/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
21 changes: 21 additions & 0 deletions core/client/serializers/tag.js
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 5 additions & 1 deletion core/client/templates/modals/delete-tag.hbs
Original file line number Diff line number Diff line change
@@ -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}}

<p>You're about to delete "<strong>{{model.name}}</strong>".<br />This is permanent! No backups, no restores, no magic undo button. <br /> We warned you, ok?</p>
<p>You're about to delete "<strong>{{model.name}}</strong>".<br />
{{#if model.post_count}}
<span class="red">This tag will be removed from {{model.post_count}} {{inflection}}.</span>
{{/if}}
This is permanent! No backups, no restores, no magic undo button. <br /> We warned you, ok?</p>

{{/gh-modal-dialog}}
2 changes: 1 addition & 1 deletion core/client/templates/settings/tags.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<span class="tag-title">{{tag.name}}</span>
<span class="label label-default">/{{tag.slug}}</span>
<p class="tag-description">{{tag.description}}</p>
<span class="tags-count">N/A</span>
<span class="tags-count">{{tag.post_count}}</span>
</button>
</div>
{{/each}}
Expand Down

0 comments on commit 15ebc5d

Please sign in to comment.