add response error code enum, belongsToTenant field, fix description template new version issue

This commit is contained in:
amentis 2024-04-04 12:56:23 +03:00
parent 3fe87a024a
commit e7f140cb51
4 changed files with 25 additions and 2 deletions

View File

@ -0,0 +1,17 @@
export enum ResponseErrorCode {
HashConflict = 100,
Forbidden = 101,
SystemError =102,
MissingTenant = 103,
TenantCodeRequired = 108,
TenantNameRequired = 109,
TenantNotAllowed = 113,
DescriptionTemplateNewVersionConflict = 114,
DmpNewVersionConflict = 115,
DmpIsFinalized = 116,
DmpBlueprintHasNoDescriptionTemplates = 120,
DmpBlueprintNewVersionConflict = 121,
DmpDescriptionTemplateCanNotRemove = 122,
TenantTampering = 123
}

View File

@ -188,6 +188,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
const action = this.route.snapshot.data['action'];
if (action && action == 'new-version') {
this.formGroup.enable();
this.formGroup.get('status').setValue(DescriptionTemplateStatus.Draft);
}
}
@ -283,7 +284,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
this.formGroup.get('status').setValue(DescriptionTemplateStatus.Finalized);
if(this.isNewVersion) this.isNewVersion = false;
this.persistEntity();
}});
}

View File

@ -24,6 +24,7 @@ import { isNullOrUndefined } from '@swimlane/ngx-datatable';
import { PopupNotificationDialogComponent } from '@app/library/notification/popup/popup-notification.component';
import { AuthService } from '@app/core/services/auth/auth.service';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
import { ResponseErrorCode } from '@app/core/common/enum/respone-error-code';
@Component({
selector: 'app-base-editor-component',
@ -120,9 +121,13 @@ export abstract class BaseEditor<EditorModelType extends BaseEditorModel, Entity
const error: HttpError = this.httpErrorHandlingService.getError(errorResponse);
if (error.statusCode === 400) {
this.editorModel.validationErrorModel.fromJSONObject(errorResponse.error);
if(errorResponse.error.code === 120){
if(errorResponse.error.code === ResponseErrorCode.DmpBlueprintHasNoDescriptionTemplates){
this.uiNotificationService.snackBarNotification(errorResponse.error.error, SnackBarNotificationLevel.Error);
}
if(errorResponse.error.code === ResponseErrorCode.DmpDescriptionTemplateCanNotRemove){
this.uiNotificationService.snackBarNotification(errorResponse.error.error, SnackBarNotificationLevel.Error);
this.refreshOnNavigateToData(null);
}
this.formService.validateAllFormFields(this.formGroup);
} else {
this.uiNotificationService.snackBarNotification(error.getMessagesString(), SnackBarNotificationLevel.Warning);

View File

@ -7,6 +7,7 @@ export interface BaseEntity {
createdAt?: Date;
updatedAt?: Date;
hash?: string;
belongsToCurrentTenant?: boolean;
}
export interface BaseEntityPersist {