From a2972c48575441560998433151ab27771de75a93 Mon Sep 17 00:00:00 2001 From: Emmy Leke Date: Wed, 22 Nov 2023 13:07:18 +0100 Subject: [PATCH] Refactor pagination and add per page options --- .../src/components/Configurator/basic.vue | 2 +- .../components/resourceList/CResourceList.vue | 137 ++++++++++++------ locale/en/corteza-webapp-admin/general.yaml | 4 + locale/en/corteza-webapp-compose/general.yaml | 3 +- .../en/corteza-webapp-discovery/general.yaml | 7 +- locale/en/corteza-webapp-privacy/general.yaml | 2 + .../en/corteza-webapp-reporter/general.yaml | 2 + .../en/corteza-webapp-workflow/general.yaml | 5 +- 8 files changed, 113 insertions(+), 49 deletions(-) diff --git a/client/web/workflow/src/components/Configurator/basic.vue b/client/web/workflow/src/components/Configurator/basic.vue index 2a38b17d3..a87ba5476 100644 --- a/client/web/workflow/src/components/Configurator/basic.vue +++ b/client/web/workflow/src/components/Configurator/basic.vue @@ -1,7 +1,7 @@ @@ -276,6 +298,11 @@ export default { type: String, default: 'query', }, + + hidePerPageOption: { + type: Boolean, + default: false + } }, data () { @@ -314,6 +341,21 @@ export default { ].filter(s => s !== 'header') }, + perPageOptions () { + const defaultText = this.pagination.limit === 0 ? this.$t('general:label.all') : this.pagination.limit.toString() + + return [ + { text: defaultText, value: this.pagination.limit }, + { text: '25', value: 25 }, + { text: '50', value: 50 }, + { text: '100', value: 100 }, + ].filter((v, i) => i === 0 || v.value !== this.pagination.limit).sort((a, b) => { + if (a.value === 0) return 1 + if (b.value === 0) return -1 + return a.value - b.value + }) + }, + disableSelectAll () { return !this.selectableItemIDs.length }, @@ -345,7 +387,7 @@ export default { }, showFooter () { - return !(this.hideTotal && this.hidePagination) + return !(this.hideTotal && this.hidePagination && this.hidePerPageOption) } }, @@ -408,6 +450,11 @@ export default { this.$router.replace({ query: { ...this.$route.query, page, pageCursor } }) }, + handlePerPageChange (limit) { + this.$router.replace({ query: { ...this.$route.query, page: 1, limit } }) + this.$refs.resourceList.refresh() + }, + setDefaultValues () { this.selected = [], this.selectableItemIDs = [] diff --git a/locale/en/corteza-webapp-admin/general.yaml b/locale/en/corteza-webapp-admin/general.yaml index 9b65b3801..8e71002d6 100644 --- a/locale/en/corteza-webapp-admin/general.yaml +++ b/locale/en/corteza-webapp-admin/general.yaml @@ -37,6 +37,7 @@ label: plural: Workflows plus-add: + Add clear: Clear + all: All none: None now: Now today: Today @@ -53,3 +54,6 @@ label: fileTypeNotAllowed: File type not allowed editor: unsavedChanges: Unsaved changes will be lost. Do you wish to leave the page? +resourceList: + pagination: + recordsPerPage: 'Records per page:' diff --git a/locale/en/corteza-webapp-compose/general.yaml b/locale/en/corteza-webapp-compose/general.yaml index bb696e362..4ff760597 100644 --- a/locale/en/corteza-webapp-compose/general.yaml +++ b/locale/en/corteza-webapp-compose/general.yaml @@ -36,6 +36,7 @@ label: here: here home: Home import: Import + all: All importPlaceholder: Upload files to import loading: Loading makeDefault: Make default @@ -44,7 +45,6 @@ label: name: Name next: Next no: No - all: All noHandle: No handle none: None now: Now @@ -164,6 +164,7 @@ resourceList: showing: '{{from}} - {{to}} of {{count}} {{data}}' single: 'One {{data}}' single_plural: '{{count}} {{data}}' + recordsPerPage: 'Records per page:' recordNavigation: next: Next record prev: Previous record diff --git a/locale/en/corteza-webapp-discovery/general.yaml b/locale/en/corteza-webapp-discovery/general.yaml index 43af6853d..f710bbf9a 100644 --- a/locale/en/corteza-webapp-discovery/general.yaml +++ b/locale/en/corteza-webapp-discovery/general.yaml @@ -1,2 +1,7 @@ federated: Federated -no-values: No values \ No newline at end of file +no-values: No values +label: + all: All +resourceList: + pagination: + recordsPerPage: 'Records per page:' \ No newline at end of file diff --git a/locale/en/corteza-webapp-privacy/general.yaml b/locale/en/corteza-webapp-privacy/general.yaml index 4632fb8af..4e12b7427 100644 --- a/locale/en/corteza-webapp-privacy/general.yaml +++ b/locale/en/corteza-webapp-privacy/general.yaml @@ -1,5 +1,6 @@ label: back: Back + all: All privacy_request: single: Privacy Request plural: Privacy Requests @@ -19,3 +20,4 @@ resourceList: showing: '{{from}} - {{to}} of {{count}} {{data}}' single: 'One {{data}}' single_plural: '{{count}} {{data}}' + recordsPerPage: 'Records per page:' diff --git a/locale/en/corteza-webapp-reporter/general.yaml b/locale/en/corteza-webapp-reporter/general.yaml index ad041683d..e8f21f894 100644 --- a/locale/en/corteza-webapp-reporter/general.yaml +++ b/locale/en/corteza-webapp-reporter/general.yaml @@ -1,6 +1,7 @@ label: add: Add and: And + all: All ascending: Ascending back: Back clear: Clear @@ -31,3 +32,4 @@ resourceList: showing: '{{from}} - {{to}} of {{count}} {{data}}' single: 'One {{data}}' single_plural: '{{count}} {{data}}' + recordsPerPage: 'Records per page:' diff --git a/locale/en/corteza-webapp-workflow/general.yaml b/locale/en/corteza-webapp-workflow/general.yaml index 790045e9d..5a4a07b4c 100644 --- a/locale/en/corteza-webapp-workflow/general.yaml +++ b/locale/en/corteza-webapp-workflow/general.yaml @@ -11,7 +11,9 @@ import: label: Import reassign-run-as: "NOTE: the Run as workflow property won't be imported and should be reassigned" upload-files: Browse or drop files to upload... -label: Label +label: + all: All + label: Label loading: Loading name: Name new-workflow: New Workflow @@ -46,6 +48,7 @@ resourceList: showing: '{{from}} - {{to}} of {{count}} {{data}}' single: 'One {{data}}' single_plural: '{{count}} {{data}}' + recordsPerPage: 'Records per page:' tooltip: permissions: Workflow permissions