|
66 | 66 | </li> |
67 | 67 | </ul> |
68 | 68 | </nav> |
69 | | - <nav v-if="typeof(props.data)==='function'" class="afcl-table-pagination-container bg-lightTableBackground dark:bg-darkTableBackground flex items-center flex-column flex-wrap md:flex-row justify-between p-4" |
70 | | - :aria-label="$t('Table navigation')"> |
71 | | - <i18n-t |
72 | | - keypath="Showing page {from}" tag="span" class="afcl-table-pagination-text text-sm font-normal text-lightTablePaginationText dark:text-darkTablePaginationText mb-4 md:mb-0 block w-full md:inline md:w-auto" |
73 | | - > |
74 | | - <template #from><span class="font-semibold text-lightTablePaginationNumeration dark:text-darkTablePaginationNumeration">{{currentPage}}</span></template> |
75 | | - </i18n-t> |
76 | | - <div> |
77 | | - <button |
78 | | - @click="switchPage(Math.max(1, currentPage - 1))" |
79 | | - class="afcl-table-pagination-button rounded-s-lg p-2 ms-0 text-blue-600 bg-lightActivePaginationButtonBackground border border-lightActivePaginationButtonBackground text-lightActivePaginationButtonText dark:bg-darkActivePaginationButtonBackground dark:border-darkActivePaginationButtonBackground dark:text-darkActivePaginationButtonText hover:opacity-90" |
80 | | - > <IconArrowLeftOutline /> </button> |
81 | | - <button |
82 | | - @click="switchPage(currentPage + 1)" |
83 | | - class="afcl-table-pagination-button rounded-e-lg p-2 text-lightUnactivePaginationButtonText border bg-lightUnactivePaginationButtonBackground border-lightUnactivePaginationButtonBorder hover:bg-lightUnactivePaginationButtonHoverBackground hover:text-lightUnactivePaginationButtonHoverText dark:bg-darkUnactivePaginationButtonBackground dark:border-darkUnactivePaginationButtonBorder dark:text-darkUnactivePaginationButtonText dark:hover:bg-darkUnactivePaginationButtonHoverBackground dark:hover:text-darkUnactivePaginationButtonHoverText" |
84 | | - > <IconArrowRightOutline /> </button> |
85 | | - </div> |
86 | | - </nav> |
87 | 69 | </div> |
88 | 70 |
|
89 | 71 |
|
|
103 | 85 | }[], |
104 | 86 | data: { |
105 | 87 | [key: string]: any, |
106 | | - }[] | ((offset: number, limit: number) => Promise<{ [key: string]: any }[]>), |
| 88 | + }[] | ((offset: number, limit: number) => Promise<{data: {[key: string]: any}[], total: number}>), |
107 | 89 | evenHighlights?: boolean, |
108 | 90 | pageSize?: number, |
109 | 91 | }>(), { |
|
113 | 95 | ); |
114 | 96 |
|
115 | 97 | const currentPage = ref(1); |
| 98 | + const recievedTotalPages = ref(1); |
116 | 99 |
|
117 | 100 | const totalPages = computed(() => { |
118 | | - if (typeof props.data === 'function') {}; |
| 101 | + if (typeof props.data === 'function') { |
| 102 | + return recievedTotalPages.value; |
| 103 | + }; |
119 | 104 | return Math.ceil(props.data.length / props.pageSize); |
120 | 105 | }); |
121 | 106 |
|
|
124 | 109 | const end = start + props.pageSize; |
125 | 110 | if (typeof props.data === 'function') { |
126 | 111 | const res = await props.data(currentPage.value, props.pageSize); |
127 | | - return res; |
| 112 | + recievedTotalPages.value = res.total; |
| 113 | + return res.data; |
128 | 114 | } |
129 | 115 | return props.data.slice(start, end); |
130 | 116 | }); |
|
0 commit comments