Upgrade primeng to 20.0.1 (#903)

* build(npm): add missed packages

* build(npm): upgrade primeng to 20.0.1

* feat(ui): upgrade ui to support 20 primeng

https://primeng.org/migration/v19#compatible

* fix(ui): p-input value max requires value

* refactor(ui): remove unused component imports

* build(npm): allow common js dependencies

* style(ui): fix some warnings

* fix(ui): replace chips with autoComplete

---------

Co-authored-by: Aditya Chandel <8075870+adityachandelgit@users.noreply.github.com>
This commit is contained in:
Alexander Puzynia
2025-08-14 12:10:45 -06:00
committed by GitHub
co-authored by Aditya Chandel
parent 77e02ac7f9
commit 60f8442514
20 changed files with 2348 additions and 546 deletions
@@ -87,7 +87,7 @@
<label for="authors">Authors</label>
<div class="flex justify-between items-center gap-2">
<div class="w-full">
<p-chips formControlName="authors" addOnBlur="true"></p-chips>
<p-autoComplete formControlName="authors" [multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" [showClear]="true" (onBlur)="onAutoCompleteBlur('authors', $event)" styleClass="w-full"></p-autoComplete>
</div>
@if (!book.metadata!['authorsLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('authors')" severity="success"></p-button>
@@ -128,7 +128,7 @@
<label for="categories">Categories</label>
<div class="flex justify-between items-center gap-2">
<div class="w-full">
<p-chips formControlName="categories" addOnBlur="true"></p-chips>
<p-autoComplete formControlName="categories" [multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" [showClear]="true" (onBlur)="onAutoCompleteBlur('categories', $event)" styleClass="w-full"></p-autoComplete>
</div>
@if (!book.metadata!['categoriesLocked']) {
<p-button icon="pi pi-lock-open" [outlined]="true" (onClick)="toggleLock('categories')" severity="success"></p-button>
@@ -21,7 +21,7 @@ import {DialogService} from 'primeng/dynamicdialog';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {MetadataRefreshRequest} from '../../model/request/metadata-refresh-request.model';
import {MetadataRefreshType} from '../../model/request/metadata-refresh-type.enum';
import {Chips} from 'primeng/chips';
import {AutoComplete} from 'primeng/autocomplete';
@Component({
selector: 'app-metadata-editor',
@@ -45,7 +45,7 @@ import {Chips} from 'primeng/chips';
Tab,
TabPanels,
TabPanel,
Chips
AutoComplete
]
})
export class MetadataEditorComponent implements OnInit {
@@ -79,6 +79,24 @@ export class MetadataEditorComponent implements OnInit {
originalMetadata!: BookMetadata;
// 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
if (!values.includes(inputValue)) {
values.push(inputValue);
this.metadataForm.get(fieldName)?.setValue(values);
}
// Clear the input
event.target.value = '';
}
}
constructor() {
this.metadataForm = new FormGroup({
title: new FormControl(''),
@@ -86,7 +86,7 @@
<p-button icon="pi pi-lock" [outlined]="true" (onClick)="toggleLock(field.controlName)" severity="warn"></p-button>
}
<div class="w-full px-4">
<p-chips formControlName="{{field.controlName}}" addOnBlur="true"></p-chips>
<p-autoComplete formControlName="{{field.controlName}}" [multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" (onBlur)="onAutoCompleteBlur(field.controlName, $event)" styleClass="w-full"></p-autoComplete>
</div>
<p-button
[icon]="isValueSaved(field.controlName) ? 'pi pi-check' : (hoveredFields[field.controlName] && isValueCopied(field.controlName) ? 'pi pi-times' : 'pi pi-arrow-left')"
@@ -103,11 +103,12 @@
(mouseleave)="onMouseLeave(field.controlName)"/>
<div class="w-full px-4">
<p-chips
<p-autoComplete
[ngModel]="fetchedMetadata[field.fetchedKey] ?? []"
[ngModelOptions]="{ standalone: true }"
[disabled]="true">
</p-chips>
[disabled]="true"
[multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" styleClass="w-full">
</p-autoComplete>
</div>
</div>
</div>
@@ -13,7 +13,7 @@ import {BookService} from '../../../book/service/book.service';
import {Textarea} from 'primeng/textarea';
import {filter, map} from 'rxjs/operators';
import {takeUntilDestroyed} from '@angular/core/rxjs-interop';
import {Chips} from 'primeng/chips';
import {AutoComplete} from 'primeng/autocomplete';
@Component({
selector: 'app-metadata-picker',
@@ -31,7 +31,7 @@ import {Chips} from 'primeng/chips';
Tooltip,
AsyncPipe,
Textarea,
Chips
AutoComplete
]
})
export class MetadataPickerComponent implements OnInit {
@@ -77,6 +77,24 @@ export class MetadataPickerComponent implements OnInit {
@Input() book$!: Observable<Book | null>;
@Output() goBack = new EventEmitter<boolean>();
// 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
if (!values.includes(inputValue)) {
values.push(inputValue);
this.metadataForm.get(fieldName)?.setValue(values);
}
// Clear the input
event.target.value = '';
}
}
metadataForm: FormGroup;
currentBookId!: number;
copiedFields: Record<string, boolean> = {};
@@ -50,7 +50,7 @@
<label for="clearAuthors" class="text-sm text-gray-300 cursor-pointer">Clear</label>
</div>
</label>
<p-chips formControlName="authors" [disabled]="clearFields.authors" addOnBlur="true"></p-chips>
<p-autoComplete formControlName="authors" [disabled]="clearFields.authors" [multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" (onBlur)="onAutoCompleteBlur('authors', $event)" styleClass="w-full"></p-autoComplete>
</div>
<!-- Publisher -->
@@ -139,7 +139,7 @@
<label for="clearGenres" class="text-sm text-gray-300 cursor-pointer">Clear</label>
</div>
</label>
<p-chips formControlName="genres" addOnBlur="true" [disabled]="clearFields.genres"></p-chips>
<p-autoComplete formControlName="genres" [disabled]="clearFields.genres" [multiple]="true" [typeahead]="false" [dropdown]="false" [forceSelection]="false" (onBlur)="onAutoCompleteBlur('genres', $event)" styleClass="w-full"></p-autoComplete>
<div class="flex items-center gap-2 mt-2">
<p-checkbox
@@ -4,13 +4,13 @@ import {CommonModule} from '@angular/common';
import {InputText} from 'primeng/inputtext';
import {Button} from 'primeng/button';
import {Tooltip} from 'primeng/tooltip';
import {Chips} from 'primeng/chips';
import {DatePicker} from 'primeng/datepicker';
import {DynamicDialogConfig, DynamicDialogRef} from 'primeng/dynamicdialog';
import {MessageService} from 'primeng/api';
import {BookService} from '../../book/service/book.service';
import {Book, BulkMetadataUpdateRequest} from '../../book/model/book.model';
import {Checkbox} from 'primeng/checkbox';
import {AutoComplete} from 'primeng/autocomplete';
import {ProgressSpinner} from 'primeng/progressspinner';
@Component({
@@ -23,10 +23,10 @@ import {ProgressSpinner} from 'primeng/progressspinner';
InputText,
Button,
Tooltip,
Chips,
DatePicker,
Checkbox,
ProgressSpinner
ProgressSpinner,
AutoComplete
],
providers: [MessageService],
templateUrl: './bulk-metadata-update-component.html',
@@ -83,6 +83,24 @@ 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()) : [];
// 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);
}
// Clear the input
event.target.value = '';
}
}
onSubmit(): void {
if (!this.metadataForm.valid) return;