File tree Expand file tree Collapse file tree 4 files changed +109
-1
lines changed Expand file tree Collapse file tree 4 files changed +109
-1
lines changed Original file line number Diff line number Diff line change
1
+ import Ember from 'ember' ;
2
+ import PaginationMixin from 'cargo/mixins/pagination' ;
3
+
4
+ // TODO: reduce duplicatoin with controllers/me/crates
5
+
6
+ export default Ember . ArrayController . extend ( PaginationMixin , {
7
+ needs : [ 'application' ] ,
8
+ queryParams : [ 'page' , 'per_page' , 'sort' ] ,
9
+ page : '1' ,
10
+ per_page : 10 ,
11
+ sort : 'alpha' ,
12
+ showSortBy : false ,
13
+
14
+ totalItems : function ( ) {
15
+ return this . store . metadataFor ( 'crate' ) . total ;
16
+ } . property ( 'model' ) ,
17
+
18
+ currentSortBy : function ( ) {
19
+ if ( this . get ( 'sort' ) === 'downloads' ) {
20
+ return 'Downloads' ;
21
+ } else {
22
+ return 'Alphabetical' ;
23
+ }
24
+ } . property ( 'sort' ) ,
25
+
26
+ actions : {
27
+ toggleShowSortBy : function ( ) {
28
+ var opt = 'showSortBy' ;
29
+ this . get ( 'controllers.application' ) . resetDropdownOption ( this , opt ) ;
30
+
31
+ } ,
32
+ } ,
33
+ } ) ;
34
+
35
+
Original file line number Diff line number Diff line change 1
1
import Ember from 'ember' ;
2
- import ajax from 'ic-ajax' ;
3
2
import AuthenticatedRoute from 'cargo/mixins/authenticated-route' ;
4
3
5
4
export default Ember . Route . extend ( AuthenticatedRoute , {
Original file line number Diff line number Diff line change
1
+ import Ember from 'ember' ;
2
+ import AuthenticatedRoute from 'cargo/mixins/authenticated-route' ;
3
+
4
+ export default Ember . Route . extend ( AuthenticatedRoute , {
5
+ queryParams : {
6
+ page : { refreshModel : true } ,
7
+ sort : { refreshModel : true } ,
8
+ } ,
9
+
10
+ model : function ( params ) {
11
+ params . following = 1 ;
12
+ return this . store . find ( 'crate' , params ) ;
13
+ } ,
14
+ } ) ;
15
+
Original file line number Diff line number Diff line change
1
+ <div id =' crates-heading' >
2
+ <img class =' logo' src =" /assets/crate.png" />
3
+ <h1 >My Crates</h1 >
4
+ </div >
5
+
6
+ {{! TODO: reduce duplication with templates/me/crates.hbs }}
7
+
8
+ <div id =' results' >
9
+ <div class =' nav' >
10
+ <span class =' amt small' >
11
+ Displaying
12
+ <span class =' cur' >{{ currentPageStart }} -{{ currentPageEnd }} </span >
13
+ of <span class =' total' >{{ totalItems }} </span > total results
14
+ </span >
15
+ </div >
16
+
17
+ <div class =' sort' >
18
+ <span class =' small' >Sort by</span >
19
+ <div class =' dropdown-container' >
20
+ <a {{ action ' toggleShowSortBy' }}
21
+ {{ bind-attr class =' showSortBy:active :dropdown' }} >
22
+ <img src =" /assets/sort.png" />
23
+ {{ currentSortBy }}
24
+ <span class =' arrow' ></span >
25
+ </a >
26
+ <ul {{ bind-attr class =' showSortBy:open :dropdown' }} >
27
+ <li >
28
+ {{ #link-to ' me.following' (query-params sort =" alpha" )}}
29
+ Alphabetical
30
+ {{ /link-to }}
31
+ </li >
32
+ <li >
33
+ {{ #link-to ' me.following' (query-params sort =" downloads" )}}
34
+ Downloads
35
+ {{ /link-to }}
36
+ </li >
37
+ </ul >
38
+ </div >
39
+ </div >
40
+ </div >
41
+
42
+ <div id =' crates' class =' white-rows' >
43
+ {{ #each }}
44
+ {{ render " crate-row" this }}
45
+ {{ /each }}
46
+ </div >
47
+
48
+ <div class =' pagination' >
49
+ {{ #link-to ' me.following' (query-params page =prevPage ) class =" prev" }}
50
+ <img src =" /assets/left-pag.png" />
51
+ {{ /link-to }}
52
+ {{ #each pages }}
53
+ {{ #link-to ' me.following' (query-params page =this )}} {{ this }} {{ /link-to }}
54
+ {{ /each }}
55
+ {{ #link-to ' me.following' (query-params page =nextPage ) class =" next" }}
56
+ <img src =" /assets/right-pag.png" />
57
+ {{ /link-to }}
58
+ </div >
59
+
You can’t perform that action at this time.
0 commit comments