Skip to content

Commit 25c7652

Browse files
authored
Merge pull request #185
* feat: changeable items per table page * Merge branch 'main' into main
1 parent c0e2aa5 commit 25c7652

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

frontend/components/Item/View/Table.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,14 @@
6363
</tr>
6464
</tbody>
6565
</table>
66-
<div v-if="hasPrev || hasNext" class="border-t p-3 justify-end flex">
66+
<div v-if="items.length > 10" class="border-t p-3 justify-end flex gap-3">
67+
<div class="flex items-center">Rows per page</div>
68+
<select v-model.number="pagination.rowsPerPage" class="select select-sm select-primary">
69+
<option :value="10">10</option>
70+
<option :value="25">25</option>
71+
<option :value="50">50</option>
72+
<option :value="100">100</option>
73+
</select>
6774
<div class="btn-group">
6875
<button :disabled="!hasPrev" class="btn btn-sm" @click="prev()">«</button>
6976
<button class="btn btn-sm">Page {{ pagination.page }}</button>
@@ -97,13 +104,22 @@
97104
] as TableHeader[];
98105
});
99106
107+
const preferences = useViewPreferences();
108+
100109
const pagination = reactive({
101110
descending: false,
102111
page: 1,
103-
rowsPerPage: 10,
112+
rowsPerPage: preferences.value.itemsPerTablePage,
104113
rowsNumber: 0,
105114
});
106115
116+
watch(
117+
() => pagination.rowsPerPage,
118+
newRowsPerPage => {
119+
preferences.value.itemsPerTablePage = newRowsPerPage;
120+
}
121+
);
122+
107123
const next = () => pagination.page++;
108124
const hasNext = computed<boolean>(() => {
109125
return pagination.page * pagination.rowsPerPage < props.items.length;

frontend/composables/use-preferences.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type LocationViewPreferences = {
99
editorAdvancedView: boolean;
1010
itemDisplayView: ViewType;
1111
theme: DaisyTheme;
12+
itemsPerTablePage: number;
1213
};
1314

1415
/**
@@ -24,6 +25,7 @@ export function useViewPreferences(): Ref<LocationViewPreferences> {
2425
editorAdvancedView: false,
2526
itemDisplayView: "card",
2627
theme: "homebox",
28+
itemsPerTablePage: 10,
2729
},
2830
{ mergeDefaults: true }
2931
);

0 commit comments

Comments
 (0)