forked from balupton/ember-cli-blog
-
Notifications
You must be signed in to change notification settings - Fork 35
/
blog-authors.js
35 lines (30 loc) · 1005 Bytes
/
blog-authors.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { sort, alias } from '@ember/object/computed';
import pagedArray from 'ember-cli-pagination/computed/paged-array';
import computedFilterByQuery from 'ember-cli-filter-by-query';
import { inject as service } from '@ember/service';
export default class BlogAuthorsComponent extends Component {
@service currentUser;
authorsSorting = Object.freeze(['name']);
@sort('args.authors', 'authorsSorting') arrangedContent;
// `arrangedContent` is then used by this filter to create `filteredContent`
@computedFilterByQuery(
'arrangedContent',
['name'],
'args.queryParamsObj.query',
{
conjunction: 'and',
sort: false,
}
)
filteredContent;
@pagedArray('filteredContent', {
page: alias('parent.args.queryParamsObj.page'),
perPage: alias('parent.args.queryParamsObj.perPage'),
})
pagedContent;
@action resetPage() {
this.args.queryParamsObj.page = 1;
}
}