File tree 9 files changed +100
-24
lines changed
9 files changed +100
-24
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ public function __construct(BankAccountRepository $repository)
34
34
*/
35
35
public function index ()
36
36
{
37
- return $ this ->repository ->all ( );
37
+ return $ this ->repository ->paginate ( 4 );
38
38
}
39
39
40
40
/**
Original file line number Diff line number Diff line change
1
+ <template >
2
+ <ul class =" pagination" >
3
+ <li :class =" {'disabled': currentPage == 0}" >
4
+ <a @click.prevent =" previousPage" href =" #" >
5
+ <i class =" material-icons" >chevron_left</i >
6
+ </a >
7
+ </li >
8
+ <li v-for =" o in pages" class =" waves-effect" :class =" {'active': currentPage == o}" >
9
+ <a @click.prevent =" setCurrentPage(o)" href =" #" >{{o + 1}}</a >
10
+ </li >
11
+ <li :class =" {'disabled': currentPage == pages - 1}" >
12
+ <a @click.prevent =" nextPage" href =" #" >
13
+ <i class =" material-icons" >chevron_right</i >
14
+ </a >
15
+ </li >
16
+ </ul >
17
+ </template >
18
+ <script >
19
+ export default {
20
+ props: {
21
+ currentPage: {
22
+ type: Number ,
23
+ ' default' : 0
24
+ },
25
+ perPage: {
26
+ type: Number ,
27
+ required: true
28
+ },
29
+ totalRecords: {
30
+ type: Number ,
31
+ required: true
32
+ }
33
+ },
34
+ computed: {
35
+ pages (){
36
+ let pages = Math .ceil (this .totalRecords / this .perPage );
37
+ return Math .max (pages, 1 );
38
+ }
39
+ },
40
+ methods: {
41
+ setCurrentPage (page ){
42
+ this .currentPage = page;
43
+ },
44
+ previousPage (){
45
+ if (this .currentPage > 0 ){
46
+ this .currentPage -- ;
47
+ }
48
+ },
49
+ nextPage (){
50
+ if (this .currentPage < this .pages - 1 ){
51
+ this .currentPage ++ ;
52
+ }
53
+ }
54
+ },
55
+ watch: {
56
+ currentPage (newValue ){
57
+ this .$dispatch (' pagination::changed' ,newValue);
58
+ }
59
+ }
60
+ }
61
+ </script >
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div class =" container" >
3
3
<div class =" row" >
4
- <div class =" col s8 offset-s2 z-depth-2" >
4
+ <div class =" card-panel col s8 offset-s2 z-depth-2" >
5
5
<h3 class =" center" >Code Financeiro</h3 >
6
6
7
7
<div class =" row" v-if =" error.error" >
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div class =" container" >
3
3
<div class =" row" >
4
- <div class =" col s8 offset-s2 z-depth-2" >
4
+ <div class =" card-panel col s8 offset-s2 z-depth-2" >
5
5
<h5 class =" center" >Efetuando logout...</h5 >
6
6
<div class =" progress" >
7
7
<div class =" indeterminate" ></div >
16
16
ready (){
17
17
setTimeout (() => {
18
18
this .logout ();
19
- },1000 );
19
+ }, 1000 );
20
20
},
21
21
methods: {
22
22
logout (){
23
23
let goToLogin = () => this .$router .go ({name: ' auth.login' });
24
24
Auth .logout ()
25
- .then (goToLogin () )
26
- .catch (goToLogin () );
25
+ .then (goToLogin)
26
+ .catch (goToLogin);
27
27
}
28
28
}
29
29
}
Original file line number Diff line number Diff line change 19
19
</thead >
20
20
<tbody >
21
21
<tr v-for =" (index,o) in bankAccounts" >
22
- <td >{{index + 1 }}</td >
22
+ <td >{{o.id }}</td >
23
23
<td >{{o.name}}</td >
24
24
<td >{{o.agency}}</td >
25
25
<td >{{o.account}}</td >
30
30
</tr >
31
31
</tbody >
32
32
</table >
33
+ <pagination :current-page.sync =" pagination.current_page" :per-page =" pagination.per_page" :total-records =" pagination.total" ></pagination >
33
34
</div >
34
35
35
36
<div class =" fixed-action-btn" >
59
60
<script >
60
61
import {BankAccount } from ' ../../services/resources' ;
61
62
import ModalComponent from ' ../../../../_default/components/Modal.vue' ;
63
+ import PaginationComponent from ' ../../../../_default/components/Pagination.vue' ;
62
64
export default {
63
65
components: {
64
66
' modal' : ModalComponent,
67
+ ' pagination' : PaginationComponent,
65
68
},
66
69
data (){
67
70
return {
68
71
bankAccounts: [],
69
72
bankAccountToDelete: null ,
70
73
modal: {
71
74
id: " modal-delete"
75
+ },
76
+ pagination: {
77
+ current_page: 0 ,
78
+ per_page: 0 ,
79
+ total: 0
72
80
}
73
81
}
74
82
},
75
83
created (){
76
- BankAccount .query ().then ((response ) => {
77
- this .bankAccounts = response .data .data ;
78
- });
84
+ this .getBankAccounts ();
79
85
},
80
86
methods: {
81
87
destroy (){
88
94
openModalDelete (bankAccount ){
89
95
this .bankAccountToDelete = bankAccount;
90
96
$ (' #modal-delete' ).modal (' open' );
97
+ },
98
+ getBankAccounts (){
99
+ BankAccount .query ({
100
+ page: this .pagination .current_page + 1
101
+ }).then ((response ) => {
102
+ this .bankAccounts = response .data .data ;
103
+ let pagination = response .data .meta .pagination ;
104
+ pagination .current_page -- ;
105
+ this .pagination = pagination;
106
+ });
107
+ }
108
+ },
109
+ events: {
110
+ ' pagination::changed' (page){
111
+ this .getBankAccounts ();
91
112
}
92
113
}
93
114
}
Original file line number Diff line number Diff line change @@ -39,13 +39,14 @@ export default {
39
39
} ) ;
40
40
} ,
41
41
logout ( ) {
42
- let afterLogout = ( ) => {
42
+ let afterLogout = ( response ) => {
43
43
this . clearAuth ( ) ;
44
+ return response ;
44
45
} ;
45
46
46
47
return JwtToken . revokeToken ( ) .
47
- then ( afterLogout ( ) )
48
- . catch ( afterLogout ( ) ) ;
48
+ then ( afterLogout )
49
+ . catch ( afterLogout ) ;
49
50
} ,
50
51
clearAuth ( ) {
51
52
this . user . data = null ;
Original file line number Diff line number Diff line change @@ -23,13 +23,14 @@ export default {
23
23
} ) ;
24
24
} ,
25
25
revokeToken ( ) {
26
- let afterReveokeToken = ( ) => {
26
+ let afterReveokeToken = ( response ) => {
27
27
this . token = null ;
28
+ return response ;
28
29
} ;
29
30
30
31
return Jwt . logout ( ) .
31
- then ( afterReveokeToken ( ) )
32
- . catch ( afterReveokeToken ( ) ) ;
32
+ then ( afterReveokeToken )
33
+ . catch ( afterReveokeToken ) ;
33
34
} ,
34
35
getAuthorizationHeader ( ) {
35
36
return `Bearer ${ LocalStorage . get ( TOKEN ) } ` ;
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments