From 061a0c9a08d82a67944326a0d82b044199386046 Mon Sep 17 00:00:00 2001 From: Amar Bolkan Date: Tue, 3 May 2022 10:52:16 +0200 Subject: [PATCH] Issue #100: Set small and medium sized image to null before saving --- .../impl/custom/ExtendedImageServiceImpl.java | 2 +- .../teams/teams-edit/teams-edit.component.ts | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/iteratec/teamdojo/service/impl/custom/ExtendedImageServiceImpl.java b/src/main/java/com/iteratec/teamdojo/service/impl/custom/ExtendedImageServiceImpl.java index 10320a78..bae4298a 100644 --- a/src/main/java/com/iteratec/teamdojo/service/impl/custom/ExtendedImageServiceImpl.java +++ b/src/main/java/com/iteratec/teamdojo/service/impl/custom/ExtendedImageServiceImpl.java @@ -61,7 +61,7 @@ public ImageDTO save(final ImageDTO image) { image.setSmallContentType(null); image.setHash(null); } - + // TODO: See Issue #100 if (shouldResizeImage(image)) { // FIXME: Validate the input (https://github.com/iteratec/TeamDojo/issues/11) final var large = image.getLarge(); diff --git a/src/main/webapp/app/custom/teams/teams-edit/teams-edit.component.ts b/src/main/webapp/app/custom/teams/teams-edit/teams-edit.component.ts index 8b53cf32..d4164c19 100644 --- a/src/main/webapp/app/custom/teams/teams-edit/teams-edit.component.ts +++ b/src/main/webapp/app/custom/teams/teams-edit/teams-edit.component.ts @@ -126,9 +126,7 @@ export class TeamsEditComponent implements OnInit { } }, error: (err: FileLoadError) => - this.eventManager.broadcast( - new EventWithContent('teamDojoApp.error', { ...err, key: 'error.file.' + err.key }) - ), + this.eventManager.broadcast(new EventWithContent('teamDojoApp.error', { ...err, key: 'error.file.' + err.key })), }); } @@ -183,8 +181,23 @@ export class TeamsEditComponent implements OnInit { ); } + /** + * small and medium size image needs to be set to null, otherwise the backend will not + * set them automatically. + * @param image + * @private + */ + private clearMediumAndSmallSizeImage(image: IImage): void { + image.small = null; + image.smallContentType = null; + image.medium = null; + image.mediumContentType = null; + } + private setImageFromEditForm(image: IImage): void { image.large = this.editForm.value.large; image.largeContentType = this.editForm.value.largeContentType; + // TODO: Issue #100 this might not be needed + this.clearMediumAndSmallSizeImage(image); } }