fixed dmp blueprint saving
This commit is contained in:
parent
1a3aa18d35
commit
97449226fe
|
@ -27,7 +27,7 @@
|
|||
<button mat-button class="finalize-btn" (click)="finalize()" [disabled]="!this.isFormValid()" type="button">{{'DMP-BLUEPRINT-EDITOR.ACTIONS.FINALIZE' | translate }}</button>
|
||||
</div>
|
||||
</div>
|
||||
<form *ngIf="formGroup" (ngSubmit)="formSubmit()">
|
||||
<form *ngIf="formGroup">
|
||||
<mat-card class="pt-3 pb-3">
|
||||
<mat-card-content>
|
||||
<div class="row">
|
||||
|
@ -331,7 +331,7 @@
|
|||
</div>
|
||||
<div class="col"></div>
|
||||
<div class="col-auto">
|
||||
<button mat-button class="action-btn" [disabled]="!canSave" type="submit">
|
||||
<button mat-button class="action-btn" [disabled]="!canSave" type="submit" (click)="save(); formSubmit()">
|
||||
{{'DMP-BLUEPRINT-EDITOR.ACTIONS.SAVE' | translate}}
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
@ -238,7 +238,8 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
|||
formSubmit(): void {
|
||||
this.formService.removeAllBackEndErrors(this.formGroup);
|
||||
this.formService.touchAllFormFields(this.formGroup);
|
||||
if (!this.isFormValid()) {
|
||||
if (!this.isFormValid() || !this.hasDescriptionTemplates()) {
|
||||
this.checkValidity();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -485,7 +486,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
|||
|
||||
checkValidity() {
|
||||
this.formService.touchAllFormFields(this.formGroup);
|
||||
if (!this.isFormValid()) { return false; }
|
||||
// if (!this.isFormValid()) { return false; }
|
||||
let errorMessages = [];
|
||||
if (!this.hasTitle()) {
|
||||
errorMessages.push("Title should be set.");
|
||||
|
@ -493,6 +494,12 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
|||
if (!this.hasDescription()) {
|
||||
errorMessages.push("Description should be set.");
|
||||
}
|
||||
if (!this.hasLanguage()) {
|
||||
errorMessages.push("Language should be set.");
|
||||
}
|
||||
if (!this.hasAccess()) {
|
||||
errorMessages.push("Access should be set.");
|
||||
}
|
||||
if (!this.hasDescriptionTemplates()) {
|
||||
errorMessages.push("At least one section should have description templates.");
|
||||
}
|
||||
|
@ -512,6 +519,16 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
|||
const dmpBlueprint: DmpBlueprintPersist = this.formGroup.value;
|
||||
return dmpBlueprint.definition.sections.some(section => section.fields.some(field => (field.category == DmpBlueprintFieldCategory.System) && (field as SystemFieldInSection).systemFieldType === DmpBlueprintSystemFieldType.Description));
|
||||
}
|
||||
|
||||
hasLanguage(): boolean {
|
||||
const dmpBlueprint: DmpBlueprintPersist = this.formGroup.value;
|
||||
return dmpBlueprint.definition.sections.some(section => section.fields.some(field => (field.category == DmpBlueprintFieldCategory.System) && (field as SystemFieldInSection).systemFieldType === DmpBlueprintSystemFieldType.Language));
|
||||
}
|
||||
|
||||
hasAccess(): boolean {
|
||||
const dmpBlueprint: DmpBlueprintPersist = this.formGroup.value;
|
||||
return dmpBlueprint.definition.sections.some(section => section.fields.some(field => (field.category == DmpBlueprintFieldCategory.System) && (field as SystemFieldInSection).systemFieldType === DmpBlueprintSystemFieldType.AccessRights));
|
||||
}
|
||||
|
||||
hasDescriptionTemplates(): boolean {
|
||||
const dmpBlueprint: DmpBlueprintPersist = this.formGroup.value;
|
||||
|
@ -537,7 +554,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
|||
}
|
||||
|
||||
finalize() {
|
||||
if (this.checkValidity()) {
|
||||
if (this.checkValidity() || !this.hasDescriptionTemplates()) {
|
||||
this.formGroup.get('status').setValue(DmpBlueprintStatus.Finalized);
|
||||
if(this.isNewVersion) this.isNewVersion = false;
|
||||
this.formSubmit();
|
||||
|
|
Loading…
Reference in New Issue