refactor(ui): new icon library and user migration (#1828)
This commit is contained in:
+4
-4
@@ -196,7 +196,7 @@ describe('ShelfAssignerComponent', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('maps custom svg and PrimeNG shelf icons to icon-display selections', () => {
|
||||
it('maps custom svg and Lucide shelf icons to icon-display selections', () => {
|
||||
const {component} = createHarness();
|
||||
|
||||
expect(component.getShelfIcon(createShelf({
|
||||
@@ -207,11 +207,11 @@ describe('ShelfAssignerComponent', () => {
|
||||
value: 'custom-icons/moon.svg',
|
||||
});
|
||||
expect(component.getShelfIcon(createShelf({
|
||||
iconType: 'PRIME_NG',
|
||||
iconType: 'LUCIDE',
|
||||
icon: 'bookmark',
|
||||
}))).toEqual({
|
||||
type: 'PRIME_NG',
|
||||
value: 'pi pi-bookmark',
|
||||
type: 'LUCIDE',
|
||||
value: 'bookmark',
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+3
-7
@@ -13,11 +13,11 @@ import {BookDialogHelperService} from '../book-browser/book-dialog-helper.servic
|
||||
import {LoadingService} from '../../../../core/services/loading.service';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {IconDisplayComponent} from '../../../../shared/components/icon-display/icon-display.component';
|
||||
import {IconSelection} from '../../../../shared/service/icon-picker.service';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {IconField} from 'primeng/iconfield';
|
||||
import {InputIcon} from 'primeng/inputicon';
|
||||
import {IconSelection, toIconSelection} from '../../../../shared/icons/icon-selection';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shelf-assigner',
|
||||
@@ -129,12 +129,8 @@ export class ShelfAssignerComponent {
|
||||
return this.selectedShelves.some(s => s.id === shelf.id);
|
||||
}
|
||||
|
||||
getShelfIcon(shelf: Shelf): IconSelection {
|
||||
if (shelf.iconType === 'CUSTOM_SVG') {
|
||||
return {type: 'CUSTOM_SVG', value: shelf.icon ?? ""};
|
||||
} else {
|
||||
return {type: 'PRIME_NG', value: `pi pi-${shelf.icon}`};
|
||||
}
|
||||
getShelfIcon(shelf: Shelf): IconSelection | null {
|
||||
return shelf.icon ? toIconSelection(shelf.icon, shelf.iconType) : null;
|
||||
}
|
||||
|
||||
filterShelves(shelves: Shelf[]): Shelf[] {
|
||||
|
||||
+2
-2
@@ -69,8 +69,8 @@
|
||||
<div class="icon-info">
|
||||
<span class="icon-label">{{ t('selectedIcon') }}</span>
|
||||
<span class="icon-name">
|
||||
@if (selectedIcon.type === 'PRIME_NG') {
|
||||
{{ selectedIcon.value }}
|
||||
@if (selectedIcon.type === 'CUSTOM_SVG') {
|
||||
{{ t('customSvg') }}
|
||||
} @else {
|
||||
{{ selectedIcon.value }}
|
||||
}
|
||||
|
||||
+8
-7
@@ -5,7 +5,8 @@ import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {Observable, of, throwError} from 'rxjs';
|
||||
import {afterEach, describe, expect, it, vi} from 'vitest';
|
||||
|
||||
import {IconSelection, IconPickerService} from '../../../../shared/service/icon-picker.service';
|
||||
import {IconPickerService} from '../../../../shared/service/icon-picker.service';
|
||||
import {IconSelection} from '../../../../shared/icons/icon-selection';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {Shelf} from '../../model/shelf.model';
|
||||
import {ShelfService} from '../../service/shelf.service';
|
||||
@@ -67,8 +68,8 @@ describe('ShelfCreatorComponent', () => {
|
||||
|
||||
it('picks an icon through the injected icon picker and ignores empty selections', () => {
|
||||
const pickedIcon: IconSelection = {
|
||||
type: 'PRIME_NG',
|
||||
value: 'pi pi-star',
|
||||
type: 'LUCIDE',
|
||||
value: 'star',
|
||||
};
|
||||
const {component, iconPickerService} = createHarness({
|
||||
iconPickerResult: pickedIcon,
|
||||
@@ -114,16 +115,16 @@ describe('ShelfCreatorComponent', () => {
|
||||
component.shelfName = 'Weekend Reads';
|
||||
component.isPublic = true;
|
||||
component.selectedIcon = {
|
||||
type: 'PRIME_NG',
|
||||
value: 'pi pi-bookmark',
|
||||
type: 'LUCIDE',
|
||||
value: 'bookmark',
|
||||
};
|
||||
|
||||
component.createShelf();
|
||||
|
||||
expect(createShelf).toHaveBeenCalledWith({
|
||||
name: 'Weekend Reads',
|
||||
icon: 'pi pi-bookmark',
|
||||
iconType: 'PRIME_NG',
|
||||
icon: 'bookmark',
|
||||
iconType: 'LUCIDE',
|
||||
publicShelf: true,
|
||||
});
|
||||
expect(translate).toHaveBeenCalledWith('common.success');
|
||||
|
||||
@@ -2,7 +2,8 @@ import {Component, inject} from '@angular/core';
|
||||
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {ShelfService} from '../../service/shelf.service';
|
||||
import {IconPickerService, IconSelection} from '../../../../shared/service/icon-picker.service';
|
||||
import {IconPickerService} from '../../../../shared/service/icon-picker.service';
|
||||
import {IconSelection} from '../../../../shared/icons/icon-selection';
|
||||
import {Shelf} from '../../model/shelf.model';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {Button} from 'primeng/button';
|
||||
|
||||
+13
-12
@@ -6,7 +6,8 @@ import {Observable, of, throwError} from 'rxjs';
|
||||
import {afterEach, describe, expect, it, vi} from 'vitest';
|
||||
|
||||
import {getTranslocoModule} from '../../../../core/testing/transloco-testing';
|
||||
import {IconSelection, IconPickerService} from '../../../../shared/service/icon-picker.service';
|
||||
import {IconPickerService} from '../../../../shared/service/icon-picker.service';
|
||||
import {IconSelection} from '../../../../shared/icons/icon-selection';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {Shelf} from '../../model/shelf.model';
|
||||
import {ShelfService} from '../../service/shelf.service';
|
||||
@@ -71,12 +72,12 @@ describe('ShelfEditDialogComponent', () => {
|
||||
};
|
||||
}
|
||||
|
||||
it('hydrates the dialog from a matching PrimeNG shelf', () => {
|
||||
it('hydrates the dialog from a matching Lucide shelf', () => {
|
||||
const shelf = createShelf({
|
||||
id: 42,
|
||||
name: 'Queue',
|
||||
icon: 'bookmark',
|
||||
iconType: 'PRIME_NG',
|
||||
iconType: 'LUCIDE',
|
||||
publicShelf: true,
|
||||
});
|
||||
|
||||
@@ -89,8 +90,8 @@ describe('ShelfEditDialogComponent', () => {
|
||||
expect(component.shelfName).toBe('Queue');
|
||||
expect(component.isPublic).toBe(true);
|
||||
expect(component.selectedIcon).toEqual({
|
||||
type: 'PRIME_NG',
|
||||
value: 'pi pi-bookmark',
|
||||
type: 'LUCIDE',
|
||||
value: 'bookmark',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -125,7 +126,7 @@ describe('ShelfEditDialogComponent', () => {
|
||||
id: 11,
|
||||
name: 'Should Not Replace',
|
||||
icon: 'bookmark',
|
||||
iconType: 'PRIME_NG',
|
||||
iconType: 'LUCIDE',
|
||||
publicShelf: true,
|
||||
}),
|
||||
]);
|
||||
@@ -141,8 +142,8 @@ describe('ShelfEditDialogComponent', () => {
|
||||
|
||||
it('picks and clears icons through the dialog-local icon selection methods', () => {
|
||||
const pickedIcon: IconSelection = {
|
||||
type: 'PRIME_NG',
|
||||
value: 'pi pi-star',
|
||||
type: 'LUCIDE',
|
||||
value: 'star',
|
||||
};
|
||||
const {component, iconPickerService} = createHarness({
|
||||
shelvesData: [createShelf()],
|
||||
@@ -166,16 +167,16 @@ describe('ShelfEditDialogComponent', () => {
|
||||
component.shelfName = 'Renamed Shelf';
|
||||
component.isPublic = true;
|
||||
component.selectedIcon = {
|
||||
type: 'PRIME_NG',
|
||||
value: 'pi pi-heart',
|
||||
type: 'LUCIDE',
|
||||
value: 'heart',
|
||||
};
|
||||
|
||||
component.save();
|
||||
|
||||
expect(updateShelf).toHaveBeenCalledWith({
|
||||
name: 'Renamed Shelf',
|
||||
icon: 'pi pi-heart',
|
||||
iconType: 'PRIME_NG',
|
||||
icon: 'heart',
|
||||
iconType: 'LUCIDE',
|
||||
publicShelf: true,
|
||||
}, 7);
|
||||
expect(messageService.add).toHaveBeenCalledWith(expect.objectContaining({
|
||||
|
||||
+3
-6
@@ -7,11 +7,12 @@ import {InputText} from 'primeng/inputtext';
|
||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {Shelf} from '../../model/shelf.model';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {IconPickerService, IconSelection} from '../../../../shared/service/icon-picker.service';
|
||||
import {IconPickerService} from '../../../../shared/service/icon-picker.service';
|
||||
import {IconDisplayComponent} from '../../../../shared/components/icon-display/icon-display.component';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {UserService} from '../../../settings/user-management/user.service';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
import {IconSelection, toIconSelection} from '../../../../shared/icons/icon-selection';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shelf-edit-dialog',
|
||||
@@ -63,11 +64,7 @@ export class ShelfEditDialogComponent implements OnInit {
|
||||
this.shelfName = shelf.name;
|
||||
this.isPublic = shelf.publicShelf ?? false;
|
||||
if (shelf.iconType && shelf.icon) {
|
||||
if (shelf.iconType === 'PRIME_NG') {
|
||||
this.selectedIcon = {type: 'PRIME_NG', value: `pi pi-${shelf.icon}`};
|
||||
} else {
|
||||
this.selectedIcon = {type: 'CUSTOM_SVG', value: shelf.icon};
|
||||
}
|
||||
this.selectedIcon = toIconSelection(shelf.icon, shelf.iconType);
|
||||
}
|
||||
}, {injector: this.injector});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {SortOption} from './sort.model';
|
||||
import {BookType} from './book.model';
|
||||
import {IconType} from '../../../shared/icons/icon-selection';
|
||||
|
||||
export type MetadataSource = 'EMBEDDED' | 'SIDECAR' | 'PREFER_SIDECAR' | 'PREFER_EMBEDDED' | 'NONE';
|
||||
|
||||
@@ -9,7 +10,7 @@ export interface Library {
|
||||
id?: number;
|
||||
name: string;
|
||||
icon?: string | null;
|
||||
iconType?: 'PRIME_NG' | 'CUSTOM_SVG' | null;
|
||||
iconType?: IconType | null;
|
||||
watch: boolean;
|
||||
fileNamingPattern?: string;
|
||||
sort?: SortOption;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {SortOption} from './sort.model';
|
||||
import {IconType} from '../../../shared/icons/icon-selection';
|
||||
|
||||
export type ShelfSystemKey = 'kobo';
|
||||
|
||||
@@ -6,7 +7,7 @@ export interface Shelf {
|
||||
id?: number;
|
||||
name: string;
|
||||
icon?: string | null;
|
||||
iconType?: 'PRIME_NG' | 'CUSTOM_SVG' | null;
|
||||
iconType?: IconType | null;
|
||||
sort?: SortOption;
|
||||
publicShelf?: boolean;
|
||||
userId?: number;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<!-- iOS needs both type="search" and a form with an action attribute. -->
|
||||
<form ngNoForm action="." class="command-palette-form" (submit)="$event.preventDefault()">
|
||||
<div class="command-palette-input-row">
|
||||
<i class="pi pi-search" aria-hidden="true"></i>
|
||||
<svg lucideSearch class="command-palette-search-icon" aria-hidden="true"></svg>
|
||||
<input
|
||||
#paletteInput
|
||||
type="search"
|
||||
@@ -27,7 +27,7 @@
|
||||
[attr.aria-label]="'close' | transloco"
|
||||
(click)="svc.hide()"
|
||||
>
|
||||
<i class="pi pi-times" aria-hidden="true"></i>
|
||||
<svg lucideX aria-hidden="true"></svg>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -86,14 +86,12 @@
|
||||
</div>
|
||||
</ng-container>
|
||||
} @else {
|
||||
@if (item.icon) {
|
||||
<app-icon-display
|
||||
class="command-palette-item-icon"
|
||||
[icon]="item.icon"
|
||||
size="18px"
|
||||
[displayEmpty]="true"
|
||||
></app-icon-display>
|
||||
}
|
||||
<app-icon-display
|
||||
class="command-palette-item-icon"
|
||||
[icon]="item.icon ?? null"
|
||||
size="18px"
|
||||
[displayEmpty]="true"
|
||||
></app-icon-display>
|
||||
<span class="command-palette-item-title">{{ item.title }}</span>
|
||||
@if (item.subtitle) {
|
||||
<span class="command-palette-item-subtitle">{{ item.subtitle }}</span>
|
||||
|
||||
@@ -36,9 +36,11 @@
|
||||
gap: var(--space-3);
|
||||
padding: var(--space-4) var(--space-5);
|
||||
|
||||
i {
|
||||
.command-palette-search-icon {
|
||||
flex-shrink: 0;
|
||||
width: 1.125rem;
|
||||
height: 1.125rem;
|
||||
color: var(--color-text-secondary);
|
||||
font-size: var(--app-text-lg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,8 +90,9 @@
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
i {
|
||||
font-size: 1.0938rem;
|
||||
svg {
|
||||
width: 1.0938rem;
|
||||
height: 1.0938rem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,12 +298,12 @@
|
||||
0
|
||||
calc(0.6563rem + env(safe-area-inset-left));
|
||||
|
||||
> .pi-search {
|
||||
> .command-palette-search-icon {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
width: 2.1875rem;
|
||||
width: 1.125rem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { filter, take } from 'rxjs/operators';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { TranslocoDirective, TranslocoPipe } from '@jsverse/transloco';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { LucideSearch, LucideX } from '@lucide/angular';
|
||||
|
||||
import { CoverPlaceholderComponent } from '../../shared/components/cover-generator/cover-generator.component';
|
||||
import { IconDisplayComponent } from '../../shared/components/icon-display/icon-display.component';
|
||||
@@ -17,7 +18,7 @@ import { CommandPaletteService } from './command-palette.service';
|
||||
@Component({
|
||||
selector: 'app-command-palette',
|
||||
standalone: true,
|
||||
imports: [A11yModule, OverlayModule, FormsModule, TranslocoDirective, TranslocoPipe, IconDisplayComponent, CoverPlaceholderComponent],
|
||||
imports: [A11yModule, OverlayModule, FormsModule, TranslocoDirective, TranslocoPipe, IconDisplayComponent, CoverPlaceholderComponent, LucideSearch, LucideX],
|
||||
templateUrl: './command-palette.component.html',
|
||||
styleUrl: './command-palette.component.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { IconSelection } from '../../shared/service/icon-picker.service';
|
||||
import { IconSelection } from '../../shared/icons/icon-selection';
|
||||
|
||||
export type PaletteItemKind =
|
||||
| 'action'
|
||||
|
||||
@@ -14,7 +14,7 @@ import { ShelfService } from '../book/service/shelf.service';
|
||||
import { MagicShelfService } from '../magic-shelf/service/magic-shelf.service';
|
||||
import { UrlHelperService } from '../../shared/service/url-helper.service';
|
||||
import { UserService } from '../settings/user-management/user.service';
|
||||
import { IconService } from '../../shared/services/icon.service';
|
||||
import { CustomSvgService } from '../../shared/services/custom-svg.service';
|
||||
import { DialogLauncherService } from '../../shared/services/dialog-launcher.service';
|
||||
|
||||
import { CommandPaletteService } from './command-palette.service';
|
||||
@@ -68,7 +68,7 @@ describe('CommandPaletteService', () => {
|
||||
{ provide: UserService, useValue: { currentUser: signal({ permissions: {} }) } },
|
||||
{ provide: MessageService, useValue: { add: vi.fn() } },
|
||||
{ provide: UrlHelperService, useValue: urlHelper },
|
||||
{ provide: IconService, useValue: { getSvgIconContent: vi.fn(() => of('')) } },
|
||||
{ provide: CustomSvgService, useValue: { getSvgIconContent: vi.fn(() => of('')) } },
|
||||
{
|
||||
provide: DialogLauncherService,
|
||||
useValue: {
|
||||
|
||||
@@ -15,10 +15,10 @@ import { MagicShelfService } from '../magic-shelf/service/magic-shelf.service';
|
||||
import { UserService } from '../settings/user-management/user.service';
|
||||
import { NavItem } from '../../shared/layout/navigation/nav-item.model';
|
||||
import { buildAllNavPages, buildQuickActionNavItems } from '../../shared/layout/navigation/nav-catalog';
|
||||
import { IconSelection } from '../../shared/service/icon-picker.service';
|
||||
import { UrlHelperService } from '../../shared/service/url-helper.service';
|
||||
import { DialogLauncherService } from '../../shared/services/dialog-launcher.service';
|
||||
import { IconService } from '../../shared/services/icon.service';
|
||||
import { CustomSvgService } from '../../shared/services/custom-svg.service';
|
||||
import { toIconSelection } from '../../shared/icons/icon-selection';
|
||||
|
||||
import { PaletteGroup, PaletteItem, PaletteItemKind } from './command-palette.model';
|
||||
|
||||
@@ -49,7 +49,7 @@ export class CommandPaletteService {
|
||||
private readonly libraryService = inject(LibraryService);
|
||||
private readonly dialogLauncherService = inject(DialogLauncherService);
|
||||
private readonly bookDialogHelperService = inject(BookDialogHelperService);
|
||||
private readonly iconService = inject(IconService);
|
||||
private readonly customSvgService = inject(CustomSvgService);
|
||||
private readonly urlHelper = inject(UrlHelperService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
|
||||
@@ -106,7 +106,7 @@ export class CommandPaletteService {
|
||||
for (const item of items) {
|
||||
if (item.icon?.type === 'CUSTOM_SVG' && !seen.has(item.icon.value)) {
|
||||
seen.add(item.icon.value);
|
||||
this.iconService.getSvgIconContent(item.icon.value).subscribe({ error: () => undefined });
|
||||
this.customSvgService.getSvgIconContent(item.icon.value).subscribe({ error: () => undefined });
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -235,7 +235,7 @@ export class CommandPaletteService {
|
||||
id: `shelf:${shelf.id}`,
|
||||
kind: 'shelf' as const,
|
||||
title: shelf.name,
|
||||
icon: this.iconSelectionFor(shelf.icon, shelf.iconType, 'pi-bookmark'),
|
||||
icon: shelf.icon ? toIconSelection(shelf.icon, shelf.iconType) : undefined,
|
||||
searchText: normalizeSearchTerm(shelf.name),
|
||||
route: [`/shelf/${shelf.id}/books`],
|
||||
}))
|
||||
@@ -248,7 +248,7 @@ export class CommandPaletteService {
|
||||
id: `magic-shelf:${shelf.id}`,
|
||||
kind: 'magicShelf' as const,
|
||||
title: shelf.name,
|
||||
icon: this.iconSelectionFor(shelf.icon, shelf.iconType, 'pi-sparkles'),
|
||||
icon: shelf.icon ? toIconSelection(shelf.icon, shelf.iconType) : undefined,
|
||||
searchText: normalizeSearchTerm(shelf.name),
|
||||
route: [`/magic-shelf/${shelf.id}/books`],
|
||||
}))
|
||||
@@ -261,7 +261,7 @@ export class CommandPaletteService {
|
||||
id: `library:${library.id}`,
|
||||
kind: 'library' as const,
|
||||
title: library.name,
|
||||
icon: this.iconSelectionFor(library.icon, library.iconType, 'pi-folder'),
|
||||
icon: library.icon ? toIconSelection(library.icon, library.iconType) : undefined,
|
||||
searchText: normalizeSearchTerm(library.name),
|
||||
route: [`/library/${library.id}/books`],
|
||||
}))
|
||||
@@ -271,16 +271,6 @@ export class CommandPaletteService {
|
||||
this.trimmedQuery().length >= MIN_BOOK_SEARCH_LENGTH ? this.localBookItems() : []
|
||||
);
|
||||
|
||||
private iconSelectionFor(
|
||||
value: string | null | undefined,
|
||||
iconType: string | null | undefined,
|
||||
fallback: string,
|
||||
): IconSelection {
|
||||
if (!value) return { type: 'PRIME_NG', value: fallback };
|
||||
if (iconType === 'CUSTOM_SVG') return { type: 'CUSTOM_SVG', value };
|
||||
return { type: 'PRIME_NG', value };
|
||||
}
|
||||
|
||||
private toPaletteBookItem(book: Book): PaletteItem {
|
||||
const metadata = book.metadata;
|
||||
const title = metadata?.title ?? book.primaryFile?.fileName ?? book.fileName ?? '';
|
||||
@@ -294,7 +284,7 @@ export class CommandPaletteService {
|
||||
id: `book:${book.id}`,
|
||||
kind: 'book',
|
||||
title,
|
||||
icon: { type: 'PRIME_NG', value: 'pi-book' },
|
||||
icon: { type: 'LUCIDE', value: 'book-open' },
|
||||
searchText: normalizeSearchTerm(haystack),
|
||||
route: ['/book', book.id],
|
||||
queryParams: { tab: 'view' },
|
||||
@@ -316,7 +306,7 @@ export class CommandPaletteService {
|
||||
id: `${kind}:${item.id}`,
|
||||
kind,
|
||||
title: item.label,
|
||||
icon: item.icon ? { type: 'PRIME_NG', value: item.icon } : undefined,
|
||||
icon: item.icon ? toIconSelection(item.icon, item.iconType) : undefined,
|
||||
searchText: normalizeSearchTerm(item.label),
|
||||
route: item.routerLink,
|
||||
command: item.action,
|
||||
|
||||
@@ -50,27 +50,27 @@
|
||||
<span>
|
||||
{{ t('iconLabel') }}
|
||||
</span>
|
||||
@if (!selectedIcon()) {
|
||||
<button class="icon-picker-trigger" (click)="openIconPicker()" type="button">
|
||||
<i class="pi pi-plus"></i>
|
||||
<span>{{ t('chooseIcon') }}</span>
|
||||
</button>
|
||||
} @else {
|
||||
@if (selectedIcon(); as icon) {
|
||||
<div class="icon-selected">
|
||||
<div class="icon-preview">
|
||||
<app-icon-display [icon]="selectedIcon()!" size="16px" />
|
||||
<app-icon-display [icon]="icon" size="16px" />
|
||||
</div>
|
||||
<span class="icon-value">
|
||||
@if (selectedIcon()!.type === 'PRIME_NG') {
|
||||
{{ selectedIcon()!.value }}
|
||||
} @else {
|
||||
@if (icon.type === 'CUSTOM_SVG') {
|
||||
{{ t('customSvg') }}
|
||||
} @else {
|
||||
{{ icon.value }}
|
||||
}
|
||||
</span>
|
||||
<button class="icon-clear" (click)="clearSelectedIcon()" type="button">
|
||||
<i class="pi pi-times"></i>
|
||||
</button>
|
||||
</div>
|
||||
} @else {
|
||||
<button class="icon-picker-trigger" (click)="openIconPicker()" type="button">
|
||||
<i class="pi pi-plus"></i>
|
||||
<span>{{ t('chooseIcon') }}</span>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -10,7 +10,7 @@ import { Library, MetadataSource, OrganizationMode } from '../book/model/library
|
||||
import { BookType } from '../book/model/book.model';
|
||||
import { ToggleSwitch } from 'primeng/toggleswitch';
|
||||
import { Tooltip } from 'primeng/tooltip';
|
||||
import { IconPickerService, IconSelection } from '../../shared/service/icon-picker.service';
|
||||
import { IconPickerService } from '../../shared/service/icon-picker.service';
|
||||
import { Button } from 'primeng/button';
|
||||
import { IconDisplayComponent } from '../../shared/components/icon-display/icon-display.component';
|
||||
import { DialogLauncherService } from '../../shared/services/dialog-launcher.service';
|
||||
@@ -20,6 +20,7 @@ import { Checkbox } from 'primeng/checkbox';
|
||||
import { Select } from 'primeng/select';
|
||||
import { TranslocoDirective, TranslocoPipe, TranslocoService } from '@jsverse/transloco';
|
||||
import { LibraryImportProgressService } from '../../shared/service/library-import-progress.service';
|
||||
import { IconSelection, toIconSelection } from '../../shared/icons/icon-selection';
|
||||
|
||||
interface FormatEntry { type: BookType; label: string }
|
||||
|
||||
@@ -139,12 +140,7 @@ export class LibraryCreatorComponent {
|
||||
this.folders.set(paths.map(p => p.path));
|
||||
|
||||
if (icon != null && iconType) {
|
||||
if (iconType === 'CUSTOM_SVG') {
|
||||
this.selectedIcon.set({ type: 'CUSTOM_SVG', value: icon });
|
||||
} else {
|
||||
const value = icon.slice(0, 6) === 'pi pi-' ? icon : `pi pi-${icon}`;
|
||||
this.selectedIcon.set({ type: 'PRIME_NG', value });
|
||||
}
|
||||
this.selectedIcon.set(toIconSelection(icon, iconType));
|
||||
}
|
||||
|
||||
if (formatPriority && formatPriority.length > 0) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||
import {MultiSelect} from 'primeng/multiselect';
|
||||
import {AutoComplete} from 'primeng/autocomplete';
|
||||
import {EMPTY_CHECK_OPERATORS, MULTI_VALUE_OPERATORS, RELATIVE_DATE_OPERATORS, parseValue, removeNulls, serializeDateRules} from '../service/magic-shelf-utils';
|
||||
import {IconPickerService, IconSelection} from '../../../shared/service/icon-picker.service';
|
||||
import {IconPickerService} from '../../../shared/service/icon-picker.service';
|
||||
import {CheckboxChangeEvent, Checkbox} from "primeng/checkbox";
|
||||
import {UserService} from "../../settings/user-management/user.service";
|
||||
import {IconDisplayComponent} from '../../../shared/components/icon-display/icon-display.component';
|
||||
@@ -23,6 +23,7 @@ import {BookService} from '../../book/service/book.service';
|
||||
import {ShelfService} from '../../book/service/shelf.service';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
import {Textarea} from 'primeng/textarea';
|
||||
import {IconSelection, toIconSelection} from '../../../shared/icons/icon-selection';
|
||||
|
||||
export type RuleOperator =
|
||||
| 'equals'
|
||||
@@ -543,9 +544,7 @@ export class MagicShelfComponent implements OnInit {
|
||||
});
|
||||
|
||||
if (iconValue) {
|
||||
this.selectedIcon = iconValue.startsWith('pi ')
|
||||
? {type: 'PRIME_NG', value: iconValue}
|
||||
: {type: 'CUSTOM_SVG', value: iconValue};
|
||||
this.selectedIcon = toIconSelection(iconValue, shelf?.iconType);
|
||||
} else {
|
||||
this.selectedIcon = null;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@ function buildMagicShelf(overrides: Partial<MagicShelf> = {}): MagicShelf {
|
||||
return {
|
||||
id: 1,
|
||||
name: 'Favorites',
|
||||
icon: 'pi pi-star',
|
||||
iconType: 'PRIME_NG',
|
||||
icon: 'star',
|
||||
iconType: 'LUCIDE',
|
||||
filterJson: JSON.stringify(buildGroupRule()),
|
||||
isPublic: false,
|
||||
...overrides,
|
||||
@@ -152,8 +152,8 @@ describe('MagicShelfService', () => {
|
||||
|
||||
service.saveShelf({
|
||||
name: 'Magic',
|
||||
icon: 'pi pi-bolt',
|
||||
iconType: 'PRIME_NG',
|
||||
icon: 'zap',
|
||||
iconType: 'LUCIDE',
|
||||
group,
|
||||
isPublic: true,
|
||||
}).subscribe();
|
||||
@@ -162,8 +162,8 @@ describe('MagicShelfService', () => {
|
||||
expect(request.request.method).toBe('POST');
|
||||
expect(request.request.body).toEqual(expect.objectContaining({
|
||||
name: 'Magic',
|
||||
icon: 'pi pi-bolt',
|
||||
iconType: 'PRIME_NG',
|
||||
icon: 'zap',
|
||||
iconType: 'LUCIDE',
|
||||
filterJson: JSON.stringify(group),
|
||||
isPublic: true,
|
||||
}));
|
||||
|
||||
@@ -9,12 +9,13 @@ import {BookService} from '../../book/service/book.service';
|
||||
import {BookRuleEvaluatorService} from './book-rule-evaluator.service';
|
||||
import {AuthService} from '../../../shared/service/auth.service';
|
||||
import {GroupRule} from '../component/magic-shelf-component';
|
||||
import {IconType} from '../../../shared/icons/icon-selection';
|
||||
|
||||
export interface MagicShelf {
|
||||
id?: number | null;
|
||||
name: string;
|
||||
icon?: string | null;
|
||||
iconType?: 'PRIME_NG' | 'CUSTOM_SVG' | null;
|
||||
iconType?: IconType | null;
|
||||
filterJson: string;
|
||||
isPublic?: boolean;
|
||||
}
|
||||
@@ -72,7 +73,7 @@ export class MagicShelfService {
|
||||
id?: number;
|
||||
name: string | null;
|
||||
icon: string | null;
|
||||
iconType?: 'PRIME_NG' | 'CUSTOM_SVG';
|
||||
iconType?: IconType | null;
|
||||
group: unknown;
|
||||
isPublic?: boolean | null;
|
||||
}): Observable<MagicShelf> {
|
||||
|
||||
Reference in New Issue
Block a user