Skip to content

Commit cb252d1

Browse files
committed
removed table dynamic items per page selection (makes no sence and causes errors when page is empty)
1 parent fc71b73 commit cb252d1

2 files changed

Lines changed: 42 additions & 44 deletions

File tree

client/src/pages/(app)/quiz-import/components/main-content/ImportExamMain.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,8 @@
107107
item-value="quiz_id"
108108
:items="quizzes?.content"
109109
:items-length="totalItems"
110-
:items-per-page="
111-
tableUtils.calcDefaultItemsPerPage(totalItems)
112-
"
113-
:items-per-page-options="
114-
tableUtils.calcItemsPerPage(totalItems)
115-
"
110+
:items-per-page="tableUtils.calcDefaultItemsPerPage()"
111+
:items-per-page-options="tableUtils.calcItemsPerPage()"
116112
:loading="isLoading"
117113
:loading-text="translate('general.loadingText')"
118114
style="min-height: 38vh"

client/src/utils/table/tableUtils.ts

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { BasicListParams, SortOrder } from "@/services/types";
1919
import router from "@/router/router";
2020
import type { RouteLocationAsRelative } from "vue-router";
2121

22-
type ItemsLike = number | { length: number } | null | undefined;
22+
//type ItemsLike = number | { length: number } | null | undefined;
2323
type ItemsPerPageOption = { value: number; title: string };
2424

2525
type Clickable = { click: () => void };
@@ -29,48 +29,50 @@ type HeaderRefs =
2929
| null
3030
| undefined;
3131

32-
export function calcDefaultItemsPerPage(itemList: ItemsLike): number {
33-
if (
34-
itemList == null ||
35-
(typeof itemList !== "number" && itemList.length === 0)
36-
) {
37-
return 0;
38-
}
32+
export function calcDefaultItemsPerPage(): number {
33+
// NOTE: @anhefti: this makes no sense, default size should not depend on result size it is just 15
34+
// if (
35+
// itemList == null ||
36+
// (typeof itemList !== "number" && itemList.length === 0)
37+
// ) {
38+
// return 5;
39+
// }
3940

40-
const maxLength = typeof itemList === "number" ? itemList : itemList.length;
41+
// const maxLength = typeof itemList === "number" ? itemList : itemList.length;
4142

42-
if (maxLength < 5) return maxLength;
43-
if (maxLength < 10) return 5;
44-
if (maxLength < 15) return 10;
43+
// if (maxLength < 5) return maxLength;
44+
// if (maxLength < 10) return 5;
45+
// if (maxLength < 15) return 10;
4546
return 15;
4647
}
4748

48-
export function calcItemsPerPage(itemList: ItemsLike): ItemsPerPageOption[] {
49-
if (
50-
itemList == null ||
51-
(typeof itemList !== "number" && itemList.length === 0)
52-
) {
53-
return [{ value: 0, title: "0" }];
54-
}
55-
56-
const maxLength = typeof itemList === "number" ? itemList : itemList.length;
57-
58-
if (maxLength <= 5) {
59-
return [{ value: maxLength, title: String(maxLength) }];
60-
}
61-
if (maxLength <= 10) {
62-
return [
63-
{ value: 5, title: "5" },
64-
{ value: maxLength, title: String(maxLength) },
65-
];
66-
}
67-
if (maxLength <= 15) {
68-
return [
69-
{ value: 5, title: "5" },
70-
{ value: 10, title: "10" },
71-
{ value: maxLength, title: String(maxLength) },
72-
];
73-
}
49+
export function calcItemsPerPage(): ItemsPerPageOption[] {
50+
// NOTE: @anhefti: this makes no sense, we should have just a static chooice of options here, not ependend on result size
51+
// if (
52+
// itemList == null ||
53+
// (typeof itemList !== "number" && itemList.length === 0)
54+
// ) {
55+
// return [{ value: 5, title: "5" }];
56+
// }
57+
58+
// const maxLength = typeof itemList === "number" ? itemList : itemList.length;
59+
60+
// if (maxLength <= 5) {
61+
// return [{ value: maxLength, title: String(maxLength) }];
62+
// }
63+
// if (maxLength <= 10) {
64+
// return [
65+
// { value: 5, title: "5" },
66+
// { value: maxLength, title: String(maxLength) },
67+
// ];
68+
// }
69+
// if (maxLength <= 15) {
70+
// return [
71+
// { value: 5, title: "5" },
72+
// { value: 10, title: "10" },
73+
// { value: maxLength, title: String(maxLength) },
74+
// ];
75+
// }
7476
return [
7577
{ value: 5, title: "5" },
7678
{ value: 10, title: "10" },

0 commit comments

Comments
 (0)