disable dmp blueprint form after finalized new version
This commit is contained in:
parent
115892875e
commit
49d8df1894
|
@ -6,6 +6,7 @@ import { BaseEntity, BaseEntityPersist } from "@common/base/base-entity.model";
|
||||||
import { Guid } from "@common/types/guid";
|
import { Guid } from "@common/types/guid";
|
||||||
import { ReferenceType } from "../reference-type/reference-type";
|
import { ReferenceType } from "../reference-type/reference-type";
|
||||||
import { PrefillingSource } from "../prefilling-source/prefilling-source";
|
import { PrefillingSource } from "../prefilling-source/prefilling-source";
|
||||||
|
import { DmpBlueprintVersionStatus } from "@app/core/common/enum/dmp-blueprint-version-status";
|
||||||
|
|
||||||
|
|
||||||
export interface DmpBlueprint extends BaseEntity {
|
export interface DmpBlueprint extends BaseEntity {
|
||||||
|
@ -13,6 +14,7 @@ export interface DmpBlueprint extends BaseEntity {
|
||||||
definition: DmpBlueprintDefinition;
|
definition: DmpBlueprintDefinition;
|
||||||
status: DmpBlueprintStatus;
|
status: DmpBlueprintStatus;
|
||||||
version: number;
|
version: number;
|
||||||
|
versionStatus: DmpBlueprintVersionStatus;
|
||||||
groupId: Guid;
|
groupId: Guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ import { DescriptionTemplatePreviewDialogComponent } from '../../description-tem
|
||||||
import { DmpBlueprintEditorModel, FieldInSectionEditorModel } from './dmp-blueprint-editor.model';
|
import { DmpBlueprintEditorModel, FieldInSectionEditorModel } from './dmp-blueprint-editor.model';
|
||||||
import { DmpBlueprintEditorResolver } from './dmp-blueprint-editor.resolver';
|
import { DmpBlueprintEditorResolver } from './dmp-blueprint-editor.resolver';
|
||||||
import { DmpBlueprintEditorService } from './dmp-blueprint-editor.service';
|
import { DmpBlueprintEditorService } from './dmp-blueprint-editor.service';
|
||||||
|
import { DmpBlueprintVersionStatus } from '@app/core/common/enum/dmp-blueprint-version-status';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -61,6 +62,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
||||||
isDeleted = false;
|
isDeleted = false;
|
||||||
formGroup: UntypedFormGroup = null;
|
formGroup: UntypedFormGroup = null;
|
||||||
showInactiveDetails = false;
|
showInactiveDetails = false;
|
||||||
|
finalized: boolean = false;
|
||||||
|
|
||||||
hoveredSectionIndex:number = -1;
|
hoveredSectionIndex:number = -1;
|
||||||
hoveredDescriptionTemplateIndex:number = -1;
|
hoveredDescriptionTemplateIndex:number = -1;
|
||||||
|
@ -104,6 +106,10 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
||||||
return this.editorModel.status == DmpBlueprintStatus.Finalized;
|
return this.editorModel.status == DmpBlueprintStatus.Finalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected get isObsoleteVersion(): boolean {
|
||||||
|
return this.editorModel.versionStatus == DmpBlueprintVersionStatus.Previous;
|
||||||
|
}
|
||||||
|
|
||||||
private hasPermission(permission: AppPermission): boolean {
|
private hasPermission(permission: AppPermission): boolean {
|
||||||
return this.authService.hasPermission(permission) || this.editorModel?.permissions?.includes(permission);
|
return this.authService.hasPermission(permission) || this.editorModel?.permissions?.includes(permission);
|
||||||
}
|
}
|
||||||
|
@ -191,11 +197,11 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
||||||
buildForm() {
|
buildForm() {
|
||||||
this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.authService.hasPermission(AppPermission.EditDmpBlueprint));
|
this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !this.authService.hasPermission(AppPermission.EditDmpBlueprint));
|
||||||
this.dmpBlueprintEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
|
this.dmpBlueprintEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
|
||||||
if (this.isFinalized || this.isDeleted) {
|
if (this.isFinalized || this.isDeleted || this.isObsoleteVersion || this.finalized) {
|
||||||
this.formGroup.disable();
|
this.formGroup.disable();
|
||||||
}
|
}
|
||||||
const action = this.route.snapshot.data['action'];
|
const action = this.route.snapshot.data['action'];
|
||||||
if (action && action == 'new-version') {
|
if (action && action == 'new-version' && !(this.isObsoleteVersion || this.finalized)) {
|
||||||
this.formGroup.enable();
|
this.formGroup.enable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -557,6 +563,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
||||||
if (this.checkValidity() || !this.hasDescriptionTemplates()) {
|
if (this.checkValidity() || !this.hasDescriptionTemplates()) {
|
||||||
this.formGroup.get('status').setValue(DmpBlueprintStatus.Finalized);
|
this.formGroup.get('status').setValue(DmpBlueprintStatus.Finalized);
|
||||||
if(this.isNewVersion) this.isNewVersion = false;
|
if(this.isNewVersion) this.isNewVersion = false;
|
||||||
|
this.finalized = true;
|
||||||
this.formSubmit();
|
this.formSubmit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { DmpBlueprintFieldCategory } from "@app/core/common/enum/dmp-blueprint-f
|
||||||
import { DmpBlueprintExtraFieldDataType } from "@app/core/common/enum/dmp-blueprint-field-type";
|
import { DmpBlueprintExtraFieldDataType } from "@app/core/common/enum/dmp-blueprint-field-type";
|
||||||
import { DmpBlueprintStatus } from "@app/core/common/enum/dmp-blueprint-status";
|
import { DmpBlueprintStatus } from "@app/core/common/enum/dmp-blueprint-status";
|
||||||
import { DmpBlueprintSystemFieldType } from "@app/core/common/enum/dmp-blueprint-system-field-type";
|
import { DmpBlueprintSystemFieldType } from "@app/core/common/enum/dmp-blueprint-system-field-type";
|
||||||
|
import { DmpBlueprintVersionStatus } from "@app/core/common/enum/dmp-blueprint-version-status";
|
||||||
import { DescriptionTemplatesInSection, DescriptionTemplatesInSectionPersist, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionPersist, DmpBlueprintDefinitionSection, DmpBlueprintDefinitionSectionPersist, DmpBlueprintPersist, ExtraFieldInSection, FieldInSection, FieldInSectionPersist, ReferenceTypeFieldInSection, SystemFieldInSection } from "@app/core/model/dmp-blueprint/dmp-blueprint";
|
import { DescriptionTemplatesInSection, DescriptionTemplatesInSectionPersist, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionPersist, DmpBlueprintDefinitionSection, DmpBlueprintDefinitionSectionPersist, DmpBlueprintPersist, ExtraFieldInSection, FieldInSection, FieldInSectionPersist, ReferenceTypeFieldInSection, SystemFieldInSection } from "@app/core/model/dmp-blueprint/dmp-blueprint";
|
||||||
import { BaseEditorModel } from "@common/base/base-form-editor-model";
|
import { BaseEditorModel } from "@common/base/base-form-editor-model";
|
||||||
import { BackendErrorValidator, DmpBlueprintSystemFieldRequiredValidator } from "@common/forms/validation/custom-validator";
|
import { BackendErrorValidator, DmpBlueprintSystemFieldRequiredValidator } from "@common/forms/validation/custom-validator";
|
||||||
|
@ -14,6 +15,7 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
|
||||||
label: string;
|
label: string;
|
||||||
definition: DmpBlueprintDefinitionEditorModel = new DmpBlueprintDefinitionEditorModel();
|
definition: DmpBlueprintDefinitionEditorModel = new DmpBlueprintDefinitionEditorModel();
|
||||||
status: DmpBlueprintStatus = DmpBlueprintStatus.Draft;
|
status: DmpBlueprintStatus = DmpBlueprintStatus.Draft;
|
||||||
|
versionStatus: DmpBlueprintVersionStatus = DmpBlueprintVersionStatus.Current;
|
||||||
description: string;
|
description: string;
|
||||||
permissions: string[];
|
permissions: string[];
|
||||||
|
|
||||||
|
@ -27,6 +29,7 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
|
||||||
super.fromModel(item);
|
super.fromModel(item);
|
||||||
this.label = item.label;
|
this.label = item.label;
|
||||||
this.status = item.status;
|
this.status = item.status;
|
||||||
|
this.versionStatus = item.versionStatus;
|
||||||
this.definition = new DmpBlueprintDefinitionEditorModel(this.validationErrorModel).fromModel(item.definition);
|
this.definition = new DmpBlueprintDefinitionEditorModel(this.validationErrorModel).fromModel(item.definition);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -23,6 +23,7 @@ export class DmpBlueprintEditorResolver extends BaseEditorResolver {
|
||||||
nameof<DmpBlueprint>(x => x.id),
|
nameof<DmpBlueprint>(x => x.id),
|
||||||
nameof<DmpBlueprint>(x => x.label),
|
nameof<DmpBlueprint>(x => x.label),
|
||||||
nameof<DmpBlueprint>(x => x.status),
|
nameof<DmpBlueprint>(x => x.status),
|
||||||
|
nameof<DmpBlueprint>(x => x.versionStatus),
|
||||||
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
|
||||||
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
|
||||||
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
|
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
|
||||||
|
|
Loading…
Reference in New Issue