From e71b54c79d814f40753d0affe954a803eef00ef5 Mon Sep 17 00:00:00 2001 From: Mattia Vianelli Date: Tue, 20 Feb 2024 17:16:08 +0100 Subject: [PATCH] DSC-1111 Fixed issue on create comcol --- .../create-collection-page.component.html | 1 + .../collection-metadata.component.html | 1 + .../create-community-page.component.html | 3 +- .../community-metadata.component.html | 2 +- .../comcol-form/comcol-form.component.ts | 38 ++++++++++++++----- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/src/app/collection-page/create-collection-page/create-collection-page.component.html b/src/app/collection-page/create-collection-page/create-collection-page.component.html index f3f9785692..ddce9dbec4 100644 --- a/src/app/collection-page/create-collection-page/create-collection-page.component.html +++ b/src/app/collection-page/create-collection-page/create-collection-page.component.html @@ -5,6 +5,7 @@ diff --git a/src/app/collection-page/edit-collection-page/collection-metadata/collection-metadata.component.html b/src/app/collection-page/edit-collection-page/collection-metadata/collection-metadata.component.html index 1cf40159ec..845c82458a 100644 --- a/src/app/collection-page/edit-collection-page/collection-metadata/collection-metadata.component.html +++ b/src/app/collection-page/edit-collection-page/collection-metadata/collection-metadata.component.html @@ -17,6 +17,7 @@ diff --git a/src/app/community-page/create-community-page/create-community-page.component.html b/src/app/community-page/create-community-page/create-community-page.component.html index 57039040c2..d99069f6c8 100644 --- a/src/app/community-page/create-community-page/create-community-page.component.html +++ b/src/app/community-page/create-community-page/create-community-page.component.html @@ -2,12 +2,13 @@
- +

{{ 'community.create.sub-head' | translate:{ parent: dsoNameService.getName(parent) } }}

diff --git a/src/app/community-page/edit-community-page/community-metadata/community-metadata.component.html b/src/app/community-page/edit-community-page/community-metadata/community-metadata.component.html index 2ca5b768e4..bf75944242 100644 --- a/src/app/community-page/edit-community-page/community-metadata/community-metadata.component.html +++ b/src/app/community-page/edit-community-page/community-metadata/community-metadata.component.html @@ -1,5 +1,5 @@ - diff --git a/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.ts b/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.ts index 6481add5d0..13a886dc93 100644 --- a/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.ts +++ b/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.ts @@ -47,6 +47,11 @@ export class ComColFormComponent implements On */ @Input() dso: T; + /** + * Boolean that represents if the comcol is being created or already exists + */ + @Input() isCreation!: boolean; + /** * Type of DSpaceObject that the form represents */ @@ -77,7 +82,7 @@ export class ComColFormComponent implements On * @type {UploaderOptions} */ uploadFilesOptions: UploaderOptions = Object.assign(new UploaderOptions(), { - autoUpload: true + autoUpload: false }); /** @@ -86,6 +91,8 @@ export class ComColFormComponent implements On @Output() submitForm: EventEmitter<{ dso: T, operations: Operation[], + uploader?: FileUploader, + deleteLogo?: boolean, }> = new EventEmitter(); /** @@ -128,6 +135,8 @@ export class ComColFormComponent implements On } ngOnInit(): void { + this.uploadFilesOptions.autoUpload = !this.isCreation; + if (hasValue(this.formModel)) { this.formModel.forEach( (fieldModel: DynamicInputModel) => { @@ -201,12 +210,20 @@ export class ComColFormComponent implements On } }); - this.submitForm.emit({ - dso: updatedDSO, - operations: operations, - }); - - this.finish.emit(); + if (!this.isCreation) { + this.submitForm.emit({ + dso: updatedDSO, + operations: operations, + }); + this.finish.emit(); + } else { + this.submitForm.emit({ + dso: updatedDSO, + deleteLogo: false, + uploader: hasValue(this.uploaderComponent) ? this.uploaderComponent.uploader : undefined, + operations: operations, + }); + } } /** @@ -327,7 +344,7 @@ export class ComColFormComponent implements On /** * Fetches the latest data for the dso */ -private fetchUpdatedDso(): Observable { + private fetchUpdatedDso(): Observable { return this.dsoService.findById(this.dso.id, false, true, followLink('logo')).pipe( tap((rd: RemoteData) => { if (rd.hasSucceeded) { @@ -340,13 +357,16 @@ private fetchUpdatedDso(): Observable { -/** + /** * The request was successful, display a success notification */ public onCompleteItem() { if (hasValue(this.dso.id)) { this.refreshDsoCache(); } + if (this.isCreation) { + this.finish.emit(); + } this.notificationsService.success(null, this.translate.get(this.type.value + '.edit.logo.notifications.add.success')); }