feat: v2.2 batch (calendar, self-service, sort, description, filename search, stats, collab, invoice) on pre-redesign base
This commit is contained in:
1 parent
453bece72c
commit
7204dd6b60
108 files changed
+10400
-105
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { recordActivity } from "@/modules/activity/service";
|
||||
import { AlbumCatalogError, albumCatalog, PHOTO_PAGE_SIZE } from "@/modules/albums/catalog";
|
||||
import { AlbumContactSheet, formatCount } from "@/modules/albums/catalog-content";
|
||||
import { filterPhotos, paginatePhotos, type InAppPage } from "@/modules/albums/filter";
|
||||
import { filterPhotos, normalizeSort, paginatePhotos, sortPhotos, type InAppPage, type PhotoSort } from "@/modules/albums/filter";
|
||||
import { PhotoGallery } from "@/modules/albums/photo-gallery";
|
||||
import { AnnouncementBanner } from "@/modules/announcements/announcement-banner";
|
||||
import { announcementService } from "@/modules/announcements/service";
|
||||
@@ -17,12 +18,13 @@ import { requireEditorial } from "../access";
|
||||
// up to 1000 matching photos, then filters/paginates in-app.
|
||||
const SEARCH_FETCH_SIZE = 1000;
|
||||
|
||||
export default async function AlbumsPage({ searchParams }: { searchParams: Promise<{ suche?: string | string[]; page?: string | string[]; format?: string | string[]; jahr?: string | string[] }> }) {
|
||||
export default async function AlbumsPage({ searchParams }: { searchParams: Promise<{ suche?: string | string[]; page?: string | string[]; format?: string | string[]; jahr?: string | string[]; sortierung?: string | string[] }> }) {
|
||||
const principal = await requireEditorial();
|
||||
const rawSearchParams = await searchParams;
|
||||
const query = normalizedQuery(singleValue(rawSearchParams.suche));
|
||||
const format = singleValue(rawSearchParams.format);
|
||||
const jahr = singleValue(rawSearchParams.jahr);
|
||||
const sortierung = normalizeSort(singleValue(rawSearchParams.sortierung));
|
||||
const hints = await announcementService.listActiveAnnouncements(new Date());
|
||||
|
||||
if (query) {
|
||||
@@ -35,12 +37,14 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
});
|
||||
} catch (error) {
|
||||
if (error instanceof AlbumCatalogError && error.code === "RATE_LIMITED") {
|
||||
return <SearchRateLimited query={query} format={format} jahr={jahr} />;
|
||||
return <SearchRateLimited query={query} format={format} jahr={jahr} sortierung={sortierung} />;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
|
||||
const filtered = filterPhotos(results.items, { format, jahr });
|
||||
await recordActivity({ editorialId: principal.editorialId, type: "search", query });
|
||||
|
||||
const filtered = sortPhotos(filterPhotos(results.items, { format, jahr }), sortierung);
|
||||
const { result: page, currentPage } = paginatePhotos(filtered, singleValue(rawSearchParams.page), PHOTO_PAGE_SIZE);
|
||||
|
||||
const downloadOptions = await loadEditorialDownloadOptions(
|
||||
@@ -58,7 +62,7 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
titleId="albums-title"
|
||||
/>
|
||||
<AnnouncementBanner items={hints} />
|
||||
<GlobalSearchForm query={query} format={format} jahr={jahr} />
|
||||
<GlobalSearchForm query={query} format={format} jahr={jahr} sortierung={sortierung} />
|
||||
<p aria-live="polite" className="result-summary" role="status">
|
||||
{formatCount(page.total, "Foto")} gefunden
|
||||
</p>
|
||||
@@ -69,7 +73,7 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
lightboxAssetIds={[...lightboxAssetIds]}
|
||||
showAlbumName
|
||||
/>
|
||||
<GlobalSearchPagination currentPage={currentPage} page={page} query={query} format={format} jahr={jahr} />
|
||||
<GlobalSearchPagination currentPage={currentPage} page={page} query={query} format={format} jahr={jahr} sortierung={sortierung} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -89,7 +93,7 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
description="Wählen Sie ein Spiel oder eine Serie, um die freigegebenen Fotos zu durchsuchen."
|
||||
/>
|
||||
<AnnouncementBanner items={hints} />
|
||||
<GlobalSearchForm query={query} format={format} jahr={jahr} />
|
||||
<GlobalSearchForm query={query} format={format} jahr={jahr} sortierung={sortierung} />
|
||||
{result.albums.length === 0 ? (
|
||||
<p className="text-muted-foreground text-center py-12">Für Ihre Redaktion sind noch keine Fotoalben freigegeben.</p>
|
||||
) : (
|
||||
@@ -99,11 +103,11 @@ export default async function AlbumsPage({ searchParams }: { searchParams: Promi
|
||||
);
|
||||
}
|
||||
|
||||
function SearchRateLimited({ query, format, jahr }: { query: string; format?: string; jahr?: string }) {
|
||||
function SearchRateLimited({ query, format, jahr, sortierung }: { query: string; format?: string; jahr?: string; sortierung: PhotoSort }) {
|
||||
return (
|
||||
<div className="space-y-6 max-w-7xl" aria-labelledby="albums-title">
|
||||
<PageHeader kicker="Bildarchiv · Suche" title="Bitte kurz warten" titleId="albums-title" />
|
||||
<GlobalSearchForm query={query} format={format} jahr={jahr} />
|
||||
<GlobalSearchForm query={query} format={format} jahr={jahr} sortierung={sortierung} />
|
||||
<p className="bg-muted p-4 rounded-md" role="status">
|
||||
Es wurden sehr viele Suchanfragen gestellt. Bitte versuchen Sie es in Kürze erneut.
|
||||
</p>
|
||||
@@ -111,7 +115,7 @@ function SearchRateLimited({ query, format, jahr }: { query: string; format?: st
|
||||
);
|
||||
}
|
||||
|
||||
function GlobalSearchForm({ query, format, jahr }: { query: string; format?: string; jahr?: string; }) {
|
||||
function GlobalSearchForm({ query, format, jahr, sortierung }: { query: string; format?: string; jahr?: string; sortierung: PhotoSort; }) {
|
||||
const currentYear = new Date().getFullYear();
|
||||
const years = Array.from({ length: 10 }, (_, i) => currentYear - i);
|
||||
|
||||
@@ -138,13 +142,17 @@ function GlobalSearchForm({ query, format, jahr }: { query: string; format?: str
|
||||
<option key={y} value={y.toString()}>{y}</option>
|
||||
))}
|
||||
</select>
|
||||
<select name="sortierung" defaultValue={sortierung} aria-label="Sortierung" className="flex h-10 w-full items-center justify-between rounded-md border border-border bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary-500 disabled:cursor-not-allowed disabled:opacity-50">
|
||||
<option value="neueste">Neueste zuerst</option>
|
||||
<option value="aelteste">Älteste zuerst</option>
|
||||
</select>
|
||||
<Button type="submit" variant="default">Suchen</Button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
function GlobalSearchPagination({ currentPage, page, query, format, jahr }: { currentPage: number; page: InAppPage; query: string; format?: string; jahr?: string }) {
|
||||
function GlobalSearchPagination({ currentPage, page, query, format, jahr, sortierung }: { currentPage: number; page: InAppPage; query: string; format?: string; jahr?: string; sortierung: PhotoSort }) {
|
||||
const hasPrev = currentPage > 1;
|
||||
const hasNext = page.nextPage !== null;
|
||||
if (!hasPrev && !hasNext) {
|
||||
@@ -154,19 +162,20 @@ function GlobalSearchPagination({ currentPage, page, query, format, jahr }: { cu
|
||||
return (
|
||||
<nav aria-label="Suchergebnisseiten" className="flex justify-between items-center mt-8 pt-4 border-t border-border text-sm font-medium">
|
||||
{hasPrev ? (
|
||||
<Link className="text-primary-600 hover:underline" href={globalPageHref(currentPage - 1, query, format, jahr)}>Vorherige Seite</Link>
|
||||
<Link className="text-primary-600 hover:underline" href={globalPageHref(currentPage - 1, query, format, jahr, sortierung)}>Vorherige Seite</Link>
|
||||
) : <div />}
|
||||
{hasNext ? (
|
||||
<Link className="text-primary-600 hover:underline" href={globalPageHref(currentPage + 1, query, format, jahr)}>Nächste Seite</Link>
|
||||
<Link className="text-primary-600 hover:underline" href={globalPageHref(currentPage + 1, query, format, jahr, sortierung)}>Nächste Seite</Link>
|
||||
) : <div />}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
function globalPageHref(page: number, query: string, format?: string, jahr?: string): string {
|
||||
function globalPageHref(page: number, query: string, format?: string, jahr?: string, sortierung?: PhotoSort): string {
|
||||
const parameters = new URLSearchParams({ suche: query, page: String(page) });
|
||||
if (format) parameters.set("format", format);
|
||||
if (jahr) parameters.set("jahr", jahr);
|
||||
if (sortierung === "aelteste") parameters.set("sortierung", sortierung);
|
||||
return `/redaktion/alben?${parameters.toString()}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user