-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add a settings per projects and per tables for the pagination and number of rows shown #8360
Closed
Closed
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6e5bfbd
modified text and removed default icon
FloodedBee d010446
Venv config
STWMichael 88ffe13
Added Button
STWMichael 5795c19
Added variablePageSize
STWMichael 117354e
feat: users can input custom pagination limit
gercokim 97e6861
fix: custom pagination limit updates after change event vs after inpu…
gercokim 90aa9c1
fix: initial load of table with default pagination limit has correct …
gercokim 03cca0a
fix: selected value in dropdown menu with custom pagination limit mat…
gercokim eaa2c74
test: added a playwright test for verifying pagination limit change
gercokim 725a099
added popup window to new button + merged from branch #7872-frontend
kateyslee 88bd7d7
popup page correctly records new pagination limit
kateyslee 42f7a04
edtied style of paginationlimit.vue
kateyslee 2a5043f
deleted small icon of table in popup
kateyslee File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,3 +96,4 @@ test_noco.db | |
httpbin | ||
.run/test-debug.run.xml | ||
|
||
venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
<script setup lang="ts"> | ||
import { | ||
Form, | ||
TabType, | ||
computed, | ||
nextTick, | ||
onMounted, | ||
ref, | ||
useBase, | ||
useTableNew, | ||
useTablesStore, | ||
useTabs, | ||
useVModel, | ||
validateTableName, | ||
} from '#imports' | ||
|
||
import NcTooltip from '~/components/nc/Tooltip.vue' | ||
import { useGlobal } from '#imports' | ||
|
||
const props = defineProps<{ | ||
modelValue: boolean | ||
sourceId: string | ||
baseId: string | ||
current: number | ||
total: number | ||
pageSize: number | ||
mode?: 'simple' | 'full' | ||
prevPageTooltip?: string | ||
nextPageTooltip?: string | ||
firstPageTooltip?: string | ||
lastPageTooltip?: string | ||
showSizeChanger?: boolean | ||
}>() | ||
|
||
// const emit = defineEmits(['update:modelValue', 'create']) | ||
const emits = defineEmits(['update:current', 'update:pageSize']) | ||
|
||
const dialogShow = useVModel(props, 'modelValue', emits) | ||
|
||
const { total, showSizeChanger } = toRefs(props) | ||
|
||
const current = useVModel(props, 'current', emits) | ||
|
||
const pageSize = useVModel(props, 'pageSize', emits) | ||
|
||
const { gridViewPageSize, setGridViewPageSize } = useGlobal() | ||
|
||
|
||
|
||
const localPageSize = computed({ | ||
get: () => { | ||
return gridViewPageSize.value | ||
}, | ||
set: (val) => { | ||
// reset to default value if user input is empty | ||
if (!val) { | ||
val = 25 | ||
} | ||
setGridViewPageSize(val) | ||
pageSize.value = val | ||
}, | ||
}) | ||
|
||
const pageSizeOptions = [ | ||
{ | ||
value: 25, | ||
label: '25 / page', | ||
}, | ||
{ | ||
value: 50, | ||
label: '50 / page', | ||
}, | ||
{ | ||
value: 75, | ||
label: '75 / page', | ||
}, | ||
{ | ||
value: 100, | ||
label: '100 / page', | ||
}, | ||
] | ||
|
||
const pageSizeDefaults = pageSizeOptions.map((item) => item.value) | ||
|
||
|
||
const customPageValue = computed({ | ||
get: () => { | ||
return "" | ||
}, | ||
set: (val) => { | ||
localPageSize.value = val | ||
}, | ||
}) | ||
|
||
const customPageOption = computed({ | ||
get: () => { | ||
if (pageSizeDefaults.includes(localPageSize.value)) { | ||
return localPageSize.value | ||
} | ||
return localPageSize.value.toString().concat(" / page") | ||
}, | ||
set: (val) => { | ||
localPageSize.value = val | ||
} | ||
}) | ||
|
||
const pageSizeRef = ref() | ||
|
||
const pageSizeDropdownVisibleChange = (value: boolean) => { | ||
if (!value && pageSizeRef.value) { | ||
pageSizeRef.value?.blur() | ||
} | ||
} | ||
|
||
</script> | ||
|
||
<template> | ||
<NcModal v-model:visible="dialogShow" :header="$t('labels.modifyPaginationLimit')" size="small" @keydown.esc="dialogShow = false"> | ||
<template #header> | ||
<div class="flex flex-row items-center gap-x-2"> | ||
{{ $t('labels.modifyPaginationLimit') }} | ||
</div> | ||
</template> | ||
<div class="nc-pagination flex flex-row items-center gap-x-2"> | ||
<a-select ref="pageSizeRef" v-model:value="customPageOption" class="!min-w-[110px]" :options="pageSizeOptions" | ||
size="small" dropdown-class-name="nc-pagination-dropdown" | ||
@dropdown-visible-change="pageSizeDropdownVisibleChange"> | ||
<template #suffixIcon> | ||
<GeneralIcon icon="arrowDown" class="text-gray-500 nc-select-page-size-expand-btn" /> | ||
</template> | ||
</a-select> | ||
<!-- Input and Button for entering a value --> | ||
<input v-model.lazy="customPageValue" type="number" placeholder="Set custom page size" size="small" /> | ||
|
||
</div> | ||
</NcModal> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
:deep(.ant-select-selector) { | ||
@apply !border-gray-200 !rounded-lg !h-[25px]; | ||
} | ||
|
||
:deep(.nc-button:not(:disabled)) { | ||
.nc-pagination-icon { | ||
@apply !text-gray-500; | ||
} | ||
} | ||
</style> | ||
|
||
<style lang="scss"> | ||
.nc-pagination-dropdown { | ||
@apply !rounded-lg; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,6 @@ const { gridViewPageSize, setGridViewPageSize } = useGlobal() | |
const localPageSize = computed({ | ||
get: () => { | ||
if (!showSizeChanger.value) return pageSize.value | ||
|
||
const storedPageSize = gridViewPageSize.value || 25 | ||
|
||
if (pageSize.value !== storedPageSize) { | ||
|
@@ -38,8 +37,11 @@ const localPageSize = computed({ | |
return pageSize.value | ||
}, | ||
set: (val) => { | ||
// reset to default value if user input is empty | ||
if (!val) { | ||
val = 25 | ||
} | ||
Comment on lines
+40
to
+43
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using a constant for the default page size instead of hardcoding '25' in multiple places. This would make the code cleaner and easier to maintain if the default size needs to be changed in the future. |
||
setGridViewPageSize(val) | ||
|
||
pageSize.value = val | ||
}, | ||
}) | ||
|
@@ -96,6 +98,32 @@ const pageSizeOptions = [ | |
}, | ||
] | ||
|
||
const pageSizeDefaults = pageSizeOptions.map((item) => item.value) | ||
|
||
const customPageValue = computed({ | ||
get: () => { | ||
if (pageSizeDefaults.includes(localPageSize.value)) { | ||
return "" | ||
} | ||
return localPageSize.value | ||
}, | ||
set: (val) => { | ||
localPageSize.value = val | ||
}, | ||
}) | ||
|
||
const customPageOption = computed({ | ||
get: () => { | ||
if (pageSizeDefaults.includes(localPageSize.value)) { | ||
return localPageSize.value | ||
} | ||
return localPageSize.value.toString().concat(" / page") | ||
}, | ||
set: (val) => { | ||
localPageSize.value = val | ||
} | ||
}) | ||
|
||
const pageListRef = ref() | ||
const pageSizeRef = ref() | ||
|
||
|
@@ -109,6 +137,7 @@ const pageSizeDropdownVisibleChange = (value: boolean) => { | |
pageSizeRef.value?.blur() | ||
} | ||
} | ||
|
||
</script> | ||
|
||
<template> | ||
|
@@ -118,14 +147,8 @@ const pageSizeDropdownVisibleChange = (value: boolean) => { | |
<template v-if="props.firstPageTooltip" #title> | ||
{{ props.firstPageTooltip }} | ||
</template> | ||
<NcButton | ||
v-e="[`a:pagination:${entityName}:first-page`]" | ||
class="first-page" | ||
type="secondary" | ||
size="xsmall" | ||
:disabled="current === 1" | ||
@click="goToFirstPage" | ||
> | ||
<NcButton v-e="[`a:pagination:${entityName}:first-page`]" class="first-page" type="secondary" size="xsmall" | ||
:disabled="current === 1" @click="goToFirstPage"> | ||
<GeneralIcon icon="doubleLeftArrow" class="nc-pagination-icon" /> | ||
</NcButton> | ||
</component> | ||
|
@@ -134,28 +157,15 @@ const pageSizeDropdownVisibleChange = (value: boolean) => { | |
<template v-if="props.prevPageTooltip" #title> | ||
{{ props.prevPageTooltip }} | ||
</template> | ||
<NcButton | ||
v-e="[`a:pagination:${entityName}:prev-page`]" | ||
class="prev-page" | ||
type="secondary" | ||
size="xsmall" | ||
:disabled="current === 1" | ||
@click="changePage({ increase: false })" | ||
> | ||
<NcButton v-e="[`a:pagination:${entityName}:prev-page`]" class="prev-page" type="secondary" size="xsmall" | ||
:disabled="current === 1" @click="changePage({ increase: false })"> | ||
<GeneralIcon icon="arrowLeft" class="nc-pagination-icon" /> | ||
</NcButton> | ||
</component> | ||
|
||
<div v-if="!isMobileMode" class="text-gray-500"> | ||
<a-select | ||
ref="pageListRef" | ||
v-model:value="current" | ||
class="!mr-[2px]" | ||
:options="pagesList" | ||
size="small" | ||
dropdown-class-name="nc-pagination-dropdown" | ||
@dropdown-visible-change="pageListDropdownVisibleChange" | ||
> | ||
<a-select ref="pageListRef" v-model:value="current" class="!mr-[2px]" :options="pagesList" size="small" | ||
dropdown-class-name="nc-pagination-dropdown" @dropdown-visible-change="pageListDropdownVisibleChange"> | ||
<template #suffixIcon> | ||
<GeneralIcon icon="arrowDown" class="text-gray-500 nc-select-expand-btn" /> | ||
</template> | ||
|
@@ -170,14 +180,8 @@ const pageSizeDropdownVisibleChange = (value: boolean) => { | |
<template v-if="props.nextPageTooltip" #title> | ||
{{ props.nextPageTooltip }} | ||
</template> | ||
<NcButton | ||
v-e="[`a:pagination:${entityName}:next-page`]" | ||
class="next-page" | ||
type="secondary" | ||
size="xsmall" | ||
:disabled="current === totalPages" | ||
@click="changePage({ increase: true })" | ||
> | ||
<NcButton v-e="[`a:pagination:${entityName}:next-page`]" class="next-page" type="secondary" size="xsmall" | ||
:disabled="current === totalPages" @click="changePage({ increase: true })"> | ||
<GeneralIcon icon="arrowRight" class="nc-pagination-icon" /> | ||
</NcButton> | ||
</component> | ||
|
@@ -186,33 +190,25 @@ const pageSizeDropdownVisibleChange = (value: boolean) => { | |
<template v-if="props.lastPageTooltip" #title> | ||
{{ props.lastPageTooltip }} | ||
</template> | ||
<NcButton | ||
v-e="[`a:pagination:${entityName}:last-page`]" | ||
class="last-page" | ||
type="secondary" | ||
size="xsmall" | ||
:disabled="current === totalPages" | ||
@click="goToLastPage" | ||
> | ||
<NcButton v-e="[`a:pagination:${entityName}:last-page`]" class="last-page" type="secondary" size="xsmall" | ||
:disabled="current === totalPages" @click="goToLastPage"> | ||
<GeneralIcon icon="doubleRightArrow" class="nc-pagination-icon" /> | ||
</NcButton> | ||
</component> | ||
</template> | ||
<div v-if="showSizeChanger && !isMobileMode" class="text-gray-500"> | ||
<a-select | ||
ref="pageSizeRef" | ||
v-model:value="localPageSize" | ||
class="!min-w-[110px]" | ||
:options="pageSizeOptions" | ||
size="small" | ||
dropdown-class-name="nc-pagination-dropdown" | ||
@dropdown-visible-change="pageSizeDropdownVisibleChange" | ||
> | ||
<a-select ref="pageSizeRef" v-model:value="customPageOption" class="!min-w-[110px]" :options="pageSizeOptions" | ||
size="small" dropdown-class-name="nc-pagination-dropdown" | ||
@dropdown-visible-change="pageSizeDropdownVisibleChange"> | ||
<template #suffixIcon> | ||
<GeneralIcon icon="arrowDown" class="text-gray-500 nc-select-page-size-expand-btn" /> | ||
</template> | ||
</a-select> | ||
</div> | ||
<div v-if="showSizeChanger && !isMobileMode" class="text-gray-500"> | ||
<!-- Input and Button for entering a value --> | ||
<input v-model.lazy="customPageValue" type="number" placeholder="Set custom page size" size="small" /> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a constant for the default page size instead of hardcoding '25' in multiple places. This would make the code cleaner and easier to maintain if the default size needs to be changed in the future.