Skip to content

Commit 945bb1c

Browse files
committed
Complete page size selection functionality
1 parent 2dc9370 commit 945bb1c

File tree

9 files changed

+75
-24
lines changed

9 files changed

+75
-24
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Component from '@ember/component';
2+
import { A } from '@ember/array';
3+
4+
export default Component.extend({
5+
pageSizes: A([10, 25, 50, 100, 250, 'All'])
6+
7+
});

app/components/tables/utilities/pagination.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ export default class extends Component {
1111
@computed('currentPage', 'pageSize', 'totalContentLength')
1212
get currentRange() {
1313
let firstIndex = this.totalContentLength === 0 ? 0 : (this.currentPage - 1) * this.pageSize + 1;
14-
let lastIndex = this.currentPage === this.pageCount ? this.totalContentLength : this.currentPage * this.pageSize;
14+
let lastIndex = (this.currentPage === this.pageCount || this.pageSize === 0) ? this.totalContentLength : this.currentPage * this.pageSize;
1515
return `${firstIndex} - ${lastIndex}`;
1616
}
1717

1818
@computed('currentPage', 'pageSize', 'totalContentLength')
1919
get pageCount() {
20-
let totalPages = 0;
21-
if (this.pageSize < this.totalContentLength) {
20+
let totalPages = 1;
21+
if (parseInt(this.pageSize) !== 0 && this.pageSize < this.totalContentLength) {
2222
totalPages = parseInt(this.totalContentLength / this.pageSize);
2323
if (this.totalContentLength % this.pageSize) {
2424
totalPages += 1;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Component from '@ember/component';
2+
3+
export default Component.extend({
4+
});

app/controllers/events/list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { computed, action } from '@ember/object';
44
export default class extends Controller {
55
queryParams = ['page', 'per_page'];
66
page = 1;
7-
per_page = 1;
7+
per_page = 2;
88

99
@computed()
1010
get columns() {

app/initializers/blanket.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export function initialize(application) {
2222
inject('routing', 'service:-routing');
2323
inject('cookies', 'service:cookies');
2424
inject('infinity', 'service:infinity');
25+
inject('headData', 'service:headData');
2526
application.inject('component', 'router', 'service:router');
2627
}
2728

app/styles/partials/overrides.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,9 @@ body.dimmable.undetached.dimmed {
7070
&[class*='left padding'] {
7171
padding-left: 0 !important;
7272
}
73+
74+
&[class*='bottom padding'] {
75+
padding-bottom: 0 !important;
76+
}
7377
}
7478
}
Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
1-
{{#ember-table as |t|}}
2-
{{t.head columns=columns}}
3-
{{#t.body rows=rows as |b|}}
4-
{{#b.row as |r|}}
5-
{{#r.cell as |cell column row|}}
6-
{{#if column.cellComponent}}
7-
{{#component column.cellComponent
8-
record=(get row column.valuePath)
9-
extraRecords=(get-properties row column.extraValuePaths)
10-
props=(hash options=column.options actions=column.actions)}}
11-
{{cell}}
12-
{{/component}}
13-
{{else}}
14-
{{cell}}
15-
{{/if}}
16-
{{/r.cell}}
17-
{{/b.row}}
18-
{{/t.body}}
19-
{{/ember-table}}
1+
<div class="ui grid">
2+
<div class="ui less bottom padding row">
3+
<div class="left aligned eight wide column">
4+
{{tables/utilities/page-size-input pageSize=pageSize}}
5+
</div>
6+
<div class="eight wide right aligned column">
7+
{{tables/utilities/search-box searchQuery=searchQuery}}
8+
</div>
9+
</div>
2010

21-
{{tables/utilities/pagination currentPage=currentPage pageSize=pageSize metaData=metaData}}
11+
<div class="row">
12+
{{#ember-table as |t|}}
13+
{{t.head columns=columns}}
14+
{{#t.body rows=rows as |b|}}
15+
{{#b.row as |r|}}
16+
{{#r.cell as |cell column row|}}
17+
{{#if column.cellComponent}}
18+
{{#component column.cellComponent
19+
record=(get row column.valuePath)
20+
extraRecords=(get-properties row column.extraValuePaths)
21+
props=(hash options=column.options actions=column.actions)}}
22+
{{cell}}
23+
{{/component}}
24+
{{else}}
25+
{{cell}}
26+
{{/if}}
27+
{{/r.cell}}
28+
{{/b.row}}
29+
{{/t.body}}
30+
{{/ember-table}}
31+
</div>
32+
33+
<div class="row">
34+
{{tables/utilities/pagination currentPage=currentPage pageSize=pageSize metaData=metaData}}
35+
</div>
36+
</div>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<span>
2+
{{t 'Show'}}
3+
{{#ui-dropdown class='inline' selected=pageSize onChange=(action (mut pageSize)) forceSelection=true}}
4+
{{input type='hidden' value=pageSize}}
5+
<div class="default text">10</div>
6+
<i class="dropdown icon"></i>
7+
<div class="menu">
8+
{{#each pageSizes as |pageSize|}}
9+
<div class="item" data-value="{{if (eq pageSize 'All') 0 pageSize}}">
10+
{{pageSize}}
11+
</div>
12+
{{/each}}
13+
</div>
14+
{{/ui-dropdown}}
15+
{{t 'entries per page'}}
16+
</span>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="ui small icon input">
2+
{{input type="text" placeholder="Search ..."}}
3+
<i class="search icon"></i>
4+
</div>

0 commit comments

Comments
 (0)