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:
+798
@@ -0,0 +1,798 @@
|
||||
@if (book; as book) {
|
||||
<form [formGroup]="metadataForm" (ngSubmit)="onSave()" class="metadata-picker" *transloco="let t; prefix: 'metadata.picker'">
|
||||
<div class="dialog-body">
|
||||
@if (detailLoading) {
|
||||
<div class="detail-loading-banner">
|
||||
<i class="pi pi-spin pi-spinner"></i>
|
||||
<span>{{ t('loadingMetadata') }}</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Column Headers -->
|
||||
<div class="column-headers">
|
||||
<div class="column-label current">
|
||||
<i class="pi pi-file-edit"></i>
|
||||
<span>{{ t('columnCurrent') }}</span>
|
||||
</div>
|
||||
<div class="column-actions">
|
||||
<p-button
|
||||
icon="pi pi-angle-left"
|
||||
[rounded]="true"
|
||||
[outlined]="true"
|
||||
severity="secondary"
|
||||
[pTooltip]="t('copyMissingTooltip')"
|
||||
tooltipPosition="bottom"
|
||||
(onClick)="copyMissing()"
|
||||
/>
|
||||
<p-button
|
||||
icon="pi pi-angle-double-left"
|
||||
[rounded]="true"
|
||||
[outlined]="true"
|
||||
severity="primary"
|
||||
[pTooltip]="t('copyAllTooltip')"
|
||||
tooltipPosition="bottom"
|
||||
(onClick)="copyAll()"
|
||||
/>
|
||||
</div>
|
||||
<div class="column-label fetched">
|
||||
<i class="pi pi-cloud-download"></i>
|
||||
<span>{{ t('columnFetched') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Cover Image Section -->
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-image"></i>
|
||||
<span>{{ t('sectionCoverImage') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="section-content" [class.dual-covers-section]="currentBook && supportsDualCovers(currentBook)">
|
||||
<!-- Ebook Cover Row -->
|
||||
@if (!currentBook || hasEbookFormat(currentBook)) {
|
||||
<div class="field-row cover-field-row">
|
||||
<label class="field-label">
|
||||
@if (currentBook && supportsDualCovers(currentBook)) {
|
||||
<i class="pi pi-book cover-type-icon"></i> {{ t('coverLabelEbook') }}
|
||||
} @else {
|
||||
{{ t('coverLabel') }}
|
||||
}
|
||||
</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current cover-side">
|
||||
<span class="cover-label mobile-only">{{ t('mobileCurrentLabel') }}</span>
|
||||
<div class="cover-wrapper">
|
||||
<p-image
|
||||
class="cover-image"
|
||||
[src]="metadataForm.get('thumbnailUrl')?.value"
|
||||
[alt]="t('currentCoverAlt')"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="lock-badge"
|
||||
[class.locked]="metadataForm.get('coverLocked')?.value"
|
||||
(click)="toggleLock('thumbnailUrl')"
|
||||
[pTooltip]="metadataForm.get('coverLocked')?.value ? t('unlockCoverTooltip') : t('lockCoverTooltip')"
|
||||
tooltipPosition="top"
|
||||
>
|
||||
<i [class]="metadataForm.get('coverLocked')?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved('thumbnailUrl')"
|
||||
[class.copied]="isValueCopied('thumbnailUrl') && !hoveredFields['thumbnailUrl']"
|
||||
[class.reset]="isValueCopied('thumbnailUrl') && hoveredFields['thumbnailUrl']"
|
||||
(click)="hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? resetField('thumbnailUrl') : copyFetchedToCurrent('thumbnailUrl')"
|
||||
(mouseenter)="onMouseEnter('thumbnailUrl')"
|
||||
(mouseleave)="onMouseLeave('thumbnailUrl')"
|
||||
>
|
||||
<i [class]="isValueSaved('thumbnailUrl') ? 'pi pi-check' : (hoveredFields['thumbnailUrl'] && isValueCopied('thumbnailUrl') ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
|
||||
<div class="field-side fetched cover-side">
|
||||
<span class="cover-label mobile-only">{{ t('mobileFetchedLabel') }}</span>
|
||||
<div class="cover-wrapper">
|
||||
<p-image
|
||||
class="cover-image"
|
||||
[src]="fetchedMetadata.thumbnailUrl!"
|
||||
[alt]="t('fetchedCoverAlt')"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Audiobook Cover Row -->
|
||||
@if (currentBook && hasAudiobookFormat(currentBook)) {
|
||||
<div class="field-row cover-field-row audiobook-cover-row">
|
||||
<label class="field-label">
|
||||
<i class="pi pi-headphones cover-type-icon"></i> {{ t('coverLabelAudiobook') }}
|
||||
</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current cover-side">
|
||||
<span class="cover-label mobile-only">{{ t('mobileCurrentLabel') }}</span>
|
||||
<div class="cover-wrapper">
|
||||
<p-image
|
||||
class="cover-image square-cover"
|
||||
[src]="metadataForm.get('audiobookThumbnailUrl')?.value"
|
||||
[alt]="t('currentAudiobookCoverAlt')"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="lock-badge"
|
||||
[class.locked]="metadataForm.get('audiobookCoverLocked')?.value"
|
||||
(click)="toggleLock('audiobookThumbnailUrl')"
|
||||
[pTooltip]="metadataForm.get('audiobookCoverLocked')?.value ? t('unlockCoverTooltip') : t('lockCoverTooltip')"
|
||||
tooltipPosition="top"
|
||||
>
|
||||
<i [class]="metadataForm.get('audiobookCoverLocked')?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if (isAudibleProvider()) {
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved('audiobookThumbnailUrl')"
|
||||
[class.copied]="isValueCopied('audiobookThumbnailUrl') && !hoveredFields['audiobookThumbnailUrl']"
|
||||
[class.reset]="isValueCopied('audiobookThumbnailUrl') && hoveredFields['audiobookThumbnailUrl']"
|
||||
(click)="hoveredFields['audiobookThumbnailUrl'] && isValueCopied('audiobookThumbnailUrl') ? resetField('audiobookThumbnailUrl') : copyFetchedToCurrent('audiobookThumbnailUrl')"
|
||||
(mouseenter)="onMouseEnter('audiobookThumbnailUrl')"
|
||||
(mouseleave)="onMouseLeave('audiobookThumbnailUrl')"
|
||||
>
|
||||
<i [class]="isValueSaved('audiobookThumbnailUrl') ? 'pi pi-check' : (hoveredFields['audiobookThumbnailUrl'] && isValueCopied('audiobookThumbnailUrl') ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
} @else {
|
||||
<div class="transfer-btn-placeholder"></div>
|
||||
}
|
||||
|
||||
<div class="field-side fetched cover-side">
|
||||
<span class="cover-label mobile-only">{{ t('mobileFetchedLabel') }}</span>
|
||||
<div class="cover-wrapper">
|
||||
@if (isAudibleProvider()) {
|
||||
<p-image
|
||||
class="cover-image square-cover"
|
||||
[src]="fetchedMetadata.thumbnailUrl!"
|
||||
[alt]="t('fetchedAudiobookCoverAlt')"
|
||||
appendTo="body"
|
||||
lazyLoad
|
||||
[preview]="true"
|
||||
/>
|
||||
} @else {
|
||||
<div class="no-cover-placeholder">
|
||||
<i class="pi pi-image"></i>
|
||||
<span>{{ t('na') }}</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Basic Information Section -->
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-info-circle"></i>
|
||||
<span>{{ t('sectionBasicInfo') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="section-content">
|
||||
@for (field of metadataFieldsTop; track field) {
|
||||
<div class="field-row">
|
||||
<label class="field-label">{{ field.label }}</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current">
|
||||
<button
|
||||
type="button"
|
||||
class="lock-btn"
|
||||
[class.locked]="metadataForm.get(field.lockedKey)?.value"
|
||||
(click)="toggleLock(field.controlName)"
|
||||
>
|
||||
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
@if (field.controlName === 'publishedDate') {
|
||||
<input pInputText formControlName="{{field.controlName}}" class="field-input" placeholder="YYYY-MM-DD"/>
|
||||
} @else {
|
||||
<input pInputText formControlName="{{field.controlName}}" class="field-input"/>
|
||||
}
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved(field.controlName)"
|
||||
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
|
||||
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
|
||||
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||
(mouseenter)="onMouseEnter(field.controlName)"
|
||||
(mouseleave)="onMouseLeave(field.controlName)"
|
||||
>
|
||||
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
|
||||
<div class="field-side fetched">
|
||||
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? ''" class="field-input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Tags & Categories Section -->
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-tags"></i>
|
||||
<span>{{ t('sectionTagsCategories') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="section-content">
|
||||
@for (field of metadataChips; track field) {
|
||||
<div class="field-row">
|
||||
<label class="field-label">{{ field.label }}</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current">
|
||||
<button
|
||||
type="button"
|
||||
class="lock-btn"
|
||||
[class.locked]="metadataForm.get(field.lockedKey)?.value"
|
||||
(click)="toggleLock(field.controlName)"
|
||||
>
|
||||
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
@if (field.controlName === 'authors') {
|
||||
<div class="author-chips-container" [class.disabled]="metadataForm.get('authors')?.disabled"
|
||||
cdkDropList cdkDropListOrientation="mixed"
|
||||
[cdkDropListDisabled]="metadataForm.get('authors')?.disabled"
|
||||
(cdkDropListDropped)="dropAuthor($event)">
|
||||
@for (author of metadataForm.get('authors')!.value; track $index) {
|
||||
<span class="author-chip" [class.main-author]="$index === 0" cdkDrag>
|
||||
@if ($index === 0) { <span class="main-author-badge">m</span> }
|
||||
{{ author }}
|
||||
@if (!metadataForm.get('authors')?.disabled) {
|
||||
<i class="pi pi-times author-chip-remove" (click)="removeAuthor($index)"></i>
|
||||
}
|
||||
</span>
|
||||
}
|
||||
@if (!metadataForm.get('authors')?.disabled) {
|
||||
<p-autoComplete
|
||||
class="author-add-input"
|
||||
[(ngModel)]="authorInputValue"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
[suggestions]="getFiltered('authors')"
|
||||
[forceSelection]="false"
|
||||
[dropdown]="false"
|
||||
(completeMethod)="filterItems($event, 'authors')"
|
||||
(onKeyUp)="onAuthorInputKeyUp($event)"
|
||||
(onSelect)="onAuthorInputSelect($event)"
|
||||
placeholder="Add author..."
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
<p-autoComplete
|
||||
class="chips-input"
|
||||
formControlName="{{field.controlName}}"
|
||||
[multiple]="true"
|
||||
[dropdown]="false"
|
||||
[forceSelection]="false"
|
||||
[showClear]="true"
|
||||
[suggestions]="getFiltered(field.controlName)"
|
||||
(completeMethod)="filterItems($event, field.controlName)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp(field.controlName, $event)"
|
||||
(onSelect)="onAutoCompleteSelect(field.controlName, $event)"
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved(field.controlName)"
|
||||
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
|
||||
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
|
||||
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||
(mouseenter)="onMouseEnter(field.controlName)"
|
||||
(mouseleave)="onMouseLeave(field.controlName)"
|
||||
>
|
||||
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
|
||||
<div class="field-side fetched">
|
||||
<p-autoComplete
|
||||
[ngModel]="fetchedMetadata[field.fetchedKey] ?? []"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
[disabled]="true"
|
||||
[multiple]="true"
|
||||
[typeahead]="false"
|
||||
[dropdown]="false"
|
||||
[forceSelection]="false"
|
||||
class="chips-input readonly"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Description Section -->
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-align-left"></i>
|
||||
<span>{{ t('sectionDescription') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="section-content">
|
||||
@for (field of metadataDescription; track field) {
|
||||
<div class="field-row textarea-row">
|
||||
<label class="field-label">{{ field.label }}</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current">
|
||||
<button
|
||||
type="button"
|
||||
class="lock-btn"
|
||||
[class.locked]="metadataForm.get(field.lockedKey)?.value"
|
||||
(click)="toggleLock(field.controlName)"
|
||||
>
|
||||
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
<textarea pTextarea formControlName="{{field.controlName}}" class="field-textarea" rows="4"></textarea>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved(field.controlName)"
|
||||
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
|
||||
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
|
||||
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||
(mouseenter)="onMouseEnter(field.controlName)"
|
||||
(mouseleave)="onMouseLeave(field.controlName)"
|
||||
>
|
||||
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
|
||||
<div class="field-side fetched">
|
||||
<textarea pTextarea [value]="fetchedMetadata[field.fetchedKey] ?? ''" class="field-textarea" rows="4" readonly></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Series Information Section -->
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-book"></i>
|
||||
<span>{{ t('sectionSeriesInfo') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="section-content">
|
||||
@for (field of metadataSeriesFields; track field) {
|
||||
<div class="field-row">
|
||||
<label class="field-label">{{ field.label }}</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current">
|
||||
<button
|
||||
type="button"
|
||||
class="lock-btn"
|
||||
[class.locked]="metadataForm.get(field.lockedKey)?.value"
|
||||
(click)="toggleLock(field.controlName)"
|
||||
>
|
||||
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
<input pInputText formControlName="{{field.controlName}}" class="field-input"/>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved(field.controlName)"
|
||||
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
|
||||
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
|
||||
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||
(mouseenter)="onMouseEnter(field.controlName)"
|
||||
(mouseleave)="onMouseLeave(field.controlName)"
|
||||
>
|
||||
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
|
||||
<div class="field-side fetched">
|
||||
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? ''" class="field-input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Book Details Section -->
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-id-card"></i>
|
||||
<span>{{ t('sectionBookDetails') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="section-content">
|
||||
@for (field of metadataBookDetailsFields; track field) {
|
||||
<div class="field-row">
|
||||
<label class="field-label">{{ field.label }}</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current">
|
||||
<button
|
||||
type="button"
|
||||
class="lock-btn"
|
||||
[class.locked]="metadataForm.get(field.lockedKey)?.value"
|
||||
(click)="toggleLock(field.controlName)"
|
||||
>
|
||||
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
<input pInputText formControlName="{{field.controlName}}" class="field-input"/>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved(field.controlName)"
|
||||
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
|
||||
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
|
||||
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||
(mouseenter)="onMouseEnter(field.controlName)"
|
||||
(mouseleave)="onMouseLeave(field.controlName)"
|
||||
>
|
||||
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
|
||||
<div class="field-side fetched">
|
||||
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? ''" class="field-input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Comic Book Details Section -->
|
||||
@if (shouldShowComicSection()) {
|
||||
<section class="form-section">
|
||||
<div class="section-header collapsible-header" (click)="comicSectionExpanded = !comicSectionExpanded">
|
||||
<i class="pi pi-bolt"></i>
|
||||
<span>{{ t('sectionComicDetails') }}</span>
|
||||
@if (!hasAnyFetchedComicData() && !hasAnyCurrentComicData()) {
|
||||
<span class="section-empty-badge">{{ t('nonePresent') }}</span>
|
||||
}
|
||||
<i [class]="comicSectionExpanded ? 'pi pi-chevron-up' : 'pi pi-chevron-down'" class="section-toggle"></i>
|
||||
</div>
|
||||
|
||||
@if (comicSectionExpanded) {
|
||||
<div class="section-content">
|
||||
<!-- Comic text/number/boolean fields -->
|
||||
@for (field of comicTextFields; track field) {
|
||||
<div class="field-row">
|
||||
<label class="field-label">{{ field.label }}</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current">
|
||||
<button
|
||||
type="button"
|
||||
class="lock-btn"
|
||||
[class.locked]="metadataForm.get(field.lockedKey)?.value"
|
||||
(click)="toggleLock(field.controlName)"
|
||||
>
|
||||
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
@if (field.type === 'boolean') {
|
||||
<p-checkbox
|
||||
formControlName="{{field.controlName}}"
|
||||
[binary]="true"
|
||||
class="field-checkbox"
|
||||
/>
|
||||
} @else {
|
||||
<input pInputText formControlName="{{field.controlName}}" class="field-input"/>
|
||||
}
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved(field.controlName)"
|
||||
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
|
||||
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
|
||||
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||
(mouseenter)="onMouseEnter(field.controlName)"
|
||||
(mouseleave)="onMouseLeave(field.controlName)"
|
||||
>
|
||||
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
|
||||
<div class="field-side fetched">
|
||||
@if (field.type === 'boolean') {
|
||||
<p-checkbox
|
||||
[ngModel]="getFetchedComicValue(field.fetchedKey)"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
[binary]="true"
|
||||
[disabled]="true"
|
||||
class="field-checkbox"
|
||||
/>
|
||||
} @else {
|
||||
<input pInputText [value]="getFetchedComicValue(field.fetchedKey) ?? ''" class="field-input" readonly/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Comic array fields (creators, characters, teams, locations) -->
|
||||
@for (field of comicArrayFields; track field) {
|
||||
<div class="field-row">
|
||||
<label class="field-label">{{ field.label }}</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current">
|
||||
<button
|
||||
type="button"
|
||||
class="lock-btn"
|
||||
[class.locked]="metadataForm.get(field.lockedKey)?.value"
|
||||
(click)="toggleLock(field.controlName)"
|
||||
>
|
||||
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
<p-autoComplete
|
||||
class="chips-input"
|
||||
formControlName="{{field.controlName}}"
|
||||
[multiple]="true"
|
||||
[dropdown]="false"
|
||||
[forceSelection]="false"
|
||||
[showClear]="true"
|
||||
[suggestions]="getFiltered(field.controlName)"
|
||||
(completeMethod)="filterItems($event, field.controlName)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp(field.controlName, $event)"
|
||||
(onSelect)="onAutoCompleteSelect(field.controlName, $event)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved(field.controlName)"
|
||||
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
|
||||
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
|
||||
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||
(mouseenter)="onMouseEnter(field.controlName)"
|
||||
(mouseleave)="onMouseLeave(field.controlName)"
|
||||
>
|
||||
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
|
||||
<div class="field-side fetched">
|
||||
<p-autoComplete
|
||||
[ngModel]="getFetchedComicValue(field.fetchedKey) ?? []"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
[disabled]="true"
|
||||
[multiple]="true"
|
||||
[typeahead]="false"
|
||||
[dropdown]="false"
|
||||
[forceSelection]="false"
|
||||
class="chips-input readonly"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- Comic textarea fields (notes) -->
|
||||
@for (field of comicTextareaFields; track field) {
|
||||
<div class="field-row textarea-row">
|
||||
<label class="field-label">{{ field.label }}</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current">
|
||||
<button
|
||||
type="button"
|
||||
class="lock-btn"
|
||||
[class.locked]="metadataForm.get(field.lockedKey)?.value"
|
||||
(click)="toggleLock(field.controlName)"
|
||||
>
|
||||
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
<textarea pTextarea formControlName="{{field.controlName}}" class="field-textarea" rows="3"></textarea>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved(field.controlName)"
|
||||
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
|
||||
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
|
||||
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||
(mouseenter)="onMouseEnter(field.controlName)"
|
||||
(mouseleave)="onMouseLeave(field.controlName)"
|
||||
>
|
||||
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
|
||||
<div class="field-side fetched">
|
||||
<textarea pTextarea [value]="getFetchedComicValue(field.fetchedKey) ?? ''" class="field-textarea" rows="3" readonly></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
|
||||
<!-- Audiobook Details Section -->
|
||||
@if (currentBook && hasAudiobookFormat(currentBook)) {
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-headphones"></i>
|
||||
<span>{{ t('sectionAudiobookDetails') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="section-content">
|
||||
@for (field of audiobookMetadataFields; track field) {
|
||||
<div class="field-row">
|
||||
<label class="field-label">{{ field.label }}</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current">
|
||||
<button
|
||||
type="button"
|
||||
class="lock-btn"
|
||||
[class.locked]="metadataForm.get(field.lockedKey)?.value"
|
||||
(click)="toggleLock(field.controlName)"
|
||||
>
|
||||
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
@if (field.type === 'boolean') {
|
||||
<p-checkbox
|
||||
formControlName="{{field.controlName}}"
|
||||
[binary]="true"
|
||||
class="field-checkbox"
|
||||
/>
|
||||
} @else {
|
||||
<input pInputText formControlName="{{field.controlName}}" class="field-input"/>
|
||||
}
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved(field.controlName)"
|
||||
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
|
||||
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
|
||||
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||
(mouseenter)="onMouseEnter(field.controlName)"
|
||||
(mouseleave)="onMouseLeave(field.controlName)"
|
||||
>
|
||||
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
|
||||
<div class="field-side fetched">
|
||||
@if (field.type === 'boolean') {
|
||||
<p-checkbox
|
||||
[ngModel]="getFetchedAudiobookValue(field.fetchedKey)"
|
||||
[ngModelOptions]="{ standalone: true }"
|
||||
[binary]="true"
|
||||
[disabled]="true"
|
||||
class="field-checkbox"
|
||||
/>
|
||||
} @else {
|
||||
<input pInputText [value]="getFetchedAudiobookValue(field.fetchedKey) ?? ''" class="field-input" readonly/>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
|
||||
<!-- Provider Metadata Section -->
|
||||
@if (metadataProviderFields.length > 0) {
|
||||
<section class="form-section">
|
||||
<div class="section-header">
|
||||
<i class="pi pi-cloud"></i>
|
||||
<span>{{ t('sectionProviderMetadata') }}</span>
|
||||
</div>
|
||||
|
||||
<div class="section-content">
|
||||
@for (field of metadataProviderFields; track field) {
|
||||
<div class="field-row">
|
||||
<label class="field-label">{{ field.label }}</label>
|
||||
<div class="field-content">
|
||||
<div class="field-side current">
|
||||
<button
|
||||
type="button"
|
||||
class="lock-btn"
|
||||
[class.locked]="metadataForm.get(field.lockedKey)?.value"
|
||||
(click)="toggleLock(field.controlName)"
|
||||
>
|
||||
<i [class]="metadataForm.get(field.lockedKey)?.value ? 'pi pi-lock' : 'pi pi-lock-open'"></i>
|
||||
</button>
|
||||
<input pInputText formControlName="{{field.controlName}}" class="field-input"/>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="transfer-btn"
|
||||
[class.saved]="isValueSaved(field.controlName)"
|
||||
[class.copied]="isValueCopied(field.controlName) && !hoveredFields[field.controlName]"
|
||||
[class.reset]="isValueCopied(field.controlName) && hoveredFields[field.controlName]"
|
||||
(click)="hoveredFields[field.controlName] && isValueCopied(field.controlName) ? resetField(field.controlName) : copyFetchedToCurrent(field.controlName)"
|
||||
(mouseenter)="onMouseEnter(field.controlName)"
|
||||
(mouseleave)="onMouseLeave(field.controlName)"
|
||||
>
|
||||
<i [class]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"></i>
|
||||
</button>
|
||||
|
||||
<div class="field-side fetched">
|
||||
<input pInputText [value]="fetchedMetadata[field.fetchedKey] ?? ''" class="field-input" readonly/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (!reviewMode) {
|
||||
<footer class="dialog-footer">
|
||||
<div class="footer-left">
|
||||
<p-button
|
||||
[label]="t('backToListBtn')"
|
||||
icon="pi pi-arrow-left"
|
||||
severity="info"
|
||||
[outlined]="true"
|
||||
(onClick)="goBackClick()"
|
||||
/>
|
||||
</div>
|
||||
<div class="footer-right">
|
||||
<p-button
|
||||
icon="pi pi-lock-open"
|
||||
severity="success"
|
||||
[outlined]="true"
|
||||
[pTooltip]="t('unlockAllTooltip')"
|
||||
tooltipPosition="top"
|
||||
(onClick)="unlockAll()"
|
||||
/>
|
||||
<p-button
|
||||
icon="pi pi-lock"
|
||||
severity="warn"
|
||||
[outlined]="true"
|
||||
[pTooltip]="t('lockAllTooltip')"
|
||||
tooltipPosition="top"
|
||||
(onClick)="lockAll()"
|
||||
/>
|
||||
<div class="footer-divider"></div>
|
||||
<p-button
|
||||
[label]="t('saveChangesBtn')"
|
||||
[icon]="isSaving ? 'pi pi-spin pi-spinner' : 'pi pi-check'"
|
||||
[loading]="isSaving"
|
||||
[disabled]="isSaving"
|
||||
severity="primary"
|
||||
type="submit"
|
||||
/>
|
||||
</div>
|
||||
</footer>
|
||||
}
|
||||
</form>
|
||||
}
|
||||
+718
@@ -0,0 +1,718 @@
|
||||
.metadata-picker {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background: var(--card-background);
|
||||
animation: fadeIn 0.3s ease-in;
|
||||
}
|
||||
|
||||
// Visibility utilities
|
||||
.mobile-only {
|
||||
display: flex;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.desktop-only {
|
||||
display: none;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Detail loading banner
|
||||
.detail-loading-banner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
padding: 0.625rem 1rem;
|
||||
background: rgba(34, 197, 94, 0.1);
|
||||
border: 1px solid rgba(34, 197, 94, 0.3);
|
||||
border-radius: 8px;
|
||||
color: var(--p-green-400);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
animation: fadeIn 0.3s ease-in;
|
||||
|
||||
i {
|
||||
font-size: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
// Body
|
||||
.dialog-body {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
padding: 1.25rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1.5rem;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background: var(--border-color);
|
||||
border-radius: 3px;
|
||||
|
||||
&:hover {
|
||||
background: var(--primary-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Column Headers - mirrors field-row structure for alignment (desktop only)
|
||||
.column-headers {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0.875rem 1rem;
|
||||
margin-bottom: 0.5rem;
|
||||
background: var(--overlay-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
// Spacer to match field-label width (desktop only)
|
||||
&::before {
|
||||
content: '';
|
||||
min-width: 120px;
|
||||
flex-shrink: 0;
|
||||
display: none;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.column-label {
|
||||
display: none;
|
||||
align-items: center;
|
||||
gap: 0.625rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 500;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
flex: 1;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
i {
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
|
||||
&.current {
|
||||
color: var(--primary-color);
|
||||
justify-content: flex-end;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
|
||||
&.fetched {
|
||||
color: var(--p-blue-400);
|
||||
justify-content: flex-start;
|
||||
padding-left: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.column-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.5rem;
|
||||
flex-shrink: 0;
|
||||
margin-left: 0.75rem;
|
||||
margin-right: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
// Sections
|
||||
.form-section {
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.75rem;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.03em;
|
||||
color: var(--text-secondary-color);
|
||||
|
||||
i {
|
||||
font-size: 0.9rem;
|
||||
color: var(--primary-color);
|
||||
}
|
||||
|
||||
&.collapsible-header {
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
transition: color 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.section-toggle {
|
||||
margin-left: auto;
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-secondary-color);
|
||||
}
|
||||
}
|
||||
|
||||
.section-empty-badge {
|
||||
font-size: 0.7rem;
|
||||
font-weight: 500;
|
||||
text-transform: none;
|
||||
letter-spacing: normal;
|
||||
color: var(--text-secondary-color);
|
||||
background: var(--surface-ground);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 4px;
|
||||
padding: 0.125rem 0.5rem;
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
.section-content {
|
||||
background: var(--overlay-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
// Cover Image
|
||||
.cover-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.cover-image {
|
||||
width: 120px;
|
||||
height: auto;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
||||
|
||||
@media (min-width: 768px) {
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
::ng-deep img {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
.lock-badge {
|
||||
position: absolute;
|
||||
top: -6px;
|
||||
right: -6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
background: var(--p-green-500);
|
||||
border: 2px solid var(--card-background);
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
i {
|
||||
font-size: 0.625rem;
|
||||
color: white;
|
||||
}
|
||||
|
||||
&.locked {
|
||||
background: var(--p-orange-500);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
}
|
||||
|
||||
.cover-label {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.03em;
|
||||
color: var(--text-secondary-color);
|
||||
}
|
||||
|
||||
// Cover type icon in label
|
||||
.cover-type-icon {
|
||||
font-size: 0.8rem;
|
||||
margin-right: 0.25rem;
|
||||
}
|
||||
|
||||
// Square cover for audiobooks
|
||||
.square-cover {
|
||||
aspect-ratio: 1;
|
||||
|
||||
::ng-deep img {
|
||||
object-fit: cover;
|
||||
aspect-ratio: 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Audiobook cover row
|
||||
.audiobook-cover-row {
|
||||
background: rgba(var(--p-primary-500-rgb), 0.03);
|
||||
}
|
||||
|
||||
// Transfer button placeholder (same width as button)
|
||||
.transfer-btn-placeholder {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
// No cover placeholder
|
||||
.no-cover-placeholder {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
background: var(--surface-ground);
|
||||
border: 1px dashed var(--border-color);
|
||||
border-radius: 6px;
|
||||
color: var(--text-secondary-color);
|
||||
|
||||
@media (min-width: 768px) {
|
||||
width: 150px;
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
i {
|
||||
font-size: 1.75rem;
|
||||
margin-bottom: 0.5rem;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
span {
|
||||
font-size: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Field Rows
|
||||
.field-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
padding: 0.875rem 1rem;
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
|
||||
&:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
// Cover field row specific styles
|
||||
.cover-field-row {
|
||||
padding: 1rem;
|
||||
|
||||
.field-label {
|
||||
text-align: center;
|
||||
margin-bottom: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
text-align: left;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.field-content {
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
gap: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
// On mobile, center covers and show labels
|
||||
.field-side {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
flex-direction: row;
|
||||
}
|
||||
}
|
||||
|
||||
// Position covers towards the arrow on desktop only
|
||||
@media (min-width: 768px) {
|
||||
padding: 1rem;
|
||||
|
||||
.field-side.current {
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.field-side.fetched {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.field-label {
|
||||
font-size: 0.85rem;
|
||||
font-weight: 500;
|
||||
color: var(--text-color);
|
||||
min-width: 100px;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
min-width: 120px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.field-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
flex: 1;
|
||||
|
||||
@media (min-width: 768px) {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.field-side {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
&.fetched {
|
||||
.field-input,
|
||||
.field-textarea,
|
||||
.chips-input {
|
||||
opacity: 0.7;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.lock-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
background: var(--p-green-500);
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
i {
|
||||
font-size: 0.75rem;
|
||||
color: white;
|
||||
}
|
||||
|
||||
&.locked {
|
||||
background: var(--p-orange-500);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
}
|
||||
|
||||
.field-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.field-textarea {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.chips-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
width: 100%;
|
||||
|
||||
&.readonly {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
.textarea-row {
|
||||
.field-content {
|
||||
@media (min-width: 768px) {
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
.field-side {
|
||||
@media (min-width: 768px) {
|
||||
align-items: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
.lock-btn {
|
||||
@media (min-width: 768px) {
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
}
|
||||
|
||||
.transfer-btn {
|
||||
@media (min-width: 768px) {
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Transfer Button
|
||||
.transfer-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: var(--card-background);
|
||||
border: 1px solid var(--border-color);
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
i {
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-secondary-color);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
border-color: var(--primary-color);
|
||||
background: var(--primary-color);
|
||||
|
||||
i {
|
||||
color: var(--primary-contrast-color);
|
||||
}
|
||||
}
|
||||
|
||||
&.saved {
|
||||
border-color: var(--p-green-500);
|
||||
background: var(--p-green-500);
|
||||
|
||||
i {
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
&.copied {
|
||||
border-color: var(--p-yellow-500);
|
||||
background: rgba(234, 179, 8, 0.15);
|
||||
|
||||
i {
|
||||
color: var(--p-yellow-500);
|
||||
}
|
||||
}
|
||||
|
||||
&.reset {
|
||||
border-color: var(--p-red-500);
|
||||
background: rgba(239, 68, 68, 0.15);
|
||||
|
||||
i {
|
||||
color: var(--p-red-500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Footer
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 1rem 1.25rem;
|
||||
background: var(--overlay-background);
|
||||
border-top: 1px solid var(--border-color);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.footer-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.footer-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.footer-divider {
|
||||
width: 1px;
|
||||
height: 24px;
|
||||
background: var(--border-color);
|
||||
margin: 0 0.25rem;
|
||||
}
|
||||
|
||||
// AutoComplete overrides
|
||||
::ng-deep .p-autocomplete {
|
||||
width: 100% !important;
|
||||
|
||||
.p-autocomplete-multiple-container {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
// Animation
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Mobile optimizations
|
||||
@media (max-width: 767px) {
|
||||
.dialog-body {
|
||||
padding: 1rem;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
flex-direction: column;
|
||||
padding: 0.875rem 1rem;
|
||||
gap: 0.75rem;
|
||||
|
||||
.footer-left,
|
||||
.footer-right {
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
|
||||
.field-label {
|
||||
font-size: 0.8rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
}
|
||||
|
||||
.author-chips-container {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.375rem;
|
||||
padding: 0.375rem;
|
||||
min-height: 2.25rem;
|
||||
border: 1px solid var(--p-inputtext-border-color);
|
||||
border-radius: 6px;
|
||||
background: var(--p-inputtext-background);
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
||||
&.disabled {
|
||||
opacity: 0.6;
|
||||
background: var(--p-inputtext-disabled-background);
|
||||
cursor: default;
|
||||
|
||||
.author-chip {
|
||||
cursor: default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.author-add-input {
|
||||
flex: 1 1 6rem;
|
||||
min-width: 6rem;
|
||||
|
||||
::ng-deep input {
|
||||
border: none !important;
|
||||
background: transparent !important;
|
||||
padding: 0.25rem;
|
||||
box-shadow: none !important;
|
||||
outline: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.author-chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 1rem;
|
||||
background: var(--p-chip-background);
|
||||
color: var(--p-chip-color);
|
||||
font-size: 0.875rem;
|
||||
cursor: grab;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.main-author-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
border-radius: 50%;
|
||||
background: var(--p-primary-color);
|
||||
color: var(--p-primary-contrast-color);
|
||||
font-size: 0.6rem;
|
||||
font-weight: 700;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.author-chip-remove {
|
||||
font-size: 0.65rem;
|
||||
cursor: pointer;
|
||||
opacity: 0.6;
|
||||
padding: 0.15rem;
|
||||
&:hover { opacity: 1; }
|
||||
}
|
||||
|
||||
.cdk-drag-preview {
|
||||
box-sizing: border-box;
|
||||
border-radius: 1rem;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.cdk-drag-placeholder {
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
.cdk-drag-animating {
|
||||
transition: transform 200ms ease;
|
||||
}
|
||||
+778
@@ -0,0 +1,778 @@
|
||||
import {Component, computed, DestroyRef, effect, EventEmitter, inject, Input, OnInit, Output} from '@angular/core';
|
||||
import {Book, BookMetadata, ComicMetadata, MetadataClearFlags, MetadataUpdateWrapper} from '../../../../book/model/book.model';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {CdkDragDrop, CdkDropList, CdkDrag, moveItemInArray} from '@angular/cdk/drag-drop';
|
||||
import {Button} from 'primeng/button';
|
||||
import {FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms';
|
||||
import {InputText} from 'primeng/inputtext';
|
||||
import {forkJoin, Observable} from 'rxjs';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
import {UrlHelperService} from '../../../../../shared/service/url-helper.service';
|
||||
import {BookService} from '../../../../book/service/book.service';
|
||||
import {BookMetadataManageService} from '../../../../book/service/book-metadata-manage.service';
|
||||
import {Textarea} from 'primeng/textarea';
|
||||
|
||||
import {AutoComplete, AutoCompleteSelectEvent} from 'primeng/autocomplete';
|
||||
import {Image} from 'primeng/image';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {LazyLoadImageModule} from 'ng-lazyload-image';
|
||||
import {AppSettingsService} from '../../../../../shared/service/app-settings.service';
|
||||
import {MetadataProviderSpecificFields} from '../../../../../shared/model/app-settings.model';
|
||||
import {ALL_COMIC_METADATA_FIELDS, ALL_METADATA_FIELDS, AUDIOBOOK_METADATA_FIELDS, COMIC_ARRAY_METADATA_FIELDS, COMIC_FORM_TO_MODEL_LOCK, COMIC_TEXT_METADATA_FIELDS, COMIC_TEXTAREA_METADATA_FIELDS, getArrayFields, getBookDetailsFields, getBottomFields, getProviderFields, getSeriesFields, getTextareaFields, getTopFields, MetadataFieldConfig, MetadataFormBuilder, MetadataUtilsService} from '../../../../../shared/metadata';
|
||||
import {TranslocoDirective, TranslocoService} from '@jsverse/transloco';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-picker',
|
||||
standalone: true,
|
||||
templateUrl: './metadata-picker.component.html',
|
||||
styleUrls: ['./metadata-picker.component.scss'],
|
||||
imports: [
|
||||
Button,
|
||||
FormsModule,
|
||||
InputText,
|
||||
ReactiveFormsModule,
|
||||
Tooltip,
|
||||
Textarea,
|
||||
AutoComplete,
|
||||
Image,
|
||||
LazyLoadImageModule,
|
||||
Checkbox,
|
||||
TranslocoDirective,
|
||||
CdkDropList,
|
||||
CdkDrag,
|
||||
]
|
||||
})
|
||||
export class MetadataPickerComponent implements OnInit {
|
||||
|
||||
// Cached arrays for template binding (avoid getter re-computation)
|
||||
metadataFieldsTop: MetadataFieldConfig[] = [];
|
||||
metadataChips: MetadataFieldConfig[] = [];
|
||||
metadataDescription: MetadataFieldConfig[] = [];
|
||||
metadataSeriesFields: MetadataFieldConfig[] = [];
|
||||
metadataBookDetailsFields: MetadataFieldConfig[] = [];
|
||||
metadataProviderFields: MetadataFieldConfig[] = [];
|
||||
metadataFieldsBottom: MetadataFieldConfig[] = [];
|
||||
audiobookMetadataFields: MetadataFieldConfig[] = [];
|
||||
comicTextFields: MetadataFieldConfig[] = [];
|
||||
comicArrayFields: MetadataFieldConfig[] = [];
|
||||
comicTextareaFields: MetadataFieldConfig[] = [];
|
||||
comicSectionExpanded = false;
|
||||
|
||||
@Input() reviewMode!: boolean;
|
||||
@Input() fetchedMetadata!: BookMetadata;
|
||||
@Input()
|
||||
set book(value: Book | null) {
|
||||
this.currentBook = value;
|
||||
|
||||
const metadata = value?.metadata;
|
||||
if (!metadata) return;
|
||||
|
||||
if (this.reviewMode) {
|
||||
this.metadataForm.reset();
|
||||
this.copiedFields = {};
|
||||
this.savedFields = {};
|
||||
this.hoveredFields = {};
|
||||
}
|
||||
|
||||
this.originalMetadata = metadata;
|
||||
this.originalMetadata.thumbnailUrl = this.urlHelper.getThumbnailUrl(metadata.bookId, metadata.coverUpdatedOn);
|
||||
this.currentBookId = metadata.bookId;
|
||||
this.patchMetadataToForm(metadata, value);
|
||||
}
|
||||
|
||||
get book(): Book | null {
|
||||
return this.currentBook;
|
||||
}
|
||||
|
||||
@Input() detailLoading = false;
|
||||
@Output() goBack = new EventEmitter<boolean>();
|
||||
|
||||
currentBook: Book | null = null;
|
||||
|
||||
private get allItems(): Record<string, string[]> { return this.uniqueMetadata(); }
|
||||
filteredItems: Record<string, string[]> = {};
|
||||
authorInputValue = '';
|
||||
|
||||
metadataForm!: FormGroup;
|
||||
currentBookId!: number;
|
||||
copiedFields: Record<string, boolean> = {};
|
||||
savedFields: Record<string, boolean> = {};
|
||||
originalMetadata!: BookMetadata;
|
||||
isSaving = false;
|
||||
hoveredFields: Record<string, boolean> = {};
|
||||
|
||||
private messageService = inject(MessageService);
|
||||
private bookService = inject(BookService);
|
||||
private bookMetadataManageService = inject(BookMetadataManageService);
|
||||
protected urlHelper = inject(UrlHelperService);
|
||||
private destroyRef = inject(DestroyRef);
|
||||
private appSettingsService = inject(AppSettingsService);
|
||||
private formBuilder = inject(MetadataFormBuilder);
|
||||
private metadataUtils = inject(MetadataUtilsService);
|
||||
private readonly t = inject(TranslocoService);
|
||||
private readonly uniqueMetadata = computed(() => this.bookService.uniqueMetadata());
|
||||
|
||||
|
||||
private enabledProviderFields: MetadataProviderSpecificFields | null = null;
|
||||
|
||||
constructor() {
|
||||
this.metadataForm = this.formBuilder.buildForm(true);
|
||||
this.initFieldArrays();
|
||||
}
|
||||
|
||||
private initFieldArrays(): void {
|
||||
this.metadataFieldsTop = getTopFields();
|
||||
this.metadataChips = getArrayFields();
|
||||
this.metadataDescription = getTextareaFields();
|
||||
this.metadataSeriesFields = getSeriesFields();
|
||||
this.metadataBookDetailsFields = getBookDetailsFields();
|
||||
this.updateProviderFields();
|
||||
this.updateBottomFields();
|
||||
this.audiobookMetadataFields = AUDIOBOOK_METADATA_FIELDS;
|
||||
this.comicTextFields = COMIC_TEXT_METADATA_FIELDS;
|
||||
this.comicArrayFields = COMIC_ARRAY_METADATA_FIELDS;
|
||||
this.comicTextareaFields = COMIC_TEXTAREA_METADATA_FIELDS;
|
||||
}
|
||||
|
||||
private updateProviderFields(): void {
|
||||
this.metadataProviderFields = getProviderFields(this.enabledProviderFields);
|
||||
}
|
||||
|
||||
private updateBottomFields(): void {
|
||||
this.metadataFieldsBottom = getBottomFields(this.enabledProviderFields);
|
||||
}
|
||||
|
||||
getFiltered(controlName: string): string[] {
|
||||
return this.filteredItems[controlName] ?? [];
|
||||
}
|
||||
|
||||
filterItems(event: { query: string }, controlName: string): void {
|
||||
const query = event.query.toLowerCase();
|
||||
this.filteredItems[controlName] = (this.allItems[controlName] ?? [])
|
||||
.filter(item => item.toLowerCase().includes(query));
|
||||
}
|
||||
|
||||
private readonly syncProviderFieldsEffect = effect(() => {
|
||||
const settings = this.appSettingsService.appSettings();
|
||||
if (settings?.metadataProviderSpecificFields) {
|
||||
this.enabledProviderFields = settings.metadataProviderSpecificFields;
|
||||
this.updateProviderFields();
|
||||
this.updateBottomFields();
|
||||
}
|
||||
});
|
||||
|
||||
ngOnInit(): void {
|
||||
}
|
||||
|
||||
private patchMetadataToForm(metadata: BookMetadata, book: Book): void {
|
||||
const patchData: Record<string, unknown> = {};
|
||||
|
||||
for (const field of ALL_METADATA_FIELDS) {
|
||||
const key = field.controlName as keyof BookMetadata;
|
||||
const lockedKey = field.lockedKey as keyof BookMetadata;
|
||||
const value = metadata[key];
|
||||
|
||||
if (field.type === 'array') {
|
||||
patchData[field.controlName] = [...(value as string[] ?? [])].sort();
|
||||
} else {
|
||||
patchData[field.controlName] = value ?? null;
|
||||
}
|
||||
patchData[field.lockedKey] = metadata[lockedKey] ?? false;
|
||||
}
|
||||
|
||||
// Handle special fields - ebook cover
|
||||
patchData['thumbnailUrl'] = this.urlHelper.getCoverUrl(metadata.bookId, metadata.coverUpdatedOn);
|
||||
patchData['coverLocked'] = metadata.coverLocked ?? false;
|
||||
|
||||
// Handle audiobook cover
|
||||
patchData['audiobookThumbnailUrl'] = this.urlHelper.getAudiobookCoverUrl(metadata.bookId, metadata.audiobookCoverUpdatedOn);
|
||||
patchData['audiobookCoverLocked'] = metadata.audiobookCoverLocked ?? false;
|
||||
|
||||
// Handle audiobook-specific metadata fields
|
||||
// narrator/abridged are now at top-level of BookMetadata, but we also check nested for backward compatibility
|
||||
for (const field of AUDIOBOOK_METADATA_FIELDS) {
|
||||
const key = field.controlName as keyof BookMetadata;
|
||||
const lockedKey = field.lockedKey as keyof BookMetadata;
|
||||
// Prefer top-level fields, fallback to nested audiobookMetadata
|
||||
const topLevelValue = metadata[key];
|
||||
const topLevelLocked = metadata[lockedKey];
|
||||
patchData[field.controlName] = topLevelValue ?? (field.type === 'boolean' ? null : '');
|
||||
patchData[field.lockedKey] = topLevelLocked ?? false;
|
||||
}
|
||||
|
||||
// Handle comic book metadata fields (nested under comicMetadata)
|
||||
const comicMeta = metadata.comicMetadata;
|
||||
for (const field of ALL_COMIC_METADATA_FIELDS) {
|
||||
const value = comicMeta?.[field.fetchedKey as keyof ComicMetadata];
|
||||
if (field.type === 'array') {
|
||||
patchData[field.controlName] = [...(value as string[] ?? [])].sort();
|
||||
} else if (field.type === 'boolean') {
|
||||
patchData[field.controlName] = value ?? null;
|
||||
} else if (field.type === 'number') {
|
||||
patchData[field.controlName] = value ?? null;
|
||||
} else {
|
||||
patchData[field.controlName] = value ?? '';
|
||||
}
|
||||
const modelLockKey = COMIC_FORM_TO_MODEL_LOCK[field.lockedKey];
|
||||
patchData[field.lockedKey] = comicMeta?.[modelLockKey as keyof ComicMetadata] ?? false;
|
||||
}
|
||||
|
||||
this.metadataForm.patchValue(patchData);
|
||||
this.applyLockStates(metadata);
|
||||
this.comicSectionExpanded = this.hasAnyFetchedComicData() || this.hasAnyCurrentComicData();
|
||||
}
|
||||
|
||||
private applyLockStates(metadata: BookMetadata): void {
|
||||
const lockedFields: Record<string, boolean> = {};
|
||||
for (const field of ALL_METADATA_FIELDS) {
|
||||
lockedFields[field.lockedKey] = !!metadata[field.lockedKey as keyof BookMetadata];
|
||||
}
|
||||
// Also handle audiobook metadata lock states (now at top-level of BookMetadata)
|
||||
for (const field of AUDIOBOOK_METADATA_FIELDS) {
|
||||
lockedFields[field.lockedKey] = !!metadata[field.lockedKey as keyof BookMetadata];
|
||||
}
|
||||
// Handle comic book metadata lock states (nested under comicMetadata)
|
||||
const comicMeta = metadata.comicMetadata;
|
||||
for (const field of ALL_COMIC_METADATA_FIELDS) {
|
||||
const modelLockKey = COMIC_FORM_TO_MODEL_LOCK[field.lockedKey];
|
||||
lockedFields[field.lockedKey] = !!comicMeta?.[modelLockKey as keyof ComicMetadata];
|
||||
}
|
||||
this.formBuilder.applyLockStates(this.metadataForm, lockedFields);
|
||||
}
|
||||
|
||||
onAutoCompleteSelect(fieldName: string, event: AutoCompleteSelectEvent) {
|
||||
const values = (this.metadataForm.get(fieldName)?.value as string[]) || [];
|
||||
if (!values.includes(event.value as string)) {
|
||||
this.metadataForm.get(fieldName)?.setValue([...values, event.value as string]);
|
||||
}
|
||||
(event.originalEvent.target as HTMLInputElement).value = '';
|
||||
}
|
||||
|
||||
onAutoCompleteKeyUp(fieldName: string, event: KeyboardEvent) {
|
||||
if (event.key === 'Enter') {
|
||||
const input = event.target as HTMLInputElement;
|
||||
const value = input.value?.trim();
|
||||
if (value) {
|
||||
const values = this.metadataForm.get(fieldName)?.value || [];
|
||||
if (!values.includes(value)) {
|
||||
this.metadataForm.get(fieldName)?.setValue([...values, value]);
|
||||
}
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dropAuthor(event: CdkDragDrop<string[]>) {
|
||||
const authors = [...(this.metadataForm.get('authors')?.value ?? [])];
|
||||
moveItemInArray(authors, event.previousIndex, event.currentIndex);
|
||||
this.metadataForm.get('authors')?.setValue(authors);
|
||||
this.metadataForm.get('authors')?.markAsDirty();
|
||||
}
|
||||
|
||||
removeAuthor(index: number) {
|
||||
const authors = [...(this.metadataForm.get('authors')?.value ?? [])];
|
||||
authors.splice(index, 1);
|
||||
this.metadataForm.get('authors')?.setValue(authors);
|
||||
this.metadataForm.get('authors')?.markAsDirty();
|
||||
}
|
||||
|
||||
onAuthorInputKeyUp(event: KeyboardEvent) {
|
||||
if (event.key === 'Enter') {
|
||||
const value = this.authorInputValue?.trim();
|
||||
if (value) {
|
||||
const authors = this.metadataForm.get('authors')?.value || [];
|
||||
if (!authors.includes(value)) {
|
||||
this.metadataForm.get('authors')?.setValue([...authors, value]);
|
||||
this.metadataForm.get('authors')?.markAsDirty();
|
||||
}
|
||||
this.authorInputValue = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onAuthorInputSelect(event: AutoCompleteSelectEvent) {
|
||||
const authors = (this.metadataForm.get('authors')?.value as string[]) || [];
|
||||
const value = event.value as string;
|
||||
if (!authors.includes(value)) {
|
||||
this.metadataForm.get('authors')?.setValue([...authors, value]);
|
||||
this.metadataForm.get('authors')?.markAsDirty();
|
||||
}
|
||||
setTimeout(() => this.authorInputValue = '');
|
||||
}
|
||||
|
||||
onSave(): void {
|
||||
this.isSaving = true;
|
||||
const updatedBookMetadata = this.buildMetadataWrapper(undefined);
|
||||
|
||||
const requests: Observable<unknown>[] = [
|
||||
this.bookMetadataManageService.updateBookMetadata(this.currentBookId, updatedBookMetadata, false, 'REPLACE_WHEN_PROVIDED')
|
||||
];
|
||||
|
||||
// Handle audiobook cover upload when fetched from Audible provider
|
||||
if (this.isAudibleProvider() && this.copiedFields['audiobookThumbnailUrl']) {
|
||||
const audiobookCoverUrl = this.fetchedMetadata.thumbnailUrl;
|
||||
if (audiobookCoverUrl) {
|
||||
requests.push(this.bookMetadataManageService.uploadAudiobookCoverFromUrl(this.currentBookId, audiobookCoverUrl));
|
||||
}
|
||||
}
|
||||
|
||||
forkJoin(requests).subscribe({
|
||||
next: () => {
|
||||
this.isSaving = false;
|
||||
for (const field of Object.keys(this.copiedFields)) {
|
||||
if (this.copiedFields[field]) {
|
||||
this.savedFields[field] = true;
|
||||
}
|
||||
}
|
||||
this.messageService.add({severity: 'info', summary: this.t.translate('metadata.picker.toast.successSummary'), detail: this.t.translate('metadata.picker.toast.metadataUpdated')});
|
||||
},
|
||||
error: () => {
|
||||
this.isSaving = false;
|
||||
this.messageService.add({severity: 'error', summary: this.t.translate('metadata.picker.toast.errorSummary'), detail: this.t.translate('metadata.picker.toast.metadataUpdateFailed')});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private buildMetadataWrapper(shouldLockAllFields: boolean | undefined): MetadataUpdateWrapper {
|
||||
const metadata = this.buildMetadataFromForm();
|
||||
|
||||
if (shouldLockAllFields !== undefined) {
|
||||
(metadata as BookMetadata & { allFieldsLocked?: boolean }).allFieldsLocked = shouldLockAllFields;
|
||||
}
|
||||
|
||||
const clearFlags = this.inferClearFlags(metadata, this.originalMetadata);
|
||||
|
||||
return {
|
||||
metadata: metadata,
|
||||
clearFlags: clearFlags
|
||||
};
|
||||
}
|
||||
|
||||
private buildMetadataFromForm(): BookMetadata {
|
||||
const metadata: Record<string, unknown> = {bookId: this.currentBookId};
|
||||
|
||||
for (const field of ALL_METADATA_FIELDS) {
|
||||
if (field.type === 'array') {
|
||||
metadata[field.controlName] = this.getArrayValue(field.controlName);
|
||||
} else if (field.type === 'number') {
|
||||
metadata[field.controlName] = this.getNumberValue(field.controlName);
|
||||
} else if (field.type === 'boolean') {
|
||||
metadata[field.controlName] = this.getBooleanValue(field.controlName);
|
||||
} else {
|
||||
metadata[field.controlName] = this.getStringValue(field.controlName);
|
||||
}
|
||||
|
||||
metadata[field.lockedKey] = this.metadataForm.get(field.lockedKey)?.value ?? false;
|
||||
}
|
||||
|
||||
metadata['thumbnailUrl'] = this.getThumbnail();
|
||||
metadata['coverLocked'] = this.metadataForm.get('coverLocked')?.value;
|
||||
metadata['audiobookCoverLocked'] = this.metadataForm.get('audiobookCoverLocked')?.value;
|
||||
|
||||
// Set audiobook content metadata (narrator/abridged) at top level
|
||||
for (const field of AUDIOBOOK_METADATA_FIELDS) {
|
||||
if (field.type === 'boolean') {
|
||||
metadata[field.controlName] = this.getBooleanValue(field.controlName);
|
||||
} else {
|
||||
metadata[field.controlName] = this.getStringValue(field.controlName);
|
||||
}
|
||||
metadata[field.lockedKey] = this.metadataForm.get(field.lockedKey)?.value ?? false;
|
||||
}
|
||||
|
||||
// Build comic metadata from form controls
|
||||
const comicMetadata: Record<string, unknown> = {};
|
||||
for (const field of ALL_COMIC_METADATA_FIELDS) {
|
||||
if (field.type === 'array') {
|
||||
comicMetadata[field.fetchedKey] = this.getArrayValue(field.controlName);
|
||||
} else if (field.type === 'number') {
|
||||
comicMetadata[field.fetchedKey] = this.getNumberValue(field.controlName);
|
||||
} else if (field.type === 'boolean') {
|
||||
comicMetadata[field.fetchedKey] = this.getBooleanValue(field.controlName);
|
||||
} else {
|
||||
comicMetadata[field.fetchedKey] = this.getStringValue(field.controlName);
|
||||
}
|
||||
}
|
||||
// Consolidate lock states back to model lock keys using the form-to-model mapping.
|
||||
// If ANY field in a group is locked, the backend group lock is set to true.
|
||||
const lockGroups: Record<string, boolean> = {};
|
||||
for (const [formKey, modelKey] of Object.entries(COMIC_FORM_TO_MODEL_LOCK)) {
|
||||
const value = this.metadataForm.get(formKey)?.value ?? false;
|
||||
if (value) {
|
||||
lockGroups[modelKey] = true;
|
||||
} else if (!(modelKey in lockGroups)) {
|
||||
lockGroups[modelKey] = false;
|
||||
}
|
||||
}
|
||||
for (const [modelKey, value] of Object.entries(lockGroups)) {
|
||||
comicMetadata[modelKey] = value;
|
||||
}
|
||||
metadata['comicMetadata'] = comicMetadata;
|
||||
|
||||
return metadata as BookMetadata;
|
||||
}
|
||||
|
||||
private getStringValue(field: string): string {
|
||||
const formValue = this.metadataForm.get(field)?.value;
|
||||
if (!formValue || formValue === '') {
|
||||
if (this.copiedFields[field]) {
|
||||
return (this.fetchedMetadata[field as keyof BookMetadata] as string) || '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
return formValue;
|
||||
}
|
||||
|
||||
private getNumberValue(field: string): number | null {
|
||||
const formValue = this.metadataForm.get(field)?.value;
|
||||
if (formValue === '' || formValue === null || formValue === undefined || isNaN(formValue)) {
|
||||
if (this.copiedFields[field]) {
|
||||
return (this.fetchedMetadata[field as keyof BookMetadata] as number | null) ?? null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return Number(formValue);
|
||||
}
|
||||
|
||||
private getArrayValue(field: string): string[] {
|
||||
const fieldValue = this.metadataForm.get(field)?.value;
|
||||
if (!fieldValue || (Array.isArray(fieldValue) && fieldValue.length === 0)) {
|
||||
if (this.copiedFields[field]) {
|
||||
const fallback = this.fetchedMetadata[field as keyof BookMetadata];
|
||||
return Array.isArray(fallback) ? fallback as string[] : [];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
if (typeof fieldValue === 'string') {
|
||||
return fieldValue.split(',').map(item => item.trim());
|
||||
}
|
||||
return Array.isArray(fieldValue) ? fieldValue as string[] : [];
|
||||
}
|
||||
|
||||
private getBooleanValue(field: string): boolean | null {
|
||||
const formValue = this.metadataForm.get(field)?.value;
|
||||
if (formValue === null || formValue === undefined) {
|
||||
if (this.copiedFields[field]) {
|
||||
return (this.fetchedMetadata[field as keyof BookMetadata] as boolean | null) ?? null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return !!formValue;
|
||||
}
|
||||
|
||||
private inferClearFlags(current: BookMetadata, original: BookMetadata): MetadataClearFlags {
|
||||
const flags: Record<string, boolean> = {};
|
||||
|
||||
for (const field of ALL_METADATA_FIELDS) {
|
||||
const key = field.controlName as keyof BookMetadata;
|
||||
const curr = current[key];
|
||||
const orig = original[key];
|
||||
|
||||
if (field.type === 'array') {
|
||||
flags[key] = !(curr as string[])?.length && !!(orig as string[])?.length;
|
||||
} else if (field.type === 'number') {
|
||||
flags[key] = curr === null && orig !== null;
|
||||
} else if (field.type === 'boolean') {
|
||||
flags[key] = curr === null && orig !== null;
|
||||
} else {
|
||||
flags[key] = !curr && !!orig;
|
||||
}
|
||||
}
|
||||
|
||||
flags['cover'] = this.copiedFields['thumbnailUrl'] === false && !current.thumbnailUrl && !!original.thumbnailUrl;
|
||||
|
||||
// Handle audiobook metadata clear flags (now at top-level of BookMetadata)
|
||||
for (const field of AUDIOBOOK_METADATA_FIELDS) {
|
||||
const key = field.controlName as keyof BookMetadata;
|
||||
const curr = current[key];
|
||||
const orig = original[key];
|
||||
|
||||
if (field.type === 'boolean') {
|
||||
flags[key] = curr === null && orig !== null;
|
||||
} else {
|
||||
flags[key] = !curr && !!orig;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle comic metadata clear flags
|
||||
const currComic = current.comicMetadata;
|
||||
const origComic = original.comicMetadata;
|
||||
if (origComic) {
|
||||
for (const field of ALL_COMIC_METADATA_FIELDS) {
|
||||
const key = field.fetchedKey as keyof ComicMetadata;
|
||||
const curr = currComic?.[key];
|
||||
const orig = origComic[key];
|
||||
|
||||
if (field.type === 'array') {
|
||||
flags[`comic_${key}`] = !(curr as string[])?.length && !!(orig as string[])?.length;
|
||||
} else if (field.type === 'boolean') {
|
||||
flags[`comic_${key}`] = curr === null && orig !== null;
|
||||
} else if (field.type === 'number') {
|
||||
flags[`comic_${key}`] = curr === null && orig !== null;
|
||||
} else {
|
||||
flags[`comic_${key}`] = !curr && !!orig;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return flags as MetadataClearFlags;
|
||||
}
|
||||
|
||||
getThumbnail(): string | null {
|
||||
if (this.copiedFields['thumbnailUrl']) {
|
||||
return (this.fetchedMetadata['thumbnailUrl' as keyof BookMetadata] as string) || null;
|
||||
}
|
||||
// For Audible provider, audiobook cover is handled separately via uploadAudiobookCoverFromUrl
|
||||
if (this.isAudibleProvider()) {
|
||||
return null;
|
||||
}
|
||||
const thumbnailUrl = this.metadataForm.get('thumbnailUrl')?.value;
|
||||
if (thumbnailUrl?.includes('api/v1')) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private updateMetadata(shouldLockAllFields: boolean | undefined): void {
|
||||
this.bookMetadataManageService.updateBookMetadata(this.currentBookId, this.buildMetadataWrapper(shouldLockAllFields), false, 'REPLACE_WHEN_PROVIDED').subscribe({
|
||||
next: () => {
|
||||
if (shouldLockAllFields !== undefined) {
|
||||
this.messageService.add({
|
||||
severity: 'success',
|
||||
summary: shouldLockAllFields ? this.t.translate('metadata.picker.toast.metadataLocked') : this.t.translate('metadata.picker.toast.metadataUnlocked'),
|
||||
detail: shouldLockAllFields
|
||||
? this.t.translate('metadata.picker.toast.allFieldsLocked')
|
||||
: this.t.translate('metadata.picker.toast.allFieldsUnlocked'),
|
||||
});
|
||||
}
|
||||
},
|
||||
error: () => {
|
||||
this.messageService.add({
|
||||
severity: 'error',
|
||||
summary: this.t.translate('metadata.picker.toast.errorSummary'),
|
||||
detail: this.t.translate('metadata.picker.toast.lockStateFailed'),
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
toggleLock(field: string): void {
|
||||
const controlName = field;
|
||||
let lockField = field;
|
||||
if (field === 'thumbnailUrl') {
|
||||
lockField = 'cover';
|
||||
} else if (field === 'audiobookThumbnailUrl') {
|
||||
lockField = 'audiobookCover';
|
||||
}
|
||||
const isLocked = this.metadataForm.get(lockField + 'Locked')?.value;
|
||||
const updatedLockedState = !isLocked;
|
||||
this.metadataForm.get(lockField + 'Locked')?.setValue(updatedLockedState);
|
||||
if (updatedLockedState) {
|
||||
this.metadataForm.get(controlName)?.disable();
|
||||
} else {
|
||||
this.metadataForm.get(controlName)?.enable();
|
||||
}
|
||||
this.updateMetadata(undefined);
|
||||
}
|
||||
|
||||
copyMissing(): void {
|
||||
this.metadataUtils.copyMissingFields(
|
||||
this.fetchedMetadata,
|
||||
this.metadataForm,
|
||||
this.copiedFields,
|
||||
(field) => this.copyFetchedToCurrent(field)
|
||||
);
|
||||
// Also copy missing comic fields
|
||||
if (this.fetchedMetadata?.comicMetadata) {
|
||||
for (const field of ALL_COMIC_METADATA_FIELDS) {
|
||||
const isLocked = this.metadataForm.get(field.lockedKey)?.value;
|
||||
const currentValue = this.metadataForm.get(field.controlName)?.value;
|
||||
const fetchedValue = this.fetchedMetadata.comicMetadata[field.fetchedKey as keyof ComicMetadata];
|
||||
const isEmpty = Array.isArray(currentValue)
|
||||
? currentValue.length === 0
|
||||
: (currentValue === null || currentValue === undefined || currentValue === '');
|
||||
const hasFetchedValue = fetchedValue !== null && fetchedValue !== undefined && fetchedValue !== '';
|
||||
if (!isLocked && isEmpty && hasFetchedValue) {
|
||||
this.copyFetchedToCurrent(field.controlName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
copyAll(): void {
|
||||
this.metadataUtils.copyAllFields(
|
||||
this.fetchedMetadata,
|
||||
this.metadataForm,
|
||||
(field) => this.copyFetchedToCurrent(field)
|
||||
);
|
||||
// Also copy all comic fields
|
||||
if (this.fetchedMetadata?.comicMetadata) {
|
||||
for (const field of ALL_COMIC_METADATA_FIELDS) {
|
||||
const isLocked = this.metadataForm.get(field.lockedKey)?.value;
|
||||
const fetchedValue = this.fetchedMetadata.comicMetadata[field.fetchedKey as keyof ComicMetadata];
|
||||
if (!isLocked && fetchedValue != null && fetchedValue !== '') {
|
||||
this.copyFetchedToCurrent(field.controlName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
copyFetchedToCurrent(field: string): void {
|
||||
// Handle comic fields (nested under comicMetadata)
|
||||
const comicConfig = this.getComicFieldConfig(field);
|
||||
if (comicConfig) {
|
||||
const isLocked = this.metadataForm.get(comicConfig.lockedKey)?.value;
|
||||
if (isLocked) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: this.t.translate('metadata.picker.toast.actionBlockedSummary'),
|
||||
detail: this.t.translate('metadata.picker.toast.fieldLockedDetail', {field: comicConfig.label})
|
||||
});
|
||||
return;
|
||||
}
|
||||
const value = this.fetchedMetadata?.comicMetadata?.[comicConfig.fetchedKey as keyof ComicMetadata];
|
||||
if (value !== null && value !== undefined && value !== '') {
|
||||
this.metadataForm.get(field)?.setValue(value);
|
||||
this.copiedFields[field] = true;
|
||||
this.highlightCopiedInput(field);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let lockField = field;
|
||||
if (field === 'thumbnailUrl') {
|
||||
lockField = 'cover';
|
||||
} else if (field === 'audiobookThumbnailUrl') {
|
||||
lockField = 'audiobookCover';
|
||||
}
|
||||
const isLocked = this.metadataForm.get(`${lockField}Locked`)?.value;
|
||||
if (isLocked) {
|
||||
this.messageService.add({
|
||||
severity: 'warn',
|
||||
summary: this.t.translate('metadata.picker.toast.actionBlockedSummary'),
|
||||
detail: this.t.translate('metadata.picker.toast.fieldLockedDetail', {field: lockField})
|
||||
});
|
||||
return;
|
||||
}
|
||||
// For audiobook cover from Audible, use the thumbnailUrl from fetched metadata
|
||||
if (field === 'audiobookThumbnailUrl') {
|
||||
this.metadataForm.get('audiobookThumbnailUrl')?.setValue(this.fetchedMetadata.thumbnailUrl);
|
||||
this.copiedFields['audiobookThumbnailUrl'] = true;
|
||||
this.highlightCopiedInput(field);
|
||||
return;
|
||||
}
|
||||
if (this.metadataUtils.copyFieldToForm(field, this.fetchedMetadata, this.metadataForm, this.copiedFields)) {
|
||||
this.highlightCopiedInput(field);
|
||||
}
|
||||
}
|
||||
|
||||
lockAll(): void {
|
||||
this.formBuilder.setAllFieldsLocked(this.metadataForm, true);
|
||||
this.updateMetadata(true);
|
||||
}
|
||||
|
||||
unlockAll(): void {
|
||||
this.formBuilder.setAllFieldsLocked(this.metadataForm, false);
|
||||
this.updateMetadata(false);
|
||||
}
|
||||
|
||||
highlightCopiedInput(field: string): void {
|
||||
this.copiedFields = {...this.copiedFields, [field]: true};
|
||||
}
|
||||
|
||||
isValueCopied(field: string): boolean {
|
||||
return this.copiedFields[field];
|
||||
}
|
||||
|
||||
isValueSaved(field: string): boolean {
|
||||
return this.savedFields[field];
|
||||
}
|
||||
|
||||
goBackClick(): void {
|
||||
this.goBack.emit(true);
|
||||
}
|
||||
|
||||
onMouseEnter(controlName: string): void {
|
||||
if (this.isValueCopied(controlName) && !this.isValueSaved(controlName)) {
|
||||
this.hoveredFields[controlName] = true;
|
||||
}
|
||||
}
|
||||
|
||||
onMouseLeave(controlName: string): void {
|
||||
this.hoveredFields[controlName] = false;
|
||||
}
|
||||
|
||||
resetField(field: string): void {
|
||||
const comicConfig = this.getComicFieldConfig(field);
|
||||
if (comicConfig) {
|
||||
const value = this.originalMetadata?.comicMetadata?.[comicConfig.fetchedKey as keyof ComicMetadata];
|
||||
this.metadataForm.get(field)?.setValue(value ?? (comicConfig.type === 'array' ? [] : comicConfig.type === 'boolean' ? null : ''));
|
||||
this.copiedFields[field] = false;
|
||||
this.hoveredFields[field] = false;
|
||||
return;
|
||||
}
|
||||
this.metadataUtils.resetField(field, this.metadataForm, this.originalMetadata, this.copiedFields, this.hoveredFields);
|
||||
}
|
||||
|
||||
isAudibleProvider(): boolean {
|
||||
return this.fetchedMetadata?.provider?.toLowerCase() === 'audible';
|
||||
}
|
||||
|
||||
getFetchedAudiobookValue(key: string): unknown {
|
||||
return this.fetchedMetadata?.[key as keyof BookMetadata];
|
||||
}
|
||||
|
||||
// Cover type detection methods
|
||||
hasEbookFormat(book: Book): boolean {
|
||||
if (book.isPhysical) {
|
||||
return true;
|
||||
}
|
||||
const allFiles = [book.primaryFile, ...(book.alternativeFormats || [])].filter(f => f?.bookType);
|
||||
return allFiles.some(f => f!.bookType !== 'AUDIOBOOK');
|
||||
}
|
||||
|
||||
hasAudiobookFormat(book: Book): boolean {
|
||||
const allFiles = [book.primaryFile, ...(book.alternativeFormats || [])].filter(f => f?.bookType);
|
||||
return allFiles.some(f => f!.bookType === 'AUDIOBOOK');
|
||||
}
|
||||
|
||||
supportsDualCovers(book: Book): boolean {
|
||||
return this.hasEbookFormat(book) && this.hasAudiobookFormat(book);
|
||||
}
|
||||
|
||||
// Comic metadata helpers
|
||||
hasAnyFetchedComicData(): boolean {
|
||||
const comic = this.fetchedMetadata?.comicMetadata;
|
||||
if (!comic) return false;
|
||||
return ALL_COMIC_METADATA_FIELDS.some(field => {
|
||||
const value = comic[field.fetchedKey as keyof ComicMetadata];
|
||||
if (value === null || value === undefined || value === '' || value === false) return false;
|
||||
if (Array.isArray(value) && value.length === 0) return false;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
hasAnyCurrentComicData(): boolean {
|
||||
const comic = this.currentBook?.metadata?.comicMetadata;
|
||||
if (!comic) return false;
|
||||
return ALL_COMIC_METADATA_FIELDS.some(field => {
|
||||
const value = comic[field.fetchedKey as keyof ComicMetadata];
|
||||
if (value === null || value === undefined || value === '' || value === false) return false;
|
||||
if (Array.isArray(value) && value.length === 0) return false;
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
shouldShowComicSection(): boolean {
|
||||
return this.hasAnyFetchedComicData() || this.hasAnyCurrentComicData() ||
|
||||
this.currentBook?.primaryFile?.bookType === 'CBX' ||
|
||||
this.fetchedMetadata?.provider?.toLowerCase() === 'comicvine';
|
||||
}
|
||||
|
||||
getFetchedComicValue(fetchedKey: string): unknown {
|
||||
return this.fetchedMetadata?.comicMetadata?.[fetchedKey as keyof ComicMetadata];
|
||||
}
|
||||
|
||||
private getComicFieldConfig(controlName: string): MetadataFieldConfig | undefined {
|
||||
return ALL_COMIC_METADATA_FIELDS.find(f => f.controlName === controlName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user