perf(ui): remove unpaginated details from bulk book dialogs (#2704)
This commit is contained in:
+1
-25
@@ -5,7 +5,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="header-text">
|
<div class="header-text">
|
||||||
<h2 class="panel-title">Bulk Edit Metadata</h2>
|
<h2 class="panel-title">Bulk Edit Metadata</h2>
|
||||||
<p class="panel-description">{{ books.length }} book{{ books.length !== 1 ? 's' : '' }} selected</p>
|
<p class="panel-description">{{ bookIds.length }} book{{ bookIds.length !== 1 ? 's' : '' }} selected</p>
|
||||||
</div>
|
</div>
|
||||||
<p-button
|
<p-button
|
||||||
icon="pi pi-times"
|
icon="pi pi-times"
|
||||||
@@ -24,30 +24,6 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="info-box">
|
|
||||||
<div class="info-header">
|
|
||||||
<p class="info-title">
|
|
||||||
Editing {{ books.length }} Book{{ books.length !== 1 ? 's' : '' }}
|
|
||||||
</p>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
(click)="showBookList = !showBookList"
|
|
||||||
class="toggle-list-btn">
|
|
||||||
{{ showBookList ? 'Hide' : 'Show' }} Titles
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@if (showBookList) {
|
|
||||||
<div class="book-list-panel">
|
|
||||||
<ul class="book-list">
|
|
||||||
@for (book of books; track book.id) {
|
|
||||||
<li>{{ book.metadata?.title || 'Untitled Book' }}</li>
|
|
||||||
}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="warning-text">
|
<div class="warning-text">
|
||||||
<i class="pi pi-exclamation-triangle warning-icon"></i>
|
<i class="pi pi-exclamation-triangle warning-icon"></i>
|
||||||
Checking <strong>Clear</strong> will remove that field's metadata from <strong>all selected books</strong>.
|
Checking <strong>Clear</strong> will remove that field's metadata from <strong>all selected books</strong>.
|
||||||
|
|||||||
-52
@@ -34,58 +34,6 @@
|
|||||||
background: color-mix(in srgb, var(--color-surface-950) 60%, transparent);
|
background: color-mix(in srgb, var(--color-surface-950) 60%, transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
.info-box {
|
|
||||||
padding: 0.875rem;
|
|
||||||
border: 1px solid var(--color-border);
|
|
||||||
border-radius: 0.3281rem;
|
|
||||||
margin-bottom: 0.875rem;
|
|
||||||
background: var(--color-page);
|
|
||||||
color: var(--color-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
.info-header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 0.4375rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.info-title {
|
|
||||||
font-size: var(--app-text-base);
|
|
||||||
font-weight: 600;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle-list-btn {
|
|
||||||
font-size: var(--app-text-sm);
|
|
||||||
color: var(--color-primary-text);
|
|
||||||
background: none;
|
|
||||||
border: none;
|
|
||||||
cursor: pointer;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.book-list-panel {
|
|
||||||
max-height: 10.5rem;
|
|
||||||
overflow-y: auto;
|
|
||||||
border-top: 1px solid var(--color-border);
|
|
||||||
padding-top: 0.4375rem;
|
|
||||||
padding-left: 0.2188rem;
|
|
||||||
font-size: var(--app-text-sm);
|
|
||||||
color: var(--color-text-secondary);
|
|
||||||
}
|
|
||||||
|
|
||||||
.book-list {
|
|
||||||
list-style-type: disc;
|
|
||||||
padding-left: 1.0938rem;
|
|
||||||
|
|
||||||
li + li {
|
|
||||||
margin-top: 0.2188rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.warning-text {
|
.warning-text {
|
||||||
padding: 0 0.875rem;
|
padding: 0 0.875rem;
|
||||||
font-size: var(--app-text-sm);
|
font-size: var(--app-text-sm);
|
||||||
|
|||||||
+2
-10
@@ -1,4 +1,4 @@
|
|||||||
import {Component, computed, effect, inject, Injector, OnInit} from '@angular/core';
|
import {Component, computed, inject, OnInit} from '@angular/core';
|
||||||
import {FormBuilder, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
import {FormBuilder, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||||
|
|
||||||
import {InputText} from '@openng/optimus-ui/inputtext';
|
import {InputText} from '@openng/optimus-ui/inputtext';
|
||||||
@@ -9,7 +9,7 @@ import {DynamicDialogConfig, DynamicDialogRef} from '@openng/optimus-ui/dynamicd
|
|||||||
import {MessageService} from '@openng/optimus-ui/api';
|
import {MessageService} from '@openng/optimus-ui/api';
|
||||||
import {BookService} from '../../../book/service/book.service';
|
import {BookService} from '../../../book/service/book.service';
|
||||||
import {BookMetadataManageService} from '../../../book/service/book-metadata-manage.service';
|
import {BookMetadataManageService} from '../../../book/service/book-metadata-manage.service';
|
||||||
import {Book, BulkMetadataUpdateRequest} from '../../../book/model/book.model';
|
import {BulkMetadataUpdateRequest} from '../../../book/model/book.model';
|
||||||
import {Checkbox} from '@openng/optimus-ui/checkbox';
|
import {Checkbox} from '@openng/optimus-ui/checkbox';
|
||||||
import {AutoComplete} from '@openng/optimus-ui/autocomplete';
|
import {AutoComplete} from '@openng/optimus-ui/autocomplete';
|
||||||
import {AutoCompleteSelectEvent} from '@openng/optimus-ui/autocomplete';
|
import {AutoCompleteSelectEvent} from '@openng/optimus-ui/autocomplete';
|
||||||
@@ -36,8 +36,6 @@ import {ProgressSpinner} from '@openng/optimus-ui/progressspinner';
|
|||||||
export class BulkMetadataUpdateComponent implements OnInit {
|
export class BulkMetadataUpdateComponent implements OnInit {
|
||||||
metadataForm!: FormGroup;
|
metadataForm!: FormGroup;
|
||||||
bookIds: number[] = [];
|
bookIds: number[] = [];
|
||||||
books: Book[] = [];
|
|
||||||
showBookList = true;
|
|
||||||
mergeCategories = true;
|
mergeCategories = true;
|
||||||
mergeMoods = true;
|
mergeMoods = true;
|
||||||
mergeTags = true;
|
mergeTags = true;
|
||||||
@@ -62,7 +60,6 @@ export class BulkMetadataUpdateComponent implements OnInit {
|
|||||||
private readonly bookService = inject(BookService);
|
private readonly bookService = inject(BookService);
|
||||||
private readonly bookMetadataManageService = inject(BookMetadataManageService);
|
private readonly bookMetadataManageService = inject(BookMetadataManageService);
|
||||||
private readonly messageService = inject(MessageService);
|
private readonly messageService = inject(MessageService);
|
||||||
private readonly injector = inject(Injector);
|
|
||||||
private readonly uniqueMetadata = computed(() => this.bookService.uniqueMetadata());
|
private readonly uniqueMetadata = computed(() => this.bookService.uniqueMetadata());
|
||||||
|
|
||||||
get allAuthors(): string[] { return this.uniqueMetadata().authors; }
|
get allAuthors(): string[] { return this.uniqueMetadata().authors; }
|
||||||
@@ -122,7 +119,6 @@ export class BulkMetadataUpdateComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.bookIds = this.config.data?.bookIds ?? [];
|
this.bookIds = this.config.data?.bookIds ?? [];
|
||||||
this.books = this.bookService.getBooksByIds(this.bookIds);
|
|
||||||
|
|
||||||
this.metadataForm = this.fb.group({
|
this.metadataForm = this.fb.group({
|
||||||
authors: [],
|
authors: [],
|
||||||
@@ -135,10 +131,6 @@ export class BulkMetadataUpdateComponent implements OnInit {
|
|||||||
moods: [],
|
moods: [],
|
||||||
tags: []
|
tags: []
|
||||||
});
|
});
|
||||||
|
|
||||||
effect(() => {
|
|
||||||
this.books = this.bookService.books().filter(book => this.bookIds.includes(book.id));
|
|
||||||
}, {injector: this.injector});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onFieldClearToggle(field: keyof typeof this.clearFields): void {
|
onFieldClearToggle(field: keyof typeof this.clearFields): void {
|
||||||
|
|||||||
+1
-15
@@ -8,7 +8,7 @@
|
|||||||
@if (isLibraryRefresh) {
|
@if (isLibraryRefresh) {
|
||||||
<p class="panel-description">Library-level custom metadata fetch</p>
|
<p class="panel-description">Library-level custom metadata fetch</p>
|
||||||
} @else {
|
} @else {
|
||||||
<p class="panel-description">{{ booksToShow.length }} books selected</p>
|
<p class="panel-description">{{ bookIds.length }} books selected</p>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<p-button
|
<p-button
|
||||||
@@ -22,20 +22,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="dialog-content">
|
<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
|
<app-metadata-fetch-options
|
||||||
[dialogData]="{ bookIds: bookIds, libraryId: libraryId, metadataRefreshType: metadataRefreshType }"></app-metadata-fetch-options>
|
[dialogData]="{ bookIds: bookIds, libraryId: libraryId, metadataRefreshType: metadataRefreshType }"></app-metadata-fetch-options>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
-31
@@ -34,37 +34,6 @@
|
|||||||
box-shadow: 0 2px 6px rgb(0 0 0 / 8%);
|
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 {
|
::ng-deep app-metadata-fetch-options {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
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 {AppSettings} from '../../../../shared/model/app-settings.model';
|
||||||
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
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 {MetadataRefreshType} from '../../model/request/metadata-refresh-type.enum';
|
||||||
import {MultiBookMetadataFetchComponent} from './multi-book-metadata-fetch-component';
|
import {MultiBookMetadataFetchComponent} from './multi-book-metadata-fetch-component';
|
||||||
|
|
||||||
describe('MultiBookMetadataFetchComponent', () => {
|
describe('MultiBookMetadataFetchComponent', () => {
|
||||||
const appSettings = signal<AppSettings | null>(null);
|
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(() => {
|
beforeEach(() => {
|
||||||
getBooksByIds.mockClear();
|
|
||||||
appSettings.set(null);
|
appSettings.set(null);
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
@@ -35,23 +26,17 @@ describe('MultiBookMetadataFetchComponent', () => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{provide: DynamicDialogRef, useValue: {close: vi.fn()}},
|
{provide: DynamicDialogRef, useValue: {close: vi.fn()}},
|
||||||
{provide: BookService, useValue: {getBooksByIds}},
|
|
||||||
{provide: AppSettingsService, useValue: {appSettings}},
|
{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());
|
const component = TestBed.runInInjectionContext(() => new MultiBookMetadataFetchComponent());
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
|
|
||||||
expect(component.bookIds).toEqual([3, 5]);
|
expect(component.bookIds).toEqual([3, 5]);
|
||||||
expect(component.metadataRefreshType).toBe(MetadataRefreshType.BOOKS);
|
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', () => {
|
it('gives precedence to dialogData Input over dynamicDialogConfig.data', () => {
|
||||||
@@ -63,7 +48,6 @@ describe('MultiBookMetadataFetchComponent', () => {
|
|||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
|
|
||||||
expect(component.bookIds).toEqual([10]);
|
expect(component.bookIds).toEqual([10]);
|
||||||
expect(getBooksByIds).toHaveBeenCalledWith([10]);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adopts the default metadata refresh options when app settings become available', () => {
|
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 {MetadataRefreshOptions} from '../../model/request/metadata-refresh-options.model';
|
||||||
|
|
||||||
import {DynamicDialogConfig, DynamicDialogRef} from '@openng/optimus-ui/dynamicdialog';
|
import {DynamicDialogConfig, DynamicDialogRef} from '@openng/optimus-ui/dynamicdialog';
|
||||||
import {BookService} from '../../../book/service/book.service';
|
|
||||||
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
import {AppSettingsService} from '../../../../shared/service/app-settings.service';
|
||||||
import {Book} from '../../../book/model/book.model';
|
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {MetadataFetchOptionsComponent} from '../metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
import {MetadataFetchOptionsComponent} from '../metadata-options-dialog/metadata-fetch-options/metadata-fetch-options.component';
|
||||||
import {Button} from '@openng/optimus-ui/button';
|
import {Button} from '@openng/optimus-ui/button';
|
||||||
@@ -27,13 +25,11 @@ export class MultiBookMetadataFetchComponent implements OnInit, OnChanges {
|
|||||||
|
|
||||||
bookIds: number[] = [];
|
bookIds: number[] = [];
|
||||||
libraryId: number | null = null;
|
libraryId: number | null = null;
|
||||||
booksToShow: Book[] = [];
|
|
||||||
metadataRefreshType: MetadataRefreshType = MetadataRefreshType.BOOKS;
|
metadataRefreshType: MetadataRefreshType = MetadataRefreshType.BOOKS;
|
||||||
currentMetadataOptions!: MetadataRefreshOptions;
|
currentMetadataOptions!: MetadataRefreshOptions;
|
||||||
|
|
||||||
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
private dynamicDialogConfig = inject(DynamicDialogConfig);
|
||||||
dialogRef = inject(DynamicDialogRef);
|
dialogRef = inject(DynamicDialogRef);
|
||||||
private bookService = inject(BookService);
|
|
||||||
private appSettingsService = inject(AppSettingsService);
|
private appSettingsService = inject(AppSettingsService);
|
||||||
expanded = false;
|
expanded = false;
|
||||||
|
|
||||||
@@ -64,7 +60,6 @@ export class MultiBookMetadataFetchComponent implements OnInit, OnChanges {
|
|||||||
this.bookIds = context.bookIds ?? [];
|
this.bookIds = context.bookIds ?? [];
|
||||||
this.libraryId = context.libraryId ?? null;
|
this.libraryId = context.libraryId ?? null;
|
||||||
this.metadataRefreshType = context.metadataRefreshType ?? MetadataRefreshType.BOOKS;
|
this.metadataRefreshType = context.metadataRefreshType ?? MetadataRefreshType.BOOKS;
|
||||||
this.booksToShow = this.bookService.getBooksByIds(this.bookIds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get isLibraryRefresh(): boolean {
|
get isLibraryRefresh(): boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user