mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
a109c1c3db
closes https://github.com/TryGhost/Ghost/issues/7002 - move sorting logic out of the controller and into the Post model This is a quick attempt at implementing the refactoring referenced in https://github.com/TryGhost/Ghost/issues/7002. The client-side sorting is working but we still have the problem of scheduled posts not appearing in the list until you scroll to the very first published post because the server is returning posts in the wrong order.
30 lines
677 B
JavaScript
30 lines
677 B
JavaScript
import Ember from 'ember';
|
|
|
|
const {
|
|
Controller,
|
|
compare,
|
|
computed,
|
|
inject: {service}
|
|
} = Ember;
|
|
const {equal} = computed;
|
|
|
|
export default Controller.extend({
|
|
feature: service(),
|
|
|
|
showDeletePostModal: false,
|
|
|
|
// See PostsRoute's shortcuts
|
|
postListFocused: equal('keyboardFocus', 'postList'),
|
|
postContentFocused: equal('keyboardFocus', 'postContent'),
|
|
|
|
sortedPosts: computed('model.@each.{status,publishedAtUTC,isNew,updatedAtUTC}', function () {
|
|
return this.get('model').toArray().sort(compare);
|
|
}),
|
|
|
|
actions: {
|
|
toggleDeletePostModal() {
|
|
this.toggleProperty('showDeletePostModal');
|
|
}
|
|
}
|
|
});
|