Feature: Autocomplete for publisher and series on book metadata edit screen (#1587)
* Autocomplete for publisher and series on book metadata edit screen * Add autocomplete to bulk edit metadata form * seriesName was missing the [disabled]="clearFields.seriesName" attribute --------- Co-authored-by: Aditya Chandel <8075870+adityachandelgit@users.noreply.github.com>
This commit is contained in:
co-authored by
Aditya Chandel
parent
f6790d53dc
commit
f141fa49ba
+26
-3
@@ -125,7 +125,18 @@
|
||||
<div class="flex flex-col gap-1 md:basis-[20%]">
|
||||
<label class="text-sm" for="publisher">Publisher</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pSize="small" pInputText id="publisher" formControlName="publisher" class="w-full"/>
|
||||
<p-autoComplete
|
||||
class="w-full"
|
||||
inputStyleClass="w-full"
|
||||
formControlName="publisher"
|
||||
inputId="publisher"
|
||||
[multiple]="false"
|
||||
[dropdown]="false"
|
||||
[suggestions]="filteredPublishers"
|
||||
[forceSelection]="false"
|
||||
[showClear]="true"
|
||||
(completeMethod)="filterPublishers($event)">
|
||||
</p-autoComplete>
|
||||
@if (!book.metadata!['publisherLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('publisher')" severity="success"></p-button>
|
||||
}
|
||||
@@ -137,7 +148,7 @@
|
||||
<div class="flex flex-col gap-1 md:basis-[14%]">
|
||||
<label class="text-sm" for="language">Language</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pSize="small" pInputText id="language" formControlName="language" class="w-full"/>
|
||||
<input pInputText id="language" formControlName="language" class="w-full"/>
|
||||
@if (!book.metadata!['languageLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('language')" severity="success"></p-button>
|
||||
}
|
||||
@@ -235,7 +246,19 @@
|
||||
<div class="flex flex-col gap-1 md:basis-[75%]">
|
||||
<label class="text-sm" for="seriesName">Series Name</label>
|
||||
<div class="flex justify-between items-center gap-2">
|
||||
<input pSize="small" pInputText id="seriesName" formControlName="seriesName" class="w-full"/>
|
||||
<p-autoComplete
|
||||
size="small"
|
||||
class="w-full"
|
||||
inputStyleClass="w-full"
|
||||
formControlName="seriesName"
|
||||
inputId="seriesName"
|
||||
[multiple]="false"
|
||||
[dropdown]="false"
|
||||
[suggestions]="filteredSeries"
|
||||
[forceSelection]="false"
|
||||
[showClear]="true"
|
||||
(completeMethod)="filterSeries($event)">
|
||||
</p-autoComplete>
|
||||
@if (!book.metadata!['seriesNameLocked']) {
|
||||
<p-button size="small" icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('seriesName')" severity="success"></p-button>
|
||||
}
|
||||
|
||||
+28
@@ -81,10 +81,14 @@ export class MetadataEditorComponent implements OnInit {
|
||||
allCategories!: string[];
|
||||
allMoods!: string[];
|
||||
allTags!: string[];
|
||||
allPublishers!: string[];
|
||||
allSeries!: string[];
|
||||
filteredCategories: string[] = [];
|
||||
filteredAuthors: string[] = [];
|
||||
filteredMoods: string[] = [];
|
||||
filteredTags: string[] = [];
|
||||
filteredPublishers: string[] = [];
|
||||
filteredSeries: string[] = [];
|
||||
|
||||
filterCategories(event: { query: string }) {
|
||||
const query = event.query.toLowerCase();
|
||||
@@ -114,6 +118,20 @@ export class MetadataEditorComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
filterPublishers(event: { query: string }) {
|
||||
const query = event.query.toLowerCase();
|
||||
this.filteredPublishers = this.allPublishers.filter((publisher) =>
|
||||
publisher.toLowerCase().includes(query)
|
||||
);
|
||||
}
|
||||
|
||||
filterSeries(event: { query: string }) {
|
||||
const query = event.query.toLowerCase();
|
||||
this.filteredSeries = this.allSeries.filter((seriesName) =>
|
||||
seriesName.toLowerCase().includes(query)
|
||||
);
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this.metadataForm = new FormGroup({
|
||||
title: new FormControl(""),
|
||||
@@ -201,6 +219,8 @@ export class MetadataEditorComponent implements OnInit {
|
||||
const categories = new Set<string>();
|
||||
const moods = new Set<string>();
|
||||
const tags = new Set<string>();
|
||||
const publishers = new Set<string>();
|
||||
const series = new Set<string>();
|
||||
|
||||
(bookState.books ?? []).forEach((book) => {
|
||||
book.metadata?.authors?.forEach((author) => authors.add(author));
|
||||
@@ -209,12 +229,20 @@ export class MetadataEditorComponent implements OnInit {
|
||||
);
|
||||
book.metadata?.moods?.forEach((mood) => moods.add(mood));
|
||||
book.metadata?.tags?.forEach((tag) => tags.add(tag));
|
||||
if (book.metadata?.publisher) {
|
||||
publishers.add(book.metadata.publisher);
|
||||
}
|
||||
if (book.metadata?.seriesName) {
|
||||
series.add(book.metadata.seriesName);
|
||||
}
|
||||
});
|
||||
|
||||
this.allAuthors = Array.from(authors);
|
||||
this.allCategories = Array.from(categories);
|
||||
this.allMoods = Array.from(moods);
|
||||
this.allTags = Array.from(tags);
|
||||
this.allPublishers = Array.from(publishers);
|
||||
this.allSeries = Array.from(series);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+133
-52
@@ -36,40 +36,39 @@
|
||||
|
||||
<form [formGroup]="metadataForm" (ngSubmit)="onSubmit()" (keydown)="onFormKeydown($event)" class="flex flex-col gap-4 w-full p-4">
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="authors" class="flex items-center justify-between gap-2">
|
||||
<span class="flex items-center gap-2">
|
||||
Author(s)
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Enter multiple authors. Press Enter after typing each name."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer"></i>
|
||||
</span>
|
||||
<div class="flex items-center gap-1">
|
||||
<p-checkbox [(ngModel)]="clearFields.authors" [ngModelOptions]="{standalone: true}" (onChange)="onFieldClearToggle('authors')" binary="true" inputId="clearAuthors"/>
|
||||
<label for="clearAuthors" class="text-sm text-gray-300 cursor-pointer">Clear</label>
|
||||
</div>
|
||||
</label>
|
||||
<p-autoComplete formControlName="authors" [disabled]="clearFields.authors" [multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" (onBlur)="onAutoCompleteBlur('authors', $event)" class="w-full"></p-autoComplete>
|
||||
</div>
|
||||
|
||||
<!-- Publisher -->
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="publisher" class="flex items-center justify-between gap-2">
|
||||
<span>Publisher</span>
|
||||
<div class="flex items-center gap-1">
|
||||
<p-checkbox [(ngModel)]="clearFields.publisher" [ngModelOptions]="{standalone: true}"
|
||||
(onChange)="onFieldClearToggle('publisher')" binary="true" inputId="clearPublisher"/>
|
||||
<label for="clearPublisher" class="text-sm text-gray-300 cursor-pointer">Clear</label>
|
||||
</div>
|
||||
</label>
|
||||
<input pInputText id="publisher" formControlName="publisher" [disabled]="clearFields.publisher" class="w-full"/>
|
||||
</div>
|
||||
|
||||
<!-- Language + Series Total + Published Date -->
|
||||
<div class="flex justify-between gap-7">
|
||||
<!-- Authors -->
|
||||
<div class="flex flex-col gap-2 w-full md:basis-[80%]">
|
||||
<label for="authors" class="flex items-center justify-between gap-2">
|
||||
<span class="flex items-center gap-2">
|
||||
Author(s)
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Enter multiple authors. Press Enter after typing each name."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer"></i>
|
||||
</span>
|
||||
<div class="flex items-center gap-1">
|
||||
<p-checkbox [(ngModel)]="clearFields.authors" [ngModelOptions]="{standalone: true}" (onChange)="onFieldClearToggle('authors')" binary="true" inputId="clearAuthors"/>
|
||||
<label for="clearAuthors" class="text-sm text-gray-300 cursor-pointer">Clear</label>
|
||||
</div>
|
||||
</label>
|
||||
<p-autoComplete
|
||||
class="w-full"
|
||||
id="authors"
|
||||
formControlName="authors"
|
||||
[disabled]="clearFields.authors"
|
||||
[multiple]="true"
|
||||
[dropdown]="false"
|
||||
[forceSelection]="false"
|
||||
[suggestions]="filteredAuthors"
|
||||
(completeMethod)="filterAuthors($event)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp('authors', $event)"
|
||||
(onSelect)="onAutoCompleteSelect('authors', $event)">
|
||||
</p-autoComplete>
|
||||
</div>
|
||||
|
||||
<!-- Language -->
|
||||
<div class="flex flex-col gap-2 w-full">
|
||||
<div class="flex flex-col gap-2 md:basis-[20%]">
|
||||
<label for="language" class="flex items-center justify-between gap-2">
|
||||
<span>Language</span>
|
||||
<div class="flex items-center gap-1">
|
||||
@@ -80,9 +79,36 @@
|
||||
</label>
|
||||
<input pInputText id="language" formControlName="language" [disabled]="clearFields.language" class="w-full"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-between gap-7">
|
||||
<!-- Publisher -->
|
||||
<div class="flex flex-col gap-2 w-full md:basis-[80%]">
|
||||
<label for="publisher" class="flex items-center justify-between gap-2">
|
||||
<span>Publisher</span>
|
||||
<div class="flex items-center gap-1">
|
||||
<p-checkbox [(ngModel)]="clearFields.publisher" [ngModelOptions]="{standalone: true}"
|
||||
(onChange)="onFieldClearToggle('publisher')" binary="true" inputId="clearPublisher"/>
|
||||
<label for="clearPublisher" class="text-sm text-gray-300 cursor-pointer">Clear</label>
|
||||
</div>
|
||||
</label>
|
||||
<p-autoComplete
|
||||
class="w-full"
|
||||
inputStyleClass="w-full"
|
||||
formControlName="publisher"
|
||||
inputId="publisher"
|
||||
[disabled]="clearFields.publisher"
|
||||
[multiple]="false"
|
||||
[dropdown]="false"
|
||||
[showClear]="true"
|
||||
[forceSelection]="false"
|
||||
[suggestions]="filteredPublishers"
|
||||
(completeMethod)="filterPublishers($event)">
|
||||
</p-autoComplete>
|
||||
</div>
|
||||
|
||||
<!-- Published Date -->
|
||||
<div class="flex flex-col gap-2 w-96">
|
||||
<div class="flex flex-col gap-2 md:basis-[20%]">
|
||||
<label for="publishedDate" class="flex items-center justify-between gap-2">
|
||||
<span>Published Date</span>
|
||||
<div class="flex items-center gap-1">
|
||||
@@ -105,11 +131,44 @@
|
||||
appendTo="body">
|
||||
</p-datepicker>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-between gap-7">
|
||||
<!-- Series Name -->
|
||||
<div class="flex flex-col gap-2 w-full md:basis-[80%]">
|
||||
<label for="seriesName" class="flex items-center justify-between gap-2">
|
||||
<span>Series Name</span>
|
||||
<div class="flex items-center gap-1">
|
||||
<p-checkbox [(ngModel)]="clearFields.seriesName" [ngModelOptions]="{standalone: true}"
|
||||
(onChange)="onFieldClearToggle('seriesName')" binary="true" inputId="clearSeriesName"/>
|
||||
<label for="clearSeriesName" class="text-sm text-gray-300 cursor-pointer">Clear</label>
|
||||
</div>
|
||||
</label>
|
||||
<p-autoComplete
|
||||
class="w-full"
|
||||
inputStyleClass="w-full"
|
||||
formControlName="seriesName"
|
||||
inputId="seriesName"
|
||||
[disabled]="clearFields.seriesName"
|
||||
[multiple]="false"
|
||||
[dropdown]="false"
|
||||
[showClear]="true"
|
||||
[forceSelection]="false"
|
||||
[suggestions]="filteredSeries"
|
||||
(completeMethod)="filterSeries($event)">
|
||||
</p-autoComplete>
|
||||
</div>
|
||||
|
||||
<!-- Series Total -->
|
||||
<div class="flex flex-col gap-2 min-w-56">
|
||||
<div class="flex flex-col gap-2 md:basis-[20%]">
|
||||
<label for="seriesTotal" class="flex items-center justify-between gap-2">
|
||||
<span>Total Books in Series</span>
|
||||
<span class="flex items-center gap-2">
|
||||
Total Books
|
||||
<i class="pi pi-info-circle text-sky-600"
|
||||
pTooltip="Total number of books in the series."
|
||||
tooltipPosition="right"
|
||||
style="cursor: pointer"></i>
|
||||
</span>
|
||||
<div class="flex items-center gap-1">
|
||||
<p-checkbox [(ngModel)]="clearFields.seriesTotal" [ngModelOptions]="{standalone: true}"
|
||||
(onChange)="onFieldClearToggle('seriesTotal')" binary="true" inputId="clearSeriesTotal"/>
|
||||
@@ -119,20 +178,6 @@
|
||||
<input pInputText id="seriesTotal" type="number" min="1" formControlName="seriesTotal"
|
||||
[disabled]="clearFields.seriesTotal" class="w-full"/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Series Name -->
|
||||
<div class="flex flex-col gap-2">
|
||||
<label for="seriesName" class="flex items-center justify-between gap-2">
|
||||
<span>Series Name</span>
|
||||
<div class="flex items-center gap-1">
|
||||
<p-checkbox [(ngModel)]="clearFields.seriesName" [ngModelOptions]="{standalone: true}"
|
||||
(onChange)="onFieldClearToggle('seriesName')" binary="true" inputId="clearSeriesName"/>
|
||||
<label for="clearSeriesName" class="text-sm text-gray-300 cursor-pointer">Clear</label>
|
||||
</div>
|
||||
</label>
|
||||
<input pInputText id="seriesName" formControlName="seriesName" [disabled]="clearFields.seriesName" class="w-full"/>
|
||||
</div>
|
||||
|
||||
<!-- Genres -->
|
||||
@@ -151,7 +196,19 @@
|
||||
<label for="clearGenres" class="text-sm text-gray-300 cursor-pointer">Clear</label>
|
||||
</div>
|
||||
</label>
|
||||
<p-autoComplete formControlName="genres" [disabled]="clearFields.genres" [multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" (onBlur)="onAutoCompleteBlur('genres', $event)" class="w-full"></p-autoComplete>
|
||||
<p-autoComplete
|
||||
class="w-full"
|
||||
id="genres"
|
||||
formControlName="genres"
|
||||
[disabled]="clearFields.genres"
|
||||
[multiple]="true"
|
||||
[dropdown]="false"
|
||||
[forceSelection]="false"
|
||||
[suggestions]="filteredGenres"
|
||||
(completeMethod)="filterGenres($event)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp('genres', $event)"
|
||||
(onSelect)="onAutoCompleteSelect('genres', $event)">
|
||||
</p-autoComplete>
|
||||
|
||||
<div class="flex items-center gap-2 mt-2">
|
||||
<p-checkbox
|
||||
@@ -183,7 +240,19 @@
|
||||
<label for="clearMoods" class="text-sm text-gray-300 cursor-pointer">Clear</label>
|
||||
</div>
|
||||
</label>
|
||||
<p-autoComplete formControlName="moods" [disabled]="clearFields.moods" [multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" (onBlur)="onAutoCompleteBlur('moods', $event)" class="w-full"></p-autoComplete>
|
||||
<p-autoComplete
|
||||
class="w-full"
|
||||
id="moods"
|
||||
formControlName="moods"
|
||||
[disabled]="clearFields.moods"
|
||||
[multiple]="true"
|
||||
[dropdown]="false"
|
||||
[forceSelection]="false"
|
||||
[suggestions]="filteredMoods"
|
||||
(completeMethod)="filterMoods($event)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp('moods', $event)"
|
||||
(onSelect)="onAutoCompleteSelect('moods', $event)">
|
||||
</p-autoComplete>
|
||||
|
||||
<div class="flex items-center gap-2 mt-2">
|
||||
<p-checkbox
|
||||
@@ -215,7 +284,19 @@
|
||||
<label for="clearTags" class="text-sm text-gray-300 cursor-pointer">Clear</label>
|
||||
</div>
|
||||
</label>
|
||||
<p-autoComplete formControlName="tags" [disabled]="clearFields.tags" [multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" (onBlur)="onAutoCompleteBlur('tags', $event)" class="w-full"></p-autoComplete>
|
||||
<p-autoComplete
|
||||
class="w-full"
|
||||
id="tags"
|
||||
formControlName="tags"
|
||||
[disabled]="clearFields.tags"
|
||||
[multiple]="true"
|
||||
[dropdown]="false"
|
||||
[forceSelection]="false"
|
||||
[suggestions]="filteredTags"
|
||||
(completeMethod)="filterTags($event)"
|
||||
(onKeyUp)="onAutoCompleteKeyUp('tags', $event)"
|
||||
(onSelect)="onAutoCompleteSelect('tags', $event)">
|
||||
</p-autoComplete>
|
||||
|
||||
<div class="flex items-center gap-2 mt-2">
|
||||
<p-checkbox
|
||||
|
||||
+109
-13
@@ -12,6 +12,7 @@ import {Book, BulkMetadataUpdateRequest} from '../../../book/model/book.model';
|
||||
import {Checkbox} from 'primeng/checkbox';
|
||||
import {AutoComplete} from 'primeng/autocomplete';
|
||||
import {ProgressSpinner} from 'primeng/progressspinner';
|
||||
import {filter, take} from "rxjs/operators";
|
||||
|
||||
@Component({
|
||||
selector: 'app-bulk-metadata-update-component',
|
||||
@@ -60,6 +61,61 @@ export class BulkMetadataUpdateComponent implements OnInit {
|
||||
private readonly bookService = inject(BookService);
|
||||
private readonly messageService = inject(MessageService);
|
||||
|
||||
allAuthors!: string[];
|
||||
allGenres!: string[];
|
||||
allMoods!: string[];
|
||||
allTags!: string[];
|
||||
allPublishers!: string[];
|
||||
allSeries!: string[];
|
||||
filteredGenres: string[] = [];
|
||||
filteredAuthors: string[] = [];
|
||||
filteredMoods: string[] = [];
|
||||
filteredTags: string[] = [];
|
||||
filteredPublishers: string[] = [];
|
||||
filteredSeries: string[] = [];
|
||||
|
||||
filterGenres(event: { query: string }) {
|
||||
const query = event.query.toLowerCase();
|
||||
this.filteredGenres = this.allGenres.filter((cat) =>
|
||||
cat.toLowerCase().includes(query)
|
||||
);
|
||||
}
|
||||
|
||||
filterAuthors(event: { query: string }) {
|
||||
const query = event.query.toLowerCase();
|
||||
this.filteredAuthors = this.allAuthors.filter((author) =>
|
||||
author.toLowerCase().includes(query)
|
||||
);
|
||||
}
|
||||
|
||||
filterMoods(event: { query: string }) {
|
||||
const query = event.query.toLowerCase();
|
||||
this.filteredMoods = this.allMoods.filter((mood) =>
|
||||
mood.toLowerCase().includes(query)
|
||||
);
|
||||
}
|
||||
|
||||
filterTags(event: { query: string }) {
|
||||
const query = event.query.toLowerCase();
|
||||
this.filteredTags = this.allTags.filter((tag) =>
|
||||
tag.toLowerCase().includes(query)
|
||||
);
|
||||
}
|
||||
|
||||
filterPublishers(event: { query: string }) {
|
||||
const query = event.query.toLowerCase();
|
||||
this.filteredPublishers = this.allPublishers.filter((publisher) =>
|
||||
publisher.toLowerCase().includes(query)
|
||||
);
|
||||
}
|
||||
|
||||
filterSeries(event: { query: string }) {
|
||||
const query = event.query.toLowerCase();
|
||||
this.filteredSeries = this.allSeries.filter((seriesName) =>
|
||||
seriesName.toLowerCase().includes(query)
|
||||
);
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.bookIds = this.config.data?.bookIds ?? [];
|
||||
this.books = this.bookService.getBooksByIdsFromState(this.bookIds);
|
||||
@@ -75,6 +131,42 @@ export class BulkMetadataUpdateComponent implements OnInit {
|
||||
moods: [],
|
||||
tags: []
|
||||
});
|
||||
|
||||
this.bookService.bookState$
|
||||
.pipe(
|
||||
filter((bookState) => bookState.loaded),
|
||||
take(1)
|
||||
)
|
||||
.subscribe((bookState) => {
|
||||
const authors = new Set<string>();
|
||||
const categories = new Set<string>();
|
||||
const moods = new Set<string>();
|
||||
const tags = new Set<string>();
|
||||
const publishers = new Set<string>();
|
||||
const series = new Set<string>();
|
||||
|
||||
(bookState.books ?? []).forEach((book) => {
|
||||
book.metadata?.authors?.forEach((author) => authors.add(author));
|
||||
book.metadata?.categories?.forEach((category) =>
|
||||
categories.add(category)
|
||||
);
|
||||
book.metadata?.moods?.forEach((mood) => moods.add(mood));
|
||||
book.metadata?.tags?.forEach((tag) => tags.add(tag));
|
||||
if (book.metadata?.publisher) {
|
||||
publishers.add(book.metadata.publisher);
|
||||
}
|
||||
if (book.metadata?.seriesName) {
|
||||
series.add(book.metadata.seriesName);
|
||||
}
|
||||
});
|
||||
|
||||
this.allAuthors = Array.from(authors);
|
||||
this.allGenres = Array.from(categories);
|
||||
this.allMoods = Array.from(moods);
|
||||
this.allTags = Array.from(tags);
|
||||
this.allPublishers = Array.from(publishers);
|
||||
this.allSeries = Array.from(series);
|
||||
});
|
||||
}
|
||||
|
||||
onFieldClearToggle(field: keyof typeof this.clearFields): void {
|
||||
@@ -89,21 +181,25 @@ export class BulkMetadataUpdateComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
// 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()) : [];
|
||||
onAutoCompleteSelect(fieldName: string, event: any) {
|
||||
const values = this.metadataForm.get(fieldName)?.value || [];
|
||||
if (!values.includes(event.value)) {
|
||||
this.metadataForm.get(fieldName)?.setValue([...values, event.value]);
|
||||
}
|
||||
(event.originalEvent.target as HTMLInputElement).value = "";
|
||||
}
|
||||
|
||||
// Add the new value if it's not already in the array
|
||||
if (!values.includes(inputValue)) {
|
||||
values.push(inputValue);
|
||||
this.metadataForm.get(fieldName)?.setValue(values);
|
||||
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 = "";
|
||||
}
|
||||
// Clear the input
|
||||
event.target.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user