TSK-1678: Show error when saving empty WorkbasketAccessItem
This commit is contained in:
parent
98f2a2f024
commit
523b610813
|
@ -12,7 +12,7 @@
|
|||
<mat-form-field appearance="legacy">
|
||||
<mat-select [value]="selectedDomain" matTooltip="Select domain">
|
||||
<mat-option *ngFor="let domain of domains" [value]="domain" (click)="switchDomain(domain)">
|
||||
{{domain? domain: 'MASTER DOMAIN'}}
|
||||
{{domain? domain : 'MASTER DOMAIN'}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
|
|
@ -90,7 +90,7 @@ const formsValidatorServiceSpy: Partial<FormsValidatorService> = {
|
|||
};
|
||||
|
||||
const notificationServiceSpy: Partial<NotificationService> = {
|
||||
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 () => {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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'
|
||||
});
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
`
|
||||
|
|
|
@ -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'
|
||||
},
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
export enum messageTypes {
|
||||
ERROR,
|
||||
SUCCESS,
|
||||
WARNING,
|
||||
INFORMATION,
|
||||
DIALOG
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue