perf(ui): remove unpaginated details from bulk book dialogs (#2704)
This commit is contained in:
+1
-15
@@ -8,7 +8,7 @@
|
||||
@if (isLibraryRefresh) {
|
||||
<p class="panel-description">Library-level custom metadata fetch</p>
|
||||
} @else {
|
||||
<p class="panel-description">{{ booksToShow.length }} books selected</p>
|
||||
<p class="panel-description">{{ bookIds.length }} books selected</p>
|
||||
}
|
||||
</div>
|
||||
<p-button
|
||||
@@ -22,20 +22,6 @@
|
||||
</div>
|
||||
|
||||
<div class="dialog-content">
|
||||
@if (!isLibraryRefresh) {
|
||||
<div class="book-list-section">
|
||||
<div class="book-list-container">
|
||||
<ul class="book-list">
|
||||
@for (book of booksToShow; track book.id) {
|
||||
<li>
|
||||
<span class="book-id">#{{ book.id }}</span>: {{ book.metadata?.title || 'Untitled' }}
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<app-metadata-fetch-options
|
||||
[dialogData]="{ bookIds: bookIds, libraryId: libraryId, metadataRefreshType: metadataRefreshType }"></app-metadata-fetch-options>
|
||||
</div>
|
||||
|
||||
-31
@@ -34,37 +34,6 @@
|
||||
box-shadow: 0 2px 6px rgb(0 0 0 / 8%);
|
||||
}
|
||||
|
||||
.book-list-section {
|
||||
flex-shrink: 0;
|
||||
margin-bottom: 0.875rem;
|
||||
}
|
||||
|
||||
.book-list-container {
|
||||
max-height: 5.25rem;
|
||||
overflow: auto;
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: 0.2188rem;
|
||||
padding: 0.4375rem;
|
||||
font-size: var(--app-text-sm);
|
||||
}
|
||||
|
||||
.book-list {
|
||||
list-style-type: disc;
|
||||
padding-left: 1.0938rem;
|
||||
|
||||
li {
|
||||
margin-bottom: 0.2188rem;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.book-id {
|
||||
color: var(--color-text-secondary);
|
||||
}
|
||||
|
||||
::ng-deep app-metadata-fetch-options {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
|
||||
+1
-17
@@ -5,22 +5,13 @@ import {DynamicDialogConfig, DynamicDialogRef} from '@openng/optimus-ui/dynamicd
|
||||
|
||||
import {AppSettings} from '../../../../shared/model/app-settings.model';
|
||||
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
||||
import {Book} from '../../../book/model/book.model';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {MetadataRefreshType} from '../../model/request/metadata-refresh-type.enum';
|
||||
import {MultiBookMetadataFetchComponent} from './multi-book-metadata-fetch-component';
|
||||
|
||||
describe('MultiBookMetadataFetchComponent', () => {
|
||||
const appSettings = signal<AppSettings | null>(null);
|
||||
const getBooksByIds = vi.fn((bookIds: number[]) => bookIds.map(bookId => ({
|
||||
id: bookId,
|
||||
title: `Book ${bookId}`,
|
||||
libraryId: 1,
|
||||
libraryName: 'Library',
|
||||
} satisfies Book)));
|
||||
|
||||
beforeEach(() => {
|
||||
getBooksByIds.mockClear();
|
||||
appSettings.set(null);
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
@@ -35,23 +26,17 @@ describe('MultiBookMetadataFetchComponent', () => {
|
||||
},
|
||||
},
|
||||
{provide: DynamicDialogRef, useValue: {close: vi.fn()}},
|
||||
{provide: BookService, useValue: {getBooksByIds}},
|
||||
{provide: AppSettingsService, useValue: {appSettings}},
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
it('reads dialog data and resolves the books to show on construction', () => {
|
||||
it('reads dialog data on construction', () => {
|
||||
const component = TestBed.runInInjectionContext(() => new MultiBookMetadataFetchComponent());
|
||||
component.ngOnInit();
|
||||
|
||||
expect(component.bookIds).toEqual([3, 5]);
|
||||
expect(component.metadataRefreshType).toBe(MetadataRefreshType.BOOKS);
|
||||
expect(getBooksByIds).toHaveBeenCalledWith([3, 5]);
|
||||
expect(component.booksToShow).toEqual([
|
||||
{id: 3, title: 'Book 3', libraryId: 1, libraryName: 'Library'},
|
||||
{id: 5, title: 'Book 5', libraryId: 1, libraryName: 'Library'},
|
||||
]);
|
||||
});
|
||||
|
||||
it('gives precedence to dialogData Input over dynamicDialogConfig.data', () => {
|
||||
@@ -63,7 +48,6 @@ describe('MultiBookMetadataFetchComponent', () => {
|
||||
component.ngOnInit();
|
||||
|
||||
expect(component.bookIds).toEqual([10]);
|
||||
expect(getBooksByIds).toHaveBeenCalledWith([10]);
|
||||
});
|
||||
|
||||
it('adopts the default metadata refresh options when app settings become available', () => {
|
||||
|
||||
-5
@@ -4,9 +4,7 @@ import {MetadataRefreshType} from '../../model/request/metadata-refresh-type.enu
|
||||
import {MetadataRefreshOptions} from '../../model/request/metadata-refresh-options.model';
|
||||
|
||||
import {DynamicDialogConfig, DynamicDialogRef} from '@openng/optimus-ui/dynamicdialog';
|
||||
import {BookService} from '../../../book/service/book.service';
|
||||
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
||||
import {Book} from '../../../book/model/book.model';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {MetadataFetchOptionsComponent} from '../metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
||||
import {Button} from '@openng/optimus-ui/button';
|
||||
@@ -27,13 +25,11 @@ export class MultiBookMetadataFetchComponent implements OnInit, OnChanges {
|
||||
|
||||
bookIds: number[] = [];
|
||||
libraryId: number | null = null;
|
||||
booksToShow: Book[] = [];
|
||||
metadataRefreshType: MetadataRefreshType = MetadataRefreshType.BOOKS;
|
||||
currentMetadataOptions!: MetadataRefreshOptions;
|
||||
|
||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||
dialogRef = inject(DynamicDialogRef);
|
||||
private bookService = inject(BookService);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
expanded = false;
|
||||
|
||||
@@ -64,7 +60,6 @@ export class MultiBookMetadataFetchComponent implements OnInit, OnChanges {
|
||||
this.bookIds = context.bookIds ?? [];
|
||||
this.libraryId = context.libraryId ?? null;
|
||||
this.metadataRefreshType = context.metadataRefreshType ?? MetadataRefreshType.BOOKS;
|
||||
this.booksToShow = this.bookService.getBooksByIds(this.bookIds);
|
||||
}
|
||||
|
||||
get isLibraryRefresh(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user