From 2c5678916e4695a9c06d12a233ec239f4b337f30 Mon Sep 17 00:00:00 2001 From: Roman Nastyuk Date: Fri, 12 Sep 2025 15:39:54 +0300 Subject: [PATCH 1/2] fix(add-to-collection): fixed bug with discarding changes in edit collection metadata step --- .../collection-metadata-step.component.ts | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/src/app/features/collections/components/add-to-collection/collection-metadata-step/collection-metadata-step.component.ts b/src/app/features/collections/components/add-to-collection/collection-metadata-step/collection-metadata-step.component.ts index 8086245b2..0c425e41e 100644 --- a/src/app/features/collections/components/add-to-collection/collection-metadata-step/collection-metadata-step.component.ts +++ b/src/app/features/collections/components/add-to-collection/collection-metadata-step/collection-metadata-step.component.ts @@ -48,6 +48,7 @@ export class CollectionMetadataStepComponent { collectionMetadataForm = signal(new FormGroup({})); collectionMetadataSaved = signal(false); + originalFormValues = signal>({}); actions = createDispatchMap({ getCollectionDetails: GetCollectionDetails, @@ -62,13 +63,23 @@ export class CollectionMetadataStepComponent { } handleDiscardChanges() { - this.collectionMetadataForm().reset(); + const form = this.collectionMetadataForm(); + const originalValues = this.originalFormValues(); + + if (this.hasFormChanges(form, originalValues)) { + this.restoreFormValues(form, originalValues); + } + this.collectionMetadataSaved.set(false); } handleSaveMetadata() { + const form = this.collectionMetadataForm(); + + this.updateOriginalValues(form); + this.collectionMetadataSaved.set(true); - this.metadataSaved.emit(this.collectionMetadataForm()); + this.metadataSaved.emit(form); this.stepChange.emit(AddToCollectionSteps.Complete); } @@ -82,6 +93,7 @@ export class CollectionMetadataStepComponent { const newForm = new FormGroup(formControls); this.collectionMetadataForm.set(newForm); + this.updateOriginalValues(newForm); } private setupEffects(): void { @@ -105,4 +117,26 @@ export class CollectionMetadataStepComponent { } }); } + + private hasFormChanges(form: FormGroup, originalValues: Record): boolean { + return Object.keys(originalValues).some((key) => { + const currentValue = form.get(key)?.value; + const originalValue = originalValues[key]; + return currentValue !== originalValue; + }); + } + + private restoreFormValues(form: FormGroup, originalValues: Record): void { + Object.keys(originalValues).forEach((key) => { + form.get(key)?.setValue(originalValues[key]); + }); + } + + private updateOriginalValues(form: FormGroup): void { + const currentValues: Record = {}; + Object.keys(form.controls).forEach((key) => { + currentValues[key] = form.get(key)?.value; + }); + this.originalFormValues.set(currentValues); + } } From 90a8a4de6229f6129c526d195a4ae77eebf3dd6e Mon Sep 17 00:00:00 2001 From: Roman Nastyuk Date: Fri, 12 Sep 2025 16:17:53 +0300 Subject: [PATCH 2/2] fix(contributors): fixed bug with first/last name separate line breakage --- .../metadata-contributors/metadata-contributors.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.html b/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.html index a65f57fb3..e211ab06b 100644 --- a/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.html +++ b/src/app/features/metadata/components/metadata-contributors/metadata-contributors.component.html @@ -12,7 +12,7 @@

{{ 'project.overview.metadata.contributors' | translate }}

@if (contributors()) { -
+
@for (contributor of contributors(); track contributor.id) {