feat(metadata): add replace mode option for metadata fetching (#2356)
Signed-off-by: Balázs Szücs <bszucs1209@gmail.com>
This commit is contained in:
+6
@@ -122,6 +122,12 @@
|
||||
<div class="flex flex-row items-center justify-between gap-4 w-full">
|
||||
|
||||
<div class="flex flex-row gap-10">
|
||||
<div class="flex flex-row items-center gap-4">
|
||||
<p pTooltip="Controls how fetched metadata replaces existing values. 'Replace Missing Only' only fills empty fields, 'Replace All Fields' overwrites existing values." tooltipPosition="top">Replace Mode:</p>
|
||||
<p-select [options]="replaceModeOptions" [(ngModel)]="replaceMode" optionLabel="label" optionValue="value"
|
||||
appendTo="body" size="small" class="min-w-40">
|
||||
</p-select>
|
||||
</div>
|
||||
<div class="flex flex-row items-center gap-4">
|
||||
<p pTooltip="Fetch and update new book cover images" tooltipPosition="top">Update covers:</p>
|
||||
<p-checkbox [(ngModel)]="refreshCovers" [binary]="true"></p-checkbox>
|
||||
|
||||
+14
-1
@@ -5,7 +5,11 @@ import {FormsModule} from '@angular/forms';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {Button} from 'primeng/button';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {FieldOptions, MetadataRefreshOptions} from '../../../model/request/metadata-refresh-options.model';
|
||||
import {
|
||||
FieldOptions,
|
||||
MetadataRefreshOptions,
|
||||
MetadataReplaceMode
|
||||
} from '../../../model/request/metadata-refresh-options.model';
|
||||
import {Tooltip} from 'primeng/tooltip';
|
||||
|
||||
@Component({
|
||||
@@ -56,6 +60,12 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
refreshCovers: boolean = false;
|
||||
mergeCategories: boolean = false;
|
||||
reviewBeforeApply: boolean = false;
|
||||
replaceMode: MetadataReplaceMode = 'REPLACE_MISSING';
|
||||
|
||||
replaceModeOptions: { label: string; value: MetadataReplaceMode }[] = [
|
||||
{ label: 'Replace Missing Only', value: 'REPLACE_MISSING' },
|
||||
{ label: 'Replace All Fields', value: 'REPLACE_ALL' }
|
||||
];
|
||||
|
||||
fieldOptions: FieldOptions = this.initializeFieldOptions();
|
||||
enabledFields: Record<keyof FieldOptions, boolean> = this.initializeEnabledFields();
|
||||
@@ -114,6 +124,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
this.refreshCovers = this.currentMetadataOptions.refreshCovers || false;
|
||||
this.mergeCategories = this.currentMetadataOptions.mergeCategories || false;
|
||||
this.reviewBeforeApply = this.currentMetadataOptions.reviewBeforeApply || false;
|
||||
this.replaceMode = this.currentMetadataOptions.replaceMode || 'REPLACE_MISSING';
|
||||
|
||||
const backendFieldOptions = this.deepCloneFieldOptions(this.currentMetadataOptions.fieldOptions as FieldOptions || {});
|
||||
for (const field of this.fields) {
|
||||
@@ -161,6 +172,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
refreshCovers: this.refreshCovers,
|
||||
mergeCategories: this.mergeCategories,
|
||||
reviewBeforeApply: this.reviewBeforeApply,
|
||||
replaceMode: this.replaceMode,
|
||||
fieldOptions: this.fieldOptions,
|
||||
enabledFields: this.enabledFields
|
||||
};
|
||||
@@ -218,6 +230,7 @@ export class MetadataAdvancedFetchOptionsComponent implements OnChanges {
|
||||
};
|
||||
}
|
||||
this.enabledFields = this.initializeEnabledFields();
|
||||
this.replaceMode = 'REPLACE_MISSING';
|
||||
|
||||
// Reset bulk selectors
|
||||
this.bulkP1 = null;
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
export type MetadataReplaceMode = 'REPLACE_ALL' | 'REPLACE_MISSING';
|
||||
|
||||
export interface MetadataRefreshOptions {
|
||||
libraryId: number | null;
|
||||
refreshCovers: boolean;
|
||||
mergeCategories: boolean;
|
||||
reviewBeforeApply: boolean;
|
||||
/**
|
||||
* Controls how fetched metadata replaces existing metadata.
|
||||
* REPLACE_ALL: Replace all fields with fetched values (even if existing values are present)
|
||||
* REPLACE_MISSING: Only fill in fields that are currently empty/null
|
||||
*/
|
||||
replaceMode?: MetadataReplaceMode;
|
||||
fieldOptions?: FieldOptions;
|
||||
enabledFields?: Record<keyof FieldOptions, boolean>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user