Dialog refactor 2 (#2321)

Co-authored-by: acx10 <acx10@users.noreply.github.com>
This commit is contained in:
ACX
2026-01-18 02:36:24 -07:00
committed by GitHub
co-authored by acx10
parent fda76eead7
commit 1889a04bac
51 changed files with 2206 additions and 1018 deletions
@@ -1,11 +1,24 @@
<div class="flex flex-col gap-6 p-4 items-center justify-center w-full max-w-[700px]">
<!-- Book Information -->
<div class="w-full text-center">
<h3 class="text-lg font-semibold mb-2">{{ book.metadata?.title || 'Unknown Title' }}</h3>
<p class="text-sm text-gray-600">{{ book.filePath }}</p>
<div class="additional-file-uploader-container">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-file-plus header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Upload Additional File</h2>
<p class="panel-description">{{ book.metadata?.title || 'Unknown Title' }}</p>
</div>
<p-button
icon="pi pi-times"
[rounded]="true"
[text]="true"
severity="secondary"
(click)="closeDialog()"
styleClass="close-button">
</p-button>
</div>
<!-- File Type Selection -->
<div class="dialog-content">
<!-- File Type Selection -->
<p-select
[options]="fileTypeOptions"
[(ngModel)]="fileType"
@@ -126,4 +139,5 @@
</div>
</ng-template>
</p-fileupload>
</div>
</div>
@@ -1,3 +1,31 @@
@use '../../../../shared/styles/panel-shared' as panel;
.additional-file-uploader-container {
display: flex;
flex-direction: column;
height: 100%;
}
.panel-header {
@include panel.panel-header;
flex-shrink: 0;
}
.dialog-content {
flex: 1;
overflow-y: auto;
min-height: 0;
padding: 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 6px rgba(0, 0, 0, 0.08);
display: flex;
flex-direction: column;
gap: 1.5rem;
}
:host ::ng-deep .p-fileupload-content p-progressbar {
display: none !important;
}
}
@@ -185,4 +185,8 @@ export class AdditionalFileUploaderComponent implements OnInit, OnDestroy {
return 'info';
}
}
closeDialog(): void {
this.dialogRef.close();
}
}
@@ -1,6 +1,6 @@
import {inject, Injectable} from '@angular/core';
import {DynamicDialogRef} from 'primeng/dynamicdialog';
import {DialogLauncherService} from '../../../../shared/services/dialog-launcher.service';
import {DialogLauncherService, DialogSize, DialogStyle} from '../../../../shared/services/dialog-launcher.service';
import {ShelfAssignerComponent} from '../shelf-assigner/shelf-assigner.component';
import {LockUnlockMetadataDialogComponent} from './lock-unlock-metadata-dialog/lock-unlock-metadata-dialog.component';
import {MetadataRefreshType} from '../../../metadata/model/request/metadata-refresh-type.enum';
@@ -27,8 +27,8 @@ export class BookDialogHelperService {
openBookDetailsDialog(bookId: number): DynamicDialogRef | null {
return this.openDialog(BookMetadataCenterComponent, {
header: 'Book Details',
styleClass: 'book-details-dialog dialog-maximal',
showHeader: false,
styleClass: `book-details-dialog ${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
data: {
bookId: bookId,
},
@@ -49,21 +49,21 @@ export class BookDialogHelperService {
return this.openDialog(ShelfAssignerComponent, {
showHeader: false,
data: data,
styleClass: 'dynamic-dialog-minimal',
styleClass: `${DialogSize.SM} ${DialogStyle.MINIMAL}`,
});
}
openShelfCreatorDialog(): DynamicDialogRef {
return this.openDialog(ShelfCreatorComponent, {
showHeader: false,
styleClass: 'dynamic-dialog-minimal',
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
})!;
}
openLockUnlockMetadataDialog(bookIds: Set<number>): DynamicDialogRef | null {
const count = bookIds.size;
return this.openDialog(LockUnlockMetadataDialogComponent, {
header: `Lock or Unlock Metadata for ${count} Selected Book${count > 1 ? 's' : ''}`,
showHeader: false,
styleClass: `${DialogSize.LG} ${DialogStyle.MINIMAL}`,
data: {
bookIds: Array.from(bookIds),
},
@@ -72,82 +72,84 @@ export class BookDialogHelperService {
openMetadataRefreshDialog(bookIds: Set<number>): DynamicDialogRef | null {
return this.openDialog(MultiBookMetadataFetchComponent, {
header: 'Metadata Refresh Options',
showHeader: false,
styleClass: `${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
data: {
bookIds: Array.from(bookIds),
metadataRefreshType: MetadataRefreshType.BOOKS,
},
styleClass: 'dialog-maximal',
});
}
openBulkMetadataEditDialog(bookIds: Set<number>): DynamicDialogRef | null {
return this.openDialog(BulkMetadataUpdateComponent, {
header: 'Bulk Edit Metadata',
showHeader: false,
styleClass: `${DialogSize.XL} ${DialogStyle.MINIMAL}`,
data: {
bookIds: Array.from(bookIds),
},
styleClass: 'dialog-maximal'
});
}
openMultibookMetadataEditorDialog(bookIds: Set<number>): DynamicDialogRef | null {
return this.openDialog(MultiBookMetadataEditorComponent, {
header: 'Multi-Book Metadata Editor',
showHeader: false,
styleClass: `${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
data: {
bookIds: Array.from(bookIds),
},
styleClass: 'dialog-full'
});
}
openFileMoverDialog(bookIds: Set<number>): DynamicDialogRef | null {
const count = bookIds.size;
return this.openDialog(FileMoverComponent, {
header: `Organize Book Files (${count} book${count !== 1 ? 's' : ''})`,
showHeader: false,
styleClass: `${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
maximizable: true,
data: {
bookIds: Array.from(bookIds),
},
styleClass: 'dialog-full',
maximizable: true,
});
}
openCustomSendDialog(bookId: number): DynamicDialogRef | null {
return this.openDialog(BookSenderComponent, {
header: 'Send Book to Email',
showHeader: false,
styleClass: `${DialogSize.SM} ${DialogStyle.MINIMAL}`,
data: {
bookId: bookId,
}
},
});
}
openCoverSearchDialog(bookId: number): DynamicDialogRef | null {
return this.openDialog(CoverSearchComponent, {
header: "Search Cover",
showHeader: false,
styleClass: `${DialogSize.FULL} ${DialogStyle.MINIMAL}`,
data: {
bookId: bookId,
},
styleClass: 'dialog-maximal',
});
}
openMetadataFetchOptionsDialog(bookId: number): DynamicDialogRef | null {
return this.openDialog(MetadataFetchOptionsComponent, {
header: 'Metadata Refresh Options',
showHeader: false,
styleClass: `${DialogSize.SM} ${DialogStyle.MINIMAL}`,
data: {
bookIds: [bookId],
metadataRefreshType: MetadataRefreshType.BOOKS,
}
},
});
}
openAdditionalFileUploaderDialog(book: Book): DynamicDialogRef | null {
return this.openDialog(AdditionalFileUploaderComponent, {
header: 'Upload Additional File',
showHeader: false,
styleClass: `${DialogSize.MD} ${DialogStyle.MINIMAL}`,
data: {
book: book,
}
},
});
}
}
@@ -1,29 +1,48 @@
<div class="p-2">
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-x-24 gap-y-4">
@for (field of lockableFields; track field) {
<div class="flex items-center justify-between">
<label class="capitalize">{{ fieldLabels[field] || field }}</label>
<p-button
[outlined]="true"
[label]="getLockLabel(field)"
[icon]="getLockIcon(field)"
[severity]="fieldLocks[field] === true ? 'danger' : fieldLocks[field] === false ? 'success' : 'secondary'"
(click)="cycleLockState(field)"
></p-button>
</div>
}
<div class="lock-unlock-container">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-lock header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Lock or Unlock Metadata</h2>
<p class="panel-description">{{ bookIds.size }} book{{ bookIds.size > 1 ? 's' : '' }} selected</p>
</div>
<p-button
icon="pi pi-times"
[rounded]="true"
[text]="true"
severity="secondary"
(click)="dialogRef.close()"
styleClass="close-button">
</p-button>
</div>
<div class="dialog-content">
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-x-24 gap-y-4">
@for (field of lockableFields; track field) {
<div class="flex items-center justify-between">
<label class="capitalize">{{ fieldLabels[field] || field }}</label>
<p-button
[outlined]="true"
[label]="getLockLabel(field)"
[icon]="getLockIcon(field)"
[severity]="fieldLocks[field] === true ? 'danger' : fieldLocks[field] === false ? 'success' : 'secondary'"
(click)="cycleLockState(field)"
></p-button>
</div>
}
</div>
</div>
<div class="dialog-footer">
<div class="footer-actions">
<p-button icon="pi pi-refresh" label="Reset" outlined="true" severity="warn" (onClick)="resetFieldLocks()"></p-button>
</div>
<div class="footer-actions">
<p-button icon="pi pi-lock" label="Lock All" outlined="true" severity="danger" (onClick)="toggleLockAll('LOCK')"></p-button>
<p-button icon="pi pi-lock-open" label="Unlock All" outlined="true" severity="success" (onClick)="toggleLockAll('UNLOCK')"></p-button>
<p-divider layout="vertical"></p-divider>
<p-button [label]="isSaving ? 'Saving...' : 'Save'" [outlined]="true" icon="pi pi-check" severity="info" (onClick)="applyFieldLocks()" [disabled]="bookIds.size === 0 || isSaving"></p-button>
</div>
</div>
</div>
<p-divider></p-divider>
<div class="flex justify-end px-4 pt-4">
<p-button icon="pi pi-refresh" label="Reset" outlined="true" severity="warn" (onClick)="resetFieldLocks()"></p-button>
<p-divider layout="vertical"></p-divider>
<div class="flex gap-4 justify-center">
<p-button icon="pi pi-lock" label="Lock All" outlined="true" severity="danger" (onClick)="toggleLockAll('LOCK')"></p-button>
<p-button icon="pi pi-lock-open" label="Unlock All" outlined="true" severity="success" (onClick)="toggleLockAll('UNLOCK')"></p-button>
</div>
<p-divider layout="vertical"></p-divider>
<p-button [label]="isSaving ? 'Saving...' : 'Save'" [outlined]="true" icon="pi pi-check" severity="info" (onClick)="applyFieldLocks()" [disabled]="bookIds.size === 0 || isSaving"></p-button>
</div>
@@ -0,0 +1,28 @@
@use '../../../../../shared/styles/panel-shared' as panel;
.lock-unlock-container {
display: flex;
flex-direction: column;
}
.panel-header {
@include panel.panel-header;
}
.dialog-content {
padding: 1.5rem;
background: var(--card-background);
border: 1px solid var(--border-color);
border-top: none;
border-bottom: none;
}
.dialog-footer {
@include panel.dialog-footer;
}
.footer-actions {
display: flex;
gap: 0.5rem;
align-items: center;
}
@@ -23,7 +23,7 @@ import {finalize} from 'rxjs';
export class LockUnlockMetadataDialogComponent implements OnInit {
private bookService = inject(BookService);
private dynamicDialogConfig = inject(DynamicDialogConfig);
private dialogRef = inject(DynamicDialogRef);
dialogRef = inject(DynamicDialogRef);
private messageService = inject(MessageService);
private loadingService = inject(LoadingService);
fieldLocks: Record<string, boolean | undefined> = {};
@@ -1,29 +1,57 @@
<div class="flex flex-col gap-10 p-4 items-center justify-center min-w-[300px] max-w-[700px] sm:min-w-[400px] mx-auto">
<div class="book-sender-container">
<div class="panel-header">
<div class="header-icon-wrapper">
<i class="pi pi-envelope header-icon"></i>
</div>
<div class="header-text">
<h2 class="panel-title">Send Book</h2>
<p class="panel-description">Email this book to a recipient</p>
</div>
<p-button
icon="pi pi-times"
[rounded]="true"
[text]="true"
severity="secondary"
(click)="dynamicDialogRef.close()"
styleClass="close-button">
</p-button>
</div>
<p-select
[options]="emailProviders"
optionLabel="label"
placeholder="Select Email Provider"
[(ngModel)]="selectedProvider"
appendTo="body"
class="w-full">
</p-select>
<div class="dialog-content">
<div class="flex flex-col gap-6">
<div class="flex flex-col gap-2">
<label class="text-sm font-medium text-gray-300">Email Provider</label>
<p-select
[options]="emailProviders"
optionLabel="label"
placeholder="Select Email Provider"
[(ngModel)]="selectedProvider"
appendTo="body"
class="w-full">
</p-select>
</div>
<p-select
[options]="emailRecipients"
optionLabel="label"
placeholder="Select Book Recipient"
[(ngModel)]="selectedRecipient"
[disabled]="!selectedProvider"
appendTo="body"
class="w-full">
</p-select>
<p-button
icon="pi pi-envelope"
label="Email Book"
[disabled]="!selectedProvider || !selectedRecipient"
(onClick)="sendBook()">
</p-button>
<div class="flex flex-col gap-2">
<label class="text-sm font-medium text-gray-300">Recipient</label>
<p-select
[options]="emailRecipients"
optionLabel="label"
placeholder="Select Book Recipient"
[(ngModel)]="selectedRecipient"
[disabled]="!selectedProvider"
appendTo="body"
class="w-full">
</p-select>
</div>
</div>
</div>
<div class="dialog-footer">
<p-button
icon="pi pi-envelope"
label="Send Book"
[disabled]="!selectedProvider || !selectedRecipient"
(onClick)="sendBook()">
</p-button>
</div>
</div>
@@ -0,0 +1,26 @@
@use '../../../../shared/styles/panel-shared' as panel;
.book-sender-container {
display: flex;
flex-direction: column;
height: 100%;
}
.panel-header {
@include panel.panel-header;
flex-shrink: 0;
}
.dialog-content {
flex: 1;
padding: 1.5rem;
background: var(--card-background);
border: 1px solid var(--border-color);
border-top: none;
border-bottom: none;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.dialog-footer {
@include panel.dialog-footer;
}
@@ -26,7 +26,7 @@ export class BookSenderComponent implements OnInit {
private emailRecipientService = inject(EmailV2RecipientService);
private emailService = inject(EmailService);
private messageService = inject(MessageService);
private dynamicDialogRef = inject(DynamicDialogRef);
dynamicDialogRef = inject(DynamicDialogRef);
private dynamicDialogConfig = inject(DynamicDialogConfig);
bookId: number = this.dynamicDialogConfig.data.bookId;