Skip to content

Commit 976d81c

Browse files
committed
feat: with pageNumber
1 parent 8a121c7 commit 976d81c

File tree

5 files changed

+20
-2
lines changed

5 files changed

+20
-2
lines changed

packages/common-helpers/src/locale/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export const localeTable: tLocaleTable = {
198198
export const localePagination: tLocalePagination = {
199199
pagination_items: "No items | Single item | {count} items",
200200
pagination_pages: "No pages | Single page | {count} pages",
201+
pagination_page: "Page {count} of",
201202
// swal: {},
202203
};
203204

packages/common-helpers/src/locale/es.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ export const localeTable: tLocaleTable = {
199199
export const localePagination: tLocalePagination = {
200200
pagination_items: "Sin elementos | Único elemento | {count} elementos",
201201
pagination_pages: "Sin páginas | Única página | {count} páginas",
202+
pagination_page: "Página {count} de",
202203
// swal: {},
203204
};
204205

packages/common-types/src/fetch.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface iPageEdge<T, C extends string | number = string> {
1616
export interface iPageInfo<C extends string | number = string> {
1717
nextCursor?: C;
1818
previousCursor?: C;
19+
pageNumber?: number;
1920
hasNextPage: boolean;
2021
hasPreviousPage: boolean;
2122
path?: string;

packages/common-types/src/locale.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ export type tLocalePagination = {
299299
pagination_items: string;
300300
/** @example "No pages | Single page | {count} pages" */
301301
pagination_pages: string;
302+
/** @example "Page {count} of" */
303+
pagination_page: string;
302304
// swal: {};
303305
};
304306

packages/components-vue/src/components/pagination/Simple.vue

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<p class="--txtSize-sm">
1111
{{ t("pagination_items", currentPage.totalCount) }}
1212
13-
{{ t("pagination_pages", Math.ceil(currentPage.totalCount / modelValue.first)) }}
13+
{{ pageCountText }}
1414
</p>
1515
</li>
1616
<li v-if="!hidePageLength && currentPage.totalCount > 5">
@@ -113,9 +113,22 @@
113113
* PaginationSimple first model
114114
*/
115115
const firstModel = computed({
116-
get: () => props.modelValue?.first ?? defaultFirst,
116+
get: () => props.modelValue?.first ?? defaultFirst ?? 0,
117117
set(first) {
118118
emit("update:model-value", { ...props.modelValue, first });
119119
},
120120
});
121+
122+
const pageCountText = computed(() => {
123+
const totalCount = props.currentPage?.totalCount ?? 0;
124+
const pagesText = t("pagination_pages", Math.ceil(totalCount / firstModel.value));
125+
126+
if (!props.currentPage?.pageInfo.pageNumber) {
127+
const pageText = t("pagination_page", props.currentPage?.pageInfo.pageNumber);
128+
129+
return `${pageText} ${pagesText}`;
130+
}
131+
132+
return pagesText;
133+
});
121134
</script>

0 commit comments

Comments
 (0)