mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor: Migrate Pagination to composition API (no-changelog) (#9752)
This commit is contained in:
@@ -74,7 +74,7 @@ interface DatatableProps {
|
||||
rows: DatatableRow[];
|
||||
currentPage?: number;
|
||||
pagination?: boolean;
|
||||
rowsPerPage?: number | '*';
|
||||
rowsPerPage?: number;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'N8nDatatable' });
|
||||
@@ -92,10 +92,6 @@ const rowsPerPageOptions = ref([10, 25, 50, 100]);
|
||||
const $style = useCssModule();
|
||||
|
||||
const totalPages = computed(() => {
|
||||
if (props.rowsPerPage === '*') {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return Math.ceil(props.rows.length / props.rowsPerPage);
|
||||
});
|
||||
|
||||
@@ -104,10 +100,6 @@ const totalRows = computed(() => {
|
||||
});
|
||||
|
||||
const visibleRows = computed(() => {
|
||||
if (props.rowsPerPage === '*') {
|
||||
return props.rows;
|
||||
}
|
||||
|
||||
const start = (props.currentPage - 1) * props.rowsPerPage;
|
||||
const end = start + props.rowsPerPage;
|
||||
|
||||
@@ -123,10 +115,10 @@ function onUpdateCurrentPage(value: number) {
|
||||
$emit('update:currentPage', value);
|
||||
}
|
||||
|
||||
function onRowsPerPageChange(value: number | '*') {
|
||||
function onRowsPerPageChange(value: number) {
|
||||
$emit('update:rowsPerPage', value);
|
||||
|
||||
const maxPage = value === '*' ? 1 : Math.ceil(totalRows.value / value);
|
||||
const maxPage = Math.ceil(totalRows.value / value);
|
||||
if (maxPage < props.currentPage) {
|
||||
onUpdateCurrentPage(maxPage);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user