The base structure

First, add the base structure of the class to mediaman.ts:

class HTMLMediaManView implements MediaManView { 
    private readonly _newBookCollectionForm: HTMLFormElement; 
    private readonly _newBookCollectionName: HTMLInputElement; 
    private readonly _bookCollectionsContainer: HTMLDivElement; 
 
    private readonly _genreOptions: string = ""; 
 
    constructor() { 
        this._newBookCollectionForm = 
document.getElementById('newBookCollection')
as HTMLFormElement; this._newBookCollectionName =
document.getElementById('newBookCollectionName') as
HTMLInputElement; this._bookCollectionsContainer =
document.getElementById("bookCollections")
as HTMLDivElement; if (!this._newBookCollectionForm) { throw new Error("Could not initialize the view. The
'newBookCollection' element id was not found. Was the
template changed?"); } if (!this._newBookCollectionName) { throw new Error("Could not initialize the view. The
'newBookCollectionName' element id was not found. Was the
template changed?"); } if (!this._bookCollectionsContainer) { throw new Error("Could not initialize the view. The
'bookCollections' element id was not found. Was the
template changed?"); } for (let genreKey in Genre) { this._genreOptions += `<option
value="${genreKey}">${Genre[genreKey]}</option>">`; } }

// Add the methods here }

In the constructor, we directly retrieve some DOM elements that we will use later:

If those cannot be found, then there's probably a bug to fix; so, again, the sooner we know, the better.

Finally, we also generate a list of <option> elements corresponding to the entries in our Genre enum. We'll use this when we generate the form used to create new books in the renderBookCollection method.

You can also add method skeletons for now:

    getNewBookCollectionName(): string { 
        ... 
    } 
 
    clearNewBookCollectionForm(): void { 
        ... 
    } 
 
    renderBookCollection(bookCollection: 
Readonly<MediaCollection<Book>>): void { ... } displayErrorMessage(message: string): void { ... } clearBookCollections(): void { ... } removeBookCollection(identifier: string): void { ... } getNewBookDetails(collectionIdentifier: string): { error?:
string, book?: Book } { ... } renderBook(collectionIdentifier: string, book: Readonly<Book>):
void { ... } removeBook(collectionIdentifier: string, bookIdentifier: string):
void { ... } clearNewBookForm(collectionIdentifier: string): void { ... }

Next, we will implement those methods one by one.