Skip to content

feat: add dropdown for selecting page size options in list view#603

Closed
kulikp1 wants to merge 14 commits into
nextfrom
feature/AdminForth/1586/add-dropdown-to-select-count-o
Closed

feat: add dropdown for selecting page size options in list view#603
kulikp1 wants to merge 14 commits into
nextfrom
feature/AdminForth/1586/add-dropdown-to-select-count-o

Conversation

@kulikp1
Copy link
Copy Markdown
Collaborator

@kulikp1 kulikp1 commented May 8, 2026

No description provided.

Comment thread adminforth/spa/src/components/ResourceListTable.vue Outdated
Comment thread adminforth/spa/src/views/ListView.vue Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for configurable “rows per page” options in the list view, wiring a new listPageSizeOptions resource option from backend to SPA and exposing it via a dropdown in the table pagination controls.

Changes:

  • Introduces options.listPageSizeOptions (static array or async callback) and resolves it server-side in /get_resource.
  • Adds a page-size select dropdown to list pagination UI and syncs pageSize with the route query (pageSize=).
  • Adjusts the shared Select placeholder logic when search is disabled.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
adminforth/types/Common.ts Adds the listPageSizeOptions resource option type.
adminforth/spa/src/views/ListView.vue Plumbs pageSizeOptions into the table and syncs pageSize with query params + refetch logic.
adminforth/spa/src/components/ResourceListTable.vue Renders the “Rows per page” dropdown and emits update:pageSize.
adminforth/spa/src/afcl/Select.vue Fixes placeholder text behavior when searchDisabled is true.
adminforth/modules/restApi.ts Resolves functional listPageSizeOptions to a concrete array in the /get_resource response.
adminforth/documentation/docs/tutorial/03-Customization/13-standardPagesTuning.md Documents listPageSizeOptions and intended UI behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread adminforth/spa/src/views/ListView.vue Outdated
Comment thread adminforth/spa/src/views/ListView.vue Outdated
Comment thread adminforth/spa/src/components/ResourceListTable.vue
Comment thread adminforth/types/Common.ts Outdated
Comment on lines +329 to +346
listPageSize: 10,
// listPageSizeOptions can be a static array
//diff-add
listPageSizeOptions: [10, 20, 50],
// OR a function for dynamic options based on user role
//diff-add
listPageSizeOptions: ({ adminUser }) => {
//diff-add
if (adminUser?.dbUser?.role === 'superadmin') {
//diff-add
return [50, 100, 500];
//diff-add
}
//diff-add
return [10, 20, 50];
//diff-add
},
}
Comment thread adminforth/documentation/docs/tutorial/03-Customization/13-standardPagesTuning.md Outdated
Comment thread adminforth/documentation/docs/tutorial/03-Customization/13-standardPagesTuning.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Comment thread adminforth/spa/src/views/ListView.vue Outdated
Comment thread adminforth/types/Common.ts
rows: any[] | null,
totalRows: number,
pageSize: number,
pageSizeOptions?: { label: string; value: any }[] | number[] | null;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ label: string; value: any }[]

I thought user can enter only array with numbers

}
});

const selectDynamicWidth = computed(() => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just remove fixed width and everything will be fine

:style="{ width: selectDynamicWidth }"
:placeholder="pageSizeInternal?.toString()"
class="text-sm "
classesForInput="h-[34px] min-h-0 py-1 pl-2 pr-6 text-sm rounded-md cursor-pointer af-button-shadow
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

w-fit

return null;
}

const firstItem = props.pageSizeOptions[0];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove it

const PAGE_SIZE_OPTIONS = computed(() => {
const array = coreStore.resource?.options?.listPageSizeOptions;

if (!Array.isArray(array)) return undefined;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null

@update:sort="sort = $event"
@update:checkboxes="checkboxes = $event"
@update:records="getListInner"
:pageSizeOptions="PAGE_SIZE_OPTIONS"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it

}

watch([page, sort, () => filtersStore.filters], async () => {
watch([page, pageSize, sort, () => filtersStore.filters], async () => {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it

}));
});

const pageSize = computed({
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove it

@SerVitasik SerVitasik closed this May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants