From ff9545d03c74db1358158eb033248490aacf6a7b Mon Sep 17 00:00:00 2001 From: Sivin Varghese <64252451+iamsivin@users.noreply.github.com> Date: Wed, 19 Mar 2025 16:45:59 +0530 Subject: [PATCH] feat: Add per-page support for agent and team overview report pagination (#11110) # Pull Request Template ## Description This PR includes per-page support for table pagination in agent and team overview reports. ## Type of change - [x] New feature (non-breaking change which adds functionality) ## How Has This Been Tested? ### Loom video https://www.loom.com/share/8c9668fe129c452986d8813a156dd3b8?sid=d637f4fe-ad0c-4f18-ad90-65e50247b3c6 ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules --- .../dashboard/components/table/Pagination.vue | 183 ++++++++++++------ .../dashboard/i18n/locale/en/report.json | 3 +- .../components/overview/AgentTable.vue | 27 ++- .../reports/components/overview/TeamTable.vue | 27 ++- 4 files changed, 177 insertions(+), 63 deletions(-) diff --git a/app/javascript/dashboard/components/table/Pagination.vue b/app/javascript/dashboard/components/table/Pagination.vue index 6de3d851c..cea8e0e90 100644 --- a/app/javascript/dashboard/components/table/Pagination.vue +++ b/app/javascript/dashboard/components/table/Pagination.vue @@ -1,12 +1,47 @@ diff --git a/app/javascript/dashboard/i18n/locale/en/report.json b/app/javascript/dashboard/i18n/locale/en/report.json index 3156115c9..294ca2e7b 100644 --- a/app/javascript/dashboard/i18n/locale/en/report.json +++ b/app/javascript/dashboard/i18n/locale/en/report.json @@ -119,7 +119,8 @@ "EMPTY_LIST": "No results found" }, "PAGINATION": { - "RESULTS": "Showing {start} to {end} of {total} results" + "RESULTS": "Showing {start} to {end} of {total} results", + "PER_PAGE_TEMPLATE": "{size} / page" } }, "AGENT_REPORTS": { diff --git a/app/javascript/dashboard/routes/dashboard/settings/reports/components/overview/AgentTable.vue b/app/javascript/dashboard/routes/dashboard/settings/reports/components/overview/AgentTable.vue index 42ca08582..483ea914d 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/reports/components/overview/AgentTable.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/reports/components/overview/AgentTable.vue @@ -7,6 +7,7 @@ import { getPaginationRowModel, } from '@tanstack/vue-table'; import { useI18n } from 'vue-i18n'; +import { useUISettings } from 'dashboard/composables/useUISettings'; import Spinner from 'shared/components/Spinner.vue'; import EmptyState from 'dashboard/components/widgets/EmptyState.vue'; @@ -30,6 +31,19 @@ const { agents, agentMetrics } = defineProps({ }); const { t } = useI18n(); +const { uiSettings, updateUISettings } = useUISettings(); + +// UI Settings key for agent table page size +const AGENT_TABLE_PAGE_SIZE_KEY = 'report_overview_agent_table_page_size'; + +// Get the saved page size from UI settings or default to 10 +const getPageSize = () => { + return uiSettings.value[AGENT_TABLE_PAGE_SIZE_KEY] || 10; +}; + +const handlePageSizeChange = pageSize => { + updateUISettings({ [AGENT_TABLE_PAGE_SIZE_KEY]: pageSize }); +}; const getAgentMetrics = id => agentMetrics.find(metrics => metrics.assignee_id === Number(id)) || {}; @@ -98,13 +112,24 @@ const table = useVueTable({ enableSorting: false, getCoreRowModel: getCoreRowModel(), getPaginationRowModel: getPaginationRowModel(), + initialState: { + pagination: { + pageSize: getPageSize(), + }, + }, });