diff --git a/booklore-api/src/main/java/com/adityachandel/booklore/service/metadata/parser/HardcoverParser.java b/booklore-api/src/main/java/com/adityachandel/booklore/service/metadata/parser/HardcoverParser.java index 40122fc1e..dc2eb25a2 100644 --- a/booklore-api/src/main/java/com/adityachandel/booklore/service/metadata/parser/HardcoverParser.java +++ b/booklore-api/src/main/java/com/adityachandel/booklore/service/metadata/parser/HardcoverParser.java @@ -15,7 +15,6 @@ import org.springframework.stereotype.Service; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDate; -import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Set; diff --git a/booklore-ui/src/app/bookdrop/bookdrop-file-metadata-picker-component/bookdrop-file-metadata-picker.component.ts b/booklore-ui/src/app/bookdrop/bookdrop-file-metadata-picker-component/bookdrop-file-metadata-picker.component.ts index 4dbb27c9d..e9764b7ad 100644 --- a/booklore-ui/src/app/bookdrop/bookdrop-file-metadata-picker-component/bookdrop-file-metadata-picker.component.ts +++ b/booklore-ui/src/app/bookdrop/bookdrop-file-metadata-picker-component/bookdrop-file-metadata-picker.component.ts @@ -49,7 +49,9 @@ export class BookdropFileMetadataPickerComponent { metadataChips = [ {label: 'Authors', controlName: 'authors', lockedKey: 'authorsLocked', fetchedKey: 'authors'}, - {label: 'Genres', controlName: 'categories', lockedKey: 'categoriesLocked', fetchedKey: 'categories'} + {label: 'Genres', controlName: 'categories', lockedKey: 'categoriesLocked', fetchedKey: 'categories'}, + {label: 'Moods', controlName: 'moods', lockedKey: 'moodsLocked', fetchedKey: 'moods'}, + {label: 'Tags', controlName: 'tags', lockedKey: 'tagsLocked', fetchedKey: 'tags'}, ]; metadataDescription = [ @@ -81,7 +83,15 @@ export class BookdropFileMetadataPickerComponent { copyMissing(): void { Object.keys(this.fetchedMetadata).forEach((field) => { - if (!this.metadataForm.get(field)?.value && this.fetchedMetadata[field]) { + const isLocked = this.metadataForm.get(`${field}Locked`)?.value; + const currentValue = this.metadataForm.get(field)?.value; + const fetchedValue = this.fetchedMetadata[field]; + + const isEmpty = Array.isArray(currentValue) + ? currentValue.length === 0 + : !currentValue; + + if (!isLocked && isEmpty && fetchedValue) { this.copyFetchedToCurrent(field); } }); @@ -140,20 +150,16 @@ export class BookdropFileMetadataPickerComponent { } } - // Handle blur event for AutoComplete to add custom values onAutoCompleteBlur(fieldName: string, event: any) { const inputValue = event.target.value?.trim(); if (inputValue) { const currentValue = this.metadataForm.get(fieldName)?.value || []; const values = Array.isArray(currentValue) ? currentValue : - typeof currentValue === 'string' && currentValue ? currentValue.split(',').map((v: string) => v.trim()) : []; - - // Add the new value if it's not already in the array + typeof currentValue === 'string' && currentValue ? currentValue.split(',').map((v: string) => v.trim()) : [] if (!values.includes(inputValue)) { values.push(inputValue); this.metadataForm.get(fieldName)?.setValue(values); } - // Clear the input event.target.value = ''; } } @@ -165,6 +171,8 @@ export class BookdropFileMetadataPickerComponent { subtitle: this.originalMetadata.subtitle || null, authors: [...(this.originalMetadata.authors ?? [])].sort(), categories: [...(this.originalMetadata.categories ?? [])].sort(), + moods: [...(this.originalMetadata.moods ?? [])].sort(), + tags: [...(this.originalMetadata.tags ?? [])].sort(), publisher: this.originalMetadata.publisher || null, publishedDate: this.originalMetadata.publishedDate || null, isbn10: this.originalMetadata.isbn10 || null, diff --git a/booklore-ui/src/app/bookdrop/bookdrop-file-review-component/bookdrop-file-review.component.ts b/booklore-ui/src/app/bookdrop/bookdrop-file-review-component/bookdrop-file-review.component.ts index 8b31c769f..519aed9a7 100644 --- a/booklore-ui/src/app/bookdrop/bookdrop-file-review-component/bookdrop-file-review.component.ts +++ b/booklore-ui/src/app/bookdrop/bookdrop-file-review-component/bookdrop-file-review.component.ts @@ -253,6 +253,8 @@ export class BookdropFileReviewComponent implements OnInit { subtitle: original?.subtitle || null, authors: [...(original?.authors ?? [])].sort(), categories: [...(original?.categories ?? [])].sort(), + moods: [...(original?.moods ?? [])].sort(), + tags: [...(original?.tags ?? [])].sort(), publisher: original?.publisher || null, publishedDate: original?.publishedDate || null, isbn10: original?.isbn10 ?? null, @@ -496,6 +498,8 @@ export class BookdropFileReviewComponent implements OnInit { subtitle: new FormControl(original?.subtitle ?? ''), authors: new FormControl([...(original?.authors ?? [])].sort()), categories: new FormControl([...(original?.categories ?? [])].sort()), + moods: new FormControl([...(original?.moods ?? [])].sort()), + tags: new FormControl([...(original?.tags ?? [])].sort()), publisher: new FormControl(original?.publisher ?? ''), publishedDate: new FormControl(original?.publishedDate ?? ''), isbn10: new FormControl(original?.isbn10 ?? ''),