Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add meetings per page #1136

Merged
merged 1 commit into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/resources/js/components/MeetingsList.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { onMount } from 'svelte';
import { Button, ButtonGroup, Checkbox, Dropdown, Indicator, TableBody, TableBodyCell, TableBodyRow, TableHead, TableHeadCell, TableSearch } from 'flowbite-svelte';
import { Button, ButtonGroup, Checkbox, Dropdown, Indicator, Label, Select, TableBody, TableBodyCell, TableBodyRow, TableHead, TableHeadCell, TableSearch } from 'flowbite-svelte';
import { ChevronDownOutline, ChevronLeftOutline, ChevronRightOutline, ChevronUpOutline, FilterSolid, PlusOutline } from 'flowbite-svelte-icons';

import { convertTo12Hour, is24hrTime, isCommaSeparatedNumbers } from '../lib/utils';
Expand All @@ -24,7 +24,8 @@
let classInput = 'text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block w-full p-2 pl-10';
let searchTerm: string = '';
let currentPosition: number = 0;
const itemsPerPage: number = 20;
let itemsPerPage: number = 20;
const itemsPerPageItems = [10, 20, 40, 60, 80, 100].map((value) => ({ value, name: value.toString() }));
const showPage: number = 5;
let totalPages: number = 0;
let pagesToShow: number[] = [];
Expand Down Expand Up @@ -151,6 +152,11 @@
renderPagination(filteredItems.length);
};

const updateItemsPerPage = () => {
currentPosition = 0; // Reset to first page when itemsPerPage changes
renderPagination(filteredItems.length);
};

function handleSort(column: keyof Meeting) {
if (sortColumn === column) {
sortDirection = sortDirection === 'asc' ? 'desc' : 'asc';
Expand Down Expand Up @@ -350,11 +356,16 @@
</TableBody>
<div slot="footer" class="flex flex-col items-start justify-between space-y-3 p-4 md:flex-row md:items-center md:space-y-0 {meetings.length ? '' : 'hidden'}" aria-label="Table navigation">
{#if meetings.length}
<span class="text-sm font-normal text-gray-500 dark:text-gray-400">
{$translations.paginationShowing}
<span class="flex items-center space-x-1 text-sm font-normal text-gray-500 dark:text-gray-400">
<span>{$translations.paginationShowing}</span>
<span class="font-semibold text-gray-900 dark:text-white">{startRange}-{endRange}</span>
{$translations.paginationOf}
<span>{$translations.paginationOf}</span>
<span class="font-semibold text-gray-900 dark:text-white">{filteredItems.length}</span>
<span class="mx-2 text-gray-500 dark:text-gray-400">/</span>
<span class="ml-4 flex items-center space-x-1">
<Label for="itemsPerPage" class="text-sm font-medium text-gray-700 dark:text-gray-300">{$translations.meetingsPerPage}</Label>
<Select id="itemsPerPage" items={itemsPerPageItems} bind:value={itemsPerPage} name="itemsPerPage" class="w-20 dark:bg-gray-600" on:change={updateItemsPerPage} />
</span>
</span>
<ButtonGroup>
<Button on:click={loadPreviousPage} disabled={currentPosition === 0}>
Expand Down
2 changes: 2 additions & 0 deletions src/resources/js/stores/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const strings = new LocalizedStrings({
meetingErrorsSomewhere: 'Seiten mit einem oder mehreren Fehlern:',
meetingIsPublishedTitle: 'Meeting ist veröffentlicht',
meetingListEditorsTitle: 'Meetingsliste Editors', // TODO: check translation
meetingsPerPage: 'Meetings per page', // TODO: Translate
meetingsTitle: 'Meetings',
meetingUnpublishedNote:
'Hinweis: Das Aufheben der Veröffentlichung eines Meetings bedeutet, dass es vorübergehend geschlossen wurde. Wenn dieses Meeting dauerhaft geschlossen wurde, lösch es bitte.',
Expand Down Expand Up @@ -290,6 +291,7 @@ const strings = new LocalizedStrings({
meetingErrorsSomewhere: 'Tabs with one or more errors:',
meetingIsPublishedTitle: 'Meeting is Published',
meetingListEditorsTitle: 'Meeting List Editors',
meetingsPerPage: 'Meetings per page',
meetingsTitle: 'Meetings',
meetingUnpublishedNote: 'Note: Unpublishing a meeting indicates a temporary closure. If this meeting has closed permanently, please delete it.',
minutesTitle: 'Minutes',
Expand Down