Add two React SPA editor screens over the existing REST APIs, retiring the last two "Classic UI only" media-collection editors. MultiCollectionsScreen (/app/multi-collections, #151): list + in-screen editor. Name + a list of manual/smart collection items, each with a Schedule-As-Group toggle; two add-pickers dedupe already-present entries. Items save with playbackOrder "Chronological" (matches the Blazor editor). RerunCollectionsScreen (/app/rerun-collections, #152): list + in-screen editor. Name, a Collection Type select restricted to the REST-supported selection set (IsSupportedSelectionType) — Collection/MultiCollection/ SmartCollection plus the media-item types TelevisionShow/TelevisionSeason/ Artist/Movie/Episode/MusicVideo/OtherVideo/Song/Image/RemoteStream (every one maps to a working LibraryBrowseMediaType picker); Playlist is excluded. A conditional single-selection picker per type, and First/Rerun playback order selects with the Blazor type-conditional option sets (reset on type change). Both screens toggle list<->editor via local state (mirroring CollectionsScreen), no sub-path routing. Wired into App.tsx (imports, ScreenId, routes, mediaNavIds, ScreenContent). Added messageFrom*Error helpers + type re-export to the api clients. Tests: multiCollections/rerunCollections api-client param+body tests, both screen tests (list render, create body, rerun type-switch swaps picker + order options, delete), and an App.tsx nav-registration test. Docs: blazor-route-parity.md (rows moved to SPA DONE), domain-model.md. web verify gate: 353 tests pass, eslint clean, tsc -b + vite build clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
67 lines
2.3 KiB
TypeScript
67 lines
2.3 KiB
TypeScript
import { ApiError, request } from './client';
|
|
import type { components } from './generated/v1';
|
|
|
|
export type MultiCollection = components['schemas']['MultiCollectionResponseModel'];
|
|
export type MultiCollectionItem = components['schemas']['MultiCollectionItemResponseModel'];
|
|
export type MultiCollectionItemRequest = components['schemas']['MultiCollectionItemRequest'];
|
|
export type PagedMultiCollections = components['schemas']['PagedMultiCollectionsResponseModel'];
|
|
export type CreateMultiCollectionRequest = components['schemas']['CreateMultiCollectionRequest'];
|
|
export type UpdateMultiCollectionRequest = components['schemas']['UpdateMultiCollectionRequest'];
|
|
|
|
export interface GetMultiCollectionsParams {
|
|
query?: string;
|
|
pageNum?: number;
|
|
pageSize?: number;
|
|
}
|
|
|
|
export function getMultiCollections(params: GetMultiCollectionsParams = {}): Promise<PagedMultiCollections> {
|
|
const searchParams = new URLSearchParams();
|
|
|
|
if (params.query != null) {
|
|
searchParams.set('query', params.query);
|
|
}
|
|
|
|
if (params.pageNum != null) {
|
|
searchParams.set('pageNum', String(params.pageNum));
|
|
}
|
|
|
|
if (params.pageSize != null) {
|
|
searchParams.set('pageSize', String(params.pageSize));
|
|
}
|
|
|
|
const queryString = searchParams.toString();
|
|
|
|
return request<PagedMultiCollections>(`/api/multi-collections${queryString ? `?${queryString}` : ''}`);
|
|
}
|
|
|
|
export function getMultiCollection(id: number): Promise<MultiCollection> {
|
|
return request<MultiCollection>(`/api/multi-collections/${id}`);
|
|
}
|
|
|
|
export function createMultiCollection(body: CreateMultiCollectionRequest): Promise<MultiCollection> {
|
|
return request<MultiCollection>('/api/multi-collections', { body, method: 'POST' });
|
|
}
|
|
|
|
export function updateMultiCollection(id: number, body: UpdateMultiCollectionRequest): Promise<MultiCollection> {
|
|
return request<MultiCollection>(`/api/multi-collections/${id}`, { body, method: 'PUT' });
|
|
}
|
|
|
|
export function deleteMultiCollection(id: number): Promise<void> {
|
|
return request<void>(`/api/multi-collections/${id}`, { method: 'DELETE' });
|
|
}
|
|
|
|
export function messageFromMultiCollectionError(
|
|
error: unknown,
|
|
fallback = 'Unable to load multi-collections'
|
|
): string {
|
|
if (error instanceof ApiError) {
|
|
return error.detail ?? error.message;
|
|
}
|
|
|
|
if (error instanceof Error) {
|
|
return error.message;
|
|
}
|
|
|
|
return fallback;
|
|
}
|