Add a shelf creation button to the left menu bar and improve the layout of the shelf creation page (#1617)
This commit is contained in:
@@ -53,7 +53,6 @@ public class FileService {
|
|||||||
private final BookRepository bookRepository;
|
private final BookRepository bookRepository;
|
||||||
private final BookAdditionalFileRepository bookAdditionalFileRepository;
|
private final BookAdditionalFileRepository bookAdditionalFileRepository;
|
||||||
private final BookMapper bookMapper;
|
private final BookMapper bookMapper;
|
||||||
private final RestTemplate restTemplate;
|
|
||||||
|
|
||||||
// @formatter:off
|
// @formatter:off
|
||||||
private static final String IMAGES_DIR = "images";
|
private static final String IMAGES_DIR = "images";
|
||||||
@@ -171,7 +170,7 @@ public class FileService {
|
|||||||
|
|
||||||
HttpEntity<String> entity = new HttpEntity<>(headers);
|
HttpEntity<String> entity = new HttpEntity<>(headers);
|
||||||
|
|
||||||
ResponseEntity<byte[]> response = restTemplate.exchange(
|
ResponseEntity<byte[]> response = new RestTemplate().exchange(
|
||||||
imageUrl,
|
imageUrl,
|
||||||
HttpMethod.GET,
|
HttpMethod.GET,
|
||||||
entity,
|
entity,
|
||||||
|
|||||||
+18
-1
@@ -7,6 +7,7 @@ import {BulkMetadataUpdateComponent} from '../../../metadata/component/bulk-meta
|
|||||||
import {MultiBookMetadataEditorComponent} from '../../../metadata/component/multi-book-metadata-editor/multi-book-metadata-editor-component';
|
import {MultiBookMetadataEditorComponent} from '../../../metadata/component/multi-book-metadata-editor/multi-book-metadata-editor-component';
|
||||||
import {MultiBookMetadataFetchComponent} from '../../../metadata/component/multi-book-metadata-fetch/multi-book-metadata-fetch-component';
|
import {MultiBookMetadataFetchComponent} from '../../../metadata/component/multi-book-metadata-fetch/multi-book-metadata-fetch-component';
|
||||||
import {FileMoverComponent} from '../../../../shared/components/file-mover/file-mover-component';
|
import {FileMoverComponent} from '../../../../shared/components/file-mover/file-mover-component';
|
||||||
|
import {ShelfCreatorComponent} from '../shelf-creator/shelf-creator.component';
|
||||||
|
|
||||||
@Injectable({providedIn: 'root'})
|
@Injectable({providedIn: 'root'})
|
||||||
export class BookDialogHelperService {
|
export class BookDialogHelperService {
|
||||||
@@ -15,7 +16,7 @@ export class BookDialogHelperService {
|
|||||||
|
|
||||||
openShelfAssigner(bookIds: Set<number>): DynamicDialogRef | null {
|
openShelfAssigner(bookIds: Set<number>): DynamicDialogRef | null {
|
||||||
return this.dialogService.open(ShelfAssignerComponent, {
|
return this.dialogService.open(ShelfAssignerComponent, {
|
||||||
header: `Update Books' Shelves`,
|
showHeader: false,
|
||||||
modal: true,
|
modal: true,
|
||||||
closable: true,
|
closable: true,
|
||||||
contentStyle: {overflow: 'auto'},
|
contentStyle: {overflow: 'auto'},
|
||||||
@@ -31,6 +32,22 @@ export class BookDialogHelperService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openShelfCreator(): DynamicDialogRef {
|
||||||
|
return this.dialogService.open(ShelfCreatorComponent, {
|
||||||
|
showHeader: false,
|
||||||
|
modal: true,
|
||||||
|
draggable: false,
|
||||||
|
dismissableMask: true,
|
||||||
|
closable: true,
|
||||||
|
contentStyle: {overflow: 'auto'},
|
||||||
|
baseZIndex: 10,
|
||||||
|
style: {
|
||||||
|
position: 'absolute',
|
||||||
|
top: '15%',
|
||||||
|
},
|
||||||
|
})!;
|
||||||
|
}
|
||||||
|
|
||||||
openLockUnlockMetadataDialog(bookIds: Set<number>): DynamicDialogRef | null {
|
openLockUnlockMetadataDialog(bookIds: Set<number>): DynamicDialogRef | null {
|
||||||
const count = bookIds.size;
|
const count = bookIds.size;
|
||||||
return this.dialogService.open(LockUnlockMetadataDialogComponent, {
|
return this.dialogService.open(LockUnlockMetadataDialogComponent, {
|
||||||
|
|||||||
+77
-35
@@ -1,47 +1,89 @@
|
|||||||
<div class="p-4 min-w-[26rem] min-h-[30rem] flex flex-col">
|
<div class="shelf-assigner">
|
||||||
|
<div class="panel-header">
|
||||||
<div class="flex flex-col flex-grow">
|
<div class="header-icon-wrapper">
|
||||||
|
<i class="pi pi-bookmark header-icon"></i>
|
||||||
@for (shelf of (shelfState$ | async)?.shelves; track shelf) {
|
|
||||||
<div>
|
|
||||||
<div class="flex flex-row items-center gap-4 py-2">
|
|
||||||
<p-checkbox [inputId]="shelf.name" name="group" [value]="shelf" [(ngModel)]="selectedShelves"></p-checkbox>
|
|
||||||
<label [for]="shelf.id">{{ shelf.name }}</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="header-text">
|
||||||
|
<h2 class="panel-title">Assign Books to Shelves</h2>
|
||||||
|
<p class="panel-description">
|
||||||
|
@if (isMultiBooks) {
|
||||||
|
Select shelves for {{ bookIds.size }} {{ bookIds.size === 1 ? 'book' : 'books' }}
|
||||||
|
} @else {
|
||||||
|
Organize "{{ book.metadata?.title }}" into your shelves
|
||||||
}
|
}
|
||||||
|
</p>
|
||||||
<div class="flex justify-between items-center pt-4 mt-auto">
|
|
||||||
<p-button outlined="true" label="Create Shelf" (onClick)="createShelfDialog()"></p-button>
|
|
||||||
<div class="flex gap-4">
|
|
||||||
<p-button severity="secondary" label="Cancel" (onClick)="closeDialog()"></p-button>
|
|
||||||
<p-button label="Save" (onClick)="updateBooksShelves()"></p-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p-dialog [style]="{ width: '26rem', height: '30rem' }" [(visible)]="displayShelfDialog" header="Create Shelf" [modal]="true" [draggable]="false" [closable]="true" (onHide)="closeShelfDialog()">
|
<div class="shelves-container">
|
||||||
<div class="py-2">
|
@if ((shelfState$ | async)?.shelves && (shelfState$ | async)!.shelves!.length > 0) {
|
||||||
<label for="shelfName">Shelf Name</label>
|
<div class="shelves-list">
|
||||||
<input id="shelfName" type="text" pInputText [(ngModel)]="shelfName" class="w-full"/>
|
<div class="list-header">
|
||||||
|
<span class="shelf-count">
|
||||||
|
<i class="pi pi-bookmark"></i>
|
||||||
|
{{ (shelfState$ | async)!.shelves!.length }} {{ (shelfState$ | async)!.shelves!.length === 1 ? 'shelf' : 'shelves' }} available
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="py-4">
|
|
||||||
<label>Shelf Icon</label>
|
<div class="shelves-grid">
|
||||||
@if (!selectedIcon) {
|
@for (shelf of (shelfState$ | async)?.shelves; track shelf.id) {
|
||||||
<div>
|
<div class="shelf-item" [class.selected]="isShelfSelected(shelf)">
|
||||||
<p-button label="Select Icon" icon="pi pi-search" (onClick)="openIconPicker()"></p-button>
|
<div class="shelf-checkbox">
|
||||||
|
<p-checkbox
|
||||||
|
[inputId]="'shelf-' + shelf.id"
|
||||||
|
name="shelves"
|
||||||
|
[value]="shelf"
|
||||||
|
[(ngModel)]="selectedShelves"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<label [for]="'shelf-' + shelf.id" class="shelf-label">
|
||||||
|
<div class="shelf-icon-wrapper">
|
||||||
|
@if (shelf.icon) {
|
||||||
|
<i [class]="'pi pi-' + shelf.icon + ' shelf-icon'"></i>
|
||||||
|
} @else {
|
||||||
|
<i class="pi pi-bookmark shelf-icon"></i>
|
||||||
}
|
}
|
||||||
@if (selectedIcon) {
|
</div>
|
||||||
<div class="flex items-center gap-4">
|
<span class="shelf-name">{{ shelf.name }}</span>
|
||||||
<i [class]="selectedIcon"></i>
|
</label>
|
||||||
<p-button icon="pi pi-times" text="true" outlined="true" severity="warn" (onClick)="clearSelectedIcon()"></p-button>
|
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<ng-template pTemplate="footer">
|
</div>
|
||||||
<p-button label="Cancel" severity="secondary" (onClick)="closeShelfDialog()" class="p-button-text"></p-button>
|
} @else {
|
||||||
<p-button label="Save" (onClick)="saveNewShelf()"></p-button>
|
<div class="empty-state">
|
||||||
</ng-template>
|
<div class="empty-icon-wrapper">
|
||||||
</p-dialog>
|
<i class="pi pi-bookmark empty-icon"></i>
|
||||||
|
</div>
|
||||||
|
<h3 class="empty-title">No Shelves Available</h3>
|
||||||
|
<p class="empty-description">
|
||||||
|
Create your first shelf to start organizing your books.<br/>
|
||||||
|
Click the button below to get started.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<p-button
|
||||||
|
label="Create Shelf"
|
||||||
|
icon="pi pi-plus"
|
||||||
|
[outlined]="true"
|
||||||
|
(onClick)="createShelfDialog()"
|
||||||
|
/>
|
||||||
|
<div class="footer-actions">
|
||||||
|
<p-button
|
||||||
|
label="Cancel"
|
||||||
|
severity="secondary"
|
||||||
|
[outlined]="true"
|
||||||
|
(onClick)="closeDialog()"
|
||||||
|
/>
|
||||||
|
<p-button
|
||||||
|
label="Save Changes"
|
||||||
|
icon="pi pi-check"
|
||||||
|
severity="success"
|
||||||
|
(onClick)="updateBooksShelves()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+358
@@ -0,0 +1,358 @@
|
|||||||
|
.shelf-assigner {
|
||||||
|
width: 550px;
|
||||||
|
max-width: 550px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
padding-top: 20px;
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 1.25rem;
|
||||||
|
background: linear-gradient(135deg, rgba(var(--primary-color-rgb), 0.1) 0%, rgba(var(--primary-color-rgb), 0.05) 100%);
|
||||||
|
border-radius: 10px 10px 0 0;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-bottom: none;
|
||||||
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
|
||||||
|
|
||||||
|
.header-icon-wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
background: var(--primary-color);
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 3px 8px rgba(var(--primary-color-rgb), 0.3);
|
||||||
|
|
||||||
|
.header-icon {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
color: var(--primary-contrast-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-text {
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
.panel-title {
|
||||||
|
margin: 0 0 0.25rem 0;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-description {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
color: var(--text-secondary-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
padding: 1rem;
|
||||||
|
|
||||||
|
.header-icon-wrapper {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
|
||||||
|
.header-icon {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-text {
|
||||||
|
.panel-title {
|
||||||
|
font-size: 1.125rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-description {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.shelves-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 1.5rem;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
padding: 1rem;
|
||||||
|
min-height: 300px;
|
||||||
|
max-height: 400px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.shelves-list {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.75rem;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0.625rem 0.875rem;
|
||||||
|
background: var(--overlay-background);
|
||||||
|
border-radius: 6px;
|
||||||
|
|
||||||
|
.shelf-count {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.375rem;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-color);
|
||||||
|
|
||||||
|
i {
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
padding: 0.5rem 0.625rem;
|
||||||
|
|
||||||
|
.shelf-count {
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.shelves-grid {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
overflow-y: auto;
|
||||||
|
flex: 1;
|
||||||
|
padding-right: 0.25rem;
|
||||||
|
|
||||||
|
&::-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.75rem;
|
||||||
|
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 {
|
||||||
|
background: rgba(var(--primary-color-rgb), 0.08);
|
||||||
|
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 {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 38px;
|
||||||
|
height: 38px;
|
||||||
|
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 {
|
||||||
|
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 {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
padding: 1.25rem 1.5rem;
|
||||||
|
background: var(--card-background);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-top: none;
|
||||||
|
border-radius: 0 0 10px 10px;
|
||||||
|
box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
|
||||||
|
|
||||||
|
.footer-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 1rem;
|
||||||
|
gap: 0.5rem;
|
||||||
|
|
||||||
|
.footer-actions {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+15
-46
@@ -1,7 +1,7 @@
|
|||||||
import {Component, inject, OnInit} from '@angular/core';
|
import {Component, inject, OnInit} from '@angular/core';
|
||||||
import {DialogService, DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||||
import {Book} from '../../model/book.model';
|
import {Book} from '../../model/book.model';
|
||||||
import {MessageService, PrimeTemplate} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {ShelfService} from '../../service/shelf.service';
|
import {ShelfService} from '../../service/shelf.service';
|
||||||
import {Observable} from 'rxjs';
|
import {Observable} from 'rxjs';
|
||||||
import {BookService} from '../../service/book.service';
|
import {BookService} from '../../service/book.service';
|
||||||
@@ -12,24 +12,19 @@ import {Button} from 'primeng/button';
|
|||||||
import {AsyncPipe} from '@angular/common';
|
import {AsyncPipe} from '@angular/common';
|
||||||
import {Checkbox} from 'primeng/checkbox';
|
import {Checkbox} from 'primeng/checkbox';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {Dialog} from 'primeng/dialog';
|
import {BookDialogHelperService} from '../book-browser/BookDialogHelperService';
|
||||||
import {InputText} from 'primeng/inputtext';
|
|
||||||
import {IconPickerService} from '../../../../shared/service/icon-picker.service';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-shelf-assigner',
|
selector: 'app-shelf-assigner',
|
||||||
standalone: true,
|
standalone: true,
|
||||||
templateUrl: './shelf-assigner.component.html',
|
templateUrl: './shelf-assigner.component.html',
|
||||||
|
styleUrl: './shelf-assigner.component.scss',
|
||||||
imports: [
|
imports: [
|
||||||
Button,
|
Button,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
AsyncPipe,
|
AsyncPipe,
|
||||||
FormsModule,
|
FormsModule
|
||||||
Dialog,
|
]
|
||||||
InputText,
|
|
||||||
PrimeTemplate
|
|
||||||
],
|
|
||||||
styleUrls: ['./shelf-assigner.component.scss']
|
|
||||||
})
|
})
|
||||||
export class ShelfAssignerComponent implements OnInit {
|
export class ShelfAssignerComponent implements OnInit {
|
||||||
|
|
||||||
@@ -38,16 +33,13 @@ export class ShelfAssignerComponent implements OnInit {
|
|||||||
private dynamicDialogRef = inject(DynamicDialogRef);
|
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||||
private messageService = inject(MessageService);
|
private messageService = inject(MessageService);
|
||||||
private bookService = inject(BookService);
|
private bookService = inject(BookService);
|
||||||
private iconPickerService = inject(IconPickerService);
|
private bookDialogHelper = inject(BookDialogHelperService);
|
||||||
|
|
||||||
shelfState$: Observable<ShelfState> = this.shelfService.shelfState$;
|
shelfState$: Observable<ShelfState> = this.shelfService.shelfState$;
|
||||||
book: Book = this.dynamicDialogConfig.data.book;
|
book: Book = this.dynamicDialogConfig.data.book;
|
||||||
selectedShelves: Shelf[] = [];
|
selectedShelves: Shelf[] = [];
|
||||||
displayShelfDialog: boolean = false;
|
|
||||||
shelfName: string = '';
|
|
||||||
bookIds: Set<number> = this.dynamicDialogConfig.data.bookIds;
|
bookIds: Set<number> = this.dynamicDialogConfig.data.bookIds;
|
||||||
isMultiBooks: boolean = this.dynamicDialogConfig.data.isMultiBooks;
|
isMultiBooks: boolean = this.dynamicDialogConfig.data.isMultiBooks;
|
||||||
selectedIcon: string | null = null;
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (!this.isMultiBooks && this.book.shelves) {
|
if (!this.isMultiBooks && this.book.shelves) {
|
||||||
@@ -62,23 +54,6 @@ export class ShelfAssignerComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveNewShelf(): void {
|
|
||||||
const newShelf: Partial<Shelf> = {
|
|
||||||
name: this.shelfName,
|
|
||||||
icon: this.selectedIcon ? this.selectedIcon.replace('pi pi-', '') : 'heart'
|
|
||||||
};
|
|
||||||
this.shelfService.createShelf(newShelf as Shelf).subscribe({
|
|
||||||
next: () => {
|
|
||||||
this.messageService.add({severity: 'info', summary: 'Success', detail: `Shelf created: ${this.shelfName}`});
|
|
||||||
this.displayShelfDialog = false;
|
|
||||||
},
|
|
||||||
error: (e) => {
|
|
||||||
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to create shelf'});
|
|
||||||
console.error('Error creating shelf:', e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
updateBooksShelves(): void {
|
updateBooksShelves(): void {
|
||||||
const idsToAssign = new Set<number | undefined>(this.selectedShelves.map(shelf => shelf.id));
|
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 idsToUnassign: Set<number> = this.isMultiBooks ? new Set() : this.getIdsToUnAssign(this.book, idsToAssign);
|
||||||
@@ -110,26 +85,20 @@ export class ShelfAssignerComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createShelfDialog(): void {
|
createShelfDialog(): void {
|
||||||
this.displayShelfDialog = true;
|
const dialogRef = this.bookDialogHelper.openShelfCreator();
|
||||||
}
|
|
||||||
|
|
||||||
closeShelfDialog(): void {
|
dialogRef.onClose.subscribe((created: boolean) => {
|
||||||
this.displayShelfDialog = false;
|
if (created) {
|
||||||
|
this.shelfService.reloadShelves();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
closeDialog(): void {
|
closeDialog(): void {
|
||||||
this.dynamicDialogRef.close();
|
this.dynamicDialogRef.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
openIconPicker() {
|
isShelfSelected(shelf: Shelf): boolean {
|
||||||
this.iconPickerService.open().subscribe(icon => {
|
return this.selectedShelves.some(s => s.id === shelf.id);
|
||||||
if (icon) {
|
|
||||||
this.selectedIcon = icon;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
clearSelectedIcon() {
|
|
||||||
this.selectedIcon = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+105
@@ -0,0 +1,105 @@
|
|||||||
|
<div class="shelf-creator">
|
||||||
|
<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">Create New Shelf</h2>
|
||||||
|
<p class="panel-description">Add a custom shelf to organize your books</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-container">
|
||||||
|
<div class="form-group highlight-group">
|
||||||
|
<label for="shelfName" class="form-label">
|
||||||
|
<i class="pi pi-tag label-icon"></i>
|
||||||
|
Shelf Name
|
||||||
|
<span class="required-indicator">*</span>
|
||||||
|
</label>
|
||||||
|
<div class="input-wrapper">
|
||||||
|
<input
|
||||||
|
id="shelfName"
|
||||||
|
type="text"
|
||||||
|
pInputText
|
||||||
|
[(ngModel)]="shelfName"
|
||||||
|
class="input-full"
|
||||||
|
placeholder="e.g., Favorites, To Read, Currently Reading"
|
||||||
|
[class.filled]="shelfName.trim()"
|
||||||
|
autofocus
|
||||||
|
/>
|
||||||
|
@if (shelfName.trim()) {
|
||||||
|
<i class="pi pi-check-circle input-icon success"></i>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="divider"></div>
|
||||||
|
|
||||||
|
<div class="form-group highlight-group">
|
||||||
|
<label class="form-label">
|
||||||
|
<i class="pi pi-palette label-icon"></i>
|
||||||
|
Shelf Icon (Optional)
|
||||||
|
</label>
|
||||||
|
@if (!selectedIcon) {
|
||||||
|
<button class="icon-select-btn" (click)="openIconPicker()" type="button">
|
||||||
|
<i class="pi pi-plus"></i>
|
||||||
|
<div class="btn-content">
|
||||||
|
<span class="btn-title">Choose an Icon</span>
|
||||||
|
<span class="btn-subtitle">Select from available icons</span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
} @else {
|
||||||
|
<div class="selected-icon-display">
|
||||||
|
<div class="icon-preview">
|
||||||
|
<i [class]="selectedIcon"></i>
|
||||||
|
</div>
|
||||||
|
<div class="icon-info">
|
||||||
|
<span class="icon-label">Selected Icon</span>
|
||||||
|
<span class="icon-name">{{ selectedIcon }}</span>
|
||||||
|
</div>
|
||||||
|
<p-button
|
||||||
|
icon="pi pi-times"
|
||||||
|
severity="danger"
|
||||||
|
[outlined]="true"
|
||||||
|
[rounded]="true"
|
||||||
|
size="small"
|
||||||
|
(onClick)="clearSelectedIcon()"
|
||||||
|
pTooltip="Remove icon"
|
||||||
|
tooltipPosition="left"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<div class="validation-status">
|
||||||
|
@if (!shelfName.trim()) {
|
||||||
|
<div class="validation-message error">
|
||||||
|
<i class="pi pi-exclamation-circle"></i>
|
||||||
|
<span>Shelf name is required</span>
|
||||||
|
</div>
|
||||||
|
} @else {
|
||||||
|
<div class="validation-message success">
|
||||||
|
<i class="pi pi-check-circle"></i>
|
||||||
|
<span>Ready to create</span>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="footer-actions">
|
||||||
|
<p-button
|
||||||
|
label="Cancel"
|
||||||
|
severity="secondary"
|
||||||
|
[outlined]="true"
|
||||||
|
(onClick)="cancel()"
|
||||||
|
/>
|
||||||
|
<p-button
|
||||||
|
label="Create Shelf"
|
||||||
|
icon="pi pi-plus"
|
||||||
|
severity="success"
|
||||||
|
(onClick)="saveNewShelf()"
|
||||||
|
[disabled]="!shelfName.trim()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
+384
@@ -0,0 +1,384 @@
|
|||||||
|
.shelf-creator {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
min-width: 600px;
|
||||||
|
padding-top: 20px;
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
min-width: auto;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 1.25rem;
|
||||||
|
background: linear-gradient(135deg, rgba(var(--primary-color-rgb), 0.1) 0%, rgba(var(--primary-color-rgb), 0.05) 100%);
|
||||||
|
border-radius: 10px 10px 0 0;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
|
||||||
|
.header-icon-wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
background: var(--primary-color);
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 3px 8px rgba(var(--primary-color-rgb), 0.3);
|
||||||
|
|
||||||
|
.header-icon {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
color: var(--primary-contrast-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-text {
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
.panel-title {
|
||||||
|
margin: 0 0 0.25rem 0;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-description {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
color: var(--text-secondary-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
padding: 1rem;
|
||||||
|
|
||||||
|
.header-icon-wrapper {
|
||||||
|
width: 40px;
|
||||||
|
height: 40px;
|
||||||
|
|
||||||
|
.header-icon {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-text {
|
||||||
|
.panel-title {
|
||||||
|
font-size: 1.125rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-description {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 1.5rem;
|
||||||
|
padding: 1.5rem;
|
||||||
|
background: var(--card-background);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-top: none;
|
||||||
|
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
padding: 1rem;
|
||||||
|
gap: 1rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
|
|
||||||
|
&.highlight-group {
|
||||||
|
padding: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
gap: 0.375rem;
|
||||||
|
|
||||||
|
&.highlight-group {
|
||||||
|
padding: 0.625rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-label {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.375rem;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-color);
|
||||||
|
|
||||||
|
.label-icon {
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.required-indicator {
|
||||||
|
color: var(--p-red-500);
|
||||||
|
margin-left: 0.125rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-wrapper {
|
||||||
|
position: relative;
|
||||||
|
|
||||||
|
.input-full {
|
||||||
|
width: 100%;
|
||||||
|
padding-right: 2.5rem;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-icon {
|
||||||
|
position: absolute;
|
||||||
|
right: 0.75rem;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
font-size: 1rem;
|
||||||
|
pointer-events: none;
|
||||||
|
|
||||||
|
&.success {
|
||||||
|
color: var(--p-green-500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-select-btn {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
width: 100%;
|
||||||
|
padding: 1rem;
|
||||||
|
background: var(--ground-background);
|
||||||
|
border: 1px dashed var(--border-color);
|
||||||
|
border-radius: 8px;
|
||||||
|
color: var(--text-color);
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background: var(--overlay-background);
|
||||||
|
border-color: var(--primary-color);
|
||||||
|
color: var(--primary-color);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 3px 8px rgba(var(--primary-color-rgb), 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
i {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 0.125rem;
|
||||||
|
|
||||||
|
.btn-title {
|
||||||
|
font-size: 0.9375rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-subtitle {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
opacity: 0.85;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
padding: 0.75rem;
|
||||||
|
gap: 0.5rem;
|
||||||
|
|
||||||
|
i {
|
||||||
|
font-size: 1.125rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-content {
|
||||||
|
.btn-title {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-subtitle {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.selected-icon-display {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
padding: 0.875rem;
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--ground-background);
|
||||||
|
|
||||||
|
.icon-preview {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 42px;
|
||||||
|
height: 42px;
|
||||||
|
background: var(--primary-color);
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 3px 8px rgba(var(--primary-color-rgb), 0.3);
|
||||||
|
|
||||||
|
i {
|
||||||
|
font-size: 1.25rem;
|
||||||
|
color: var(--primary-contrast-color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-info {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.125rem;
|
||||||
|
|
||||||
|
.icon-label {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
color: var(--text-secondary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-name {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--text-color);
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
padding: 0.625rem;
|
||||||
|
gap: 0.5rem;
|
||||||
|
|
||||||
|
.icon-preview {
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
|
||||||
|
i {
|
||||||
|
font-size: 1.125rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-info {
|
||||||
|
.icon-label {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.icon-name {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.divider {
|
||||||
|
height: 1px;
|
||||||
|
background: linear-gradient(90deg, transparent, var(--border-color), transparent);
|
||||||
|
margin: 0.25rem 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dialog-footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1rem;
|
||||||
|
padding: 1.25rem 1.5rem;
|
||||||
|
background: var(--card-background);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
|
border-top: none;
|
||||||
|
border-radius: 0 0 10px 10px;
|
||||||
|
box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
|
||||||
|
|
||||||
|
.validation-status {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.75rem;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: stretch;
|
||||||
|
padding: 1rem;
|
||||||
|
gap: 0.75rem;
|
||||||
|
|
||||||
|
.validation-status {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer-actions {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.validation-message {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.375rem;
|
||||||
|
padding: 0.5rem 0.75rem;
|
||||||
|
font-weight: 500;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 0.875rem;
|
||||||
|
width: fit-content;
|
||||||
|
max-width: 100%;
|
||||||
|
|
||||||
|
i {
|
||||||
|
font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.error {
|
||||||
|
background: rgba(239, 68, 68, 0.1);
|
||||||
|
color: rgb(239, 68, 68);
|
||||||
|
border: 1px solid rgba(239, 68, 68, 0.3);
|
||||||
|
|
||||||
|
i {
|
||||||
|
color: rgb(239, 68, 68);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.success {
|
||||||
|
background: rgba(34, 197, 94, 0.1);
|
||||||
|
color: rgb(34, 197, 94);
|
||||||
|
border: 1px solid rgba(34, 197, 94, 0.3);
|
||||||
|
|
||||||
|
i {
|
||||||
|
color: rgb(34, 197, 94);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
padding: 0.375rem 0.5rem;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
i {
|
||||||
|
font-size: 0.875rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import {Component, inject} from '@angular/core';
|
||||||
|
import {DynamicDialogRef} from 'primeng/dynamicdialog';
|
||||||
|
import {MessageService} from 'primeng/api';
|
||||||
|
import {ShelfService} from '../../service/shelf.service';
|
||||||
|
import {IconPickerService} from '../../../../shared/service/icon-picker.service';
|
||||||
|
import {Shelf} from '../../model/shelf.model';
|
||||||
|
import {FormsModule} from '@angular/forms';
|
||||||
|
import {Button} from 'primeng/button';
|
||||||
|
import {InputText} from 'primeng/inputtext';
|
||||||
|
import {Tooltip} from 'primeng/tooltip';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-shelf-creator',
|
||||||
|
standalone: true,
|
||||||
|
templateUrl: './shelf-creator.component.html',
|
||||||
|
imports: [
|
||||||
|
FormsModule,
|
||||||
|
Button,
|
||||||
|
InputText,
|
||||||
|
Tooltip
|
||||||
|
],
|
||||||
|
styleUrl: './shelf-creator.component.scss',
|
||||||
|
})
|
||||||
|
export class ShelfCreatorComponent {
|
||||||
|
private shelfService = inject(ShelfService);
|
||||||
|
private dynamicDialogRef = inject(DynamicDialogRef);
|
||||||
|
private messageService = inject(MessageService);
|
||||||
|
private iconPickerService = inject(IconPickerService);
|
||||||
|
|
||||||
|
shelfName: string = '';
|
||||||
|
selectedIcon: string | null = null;
|
||||||
|
|
||||||
|
saveNewShelf(): void {
|
||||||
|
const newShelf: Partial<Shelf> = {
|
||||||
|
name: this.shelfName,
|
||||||
|
icon: this.selectedIcon ? this.selectedIcon.replace('pi pi-', '') : 'heart'
|
||||||
|
};
|
||||||
|
this.shelfService.createShelf(newShelf as Shelf).subscribe({
|
||||||
|
next: () => {
|
||||||
|
this.messageService.add({severity: 'info', summary: 'Success', detail: `Shelf created: ${this.shelfName}`});
|
||||||
|
this.dynamicDialogRef.close(true);
|
||||||
|
},
|
||||||
|
error: (e) => {
|
||||||
|
this.messageService.add({severity: 'error', summary: 'Error', detail: 'Failed to create shelf'});
|
||||||
|
console.error('Error creating shelf:', e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
openIconPicker(): void {
|
||||||
|
this.iconPickerService.open().subscribe(icon => {
|
||||||
|
if (icon) {
|
||||||
|
this.selectedIcon = icon;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
clearSelectedIcon(): void {
|
||||||
|
this.selectedIcon = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
cancel(): void {
|
||||||
|
this.dynamicDialogRef.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -178,7 +178,7 @@ export class AppMenuComponent implements OnInit {
|
|||||||
type: 'shelf',
|
type: 'shelf',
|
||||||
label: 'Shelves',
|
label: 'Shelves',
|
||||||
hasDropDown: true,
|
hasDropDown: true,
|
||||||
hasCreate: false,
|
hasCreate: true,
|
||||||
items,
|
items,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import {Button} from 'primeng/button';
|
|||||||
import {Menu} from 'primeng/menu';
|
import {Menu} from 'primeng/menu';
|
||||||
import {UserService} from '../../../../features/settings/user-management/user.service';
|
import {UserService} from '../../../../features/settings/user-management/user.service';
|
||||||
import {DialogLauncherService} from '../../../services/dialog-launcher.service';
|
import {DialogLauncherService} from '../../../services/dialog-launcher.service';
|
||||||
|
import {ShelfCreatorComponent} from '../../../../features/book/components/shelf-creator/shelf-creator.component';
|
||||||
|
import {BookDialogHelperService} from '../../../../features/book/components/book-browser/BookDialogHelperService';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: '[app-menuitem]',
|
selector: '[app-menuitem]',
|
||||||
@@ -56,7 +58,8 @@ export class AppMenuitemComponent implements OnInit, OnDestroy {
|
|||||||
public router: Router,
|
public router: Router,
|
||||||
private menuService: MenuService,
|
private menuService: MenuService,
|
||||||
private userService: UserService,
|
private userService: UserService,
|
||||||
private dialogLauncher: DialogLauncherService
|
private dialogLauncher: DialogLauncherService,
|
||||||
|
private bookDialogHelperService: BookDialogHelperService
|
||||||
) {
|
) {
|
||||||
this.userService.userState$.subscribe(userState => {
|
this.userService.userState$.subscribe(userState => {
|
||||||
if (userState?.user) {
|
if (userState?.user) {
|
||||||
@@ -151,6 +154,9 @@ export class AppMenuitemComponent implements OnInit, OnDestroy {
|
|||||||
if (item.type === 'magicShelf') {
|
if (item.type === 'magicShelf') {
|
||||||
this.dialogLauncher.openMagicShelfDialog();
|
this.dialogLauncher.openMagicShelfDialog();
|
||||||
}
|
}
|
||||||
|
if (item.type === 'shelf') {
|
||||||
|
this.bookDialogHelperService.openShelfCreator();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
triggerLink() {
|
triggerLink() {
|
||||||
|
|||||||
Reference in New Issue
Block a user