WIP: Locking

This commit is contained in:
aditya.chandel
2025-01-25 22:02:37 -07:00
parent a298f12649
commit 596207b0c5
14 changed files with 456 additions and 108 deletions
@@ -36,6 +36,26 @@ export interface BookMetadata {
categories: Category[];
awards?: Award[];
titleLocked?: boolean;
subtitleLocked?: boolean;
publisherLocked?: boolean;
publishedDateLocked?: boolean;
descriptionLocked?: boolean;
seriesNameLocked?: boolean;
seriesNumberLocked?: boolean;
seriesTotalLocked?: boolean;
isbn13Locked?: boolean;
isbn10Locked?: boolean;
asinLocked?: boolean;
pageCountLocked?: boolean;
languageLocked?: boolean;
ratingLocked?: boolean;
reviewCountLocked?: boolean;
coverUpdatedOnLocked?: boolean;
authorsLocked?: boolean;
categoriesLocked?: boolean;
awardsLocked?: boolean;
[key: string]: any;
}
@@ -203,4 +203,21 @@ export class BookService {
const book = this.bookStateSubject.value.books?.find(book => book.id === bookId);
return book?.metadata ?? null;
}
updateLock(bookId: number, field: string, isLocked: boolean): void {
const currentState = this.bookStateSubject.value;
const updatedBooks = (currentState.books || []).map(book => {
if (book.id === bookId && book.metadata) {
return {
...book,
metadata: {
...book.metadata,
[`${field}Locked`]: isLocked
}
};
}
return book;
});
this.bookStateSubject.next({...currentState, books: updatedBooks});
}
}