mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
cc4ff8c6d4
refs https://github.com/TryGhost/Team/issues/3168 - This is basic scaffolding for collection resources UI in Admin. For the most part it's a copy-paste of tags code with slight modifications to fit the collections usecase
32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
|
|
export default class CollectionsRoute extends AuthenticatedRoute {
|
|
// authors aren't allowed to manage tags
|
|
beforeModel() {
|
|
super.beforeModel(...arguments);
|
|
|
|
if (this.session.user.isAuthorOrContributor) {
|
|
return this.transitionTo('home');
|
|
}
|
|
}
|
|
|
|
// set model to a live array so all collections are shown and created/deleted collections
|
|
// are automatically added/removed. Also load all collections in the background,
|
|
// pausing to show the loading spinner if no collections have been loaded yet
|
|
model() {
|
|
let promise = this.store.query('collection', {limit: 'all', include: 'count.posts'});
|
|
let collections = this.store.peekAll('collection');
|
|
if (this.store.peekAll('collection').get('length') === 0) {
|
|
return promise.then(() => collections);
|
|
} else {
|
|
return collections;
|
|
}
|
|
}
|
|
|
|
buildRouteInfoMetadata() {
|
|
return {
|
|
titleToken: 'Collections'
|
|
};
|
|
}
|
|
}
|