mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
Update client for tag.post_count -> tag.count.posts rename
refs #6105 - adds `raw` ember-data transform to handle standard JSON `count` attribute - update mirage factory to return correct `count.posts` format - rename all uses of `post_count` to `count.posts`
This commit is contained in:
parent
933d6cd677
commit
c151be05de
@ -1,16 +1,18 @@
|
|||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
|
|
||||||
export default Ember.Controller.extend({
|
const {Controller, computed, inject} = Ember;
|
||||||
notifications: Ember.inject.service(),
|
|
||||||
application: Ember.inject.controller(),
|
|
||||||
|
|
||||||
postInflection: Ember.computed('model.post_count', function () {
|
export default Controller.extend({
|
||||||
return this.get('model.post_count') > 1 ? 'posts' : 'post';
|
application: inject.controller(),
|
||||||
|
notifications: inject.service(),
|
||||||
|
|
||||||
|
postInflection: computed('model.count.posts', function () {
|
||||||
|
return this.get('model.count.posts') > 1 ? 'posts' : 'post';
|
||||||
}),
|
}),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
confirmAccept: function () {
|
confirmAccept: function () {
|
||||||
var tag = this.get('model');
|
let tag = this.get('model');
|
||||||
|
|
||||||
this.send('closeMenus');
|
this.send('closeMenus');
|
||||||
|
|
||||||
|
@ -11,9 +11,13 @@ export default Mirage.Factory.extend({
|
|||||||
meta_title(i) { return `Meta Title for tag ${i}`; },
|
meta_title(i) { return `Meta Title for tag ${i}`; },
|
||||||
name(i) { return `Tag ${i}`; },
|
name(i) { return `Tag ${i}`; },
|
||||||
parent() { return null; },
|
parent() { return null; },
|
||||||
post_count() { return 1; },
|
|
||||||
slug(i) { return `tag-${i}`; },
|
slug(i) { return `tag-${i}`; },
|
||||||
updated_at() { return '2015-10-19T16:25:07.756Z'; },
|
updated_at() { return '2015-10-19T16:25:07.756Z'; },
|
||||||
updated_by() { return 1; },
|
updated_by() { return 1; },
|
||||||
uuid(i) { return `tag-${i}`; }
|
uuid(i) { return `tag-${i}`; },
|
||||||
|
count() {
|
||||||
|
return {
|
||||||
|
posts: 1
|
||||||
|
};
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
@ -17,5 +17,5 @@ export default DS.Model.extend(ValidationEngine, {
|
|||||||
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')
|
count: DS.attr('raw')
|
||||||
});
|
});
|
||||||
|
@ -9,7 +9,7 @@ export default AuthenticatedRoute.extend(CurrentUserSettings, PaginationRoute, S
|
|||||||
|
|
||||||
paginationModel: 'tag',
|
paginationModel: 'tag',
|
||||||
paginationSettings: {
|
paginationSettings: {
|
||||||
include: 'post_count',
|
include: 'count.posts',
|
||||||
limit: 15
|
limit: 15
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ export default ApplicationSerializer.extend({
|
|||||||
// Properties that exist on the model but we don't want sent in the payload
|
// Properties that exist on the model but we don't want sent in the payload
|
||||||
|
|
||||||
delete data.uuid;
|
delete data.uuid;
|
||||||
delete data.post_count;
|
delete data.count;
|
||||||
|
|
||||||
hash[root] = [data];
|
hash[root] = [data];
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{{#gh-modal-dialog action="closeModal" showClose=true type="action" style="wide"
|
{{#gh-modal-dialog action="closeModal" showClose=true type="action" style="wide"
|
||||||
title="Are you sure you want to delete this tag?" confirm=confirm}}
|
title="Are you sure you want to delete this tag?" confirm=confirm}}
|
||||||
|
|
||||||
{{#if model.post_count}}
|
{{#if model.count.posts}}
|
||||||
<strong>WARNING:</strong> <span class="red">This tag is attached to {{model.post_count}} {{postInflection}}.</span> You're about to delete "<strong>{{model.name}}</strong>". This is permanent! No backups, no restores, no magic undo button. We warned you, ok?
|
<strong>WARNING:</strong> <span class="red">This tag is attached to {{model.count.posts}} {{postInflection}}.</span> You're about to delete "<strong>{{model.name}}</strong>". This is permanent! No backups, no restores, no magic undo button. We warned you, ok?
|
||||||
{{else}}
|
{{else}}
|
||||||
<strong>WARNING:</strong> You're about to delete "<strong>{{model.name}}</strong>". This is permanent! No backups, no restores, no magic undo button. We warned you, ok?
|
<strong>WARNING:</strong> You're about to delete "<strong>{{model.name}}</strong>". This is permanent! No backups, no restores, no magic undo button. We warned you, ok?
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -20,7 +20,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">{{tag.post_count}}</span>
|
<span class="tags-count">{{tag.count.posts}}</span>
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
13
ghost/admin/app/transforms/raw.js
Normal file
13
ghost/admin/app/transforms/raw.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import DS from 'ember-data';
|
||||||
|
|
||||||
|
const {Transform} = DS;
|
||||||
|
|
||||||
|
export default Transform.extend({
|
||||||
|
deserialize: function (serialized) {
|
||||||
|
return serialized;
|
||||||
|
},
|
||||||
|
|
||||||
|
serialize: function (deserialized) {
|
||||||
|
return deserialized;
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user