refactor(frontend): rename booklore-ui to frontend

- Frontend path:
  - rename the tracked Angular app tree from `booklore-ui/` to `frontend/`
  - preserve file contents during the move so this commit stays focused on the path change itself
- Frontend docs:
  - update the moved frontend README and contribution guide where they refer to the renamed folder
  - keep those edits limited to path references introduced by the directory rename
This commit is contained in:
James Cox
2026-04-22 17:26:39 -04:00
committed by Zach Yale
parent c99aa87877
commit 874b013f75
1493 changed files with 3 additions and 3 deletions
@@ -0,0 +1,118 @@
<ng-container *transloco="let t; prefix: 'book.shelfAssigner'">
<div class="shelf-assigner">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-bookmark header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">{{ t('title') }}</h2>
<p class="panel-description">
@if (isMultiBooks) {
{{ t('descriptionMulti', { count: bookIds.size }) }}
} @else {
{{ t('descriptionSingle', { title: book.metadata?.title }) }}
}
</p>
</div>
<p-button
icon="pi pi-times"
[text]="true"
[rounded]="true"
severity="secondary"
(onClick)="closeDialog()"
class="close-button">
</p-button>
</div>
<div class="shelves-container">
@if (shelves(); as shelves) {
@if (shelves.length > 0) {
<div class="shelves-list">
<div class="list-header">
<span class="shelf-count">
<i class="pi pi-bookmark"></i>
{{ t('shelvesAvailable', { count: shelves.length }) }}
</span>
<p-iconfield class="shelf-search">
<p-inputicon class="pi pi-search"/>
<input
type="text"
pInputText
[(ngModel)]="searchQuery"
[placeholder]="t('searchPlaceholder')"
/>
@if (searchQuery) {
<button type="button" class="clear-icon" (click)="searchQuery = ''">
<i class="pi pi-times"></i>
</button>
}
</p-iconfield>
</div>
<div class="shelves-grid">
@for (shelf of filterShelves(shelves); track shelf.id) {
<div class="shelf-item" [class.selected]="isShelfSelected(shelf)">
<div class="shelf-checkbox">
<p-checkbox
[inputId]="'shelf-' + shelf.id"
name="shelves"
[value]="shelf"
[(ngModel)]="selectedShelves"
/>
</div>
<label [for]="'shelf-' + shelf.id" class="shelf-label">
@if (shelf.icon) {
<div class="shelf-icon-wrapper">
<app-icon-display
[icon]="getShelfIcon(shelf)"
size="20px"
iconClass="shelf-icon"
/>
</div>
} @else {
<div class="shelf-icon-wrapper-empty">
</div>
}
<span class="shelf-name">{{ shelf.name }}</span>
</label>
</div>
}
</div>
</div>
} @else {
<div class="empty-state">
<div class="empty-icon-wrapper">
<i class="pi pi-bookmark empty-icon"></i>
</div>
<h3 class="empty-title">{{ t('emptyTitle') }}</h3>
<p class="empty-description" [innerHTML]="t('emptyDescription')"></p>
</div>
}
}
</div>
<div class="dialog-footer">
<p-button
[label]="t('createShelf')"
icon="pi pi-plus"
[outlined]="true"
severity="info"
(onClick)="createShelfDialog()"
/>
<div class="footer-actions">
<p-button
[label]="t('cancelButton')"
severity="secondary"
[outlined]="true"
(onClick)="closeDialog()"
/>
<p-button
[label]="t('saveChanges')"
icon="pi pi-check"
severity="success"
(onClick)="updateBooksShelves()"
/>
</div>
</div>
</div>
</ng-container>
@@ -0,0 +1,311 @@
@use '../../../../shared/styles/panel-shared' as panel;
.shelf-assigner {
width: 550px;
max-width: 550px;
display: flex;
flex-direction: column;
@media (max-width: 640px) {
width: 100%;
max-width: 100%;
}
}
.panel-header {
@include panel.panel-header;
border-bottom: none;
}
.shelves-container {
display: flex;
flex-direction: column;
gap: 1rem;
padding: 1rem 2rem;
background: var(--card-background);
border: 1px solid var(--border-color);
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
min-height: 350px;
max-height: 450px;
overflow: hidden;
@media (max-width: 480px) {
padding: 1rem;
min-height: 300px;
max-height: 400px;
}
}
.shelves-list {
display: flex;
flex-direction: column;
gap: 0.75rem;
height: 100%;
overflow: hidden;
}
.list-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.625rem 0.875rem;
background: var(--overlay-background);
border-radius: 6px;
gap: 0.5rem;
.shelf-count {
display: flex;
align-items: center;
gap: 0.375rem;
font-size: 0.9rem;
font-weight: 600;
color: var(--text-color);
white-space: nowrap;
i {
color: var(--primary-color);
}
}
.shelf-search {
flex: 1;
max-width: 200px;
position: relative;
input {
width: 100%;
font-size: 0.85rem;
padding: 0.375rem 2rem 0.375rem 2rem;
}
.clear-icon {
position: absolute;
right: 0.5rem;
top: 50%;
transform: translateY(-50%);
cursor: pointer;
color: var(--text-secondary-color);
font-size: 0.75rem;
z-index: 1;
&:hover {
color: var(--text-color);
}
}
}
@media (max-width: 480px) {
padding: 0.5rem 0.625rem;
flex-wrap: wrap;
.shelf-count {
font-size: 0.85rem;
}
.shelf-search {
max-width: 100%;
order: 1;
}
}
}
.shelves-grid {
display: flex;
flex-direction: column;
gap: 0.75rem;
overflow-y: auto;
flex: 1;
padding-right: 0.25rem;
min-height: 0;
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-track {
background: var(--overlay-background);
border-radius: 3px;
}
&::-webkit-scrollbar-thumb {
background: var(--border-color);
border-radius: 3px;
transition: background 0.2s ease;
&:hover {
background: var(--primary-color);
}
}
scrollbar-width: thin;
scrollbar-color: var(--border-color) var(--overlay-background);
}
.shelf-item {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 0.5rem 1rem;
background: var(--ground-background);
border: 1px solid var(--border-color);
border-radius: 8px;
transition: all 0.3s ease;
cursor: pointer;
&:hover {
border-color: var(--primary-color);
transform: translateX(3px);
box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
.shelf-icon {
color: var(--primary-color);
transform: scale(1.08);
}
}
&.selected {
border-color: var(--primary-color);
.shelf-icon-wrapper {
background: var(--primary-color);
.shelf-icon {
color: var(--primary-contrast-color);
}
}
}
.shelf-checkbox {
display: flex;
align-items: center;
}
.shelf-label {
flex: 1;
display: flex;
align-items: center;
gap: 0.75rem;
cursor: pointer;
min-width: 0;
.shelf-icon-wrapper, .shelf-icon-wrapper-empty {
width: 34px;
height: 34px;
}
.shelf-icon-wrapper {
display: flex;
align-items: center;
justify-content: center;
background: var(--overlay-background);
border-radius: 8px;
flex-shrink: 0;
.shelf-icon {
font-size: 1.125rem;
color: var(--text-secondary-color);
transition: all 0.3s ease;
}
}
.shelf-name {
font-size: 0.9375rem;
color: var(--text-color);
font-weight: 500;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
@media (max-width: 480px) {
padding: 0.625rem;
gap: 0.5rem;
.shelf-label {
gap: 0.5rem;
.shelf-icon-wrapper, .shelf-icon-wrapper-empty {
width: 32px;
height: 32px;
.shelf-icon {
font-size: 1rem;
}
}
.shelf-name {
font-size: 0.875rem;
}
}
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
padding: 2rem 1rem;
flex: 1;
.empty-icon-wrapper {
display: flex;
align-items: center;
justify-content: center;
width: 80px;
height: 80px;
background: var(--overlay-background);
border-radius: 50%;
margin-bottom: 1rem;
.empty-icon {
font-size: 2.5rem;
color: var(--text-secondary-color);
opacity: 0.5;
}
}
.empty-title {
margin: 0 0 0.5rem 0;
font-size: 1.125rem;
font-weight: 600;
color: var(--text-color);
}
.empty-description {
margin: 0;
font-size: 0.875rem;
color: var(--text-secondary-color);
max-width: 350px;
line-height: 1.5;
}
@media (max-width: 480px) {
padding: 1.5rem 0.75rem;
.empty-icon-wrapper {
width: 60px;
height: 60px;
.empty-icon {
font-size: 2rem;
}
}
.empty-title {
font-size: 1rem;
}
.empty-description {
font-size: 0.8rem;
max-width: 100%;
}
}
}
.dialog-footer {
@include panel.dialog-footer;
border-top: none;
}
@@ -0,0 +1,171 @@
import {Component, computed, effect, inject} from '@angular/core';
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
import {Book} from '../../model/book.model';
import {MessageService} from 'primeng/api';
import {ShelfService} from '../../service/shelf.service';
import {finalize} from 'rxjs';
import {BookService} from '../../service/book.service';
import {Shelf} from '../../model/shelf.model';
import {Button} from 'primeng/button';
import {Checkbox} from 'primeng/checkbox';
import {FormsModule} from '@angular/forms';
import {BookDialogHelperService} from '../book-browser/book-dialog-helper.service';
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';
@Component({
selector: 'app-shelf-assigner',
standalone: true,
templateUrl: './shelf-assigner.component.html',
styleUrl: './shelf-assigner.component.scss',
imports: [
Button,
Checkbox,
FormsModule,
IconDisplayComponent,
TranslocoDirective,
InputText,
IconField,
InputIcon
]
})
export class ShelfAssignerComponent {
private shelfService = inject(ShelfService);
private dynamicDialogConfig = inject(DynamicDialogConfig);
private dynamicDialogRef = inject(DynamicDialogRef);
private messageService = inject(MessageService);
private bookService = inject(BookService);
private bookDialogHelper = inject(BookDialogHelperService);
private loadingService = inject(LoadingService);
private userService = inject(UserService);
private readonly t = inject(TranslocoService);
searchQuery = '';
private currentUser = this.userService.currentUser;
book: Book = this.dynamicDialogConfig.data.book;
selectedShelves: Shelf[] = [];
bookIds: Set<number> = this.dynamicDialogConfig.data.bookIds;
isMultiBooks: boolean = this.dynamicDialogConfig.data.isMultiBooks;
private readonly shelfSortField = computed<'name' | 'id'>(() => {
const sorting = this.currentUser()?.userSettings.sidebarShelfSorting;
return sorting ? this.validateSortField(sorting.field) : 'name';
});
private readonly shelfSortOrder = computed<'asc' | 'desc'>(() => {
const sorting = this.currentUser()?.userSettings.sidebarShelfSorting;
return sorting ? this.validateSortOrder(sorting.order) : 'asc';
});
readonly shelves = computed(() => {
const user = this.currentUser();
const filteredShelves = this.shelfService.shelves().filter(shelf => shelf.userId === user?.id);
return this.sortShelves(filteredShelves);
});
private hasInitializedSelectedShelves = false;
private readonly initializeSelectedShelvesEffect = effect(() => {
if (this.isMultiBooks || this.hasInitializedSelectedShelves || !this.book.shelves?.length) {
return;
}
const selectedShelves = this.shelves().filter(shelf =>
this.book.shelves?.some(bookShelf => bookShelf.id === shelf.id)
);
if (selectedShelves.length > 0 || this.shelfService.shelves().length > 0) {
this.selectedShelves = selectedShelves;
this.hasInitializedSelectedShelves = true;
}
});
updateBooksShelves(): void {
const idsToAssign = new Set<number | undefined>(this.selectedShelves.map(shelf => shelf.id));
const idsToUnassign: Set<number> = this.isMultiBooks ? new Set() : this.getIdsToUnAssign(this.book, idsToAssign);
const bookIds = this.isMultiBooks ? this.bookIds : new Set([this.book.id]);
this.updateBookShelves(bookIds, idsToAssign, idsToUnassign);
}
private updateBookShelves(bookIds: Set<number>, idsToAssign: Set<number | undefined>, idsToUnassign: Set<number>): void {
const loader = this.loadingService.show(this.t.translate('book.shelfAssigner.loading.updatingShelves', { count: bookIds.size }));
this.bookService.updateBookShelves(bookIds, idsToAssign, idsToUnassign)
.pipe(finalize(() => this.loadingService.hide(loader)))
.subscribe({
next: () => {
this.messageService.add({severity: 'info', summary: this.t.translate('common.success'), detail: this.t.translate('book.shelfAssigner.toast.updateSuccessDetail')});
this.dynamicDialogRef.close({assigned: true});
},
error: () => {
this.messageService.add({severity: 'error', summary: this.t.translate('common.error'), detail: this.t.translate('book.shelfAssigner.toast.updateFailedDetail')});
this.dynamicDialogRef.close({assigned: false});
}
});
}
private getIdsToUnAssign(book: Book, idsToAssign: Set<number | undefined>): Set<number> {
const idsToUnassign = new Set<number>();
book.shelves?.forEach(shelf => {
if (!idsToAssign.has(shelf.id)) {
idsToUnassign.add(shelf.id!);
}
});
return idsToUnassign;
}
createShelfDialog(): void {
this.bookDialogHelper.openShelfCreatorDialog();
}
closeDialog(): void {
this.dynamicDialogRef.close({assigned: false});
}
isShelfSelected(shelf: Shelf): boolean {
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}`};
}
}
filterShelves(shelves: Shelf[]): Shelf[] {
if (!this.searchQuery.trim()) {
return shelves;
}
const query = this.searchQuery.trim().toLowerCase();
return shelves.filter(s => s.name.toLowerCase().includes(query));
}
private sortShelves(shelves: Shelf[]): Shelf[] {
const sortField = this.shelfSortField();
const sortOrder = this.shelfSortOrder();
return [...shelves].sort((a, b) => {
const aVal = (a as unknown as Record<string, unknown>)[sortField] ?? '';
const bVal = (b as unknown as Record<string, unknown>)[sortField] ?? '';
let comparison = 0;
if (typeof aVal === 'string' && typeof bVal === 'string') {
comparison = aVal.localeCompare(bVal);
} else if (typeof aVal === 'number' && typeof bVal === 'number') {
comparison = aVal - bVal;
}
return sortOrder === 'asc' ? comparison : -comparison;
});
}
private validateSortField(field: string): 'name' | 'id' {
return field === 'id' ? 'id' : 'name';
}
private validateSortOrder(order: string): 'asc' | 'desc' {
return order === 'desc' ? 'desc' : 'asc';
}
}