0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Updated tag management UI with the post counts

closes #4683
- added post count to 'delete tag' modal
- fixed lint errors
- preventing extra data to be sent to server
- adjustments suggested by @jaswilli
This commit is contained in:
Eugene Kulabuhov 2014-12-19 00:44:37 +00:00
parent 49e4bf3b77
commit 52c5202885
6 changed files with 34 additions and 4 deletions

View file

@ -1,4 +1,8 @@
var DeleteTagController = Ember.Controller.extend({ var DeleteTagController = Ember.Controller.extend({
inflection: function () {
return this.get('model').get('post_count') > 1 ? 'posts' : 'post';
}.property('model'),
actions: { actions: {
confirmAccept: function () { confirmAccept: function () {
var tag = this.get('model'), var tag = this.get('model'),

View file

@ -16,7 +16,8 @@ var Tag = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
created_at: DS.attr('moment-date'), created_at: DS.attr('moment-date'),
updated_at: DS.attr('moment-date'), updated_at: DS.attr('moment-date'),
created_by: DS.attr(), created_by: DS.attr(),
updated_by: DS.attr() updated_by: DS.attr(),
post_count: DS.attr('number')
}); });
export default Tag; export default Tag;

View file

@ -22,7 +22,7 @@ var TagsRoute = AuthenticatedRoute.extend(CurrentUserSettings, PaginationRouteMi
}, },
model: function () { model: function () {
return this.store.find('tag'); return this.store.find('tag', {include: 'post_count'});
}, },
setupController: function (controller, model) { setupController: function (controller, model) {

View file

@ -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;

View file

@ -1,6 +1,10 @@
{{#gh-modal-dialog action="closeModal" showClose=true type="action" style="wide,centered" animation="fade" {{#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}} 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}} {{/gh-modal-dialog}}

View file

@ -13,7 +13,7 @@
<span class="tag-title">{{tag.name}}</span> <span class="tag-title">{{tag.name}}</span>
<span class="label label-default">/{{tag.slug}}</span> <span class="label label-default">/{{tag.slug}}</span>
<p class="tag-description">{{tag.description}}</p> <p class="tag-description">{{tag.description}}</p>
<span class="tags-count">N/A</span> <span class="tags-count">{{tag.post_count}}</span>
</button> </button>
</div> </div>
{{/each}} {{/each}}