| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 1 | import i18n from '@/i18n'; |
| SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 2 | export const currentPage = 1; |
| 3 | export const perPage = 20; |
| 4 | export const itemsPerPageOptions = [ |
| 5 | { |
| 6 | value: 10, |
| 7 | text: '10', |
| Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 8 | }, |
| SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 9 | { |
| 10 | value: 20, |
| 11 | text: '20', |
| 12 | }, |
| 13 | { |
| 14 | value: 30, |
| 15 | text: '30', |
| 16 | }, |
| 17 | { |
| 18 | value: 40, |
| 19 | text: '40', |
| 20 | }, |
| 21 | { |
| 22 | value: 0, |
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 23 | text: i18n.global.t('global.table.viewAll'), |
| SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 24 | }, |
| 25 | ]; |
| 26 | const BVPaginationMixin = { |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 27 | watch: { |
| 28 | perPage(newPerPage) { |
| 29 | // When switching to "View all" (perPage === 0), reset to first page |
| 30 | // to avoid empty views when previously on a later page. |
| 31 | if (newPerPage === 0) { |
| 32 | this.currentPage = 1; |
| 33 | } |
| 34 | }, |
| 35 | }, |
| Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 36 | methods: { |
| 37 | getTotalRowCount(count) { |
| 38 | return this.perPage === 0 ? 0 : count; |
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 39 | }, |
| 40 | }, |
| Yoshie Muranaka | f9832b0 | 2020-05-12 12:04:46 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | export default BVPaginationMixin; |