view data fixes
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
import type { MediaViewData } from '@/lib/view-data/MediaViewData';
|
||||
|
||||
import { ViewModel } from "../contracts/view-models/ViewModel";
|
||||
|
||||
type MediaAssetViewData = MediaViewData['assets'][number];
|
||||
import type { MediaAssetViewData } from "../view-data/MediaViewData";
|
||||
|
||||
/**
|
||||
* Media View Model
|
||||
@@ -11,23 +8,20 @@ type MediaAssetViewData = MediaViewData['assets'][number];
|
||||
* Represents a single media asset card in the UI.
|
||||
*/
|
||||
export class MediaViewModel extends ViewModel {
|
||||
id: string;
|
||||
src: string;
|
||||
title: string;
|
||||
category: string;
|
||||
date?: string;
|
||||
dimensions?: string;
|
||||
private readonly data: MediaAssetViewData;
|
||||
|
||||
constructor(viewData: MediaAssetViewData) {
|
||||
constructor(data: MediaAssetViewData) {
|
||||
super();
|
||||
this.id = viewData.id;
|
||||
this.src = viewData.src;
|
||||
this.title = viewData.title;
|
||||
this.category = viewData.category;
|
||||
if (viewData.date !== undefined) this.date = viewData.date;
|
||||
if (viewData.dimensions !== undefined) this.dimensions = viewData.dimensions;
|
||||
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}` : ''}`;
|
||||
|
||||
Reference in New Issue
Block a user