Skip to content

Commit 6faf893

Browse files
committed
Inline pagination mixin
1 parent 66014ec commit 6faf893

File tree

12 files changed

+34
-29
lines changed

12 files changed

+34
-29
lines changed

app/controllers/categories.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../mixins/pagination';
5+
import { pagination } from '../utils/pagination';
66

7-
export default Controller.extend(PaginationMixin, {
7+
export default Controller.extend({
88
queryParams: ['page', 'per_page', 'sort'],
99
page: '1',
1010
per_page: 100,
1111
sort: 'alpha',
1212

1313
totalItems: readOnly('model.meta.total'),
14+
pagination: pagination(),
1415

1516
currentSortBy: computed('sort', function () {
1617
return this.sort === 'crates' ? '# Crates' : 'Alphabetical';

app/controllers/category/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../../mixins/pagination';
5+
import { pagination } from '../../utils/pagination';
66

7-
export default Controller.extend(PaginationMixin, {
7+
export default Controller.extend({
88
queryParams: ['page', 'per_page', 'sort'],
99
page: '1',
1010
per_page: 10,
1111
sort: 'recent-downloads',
1212

1313
totalItems: readOnly('model.meta.total'),
14+
pagination: pagination(),
1415

1516
category: null,
1617

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import Controller from '@ember/controller';
22
import { readOnly } from '@ember/object/computed';
33

4-
import PaginationMixin from '../../mixins/pagination';
4+
import { pagination } from '../../utils/pagination';
55

6-
export default Controller.extend(PaginationMixin, {
6+
export default Controller.extend({
77
queryParams: ['page', 'per_page'],
88
page: '1',
99
per_page: 10,
1010
crate: null,
1111

1212
totalItems: readOnly('model.meta.total'),
13+
pagination: pagination(),
1314
});

app/controllers/crates.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../mixins/pagination';
5+
import { pagination } from '../utils/pagination';
66

7-
export default Controller.extend(PaginationMixin, {
7+
export default Controller.extend({
88
queryParams: ['letter', 'page', 'per_page', 'sort'],
99
letter: null,
1010
page: '1',
@@ -13,6 +13,7 @@ export default Controller.extend(PaginationMixin, {
1313
alphabet: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split(''),
1414

1515
totalItems: readOnly('model.meta.total'),
16+
pagination: pagination(),
1617

1718
currentSortBy: computed('sort', function () {
1819
if (this.sort === 'downloads') {

app/controllers/keyword/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../../mixins/pagination';
5+
import { pagination } from '../../utils/pagination';
66

7-
export default Controller.extend(PaginationMixin, {
7+
export default Controller.extend({
88
queryParams: ['page', 'per_page', 'sort'],
99
page: '1',
1010
per_page: 10,
1111
sort: 'recent-downloads',
1212

1313
totalItems: readOnly('model.meta.total'),
14+
pagination: pagination(),
1415

1516
currentSortBy: computed('sort', function () {
1617
if (this.sort === 'downloads') {

app/controllers/keywords.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../mixins/pagination';
5+
import { pagination } from '../utils/pagination';
66

7-
export default Controller.extend(PaginationMixin, {
7+
export default Controller.extend({
88
queryParams: ['page', 'per_page', 'sort'],
99
page: '1',
1010
per_page: 10,
1111
sort: 'crates',
1212

1313
totalItems: readOnly('model.meta.total'),
14+
pagination: pagination(),
1415

1516
currentSortBy: computed('sort', function () {
1617
return this.sort === 'crates' ? '# Crates' : 'Alphabetical';

app/controllers/me/crates.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../../mixins/pagination';
5+
import { pagination } from '../../utils/pagination';
66

77
// TODO: reduce duplicatoin with controllers/crates
88

9-
export default Controller.extend(PaginationMixin, {
9+
export default Controller.extend({
1010
queryParams: ['page', 'per_page', 'sort'],
1111
page: '1',
1212
per_page: 10,
1313
sort: 'alpha',
1414

1515
totalItems: readOnly('model.meta.total'),
16+
pagination: pagination(),
1617

1718
currentSortBy: computed('sort', function () {
1819
if (this.sort === 'downloads') {

app/controllers/me/following.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../../mixins/pagination';
5+
import { pagination } from '../../utils/pagination';
66

77
// TODO: reduce duplicatoin with controllers/me/crates
88

9-
export default Controller.extend(PaginationMixin, {
9+
export default Controller.extend({
1010
queryParams: ['page', 'per_page', 'sort'],
1111
page: '1',
1212
per_page: 10,
1313
sort: 'alpha',
1414

1515
totalItems: readOnly('model.meta.total'),
16+
pagination: pagination(),
1617

1718
currentSortBy: computed('sort', function () {
1819
return this.sort === 'downloads' ? 'Downloads' : 'Alphabetical';

app/controllers/search.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { bool, readOnly } from '@ember/object/computed';
44

55
import { task } from 'ember-concurrency';
66

7-
import PaginationMixin from '../mixins/pagination';
7+
import { pagination } from '../utils/pagination';
88

9-
export default Controller.extend(PaginationMixin, {
9+
export default Controller.extend({
1010
queryParams: ['all_keywords', 'page', 'per_page', 'q', 'sort'],
1111
q: null,
1212
page: '1',
@@ -23,6 +23,7 @@ export default Controller.extend(PaginationMixin, {
2323
}),
2424

2525
totalItems: readOnly('model.meta.total'),
26+
pagination: pagination(),
2627

2728
currentSortBy: computed('sort', function () {
2829
if (this.sort === 'downloads') {

app/controllers/team.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../mixins/pagination';
5+
import { pagination } from '../utils/pagination';
66

7-
export default Controller.extend(PaginationMixin, {
7+
export default Controller.extend({
88
queryParams: ['page', 'per_page', 'sort'],
99
page: '1',
1010
per_page: 10,
1111
sort: 'alpha',
1212

1313
totalItems: readOnly('model.crates.meta.total'),
14+
pagination: pagination(),
1415

1516
currentSortBy: computed('sort', function () {
1617
if (this.sort === 'downloads') {

app/controllers/user.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ import Controller from '@ember/controller';
22
import { computed } from '@ember/object';
33
import { readOnly } from '@ember/object/computed';
44

5-
import PaginationMixin from '../mixins/pagination';
5+
import { pagination } from '../utils/pagination';
66

77
// TODO: reduce duplication with controllers/crates
88

9-
export default Controller.extend(PaginationMixin, {
9+
export default Controller.extend({
1010
queryParams: ['page', 'per_page', 'sort'],
1111
page: '1',
1212
per_page: 10,
1313
sort: 'alpha',
1414

1515
totalItems: readOnly('model.crates.meta.total'),
16+
pagination: pagination(),
1617

1718
currentSortBy: computed('sort', function () {
1819
if (this.sort === 'downloads') {

app/mixins/pagination.js renamed to app/utils/pagination.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
import { computed } from '@ember/object';
2-
import Mixin from '@ember/object/mixin';
32

43
const VIEWABLE_PAGES = 9;
54

6-
// eslint-disable-next-line ember/no-new-mixins
7-
export default Mixin.create({
8-
pagination: pagination(),
9-
});
10-
11-
function pagination() {
5+
export function pagination() {
126
return computed('page', 'per_page', 'totalItems', function () {
137
let { page, per_page: perPage, totalItems } = this;
148
return _pagination(page, perPage, totalItems);

0 commit comments

Comments
 (0)