35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import { ViewModel } from "../contracts/view-models/ViewModel";
|
|
import type { MediaAssetViewData } from "../view-data/MediaViewData";
|
|
|
|
/**
|
|
* Media View Model
|
|
*
|
|
* Client-only ViewModel created from ViewData (never DTO).
|
|
* Represents a single media asset card in the UI.
|
|
*/
|
|
export class MediaViewModel extends ViewModel {
|
|
private readonly data: MediaAssetViewData;
|
|
|
|
constructor(data: MediaAssetViewData) {
|
|
super();
|
|
this.data = data;
|
|
}
|
|
|
|
get id(): string { return this.data.id; }
|
|
get src(): string { return this.data.src; }
|
|
get title(): string { return this.data.title; }
|
|
get category(): string { return this.data.category; }
|
|
get date(): string | undefined { return this.data.date; }
|
|
get dimensions(): string | undefined { return this.data.dimensions; }
|
|
|
|
/** UI-specific: Combined subtitle used by MediaCard */
|
|
get subtitle(): string {
|
|
return `${this.category}${this.dimensions ? ` • ${this.dimensions}` : ''}`;
|
|
}
|
|
|
|
/** UI-specific: Whether any metadata is present */
|
|
get hasMetadata(): boolean {
|
|
return !!this.date || !!this.dimensions;
|
|
}
|
|
}
|