mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.7 KiB
64 lines
1.7 KiB
2 years ago
|
<script setup lang="ts">
|
||
2 years ago
|
import { computed, inject } from '#imports'
|
||
2 years ago
|
import { ChangePageInj, PaginationDataInj } from '~/context'
|
||
2 years ago
|
|
||
2 years ago
|
const paginatedData = inject(PaginationDataInj)!
|
||
2 years ago
|
|
||
2 years ago
|
const changePage = inject(ChangePageInj)!
|
||
2 years ago
|
|
||
2 years ago
|
const count = computed(() => paginatedData.value?.totalRows ?? Infinity)
|
||
2 years ago
|
|
||
2 years ago
|
const size = computed(() => paginatedData.value?.pageSize ?? 25)
|
||
2 years ago
|
|
||
|
const page = computed({
|
||
|
get: () => paginatedData?.value?.page ?? 1,
|
||
|
set: (p) => changePage?.(p),
|
||
2 years ago
|
})
|
||
|
</script>
|
||
|
|
||
|
<template>
|
||
2 years ago
|
<div class="flex items-center mb-1">
|
||
2 years ago
|
<span v-if="count !== null && count !== Infinity" class="caption ml-5 text-gray-500">
|
||
2 years ago
|
{{ count }} {{ count !== 1 ? $t('objects.records') : $t('objects.record') }}
|
||
2 years ago
|
</span>
|
||
2 years ago
|
|
||
|
<div class="flex-1" />
|
||
2 years ago
|
|
||
|
<a-pagination
|
||
|
v-if="count !== Infinity"
|
||
|
v-model:current="page"
|
||
|
size="small"
|
||
2 years ago
|
class="!text-xs !m-1 nc-pagination"
|
||
2 years ago
|
:total="count"
|
||
|
:page-size="size"
|
||
|
show-less-items
|
||
|
:show-size-changer="false"
|
||
2 years ago
|
/>
|
||
2 years ago
|
<div v-else class="mx-auto flex items-center mt-n1" style="max-width: 250px">
|
||
2 years ago
|
<span class="text-xs" style="white-space: nowrap"> Change page:</span>
|
||
|
<a-input :value="page" size="small" class="ml-1 !text-xs" type="number" @keydown.enter="changePage(page)">
|
||
|
<template #suffix>
|
||
2 years ago
|
<MdiKeyboardReturn class="mt-1" @click="changePage(page)" />
|
||
2 years ago
|
</template>
|
||
2 years ago
|
</a-input>
|
||
2 years ago
|
</div>
|
||
|
|
||
2 years ago
|
<div class="flex-1" />
|
||
2 years ago
|
</div>
|
||
|
</template>
|
||
2 years ago
|
|
||
|
<style scoped>
|
||
|
:deep(.ant-pagination-item a) {
|
||
2 years ago
|
@apply text-sm !leading-[21px] !no-underline;
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
:deep(.ant-pagination-item:not(.ant-pagination-item-active) a) {
|
||
|
line-height: 21px !important;
|
||
2 years ago
|
@apply text-sm !text-gray-500;
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
:deep(.ant-pagination-item-link) {
|
||
2 years ago
|
@apply text-gray-500;
|
||
|
}
|
||
2 years ago
|
</style>
|