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:
@@ -0,0 +1,206 @@
|
||||
<div class="book-notes-container">
|
||||
<div class="notes-content">
|
||||
@if (loading) {
|
||||
<div class="loading-state">
|
||||
<p-progressSpinner/>
|
||||
<span class="loading-text">Loading notes...</span>
|
||||
</div>
|
||||
} @else if (notes.length === 0) {
|
||||
<div class="empty-state">
|
||||
<div class="empty-state-icon">
|
||||
<p-button
|
||||
outlined
|
||||
rounded
|
||||
icon="pi pi-plus"
|
||||
severity="primary"
|
||||
(click)="openCreateDialog()"
|
||||
pTooltip="Add New Note"
|
||||
tooltipPosition="top"
|
||||
class="action-btn floating-btn">
|
||||
</p-button>
|
||||
</div>
|
||||
<p class="empty-state-title">No notes yet for this book</p>
|
||||
<p class="empty-state-subtitle">
|
||||
Click "Add Note" to create your first note and start capturing your thoughts
|
||||
</p>
|
||||
<div class="empty-state-decoration"></div>
|
||||
</div>
|
||||
} @else {
|
||||
<div class="notes-scroll-container">
|
||||
<div class="notes-horizontal-list">
|
||||
@for (note of notes; track note.id + '-' + note.createdAt + '-' + $index) {
|
||||
<div class="note-card">
|
||||
<div class="note-header">
|
||||
<div class="note-header-inner">
|
||||
<div class="note-title-group">
|
||||
<h4 class="note-title">{{ note.title }}</h4>
|
||||
<div class="note-meta">
|
||||
<i class="pi pi-clock note-meta-icon"></i>
|
||||
<span class="note-meta-text">
|
||||
@if (note.createdAt !== note.updatedAt) {
|
||||
Updated {{ formatDate(note.updatedAt) }}
|
||||
} @else {
|
||||
Created {{ formatDate(note.createdAt) }}
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="note-actions">
|
||||
<p-button
|
||||
icon="pi pi-pencil"
|
||||
size="small"
|
||||
severity="secondary"
|
||||
text
|
||||
(onClick)="openEditDialog(note)"
|
||||
pTooltip="Edit note"
|
||||
tooltipPosition="top"
|
||||
class="action-btn-hover">
|
||||
</p-button>
|
||||
<p-button
|
||||
icon="pi pi-trash"
|
||||
size="small"
|
||||
severity="danger"
|
||||
text
|
||||
(onClick)="deleteNote(note)"
|
||||
pTooltip="Delete note"
|
||||
tooltipPosition="top"
|
||||
class="action-btn-hover">
|
||||
</p-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="note-content-area">
|
||||
<div class="note-body">{{ note.content }}</div>
|
||||
<div class="note-fade-overlay"></div>
|
||||
</div>
|
||||
<div class="note-bottom-glow"></div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (notes.length > 0) {
|
||||
<div class="action-bar">
|
||||
<p-button
|
||||
outlined
|
||||
icon="pi pi-plus"
|
||||
severity="success"
|
||||
(click)="openCreateDialog()"
|
||||
pTooltip="Add New Note"
|
||||
tooltipPosition="left">
|
||||
</p-button>
|
||||
</div>
|
||||
}
|
||||
|
||||
<p-dialog
|
||||
header="Add New Note"
|
||||
[(visible)]="showCreateDialog"
|
||||
[modal]="true"
|
||||
[style]="{width: '500px'}"
|
||||
[closable]="true"
|
||||
[dismissableMask]="true">
|
||||
|
||||
<div class="dialog-form">
|
||||
<div class="field">
|
||||
<label for="create-title" class="field-label">Title</label>
|
||||
<input
|
||||
id="create-title"
|
||||
pInputText
|
||||
[(ngModel)]="newNote.title"
|
||||
placeholder="Enter note title"
|
||||
class="field-input"
|
||||
maxlength="255"/>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="create-content" class="field-label">Content</label>
|
||||
<textarea
|
||||
id="create-content"
|
||||
pTextarea
|
||||
[(ngModel)]="newNote.content"
|
||||
placeholder="Enter your note content..."
|
||||
[rows]="8"
|
||||
class="field-input"
|
||||
[autoResize]="true">
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ng-template #footer>
|
||||
<div class="dialog-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
severity="secondary"
|
||||
outlined
|
||||
(onClick)="cancelCreate()">
|
||||
</p-button>
|
||||
<p-button
|
||||
outlined
|
||||
severity="success"
|
||||
label="Save Note"
|
||||
icon="pi pi-save"
|
||||
(onClick)="createNote()">
|
||||
</p-button>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-dialog>
|
||||
|
||||
<p-dialog
|
||||
header="Edit Note"
|
||||
[(visible)]="showEditDialog"
|
||||
[modal]="true"
|
||||
[style]="{width: '500px'}"
|
||||
[closable]="true"
|
||||
[dismissableMask]="true">
|
||||
|
||||
<div class="dialog-form">
|
||||
<div class="field">
|
||||
<label for="edit-title" class="field-label">Title</label>
|
||||
<input
|
||||
id="edit-title"
|
||||
pInputText
|
||||
[(ngModel)]="editNote.title"
|
||||
placeholder="Enter note title"
|
||||
class="field-input"
|
||||
maxlength="255"/>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="edit-content" class="field-label">Content</label>
|
||||
<textarea
|
||||
id="edit-content"
|
||||
pTextarea
|
||||
[(ngModel)]="editNote.content"
|
||||
placeholder="Enter your note content..."
|
||||
[rows]="8"
|
||||
class="field-input"
|
||||
[autoResize]="true">
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ng-template #footer>
|
||||
<div class="dialog-actions">
|
||||
<p-button
|
||||
label="Cancel"
|
||||
severity="secondary"
|
||||
outlined
|
||||
(onClick)="cancelEdit()">
|
||||
</p-button>
|
||||
<p-button
|
||||
outlined
|
||||
severity="success"
|
||||
label="Update Note"
|
||||
icon="pi pi-save"
|
||||
(onClick)="updateNote()">
|
||||
</p-button>
|
||||
</div>
|
||||
</ng-template>
|
||||
</p-dialog>
|
||||
|
||||
<p-confirmDialog key="deleteNote"></p-confirmDialog>
|
||||
</div>
|
||||
@@ -0,0 +1,320 @@
|
||||
.book-notes-container {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
display: flex;
|
||||
min-height: 250px;
|
||||
|
||||
.notes-content {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.action-bar {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 0;
|
||||
transform: translateY(-50%);
|
||||
z-index: 1000;
|
||||
}
|
||||
}
|
||||
|
||||
.loading-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 2rem;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
position: relative;
|
||||
padding: 3rem !important;
|
||||
text-align: center;
|
||||
color: #9ca3af;
|
||||
|
||||
.empty-state-title {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
margin-top: 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
color: #e5e7eb;
|
||||
}
|
||||
|
||||
.empty-state-subtitle {
|
||||
max-width: 400px;
|
||||
margin: 0.5rem auto 0;
|
||||
line-height: 1.6;
|
||||
font-size: 0.875rem;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.empty-state-decoration {
|
||||
position: absolute;
|
||||
top: 20%;
|
||||
right: 15%;
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border-radius: 50%;
|
||||
filter: blur(40px);
|
||||
animation: float 4s ease-in-out infinite;
|
||||
}
|
||||
}
|
||||
|
||||
.notes-scroll-container {
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
height: 100%;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
height: 10px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: rgba(30, 30, 30, 0.5);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
scrollbar-width: thin;
|
||||
}
|
||||
|
||||
.notes-horizontal-list {
|
||||
display: flex;
|
||||
gap: 1.5rem;
|
||||
padding: 0.5rem;
|
||||
}
|
||||
|
||||
.note-card {
|
||||
width: 500px;
|
||||
height: 240px;
|
||||
flex-shrink: 0;
|
||||
padding: 0;
|
||||
border-radius: 16px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
border: 1px solid var(--p-content-border-color);
|
||||
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
|
||||
@media (max-width: 768px) {
|
||||
width: 340px;
|
||||
height: 220px;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
width: 290px;
|
||||
height: 200px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-2px);
|
||||
border-color: color-mix(in srgb, var(--primary-color), transparent 50%);
|
||||
|
||||
.note-bottom-glow {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.action-btn-hover {
|
||||
opacity: 1;
|
||||
transform: scale(1);
|
||||
}
|
||||
}
|
||||
|
||||
.note-header {
|
||||
flex-shrink: 0;
|
||||
background: linear-gradient(135deg, rgba(40, 40, 40, 0.8), rgba(30, 30, 30, 0.8));
|
||||
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
|
||||
position: relative;
|
||||
|
||||
.note-header-inner {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
padding: 0.75rem;
|
||||
}
|
||||
|
||||
.note-title-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.note-title {
|
||||
max-width: 350px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
background: linear-gradient(135deg, #f8fafc, #e2e8f0);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
font-weight: 500;
|
||||
font-size: 1.125rem;
|
||||
margin: 0;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
max-width: 200px;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
max-width: 180px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
}
|
||||
|
||||
.note-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
opacity: 0.8;
|
||||
|
||||
i {
|
||||
color: #3b82f6;
|
||||
}
|
||||
}
|
||||
|
||||
.note-meta-icon {
|
||||
font-size: 0.75rem;
|
||||
margin-right: 0.25rem;
|
||||
}
|
||||
|
||||
.note-meta-text {
|
||||
font-size: 0.875rem;
|
||||
color: #9ca3af;
|
||||
}
|
||||
|
||||
.note-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-shrink: 0;
|
||||
|
||||
.action-btn-hover {
|
||||
opacity: 0.7;
|
||||
transition: all 0.3s ease;
|
||||
transform: scale(0.9);
|
||||
|
||||
::ng-deep .p-button {
|
||||
border-radius: 8px;
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.note-content-area {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
padding: 1rem;
|
||||
|
||||
.note-fade-overlay {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 30px;
|
||||
background: linear-gradient(transparent, rgba(20, 20, 20, 0.9));
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
.note-bottom-glow {
|
||||
position: absolute;
|
||||
bottom: -5px;
|
||||
left: 20%;
|
||||
right: 20%;
|
||||
height: 10px;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
transparent,
|
||||
color-mix(in srgb, var(--primary-color), transparent 60%),
|
||||
transparent
|
||||
);
|
||||
border-radius: 50%;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
filter: blur(5px);
|
||||
}
|
||||
}
|
||||
|
||||
.note-body {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
max-height: 180px;
|
||||
overflow-y: auto;
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
padding-right: 8px;
|
||||
box-sizing: border-box;
|
||||
line-height: 1.6;
|
||||
color: #e2e8f0;
|
||||
|
||||
@media (max-width: 768px) {
|
||||
max-height: 140px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
@media (max-width: 480px) {
|
||||
max-height: 120px;
|
||||
font-size: 0.85rem;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.field-label {
|
||||
display: block;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.field-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dialog-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
@keyframes float {
|
||||
0%, 100% {
|
||||
transform: translateY(0px);
|
||||
}
|
||||
50% {
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% {
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
transform: scale(1.05);
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,255 @@
|
||||
import {Component, DestroyRef, inject, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from '@angular/forms';
|
||||
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
|
||||
import {Button} from 'primeng/button';
|
||||
import {Dialog} from 'primeng/dialog';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {Textarea} from 'primeng/textarea';
|
||||
import {ConfirmDialog} from 'primeng/confirmdialog';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {ConfirmationService, MessageService} from 'primeng/api';
|
||||
import {TranslocoService} from '@jsverse/transloco';
|
||||
import {BookNote, BookNoteService, CreateBookNoteRequest} from '../../../../shared/service/book-note.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-book-notes-component',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
Button,
|
||||
Dialog,
|
||||
InputText,
|
||||
Textarea,
|
||||
ConfirmDialog,
|
||||
ProgressSpinner,
|
||||
Tooltip
|
||||
],
|
||||
templateUrl: './book-notes-component.html',
|
||||
styleUrl: './book-notes-component.scss'
|
||||
})
|
||||
export class BookNotesComponent implements OnInit, OnChanges {
|
||||
@Input() bookId!: number;
|
||||
|
||||
private bookNoteService = inject(BookNoteService);
|
||||
private confirmationService = inject(ConfirmationService);
|
||||
private messageService = inject(MessageService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private readonly t = inject(TranslocoService);
|
||||
|
||||
notes: BookNote[] = [];
|
||||
loading = false;
|
||||
showCreateDialog = false;
|
||||
showEditDialog = false;
|
||||
selectedNote: BookNote | null = null;
|
||||
|
||||
newNote: CreateBookNoteRequest = {
|
||||
bookId: 0,
|
||||
title: '',
|
||||
content: ''
|
||||
};
|
||||
|
||||
editNote: CreateBookNoteRequest = {
|
||||
bookId: 0,
|
||||
title: '',
|
||||
content: ''
|
||||
};
|
||||
|
||||
ngOnInit(): void {
|
||||
if (this.bookId) {
|
||||
this.loadNotes();
|
||||
}
|
||||
}
|
||||
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (changes['bookId'] && changes['bookId'].currentValue) {
|
||||
this.loadNotes();
|
||||
}
|
||||
}
|
||||
|
||||
loadNotes(): void {
|
||||
if (!this.bookId) return;
|
||||
|
||||
this.loading = true;
|
||||
this.bookNoteService.getNotesForBook(this.bookId)
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe({
|
||||
next: (notes) => {
|
||||
this.notes = notes.sort((a, b) =>
|
||||
new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
|
||||
);
|
||||
this.loading = false;
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Failed to load notes:', error);
|
||||
this.loading = false;
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('book.notes.toast.loadFailedDetail')
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
openCreateDialog(): void {
|
||||
this.newNote = {
|
||||
bookId: this.bookId,
|
||||
title: '',
|
||||
content: ''
|
||||
};
|
||||
this.showCreateDialog = true;
|
||||
}
|
||||
|
||||
openEditDialog(note: BookNote): void {
|
||||
this.selectedNote = note;
|
||||
this.editNote = {
|
||||
id: note.id,
|
||||
bookId: note.bookId,
|
||||
title: note.title,
|
||||
content: note.content
|
||||
};
|
||||
this.showEditDialog = true;
|
||||
}
|
||||
|
||||
createNote(): void {
|
||||
if (!this.newNote.title.trim() || !this.newNote.content.trim()) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: this.t.translate('book.notes.toast.validationSummary'),
|
||||
detail: this.t.translate('book.notes.toast.validationDetail')
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.bookNoteService.createOrUpdateNote(this.newNote)
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe({
|
||||
next: (note) => {
|
||||
this.notes.unshift(note);
|
||||
this.showCreateDialog = false;
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('book.notes.toast.createSuccessDetail')
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Failed to create note:', error);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('book.notes.toast.createFailedDetail')
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateNote(): void {
|
||||
if (!this.editNote.title?.trim() || !this.editNote.content?.trim()) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: this.t.translate('book.notes.toast.validationSummary'),
|
||||
detail: this.t.translate('book.notes.toast.validationDetail')
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
this.bookNoteService.createOrUpdateNote(this.editNote)
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe({
|
||||
next: (updatedNote) => {
|
||||
const index = this.notes.findIndex(n => n.id === this.selectedNote?.id);
|
||||
if (index !== -1) {
|
||||
this.notes[index] = updatedNote;
|
||||
this.notes.sort((a, b) =>
|
||||
new Date(b.updatedAt).getTime() - new Date(a.updatedAt).getTime()
|
||||
);
|
||||
}
|
||||
this.showEditDialog = false;
|
||||
this.selectedNote = null;
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('book.notes.toast.updateSuccessDetail')
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Failed to update note:', error);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('book.notes.toast.updateFailedDetail')
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
deleteNote(note: BookNote): void {
|
||||
this.confirmationService.confirm({
|
||||
key: 'deleteNote',
|
||||
message: this.t.translate('book.notes.confirm.deleteMessage', {title: note.title}),
|
||||
header: this.t.translate('book.notes.confirm.deleteHeader'),
|
||||
icon: 'pi pi-exclamation-triangle',
|
||||
acceptIcon: 'pi pi-trash',
|
||||
rejectIcon: 'pi pi-times',
|
||||
acceptButtonStyleClass: 'p-button-danger, p-button-outlined p-button-danger',
|
||||
rejectButtonStyleClass: 'p-button-danger, p-button-outlined p-button-info',
|
||||
accept: () => {
|
||||
this.performDelete(note.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private performDelete(noteId: number): void {
|
||||
this.bookNoteService.deleteNote(noteId).subscribe({
|
||||
next: () => {
|
||||
this.notes = this.notes.filter(n => n.id !== noteId);
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: this.t.translate('common.success'),
|
||||
detail: this.t.translate('book.notes.toast.deleteSuccessDetail')
|
||||
});
|
||||
},
|
||||
error: (error) => {
|
||||
console.error('Failed to delete note:', error);
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('common.error'),
|
||||
detail: this.t.translate('book.notes.toast.deleteFailedDetail')
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
cancelCreate(): void {
|
||||
this.showCreateDialog = false;
|
||||
this.newNote = {
|
||||
bookId: this.bookId,
|
||||
title: '',
|
||||
content: ''
|
||||
};
|
||||
}
|
||||
|
||||
cancelEdit(): void {
|
||||
this.showEditDialog = false;
|
||||
this.selectedNote = null;
|
||||
this.editNote = {
|
||||
bookId: this.bookId,
|
||||
title: '',
|
||||
content: ''
|
||||
};
|
||||
}
|
||||
|
||||
formatDate(dateString: string): string {
|
||||
return new Date(dateString).toLocaleDateString('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user