From 75105e06f7147f66543a51a881f2309d15f1035f Mon Sep 17 00:00:00 2001 From: Tristan2357 <19949441+Tristan2357@users.noreply.github.com> Date: Wed, 16 Mar 2022 14:19:10 +0100 Subject: [PATCH] TSK-1796: Whitespace trimming for Front- and Backend (#1829) * TSK-1796: Trim whitespaces in frontend * TSK-1796: Trim whitespaces in backend --- .../internal/models/ClassificationImpl.java | 212 +++++++++--------- .../models/ClassificationSummaryImpl.java | 35 +-- .../internal/models/ObjectReferenceImpl.java | 8 +- .../task/internal/models/TaskSummaryImpl.java | 44 ++-- .../internal/models/WorkbasketImpl.java | 2 +- .../models/WorkbasketSummaryImpl.java | 82 +++---- .../classification-details.component.ts | 18 +- .../workbasket-information.component.ts | 2 + web/src/app/shared/util/form-trimmer.ts | 21 ++ .../task-details/task-details.component.ts | 27 ++- 10 files changed, 240 insertions(+), 211 deletions(-) create mode 100644 web/src/app/shared/util/form-trimmer.ts diff --git a/lib/taskana-core/src/main/java/pro/taskana/classification/internal/models/ClassificationImpl.java b/lib/taskana-core/src/main/java/pro/taskana/classification/internal/models/ClassificationImpl.java index bc6a201c5..69a159831 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/classification/internal/models/ClassificationImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/classification/internal/models/ClassificationImpl.java @@ -38,112 +38,6 @@ public class ClassificationImpl extends ClassificationSummaryImpl implements Cla this.applicationEntryPoint = applicationEntryPoint; } - @Override - public ClassificationImpl copy(String key) { - return new ClassificationImpl(this, key); - } - - @Override - public Boolean getIsValidInDomain() { - return isValidInDomain; - } - - @Override - public void setIsValidInDomain(Boolean isValidInDomain) { - this.isValidInDomain = isValidInDomain; - } - - @Override - public Instant getCreated() { - return created != null ? created.truncatedTo(ChronoUnit.MILLIS) : null; - } - - public void setCreated(Instant created) { - this.created = created != null ? created.truncatedTo(ChronoUnit.MILLIS) : null; - } - - @Override - public Instant getModified() { - return modified != null ? modified.truncatedTo(ChronoUnit.MILLIS) : null; - } - - public void setModified(Instant modified) { - this.modified = modified != null ? modified.truncatedTo(ChronoUnit.MILLIS) : null; - } - - @Override - public String getDescription() { - return description; - } - - @Override - public void setDescription(String description) { - this.description = description; - } - - @Deprecated - @Override - public void setCustomAttribute(ClassificationCustomField customField, String value) { - setCustomField(customField, value); - } - - @Override - public void setCustomField(ClassificationCustomField customField, String value) { - switch (customField) { - case CUSTOM_1: - custom1 = value; - break; - case CUSTOM_2: - custom2 = value; - break; - case CUSTOM_3: - custom3 = value; - break; - case CUSTOM_4: - custom4 = value; - break; - case CUSTOM_5: - custom5 = value; - break; - case CUSTOM_6: - custom6 = value; - break; - case CUSTOM_7: - custom7 = value; - break; - case CUSTOM_8: - custom8 = value; - break; - default: - throw new SystemException("Unknown customField '" + customField + "'"); - } - } - - @Override - public ClassificationSummary asSummary() { - ClassificationSummaryImpl summary = new ClassificationSummaryImpl(); - summary.setCategory(this.category); - summary.setDomain(this.domain); - summary.setId(this.id); - summary.setKey(this.key); - summary.setName(this.name); - summary.setType(this.type); - summary.setParentId(this.parentId); - summary.setParentKey(this.parentKey); - summary.setPriority(this.priority); - summary.setServiceLevel(this.serviceLevel); - summary.setApplicationEntryPoint(this.applicationEntryPoint); - summary.setCustom1(custom1); - summary.setCustom2(custom2); - summary.setCustom3(custom3); - summary.setCustom4(custom4); - summary.setCustom5(custom5); - summary.setCustom6(custom6); - summary.setCustom7(custom7); - summary.setCustom8(custom8); - return summary; - } - @Override protected boolean canEqual(Object other) { return (other instanceof ClassificationImpl); @@ -222,4 +116,110 @@ public class ClassificationImpl extends ClassificationSummaryImpl implements Cla + custom8 + "]"; } + + @Override + public ClassificationImpl copy(String key) { + return new ClassificationImpl(this, key); + } + + @Override + public Boolean getIsValidInDomain() { + return isValidInDomain; + } + + @Override + public void setIsValidInDomain(Boolean isValidInDomain) { + this.isValidInDomain = isValidInDomain; + } + + @Override + public Instant getCreated() { + return created != null ? created.truncatedTo(ChronoUnit.MILLIS) : null; + } + + public void setCreated(Instant created) { + this.created = created != null ? created.truncatedTo(ChronoUnit.MILLIS) : null; + } + + @Override + public Instant getModified() { + return modified != null ? modified.truncatedTo(ChronoUnit.MILLIS) : null; + } + + public void setModified(Instant modified) { + this.modified = modified != null ? modified.truncatedTo(ChronoUnit.MILLIS) : null; + } + + @Override + public String getDescription() { + return description; + } + + @Override + public void setDescription(String description) { + this.description = description == null ? null : description.trim(); + } + + @Deprecated + @Override + public void setCustomAttribute(ClassificationCustomField customField, String value) { + setCustomField(customField, value); + } + + @Override + public void setCustomField(ClassificationCustomField customField, String value) { + switch (customField) { + case CUSTOM_1: + custom1 = value; + break; + case CUSTOM_2: + custom2 = value; + break; + case CUSTOM_3: + custom3 = value; + break; + case CUSTOM_4: + custom4 = value; + break; + case CUSTOM_5: + custom5 = value; + break; + case CUSTOM_6: + custom6 = value; + break; + case CUSTOM_7: + custom7 = value; + break; + case CUSTOM_8: + custom8 = value; + break; + default: + throw new SystemException("Unknown customField '" + customField + "'"); + } + } + + @Override + public ClassificationSummary asSummary() { + ClassificationSummaryImpl summary = new ClassificationSummaryImpl(); + summary.setCategory(this.category); + summary.setDomain(this.domain); + summary.setId(this.id); + summary.setKey(this.key); + summary.setName(this.name); + summary.setType(this.type); + summary.setParentId(this.parentId); + summary.setParentKey(this.parentKey); + summary.setPriority(this.priority); + summary.setServiceLevel(this.serviceLevel); + summary.setApplicationEntryPoint(this.applicationEntryPoint); + summary.setCustom1(custom1); + summary.setCustom2(custom2); + summary.setCustom3(custom3); + summary.setCustom4(custom4); + summary.setCustom5(custom5); + summary.setCustom6(custom6); + summary.setCustom7(custom7); + summary.setCustom8(custom8); + return summary; + } } diff --git a/lib/taskana-core/src/main/java/pro/taskana/classification/internal/models/ClassificationSummaryImpl.java b/lib/taskana-core/src/main/java/pro/taskana/classification/internal/models/ClassificationSummaryImpl.java index 96665d04a..cdb9204b9 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/classification/internal/models/ClassificationSummaryImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/classification/internal/models/ClassificationSummaryImpl.java @@ -66,7 +66,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } public void setKey(String key) { - this.key = key; + this.key = key == null ? null : key.trim(); } @Override @@ -93,7 +93,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } public void setDomain(String domain) { - this.domain = domain; + this.domain = domain == null ? null : domain.trim(); } @Override @@ -102,7 +102,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } public void setName(String name) { - this.name = name; + this.name = name == null ? null : name.trim(); } @Override @@ -138,7 +138,8 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } public void setApplicationEntryPoint(String applicationEntryPoint) { - this.applicationEntryPoint = applicationEntryPoint; + this.applicationEntryPoint = + applicationEntryPoint == null ? null : applicationEntryPoint.trim(); } @Override @@ -180,12 +181,17 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } } + @Override + public ClassificationSummaryImpl copy() { + return new ClassificationSummaryImpl(this); + } + public String getCustom1() { return custom1; } public void setCustom1(String custom1) { - this.custom1 = custom1; + this.custom1 = custom1 == null ? null : custom1.trim(); } public String getCustom2() { @@ -193,7 +199,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } public void setCustom2(String custom2) { - this.custom2 = custom2; + this.custom2 = custom2 == null ? null : custom2.trim(); } public String getCustom3() { @@ -201,7 +207,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } public void setCustom3(String custom3) { - this.custom3 = custom3; + this.custom3 = custom3 == null ? null : custom3.trim(); } public String getCustom4() { @@ -209,7 +215,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } public void setCustom4(String custom4) { - this.custom4 = custom4; + this.custom4 = custom4 == null ? null : custom4.trim(); } public String getCustom5() { @@ -217,7 +223,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } public void setCustom5(String custom5) { - this.custom5 = custom5; + this.custom5 = custom5 == null ? null : custom5.trim(); } public String getCustom6() { @@ -225,7 +231,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } public void setCustom6(String custom6) { - this.custom6 = custom6; + this.custom6 = custom6 == null ? null : custom6.trim(); } public String getCustom7() { @@ -233,7 +239,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } public void setCustom7(String custom7) { - this.custom7 = custom7; + this.custom7 = custom7 == null ? null : custom7.trim(); } public String getCustom8() { @@ -241,12 +247,7 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } public void setCustom8(String custom8) { - this.custom8 = custom8; - } - - @Override - public ClassificationSummaryImpl copy() { - return new ClassificationSummaryImpl(this); + this.custom8 = custom8 == null ? null : custom8.trim(); } protected boolean canEqual(Object other) { diff --git a/lib/taskana-core/src/main/java/pro/taskana/task/internal/models/ObjectReferenceImpl.java b/lib/taskana-core/src/main/java/pro/taskana/task/internal/models/ObjectReferenceImpl.java index de735d30e..fc8c9a505 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/task/internal/models/ObjectReferenceImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/task/internal/models/ObjectReferenceImpl.java @@ -58,7 +58,7 @@ public class ObjectReferenceImpl implements ObjectReference { } public void setCompany(String company) { - this.company = company; + this.company = company == null ? null : company.trim(); } @Override @@ -67,7 +67,7 @@ public class ObjectReferenceImpl implements ObjectReference { } public void setSystem(String system) { - this.system = system; + this.system = system == null ? null : system.trim(); } @Override @@ -85,7 +85,7 @@ public class ObjectReferenceImpl implements ObjectReference { } public void setType(String type) { - this.type = type; + this.type = type == null ? null : type.trim(); } @Override @@ -94,7 +94,7 @@ public class ObjectReferenceImpl implements ObjectReference { } public void setValue(String value) { - this.value = value; + this.value = value == null ? null : value.trim(); } @Override diff --git a/lib/taskana-core/src/main/java/pro/taskana/task/internal/models/TaskSummaryImpl.java b/lib/taskana-core/src/main/java/pro/taskana/task/internal/models/TaskSummaryImpl.java index 57a80a43c..36b114375 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/task/internal/models/TaskSummaryImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/task/internal/models/TaskSummaryImpl.java @@ -208,7 +208,7 @@ public class TaskSummaryImpl implements TaskSummary { } public void setName(String name) { - this.name = name; + this.name = name == null ? null : name.trim(); } @Override @@ -217,7 +217,7 @@ public class TaskSummaryImpl implements TaskSummary { } public void setNote(String note) { - this.note = note; + this.note = note == null ? null : note.trim(); } @Override @@ -226,7 +226,7 @@ public class TaskSummaryImpl implements TaskSummary { } public void setDescription(String description) { - this.description = description; + this.description = description == null ? null : description.trim(); } @Override @@ -328,7 +328,7 @@ public class TaskSummaryImpl implements TaskSummary { } public void setOwnerLongName(String ownerLongName) { - this.ownerLongName = ownerLongName; + this.ownerLongName = ownerLongName == null ? null : ownerLongName.trim(); } @Override @@ -415,12 +415,12 @@ public class TaskSummaryImpl implements TaskSummary { return new TaskSummaryImpl(this); } - // utility method to allow mybatis access to workbasketSummary + // auxiliary method to allow mybatis access to workbasketSummary public WorkbasketSummaryImpl getWorkbasketSummaryImpl() { return (WorkbasketSummaryImpl) workbasketSummary; } - // utility method to allow mybatis access to workbasketSummary + // auxiliary method to allow mybatis access to workbasketSummary public void setWorkbasketSummaryImpl(WorkbasketSummaryImpl workbasketSummary) { setWorkbasketSummary(workbasketSummary); } @@ -502,7 +502,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom1(String custom1) { - this.custom1 = custom1; + this.custom1 = custom1 == null ? null : custom1.trim(); } public String getCustom2() { @@ -511,7 +511,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom2(String custom2) { - this.custom2 = custom2; + this.custom2 = custom2 == null ? null : custom2.trim(); } public String getCustom3() { @@ -520,7 +520,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom3(String custom3) { - this.custom3 = custom3; + this.custom3 = custom3 == null ? null : custom3.trim(); } public String getCustom4() { @@ -529,7 +529,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom4(String custom4) { - this.custom4 = custom4; + this.custom4 = custom4 == null ? null : custom4.trim(); } public String getCustom5() { @@ -538,7 +538,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom5(String custom5) { - this.custom5 = custom5; + this.custom5 = custom5 == null ? null : custom5.trim(); } public String getCustom6() { @@ -547,7 +547,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom6(String custom6) { - this.custom6 = custom6; + this.custom6 = custom6 == null ? null : custom6.trim(); } public String getCustom7() { @@ -556,7 +556,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom7(String custom7) { - this.custom7 = custom7; + this.custom7 = custom7 == null ? null : custom7.trim(); } public String getCustom8() { @@ -565,7 +565,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom8(String custom8) { - this.custom8 = custom8; + this.custom8 = custom8 == null ? null : custom8.trim(); } public String getCustom9() { @@ -574,7 +574,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom9(String custom9) { - this.custom9 = custom9; + this.custom9 = custom9 == null ? null : custom9.trim(); } public String getCustom10() { @@ -583,7 +583,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom10(String custom10) { - this.custom10 = custom10; + this.custom10 = custom10 == null ? null : custom10.trim(); } public String getCustom11() { @@ -592,7 +592,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom11(String custom11) { - this.custom11 = custom11; + this.custom11 = custom11 == null ? null : custom11.trim(); } public String getCustom12() { @@ -601,7 +601,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom12(String custom12) { - this.custom12 = custom12; + this.custom12 = custom12 == null ? null : custom12.trim(); } public String getCustom13() { @@ -610,7 +610,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom13(String custom13) { - this.custom13 = custom13; + this.custom13 = custom13 == null ? null : custom13.trim(); } public String getCustom14() { @@ -619,7 +619,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom14(String custom14) { - this.custom14 = custom14; + this.custom14 = custom14 == null ? null : custom14.trim(); } public String getCustom15() { @@ -628,7 +628,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom15(String custom15) { - this.custom15 = custom15; + this.custom15 = custom15 == null ? null : custom15.trim(); } public String getCustom16() { @@ -637,7 +637,7 @@ public class TaskSummaryImpl implements TaskSummary { // auxiliary Method needed by Mybatis public void setCustom16(String custom16) { - this.custom16 = custom16; + this.custom16 = custom16 == null ? null : custom16.trim(); } protected boolean canEqual(Object other) { diff --git a/lib/taskana-core/src/main/java/pro/taskana/workbasket/internal/models/WorkbasketImpl.java b/lib/taskana-core/src/main/java/pro/taskana/workbasket/internal/models/WorkbasketImpl.java index dd56eef4e..a578b01ae 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/workbasket/internal/models/WorkbasketImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/workbasket/internal/models/WorkbasketImpl.java @@ -21,7 +21,7 @@ public class WorkbasketImpl extends WorkbasketSummaryImpl implements Workbasket super(copyFrom); created = copyFrom.created; modified = copyFrom.modified; - this.key = key; + this.key = key == null ? null : key.trim(); } @Deprecated diff --git a/lib/taskana-core/src/main/java/pro/taskana/workbasket/internal/models/WorkbasketSummaryImpl.java b/lib/taskana-core/src/main/java/pro/taskana/workbasket/internal/models/WorkbasketSummaryImpl.java index f4137abdd..aeaa73129 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/workbasket/internal/models/WorkbasketSummaryImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/workbasket/internal/models/WorkbasketSummaryImpl.java @@ -61,7 +61,7 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary { } public void setKey(String key) { - this.key = key; + this.key = key == null ? null : key.trim(); } @Override @@ -70,7 +70,7 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary { } public void setName(String name) { - this.name = name; + this.name = name == null ? null : name.trim(); } @Override @@ -79,7 +79,7 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary { } public void setDescription(String description) { - this.description = description; + this.description = description == null ? null : description.trim(); } @Override @@ -88,7 +88,7 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary { } public void setOwner(String owner) { - this.owner = owner; + this.owner = owner == null ? null : owner.trim(); } @Override @@ -97,7 +97,7 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary { } public void setDomain(String domain) { - this.domain = domain; + this.domain = domain == null ? null : domain.trim(); } @Override @@ -131,45 +131,13 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary { } } - public String getCustom1() { - return custom1; - } - - public void setCustom1(String custom1) { - this.custom1 = custom1; - } - - public String getCustom2() { - return custom2; - } - - public void setCustom2(String custom2) { - this.custom2 = custom2; - } - - public String getCustom3() { - return custom3; - } - - public void setCustom3(String custom3) { - this.custom3 = custom3; - } - - public String getCustom4() { - return custom4; - } - - public void setCustom4(String custom4) { - this.custom4 = custom4; - } - @Override public String getOrgLevel1() { return orgLevel1; } public void setOrgLevel1(String orgLevel1) { - this.orgLevel1 = orgLevel1; + this.orgLevel1 = orgLevel1 == null ? null : orgLevel1.trim(); } @Override @@ -178,7 +146,7 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary { } public void setOrgLevel2(String orgLevel2) { - this.orgLevel2 = orgLevel2; + this.orgLevel2 = orgLevel2 == null ? null : orgLevel2.trim(); } @Override @@ -187,7 +155,7 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary { } public void setOrgLevel3(String orgLevel3) { - this.orgLevel3 = orgLevel3; + this.orgLevel3 = orgLevel3 == null ? null : orgLevel3.trim(); } @Override @@ -196,7 +164,7 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary { } public void setOrgLevel4(String orgLevel4) { - this.orgLevel4 = orgLevel4; + this.orgLevel4 = orgLevel4 == null ? null : orgLevel4.trim(); } @Override @@ -213,6 +181,38 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary { return new WorkbasketSummaryImpl(this); } + public String getCustom1() { + return custom1; + } + + public void setCustom1(String custom1) { + this.custom1 = custom1 == null ? null : custom1.trim(); + } + + public String getCustom2() { + return custom2; + } + + public void setCustom2(String custom2) { + this.custom2 = custom2 == null ? null : custom2.trim(); + } + + public String getCustom3() { + return custom3; + } + + public void setCustom3(String custom3) { + this.custom3 = custom3 == null ? null : custom3.trim(); + } + + public String getCustom4() { + return custom4; + } + + public void setCustom4(String custom4) { + this.custom4 = custom4 == null ? null : custom4.trim(); + } + protected boolean canEqual(Object other) { return (other instanceof WorkbasketSummaryImpl); } diff --git a/web/src/app/administration/components/classification-details/classification-details.component.ts b/web/src/app/administration/components/classification-details/classification-details.component.ts index 4ff3d93bf..06206be20 100644 --- a/web/src/app/administration/components/classification-details/classification-details.component.ts +++ b/web/src/app/administration/components/classification-details/classification-details.component.ts @@ -20,15 +20,16 @@ import { Classification } from '../../../shared/models/classification'; import { customFieldCount } from '../../../shared/models/classification-summary'; import { - SaveCreatedClassification, + CopyClassification, + DeselectClassification, RemoveSelectedClassification, RestoreSelectedClassification, + SaveCreatedClassification, SaveModifiedClassification, - SelectClassification, - CopyClassification, - DeselectClassification + SelectClassification } from '../../../shared/store/classification-store/classification.actions'; import { Pair } from '../../../shared/models/pair'; +import { trimForm } from '../../../shared/util/form-trimmer'; @Component({ selector: 'taskana-administration-classification-details', @@ -104,6 +105,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy { onSubmit() { this.formsValidatorService.formSubmitAttempt = true; + trimForm(this.classificationForm); this.formsValidatorService .validateFormInformation(this.classificationForm, this.toggleValidationMap) .then((value) => { @@ -215,12 +217,12 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy { this.location.go(this.location.path().replace(/(classifications).*/g, 'classifications')); } - private afterRequest() { - this.requestInProgressService.setRequestInProgress(false); - } - ngOnDestroy(): void { this.destroy$.next(); this.destroy$.complete(); } + + private afterRequest() { + this.requestInProgressService.setRequestInProgress(false); + } } diff --git a/web/src/app/administration/components/workbasket-information/workbasket-information.component.ts b/web/src/app/administration/components/workbasket-information/workbasket-information.component.ts index a5795fac4..fe77a6812 100644 --- a/web/src/app/administration/components/workbasket-information/workbasket-information.component.ts +++ b/web/src/app/administration/components/workbasket-information/workbasket-information.component.ts @@ -23,6 +23,7 @@ import { WorkbasketSelectors } from '../../../shared/store/workbasket-store/work import { ButtonAction } from '../../models/button-action'; import { AccessId } from '../../../shared/models/access-id'; import { cloneDeep } from 'lodash'; +import { trimForm } from '../../../shared/util/form-trimmer'; @Component({ selector: 'taskana-administration-workbasket-information', @@ -123,6 +124,7 @@ export class WorkbasketInformationComponent implements OnInit, OnChanges, OnDest onSubmit() { this.formsValidatorService.formSubmitAttempt = true; + trimForm(this.workbasketForm); this.formsValidatorService.validateFormInformation(this.workbasketForm, this.toggleValidationMap).then((value) => { if (value && this.isOwnerValid) { this.onSave(); diff --git a/web/src/app/shared/util/form-trimmer.ts b/web/src/app/shared/util/form-trimmer.ts new file mode 100644 index 000000000..c28e73fa3 --- /dev/null +++ b/web/src/app/shared/util/form-trimmer.ts @@ -0,0 +1,21 @@ +import { NgForm } from '@angular/forms'; + +export function trimForm(form: NgForm) { + Object.keys(form.form.controls).forEach((controlName) => { + let control = form.form.controls[controlName]; + if (typeof control.value === 'string') { + control.setValue(control.value.trim()); + } + }); +} + +export function trimObject(object: Object) { + Object.keys(object).forEach((controlName) => { + let prop = object[controlName]; + if (typeof prop === 'string') { + object[controlName] = prop.trim(); + } else if (typeof prop === 'object' && prop !== null) { + trimObject(prop); + } + }); +} diff --git a/web/src/app/workplace/components/task-details/task-details.component.ts b/web/src/app/workplace/components/task-details/task-details.component.ts index 8d5384b90..5ccb26f6c 100644 --- a/web/src/app/workplace/components/task-details/task-details.component.ts +++ b/web/src/app/workplace/components/task-details/task-details.component.ts @@ -11,6 +11,7 @@ import { WorkplaceService } from 'app/workplace/services/workplace.service'; import { MasterAndDetailService } from 'app/shared/services/master-and-detail/master-and-detail.service'; import { NotificationService } from '../../../shared/services/notifications/notification.service'; import { take, takeUntil } from 'rxjs/operators'; +import { trimObject } from '../../../shared/util/form-trimmer'; import { ObjectReference } from '../../models/object-reference'; @Component({ @@ -83,17 +84,17 @@ export class TaskDetailsComponent implements OnInit, OnDestroy { this.requestInProgressService.setRequestInProgress(false); this.task = new Task('', new ObjectReference(), this.currentWorkbasket); } else { - this.taskService.getTask(this.currentId).subscribe( - (task) => { + this.taskService.getTask(this.currentId).subscribe({ + next: (task) => { this.requestInProgressService.setRequestInProgress(false); this.task = task; this.cloneTask(); this.taskService.selectTask(task); }, - () => { + error: () => { this.requestInProgressService.setRequestInProgress(false); } - ); + }); } } @@ -162,25 +163,27 @@ export class TaskDetailsComponent implements OnInit, OnDestroy { private updateTask() { this.requestInProgressService.setRequestInProgress(true); - this.taskService.updateTask(this.task).subscribe( - (task) => { + trimObject(this.task); + this.taskService.updateTask(this.task).subscribe({ + next: (task) => { this.requestInProgressService.setRequestInProgress(false); this.task = task; this.cloneTask(); this.taskService.publishUpdatedTask(task); this.notificationService.showSuccess('TASK_UPDATE', { taskName: task.name }); }, - () => { + error: () => { this.requestInProgressService.setRequestInProgress(false); } - ); + }); } private createTask() { this.requestInProgressService.setRequestInProgress(true); this.addDateToTask(); - this.taskService.createTask(this.task).subscribe( - (task) => { + trimObject(this.task); + this.taskService.createTask(this.task).subscribe({ + next: (task) => { this.requestInProgressService.setRequestInProgress(false); this.notificationService.showSuccess('TASK_CREATE', { taskName: task.name }); this.task = task; @@ -191,10 +194,10 @@ export class TaskDetailsComponent implements OnInit, OnDestroy { queryParamsHandling: 'merge' }); }, - () => { + error: () => { this.requestInProgressService.setRequestInProgress(false); } - ); + }); } private addDateToTask() {