This repository was archived by the owner on Dec 18, 2024. It is now read-only.
Commit 786a1fb 1 parent a2486b5 commit 786a1fb Copy full SHA for 786a1fb
File tree 5 files changed +35
-9
lines changed
5 files changed +35
-9
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,14 @@ section.au-enter-active {
3
3
animation : fadeIn 1s ;
4
4
}
5
5
6
+ .aurelia-animators > .au-enter {
7
+ opacity : 0 !important ;
8
+ }
9
+
10
+ .aurelia-animators > .au-enter-active {
11
+ animation : fadeIn 2s ;
12
+ }
13
+
6
14
/* animation definitions */
7
15
@keyframes fadeIn {
8
16
0% {
@@ -13,4 +21,4 @@ section.au-enter-active {
13
21
opacity : 1 ;
14
22
transform : none
15
23
}
16
- }
24
+ }
Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ export class NewsCommentsService {
7
7
this . apiClient = apiClient ;
8
8
}
9
9
10
- getRecent ( newsId ) {
11
- return this . apiClient . find ( 'news/' + newsId + '/comments' )
10
+ getAll ( newsId , page = 1 ) {
11
+ return this . apiClient . find ( 'news/' + newsId + '/comments' , { page : page } )
12
12
. catch ( error => Promise . reject ( error ) ) ;
13
13
}
14
14
Original file line number Diff line number Diff line change @@ -24,9 +24,11 @@ export class View {
24
24
this . user = null ;
25
25
} ) ;
26
26
27
- let commentsPromise = this . newsCommentsService . getRecent ( params . id )
27
+ let commentsPromise = this . newsCommentsService . getAll ( params . id )
28
28
. then ( comments => {
29
- this . comments = comments ;
29
+ this . comments = comments . data . reverse ( ) ;
30
+ this . currentPage = comments . current_page ;
31
+ this . lastPage = comments . last_page ;
30
32
} )
31
33
. catch ( ( ) => {
32
34
this . comments = [ ] ;
@@ -66,6 +68,18 @@ export class View {
66
68
} ) ;
67
69
}
68
70
71
+ loadMore ( ) {
72
+ this . newsCommentsService . getAll ( this . newsId , this . currentPage + 1 )
73
+ . then ( comments => {
74
+ this . comments = comments . data . reverse ( ) . concat ( this . comments ) ;
75
+ this . currentPage = comments . current_page ;
76
+ this . lastPage = comments . last_page ;
77
+ } )
78
+ . catch ( ( ) => {
79
+ this . comments = [ ] ;
80
+ } ) ;
81
+ }
82
+
69
83
get isAuthenticated ( ) {
70
84
return this . authService . isAuthenticated ( ) ;
71
85
}
Original file line number Diff line number Diff line change @@ -7,14 +7,13 @@ <h4 class="card-title">Sign In</h4>
7
7
< form submit.delegate ="signIn() " novalidate >
8
8
< div class ="form-group row ">
9
9
< label for ="username " class ="col-sm-2 form-control-label "> Username</ label >
10
-
11
10
< div class ="col-sm-10 ">
12
11
< input type ="text " class ="form-control " id ="username " placeholder ="Username " value.bind ="username ">
13
12
</ div >
14
13
</ div >
14
+
15
15
< div class ="form-group row ">
16
16
< label for ="password " class ="col-sm-2 form-control-label "> Password</ label >
17
-
18
17
< div class ="col-sm-10 ">
19
18
< input type ="password " class ="form-control " id ="password " placeholder ="Password " value.bind ="password ">
20
19
</ div >
Original file line number Diff line number Diff line change @@ -21,9 +21,13 @@ <h4><a href="#/news/view/${news.id}">${news.title}</a></h4>
21
21
</ div >
22
22
< div class ="card-text "> ${news.text}</ div >
23
23
</ div >
24
- < div class ="card-footer " if.bind ="isAuthenticated || comments.length > 0 ">
25
- < div class ="news-card-comment " repeat.for ="item of comments ">
24
+ < div class ="card-footer aurelia-animators " if.bind ="isAuthenticated || comments.length > 0 ">
25
+ < div class ="news-card-comment ">
26
+ < a click.delegate ="loadMore() "> Load more...</ a >
27
+ </ div >
28
+ < div class ="news-card-comment au-animate " repeat.for ="item of comments ">
26
29
< a href ="#/profiles/view/${item.user.id} " class ="pull-left ">
30
+ <!-- Todo -->
27
31
< img alt ="${item.user.username} " src ="http://lr.local/img/avatar/${item.user.avatar} ">
28
32
</ a >
29
33
< div class ="media-body ">
@@ -34,6 +38,7 @@ <h4><a href="#/news/view/${news.id}">${news.title}</a></h4>
34
38
</ div >
35
39
< div class ="news-card-comment " if.bind ="isAuthenticated ">
36
40
< a href ="#/profiles/view/${user.id} " class ="pull-left ">
41
+ <!-- Todo: image path -->
37
42
< img alt ="${user.username} " src ="http://lr.local/img/avatar/${user.avatar} ">
38
43
</ a >
39
44
< div class ="media-body ">
You can’t perform that action at this time.
0 commit comments