Support Individual Metadata Editing for Multiple Books
This commit is contained in:
committed by
Aditya Chandel
parent
82c843bbe5
commit
551234f02a
+1
-1
@@ -9,7 +9,7 @@
|
||||
<p-tab value="match">Search Metadata</p-tab>
|
||||
}
|
||||
</p-tablist>
|
||||
<p-tabpanels class="h-[calc(100vh-10rem)]">
|
||||
<p-tabpanels class="overflow-auto" style="height: calc(100vh - 10rem);">
|
||||
<p-tabpanel value="view">
|
||||
<app-metadata-viewer [book]="book" [recommendedBooks]="recommendedBooks"></app-metadata-viewer>
|
||||
</p-tabpanel>
|
||||
|
||||
@@ -20,5 +20,4 @@ export class BookMetadataCenterService {
|
||||
emitBookChanged(book: Book | null) {
|
||||
this.bookChangedSubject.next(book);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+26
-13
@@ -1,12 +1,13 @@
|
||||
@if (bookMetadata$ | async; as metadata) {
|
||||
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="pt-2 flex flex-col h-full">
|
||||
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="flex flex-col h-full">
|
||||
@if (isLoading) {
|
||||
<div class="absolute inset-0 bg-black opacity-25 z-10"></div>
|
||||
<div class="absolute inset-0 bg-black opacity-25 z-10 "></div>
|
||||
}
|
||||
@if (isLoading) {
|
||||
<p-progressSpinner [style]="{position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%, -50%)'}"></p-progressSpinner>
|
||||
}
|
||||
<div class="overflow-y-scroll flex-1">
|
||||
|
||||
<div class="flex-grow overflow-auto p-4">
|
||||
<div class="flex flex-row w-full gap-4">
|
||||
<div class="flex flex-col items-center gap-2 relative">
|
||||
<img
|
||||
@@ -349,7 +350,7 @@
|
||||
<p-tabpanels>
|
||||
<p-tabpanel value="editor">
|
||||
<form [formGroup]="metadataForm">
|
||||
<p-editor #quillEditor formControlName="description" [readonly]="quillDisabled()" [style]="{ height: '215px' }">
|
||||
<p-editor #quillEditor formControlName="description" [readonly]="quillDisabled()" [style]="{ height: '200px' }">
|
||||
<ng-template #header>
|
||||
<span class="ql-formats">
|
||||
<button class="ql-bold" aria-label="Bold"></button>
|
||||
@@ -383,7 +384,7 @@
|
||||
<p-tabpanel value="html" class="w-full">
|
||||
<textarea
|
||||
class="w-full p-4"
|
||||
rows="10"
|
||||
rows="9"
|
||||
[disabled]="quillDisabled()"
|
||||
[ngModel]="htmlTextarea"
|
||||
(ngModelChange)="onHtmlTextareaChange($event)"
|
||||
@@ -403,15 +404,27 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-x-4 mt-auto">
|
||||
|
||||
|
||||
<div class="mt-auto">
|
||||
<p-divider></p-divider>
|
||||
<div class="flex gap-x-4 justify-end">
|
||||
<p-button label="Restore Metadata" icon="pi pi-refresh" [outlined]="true" severity="danger" (onClick)="restoreMetadata()"></p-button>
|
||||
<p-divider layout="vertical"/>
|
||||
<p-button label="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()"></p-button>
|
||||
<p-button label="Lock All" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()"></p-button>
|
||||
<p-divider layout="vertical"/>
|
||||
<p-button label="Save" icon="pi pi-check" type="submit"></p-button>
|
||||
<div class="flex justify-between px-2 pt-1 pb-4 bg-gray-900 z-10">
|
||||
@if (showNavigationButtons) {
|
||||
<div class="flex gap-x-4">
|
||||
<p-button label="Close" icon="pi pi-times" [outlined]="true" severity="danger" (onClick)="closeDialog()"></p-button>
|
||||
<p-divider layout="vertical"/>
|
||||
<p-button label="Previous Book" [disabled]="disablePrevious" icon="pi pi-arrow-left" [outlined]="true" severity="info" (onClick)="onPrevious()"></p-button>
|
||||
<p-button label="Next Book" [disabled]="disableNext" icon="pi pi-arrow-right" iconPos="right" [outlined]="true" severity="info" (onClick)="onNext()"></p-button>
|
||||
</div>
|
||||
}
|
||||
<div class="flex gap-x-4 items-center ml-auto">
|
||||
<p-button label="Restore Metadata" icon="pi pi-refresh" [outlined]="true" severity="danger" (onClick)="restoreMetadata()"></p-button>
|
||||
<p-divider layout="vertical"/>
|
||||
<p-button label="Unlock All" icon="pi pi-lock-open" [outlined]="true" severity="success" (onClick)="unlockAll()"></p-button>
|
||||
<p-button label="Lock All" icon="pi pi-lock" [outlined]="true" severity="warn" (onClick)="lockAll()"></p-button>
|
||||
<p-divider layout="vertical"/>
|
||||
<p-button label="Save" icon="pi pi-check" [loading]="isSaving" [disabled]="isSaving" type="submit"></p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
+24
-2
@@ -1,4 +1,4 @@
|
||||
import {Component, inject, OnInit, ViewChild} from '@angular/core';
|
||||
import {Component, EventEmitter, inject, Input, OnInit, Output, ViewChild} from '@angular/core';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Divider} from 'primeng/divider';
|
||||
@@ -48,6 +48,14 @@ export class MetadataEditorComponent implements OnInit {
|
||||
|
||||
@ViewChild(Editor) quillEditor!: Editor;
|
||||
|
||||
@Output() nextBookClicked = new EventEmitter<void>();
|
||||
@Output() previousBookClicked = new EventEmitter<void>();
|
||||
@Output() closeDialogButtonClicked = new EventEmitter<void>();
|
||||
|
||||
@Input() disableNext = false;
|
||||
@Input() disablePrevious = false;
|
||||
@Input() showNavigationButtons = false;
|
||||
|
||||
private metadataCenterService = inject(BookMetadataCenterService);
|
||||
private messageService = inject(MessageService);
|
||||
private bookService = inject(BookService);
|
||||
@@ -60,6 +68,7 @@ export class MetadataEditorComponent implements OnInit {
|
||||
isUploading = false;
|
||||
isLoading = false;
|
||||
htmlTextarea = '';
|
||||
isSaving = false;
|
||||
|
||||
constructor() {
|
||||
this.metadataForm = new FormGroup({
|
||||
@@ -233,12 +242,15 @@ export class MetadataEditorComponent implements OnInit {
|
||||
}
|
||||
|
||||
onSave(): void {
|
||||
this.isSaving = true;
|
||||
this.bookService.updateBookMetadata(this.currentBookId, this.buildMetadata(undefined), false).subscribe({
|
||||
next: (response) => {
|
||||
this.isSaving = false;
|
||||
this.messageService.add({severity: 'info', summary: 'Success', detail: 'Book metadata updated'});
|
||||
this.metadataCenterService.emitMetadata(response);
|
||||
},
|
||||
error: (err) => {
|
||||
this.isSaving = false;
|
||||
console.error('Update metadata failed:', err);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
@@ -363,7 +375,6 @@ export class MetadataEditorComponent implements OnInit {
|
||||
this.bookService.updateBookMetadata(this.currentBookId, this.buildMetadata(shouldLockAllFields), false).subscribe({
|
||||
next: (response) => {
|
||||
this.metadataCenterService.emitMetadata(response);
|
||||
|
||||
if (shouldLockAllFields !== undefined) {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
@@ -444,4 +455,15 @@ export class MetadataEditorComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
onNext() {
|
||||
this.nextBookClicked.emit();
|
||||
}
|
||||
|
||||
onPrevious() {
|
||||
this.previousBookClicked.emit();
|
||||
}
|
||||
|
||||
closeDialog() {
|
||||
this.closeDialogButtonClicked.emit();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
<div class="pt-2 flex flex-col h-full overflow-hidden">
|
||||
<div class="pt-2 flex flex-col h-full">
|
||||
@if (metadata$ | async; as metadata) {
|
||||
<div>
|
||||
<div class="flex flex-row">
|
||||
@@ -287,7 +287,7 @@
|
||||
<p-divider></p-divider>
|
||||
|
||||
@if (metadata$ | async; as metadata) {
|
||||
<div class="flex-1 overflow-auto space-y-2 px-2">
|
||||
<div class="flex-1 space-y-2 px-2">
|
||||
<div [ngClass]="{ 'line-clamp-5': !isExpanded, 'line-clamp-none': isExpanded }" class="transition-all duration-300 overflow-hidden description-container">
|
||||
<div class="readonly-editor px-2">
|
||||
<p-editor #quillEditor [readonly]="true" [style]="{height: '250px'}" [(ngModel)]="metadata.description">
|
||||
|
||||
Reference in New Issue
Block a user