From 523b610813ea3ff8ff304a7c263c148853082a30 Mon Sep 17 00:00:00 2001
From: Sofie Hofmann <29145005+sofie29@users.noreply.github.com>
Date: Thu, 29 Jul 2021 10:17:00 +0200
Subject: [PATCH] TSK-1678: Show error when saving empty WorkbasketAccessItem
---
.../administration-overview.component.html | 2 +-
.../classification-details.component.spec.ts | 6 +++---
.../classification-details.component.ts | 2 +-
.../services/forms-validator/forms-validator.service.ts | 6 +++---
.../services/notifications/notification.service.ts | 4 ----
.../services/obtain-message/message-by-error-code.ts | 9 +++------
.../app/shared/services/obtain-message/message-types.ts | 1 -
7 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/web/src/app/administration/components/administration-overview/administration-overview.component.html b/web/src/app/administration/components/administration-overview/administration-overview.component.html
index adbc63c1b..ec7378d81 100644
--- a/web/src/app/administration/components/administration-overview/administration-overview.component.html
+++ b/web/src/app/administration/components/administration-overview/administration-overview.component.html
@@ -12,7 +12,7 @@
- {{domain? domain: 'MASTER DOMAIN'}}
+ {{domain? domain : 'MASTER DOMAIN'}}
diff --git a/web/src/app/administration/components/classification-details/classification-details.component.spec.ts b/web/src/app/administration/components/classification-details/classification-details.component.spec.ts
index a642ba5b2..9dc2abc88 100644
--- a/web/src/app/administration/components/classification-details/classification-details.component.spec.ts
+++ b/web/src/app/administration/components/classification-details/classification-details.component.spec.ts
@@ -90,7 +90,7 @@ const formsValidatorServiceSpy: Partial = {
};
const notificationServiceSpy: Partial = {
- showWarning: jest.fn().mockReturnValue(of()),
+ showError: jest.fn().mockReturnValue(of()),
showSuccess: jest.fn().mockReturnValue(of()),
showDialog: jest.fn().mockReturnValue(of())
};
@@ -157,9 +157,9 @@ describe('ClassificationDetailsComponent', () => {
it('should show warning when onCopy() is called and isCreatingNewClassification is true', () => {
component.isCreatingNewClassification = true;
const notificationService = TestBed.inject(NotificationService);
- const showWarningSpy = jest.spyOn(notificationService, 'showWarning');
+ const showErrorSpy = jest.spyOn(notificationService, 'showError');
component.onCopy();
- expect(showWarningSpy).toHaveBeenCalled();
+ expect(showErrorSpy).toHaveBeenCalled();
});
it('should dispatch action when onCopy() is called and isCreatingNewClassification is false', async () => {
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 fd2a99910..83e60a898 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
@@ -126,7 +126,7 @@ export class ClassificationDetailsComponent implements OnInit, OnDestroy {
onCopy() {
if (this.isCreatingNewClassification) {
- this.notificationsService.showWarning('CLASSIFICATION_COPY_NOT_CREATED');
+ this.notificationsService.showError('CLASSIFICATION_COPY_NOT_CREATED');
} else {
this.store.dispatch(new CopyClassification());
}
diff --git a/web/src/app/shared/services/forms-validator/forms-validator.service.ts b/web/src/app/shared/services/forms-validator/forms-validator.service.ts
index 66bcd8e7e..4bf3e3767 100644
--- a/web/src/app/shared/services/forms-validator/forms-validator.service.ts
+++ b/web/src/app/shared/services/forms-validator/forms-validator.service.ts
@@ -53,9 +53,9 @@ export class FormsValidatorService {
const responseOwner = new ResponseOwner(values[1]);
if (!(values[0] && responseOwner.valid)) {
if (!responseOwner.valid) {
- this.notificationsService.showWarning('OWNER_NOT_VALID', { owner: responseOwner.field });
+ this.notificationsService.showError('OWNER_NOT_VALID', { owner: responseOwner.field });
} else {
- this.notificationsService.showWarning('EMPTY_FIELDS');
+ this.notificationsService.showError('EMPTY_FIELDS');
}
}
return values[0] && responseOwner.valid;
@@ -84,7 +84,7 @@ export class FormsValidatorService {
result = result && responseOwner.valid;
});
if (!result) {
- this.notificationsService.showWarning('OWNER_NOT_VALID', {
+ this.notificationsService.showError('OWNER_NOT_VALID', {
owner: responseOwner ? responseOwner.field : 'owner'
});
}
diff --git a/web/src/app/shared/services/notifications/notification.service.ts b/web/src/app/shared/services/notifications/notification.service.ts
index 1940d4512..837ad90d2 100644
--- a/web/src/app/shared/services/notifications/notification.service.ts
+++ b/web/src/app/shared/services/notifications/notification.service.ts
@@ -40,10 +40,6 @@ export class NotificationService {
);
}
- showWarning(warningKey: string, messageVariables: object = {}) {
- this.toastService.warning(this.obtainMessageService.getMessage(warningKey, messageVariables, messageTypes.WARNING));
- }
-
showInformation(informationKey: string, messageVariables: object = {}) {
this.toastService.show(
`
diff --git a/web/src/app/shared/services/obtain-message/message-by-error-code.ts b/web/src/app/shared/services/obtain-message/message-by-error-code.ts
index b114d58eb..028403a25 100644
--- a/web/src/app/shared/services/obtain-message/message-by-error-code.ts
+++ b/web/src/app/shared/services/obtain-message/message-by-error-code.ts
@@ -19,12 +19,15 @@ export const messageByErrorCode = {
'The service level has to be a positive ISO-8601 duration format and only whole days are supported. ' +
"The format must be 'PnD'.",
INVALID_ARGUMENT: 'A method was called with an invalid argument.',
+ EMPTY_FIELDS: 'There are empty fields which are required',
+ OWNER_NOT_VALID: 'The {owner} introduced is not valid',
CLASSIFICATION_IN_USE:
'Classification with key {classificationKey} in domain {domain} cannot be deleted since there are Tasks associated with this Classification.',
CLASSIFICATION_ALREADY_EXISTS:
'Classification with key {classificationKey} cannot be saved since a Classification with the same key already exists in domain {domain}',
CLASSIFICATION_WITH_ID_NOT_FOUND: 'Classification with id {classificationId} cannot be found',
+ CLASSIFICATION_COPY_NOT_CREATED: 'Cannot copy a not created Classification',
WORKBASKET_WITH_ID_NOT_FOUND: 'Workbasket with id {workbasketId} cannot be found',
WORKBASKET_WITH_KEY_NOT_FOUND: 'Workbasket with key {workbasketKey} cannot be found in domain {domain}',
@@ -85,12 +88,6 @@ export const messageByErrorCode = {
TASK_RESTORE: 'Task restored'
},
- [messageTypes.WARNING]: {
- CLASSIFICATION_COPY_NOT_CREATED: 'Cannot copy a not created Classification',
- EMPTY_FIELDS: 'There are empty fields which are required',
- OWNER_NOT_VALID: 'The {owner} introduced is not valid'
- },
-
[messageTypes.INFORMATION]: {
EMPTY_WORKBASKET: 'Selected Workbasket is empty'
},
diff --git a/web/src/app/shared/services/obtain-message/message-types.ts b/web/src/app/shared/services/obtain-message/message-types.ts
index f52e51b31..562c25420 100644
--- a/web/src/app/shared/services/obtain-message/message-types.ts
+++ b/web/src/app/shared/services/obtain-message/message-types.ts
@@ -1,7 +1,6 @@
export enum messageTypes {
ERROR,
SUCCESS,
- WARNING,
INFORMATION,
DIALOG
}