From 0086cf78e9a3fc51157639f344fa3e8fa2b97ebb Mon Sep 17 00:00:00 2001 From: Sondissimo Date: Wed, 14 Jun 2023 10:37:01 +0200 Subject: [PATCH] DSC-1111 Synced with main --- .../collection-form.component.ts | 8 +-- .../community-form.component.ts | 6 ++- .../community-metadata.component.html | 2 +- .../comcol-form/comcol-form.component.html | 51 ++++++++++++------- .../comcol-form/comcol-form.component.ts | 31 ++++++++++- .../comcol-metadata.component.ts | 11 +++- src/assets/i18n/en.json5 | 2 + 7 files changed, 84 insertions(+), 27 deletions(-) diff --git a/src/app/collection-page/collection-form/collection-form.component.ts b/src/app/collection-page/collection-form/collection-form.component.ts index aae200b401..7f2fb81ec8 100644 --- a/src/app/collection-page/collection-form/collection-form.component.ts +++ b/src/app/collection-page/collection-form/collection-form.component.ts @@ -23,7 +23,7 @@ import { getFirstSucceededRemoteListPayload } from '../../core/shared/operators' import { collectionFormEntityTypeSelectionConfig, collectionFormModels, } from './collection-form.models'; import { NONE_ENTITY_TYPE } from '../../core/shared/item-relationships/item-type.resource-type'; import { hasNoValue, isNotNull } from 'src/app/shared/empty.util'; - +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; /** * Form used for creating and editing collections @@ -64,8 +64,10 @@ export class CollectionFormComponent extends ComColFormComponent imp protected requestService: RequestService, protected objectCache: ObjectCacheService, protected entityTypeService: EntityTypeDataService, - protected chd: ChangeDetectorRef) { - super(formService, translate, notificationsService, authService, requestService, objectCache); + protected chd: ChangeDetectorRef, + protected submissionDefinitionService: SubmissionDefinitionsConfigDataService, + protected modalService: NgbModal) { + super(formService, translate, notificationsService, authService, requestService, objectCache, modalService); } ngOnInit(): void { diff --git a/src/app/community-page/community-form/community-form.component.ts b/src/app/community-page/community-form/community-form.component.ts index fa4809738d..53f36c30cb 100644 --- a/src/app/community-page/community-form/community-form.component.ts +++ b/src/app/community-page/community-form/community-form.component.ts @@ -14,6 +14,7 @@ import { AuthService } from '../../core/auth/auth.service'; import { RequestService } from '../../core/data/request.service'; import { ObjectCacheService } from '../../core/cache/object-cache.service'; import { environment } from '../../../environments/environment'; +import {NgbModal} from '@ng-bootstrap/ng-bootstrap'; /** * Form used for creating and editing communities @@ -78,8 +79,9 @@ export class CommunityFormComponent extends ComColFormComponent imple protected authService: AuthService, protected dsoService: CommunityDataService, protected requestService: RequestService, - protected objectCache: ObjectCacheService) { - super(formService, translate, notificationsService, authService, requestService, objectCache); + protected objectCache: ObjectCacheService, + protected modalService: NgbModal) { + super(formService, translate, notificationsService, authService, requestService, objectCache, modalService); } ngOnChanges(changes: SimpleChanges) { 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..169f79df67 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 @@ + (finish)="returnToEdit()"> diff --git a/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.html b/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.html index 2dd1795637..c6386634ea 100644 --- a/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.html +++ b/src/app/shared/comcol/comcol-forms/comcol-form/comcol-form.component.html @@ -4,25 +4,28 @@ {{type.value + '.edit.logo.label' | translate}} -
+
- - -
@@ -41,12 +44,24 @@
- - + + + + + + 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 631a9f0b19..7767da6399 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 @@ -22,7 +22,7 @@ import { UploaderComponent } from '../../../upload/uploader/uploader.component'; import { Operation } from 'fast-json-patch'; import { NoContent } from '../../../../core/shared/NoContent.model'; import { getFirstCompletedRemoteData } from '../../../../core/shared/operators'; - +import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; /** * A form for creating and editing Communities or Collections */ @@ -118,12 +118,15 @@ export class ComColFormComponent implements On */ protected dsoService: ComColDataService; + public uploader = new FileUploader(this.uploadFilesOptions); + public constructor(protected formService: DynamicFormService, protected translate: TranslateService, protected notificationsService: NotificationsService, protected authService: AuthService, protected requestService: RequestService, - protected objectCache: ObjectCacheService) { + protected objectCache: ObjectCacheService, + protected modalService: NgbModal) { } ngOnInit(): void { @@ -265,6 +268,30 @@ export class ComColFormComponent implements On this.markLogoForDeletion = false; } + openModal(content: any) { + this.modalService.open(content); + } + + confirmLogoDelete(removeLogo: any) { + this.modalService.open(removeLogo).result.then( (result) => { + if (result === 'delete') { + this.deleteLogo(); + this.onSubmit(); + } else if (result === 'cancel') { + return; + } + }); + } + + handleLogoReplace(event: Event) { + const fileInput = event.target as HTMLInputElement; + if (fileInput.files && fileInput.files.length > 0) { + this.markLogoForDeletion = true; + this.onSubmit(); + this.uploader.uploadAll(); + } + } + /** * Refresh the object's cache to ensure the latest version */ diff --git a/src/app/shared/comcol/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.ts b/src/app/shared/comcol/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.ts index d59030251d..1547ad739e 100644 --- a/src/app/shared/comcol/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.ts +++ b/src/app/shared/comcol/comcol-forms/edit-comcol-page/comcol-metadata/comcol-metadata.component.ts @@ -88,6 +88,15 @@ export class ComcolMetadataComponent imp take(1) ).subscribe((dsoRD: RemoteData) => { this.router.navigate([this.frontendURL + dsoRD.payload.id]); - }); + }); + } + + returnToEdit() { + this.dsoRD$.pipe( + getFirstSucceededRemoteData(), + take(1) + ).subscribe((dsoRD: RemoteData) => { + this.router.navigate([this.frontendURL + dsoRD.payload.id + '/edit/metadata']); + }); } } diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index e20a724158..315fcb6672 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -978,6 +978,8 @@ "collection.edit.item-mapper.tabs.map": "Map new items", + "collection.edit.logo.replace.title": "Replace logo", + "collection.edit.logo.delete.title": "Delete logo", "collection.edit.logo.delete-undo.title": "Undo delete",