|
1 | 1 | <script lang="ts" setup> |
2 | | -import { ref, watch } from 'vue' |
| 2 | +import { computed, ref, watch } from 'vue' |
3 | 3 | import DsfrTableRow, { type DsfrTableRowProps } from './DsfrTableRow.vue' |
4 | 4 | import DsfrTableHeaders from './DsfrTableHeaders.vue' |
5 | 5 | import { type DsfrTableHeadersProps } from './DsfrTableHeaders.vue' |
@@ -30,15 +30,17 @@ const pageCount = ref(props.rows.length > optionSelected.value ? Math.ceil(props |
30 | 30 | const paginationOptions = [5, 10, 25, 50, 100] |
31 | 31 | const returnLowestLimit = () => currentPage.value * optionSelected.value - optionSelected.value |
32 | 32 | const returnHighestLimit = () => currentPage.value * optionSelected.value |
33 | | -let truncatedResults = props.rows.slice(returnLowestLimit(), returnHighestLimit()) |
34 | 33 |
|
35 | | -watch(() => optionSelected.value, (newVal) => { |
36 | | - props.rows.length > optionSelected.value ? pageCount.value = Math.ceil(props.rows.length / newVal) : pageCount.value = 1 |
37 | | - truncatedResults = props.rows.slice(returnLowestLimit(), returnHighestLimit()) |
| 34 | +watch(() => optionSelected.value, (newVal, OldVal) => { |
| 35 | + pageCount.value = props.rows.length > optionSelected.value ? Math.ceil(props.rows.length / newVal) : 1 |
38 | 36 | }) |
39 | 37 |
|
40 | | -watch(() => currentPage.value, () => { |
41 | | - truncatedResults = props.rows.slice(returnLowestLimit(), returnHighestLimit()) |
| 38 | +const truncatedResults = computed(() => { |
| 39 | + if(props.pagination) { |
| 40 | + return props.rows.slice(returnLowestLimit(), returnHighestLimit()) |
| 41 | + } |
| 42 | +
|
| 43 | + return props.rows; |
42 | 44 | }) |
43 | 45 |
|
44 | 46 | const goFirstPage = () => { currentPage.value = 1 } |
|
0 commit comments