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:
parent
49e4bf3b77
commit
52c5202885
6 changed files with 34 additions and 4 deletions
|
@ -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'),
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
21
ghost/admin/serializers/tag.js
Normal file
21
ghost/admin/serializers/tag.js
Normal 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;
|
|
@ -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}}
|
|
@ -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}}
|
||||
|
|
Loading…
Add table
Reference in a new issue