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>
|
<button mat-button class="finalize-btn" (click)="finalize()" [disabled]="!this.isFormValid()" type="button">{{'DMP-BLUEPRINT-EDITOR.ACTIONS.FINALIZE' | translate }}</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<form *ngIf="formGroup" (ngSubmit)="formSubmit()">
|
<form *ngIf="formGroup">
|
||||||
<mat-card class="pt-3 pb-3">
|
<mat-card class="pt-3 pb-3">
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -331,7 +331,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col"></div>
|
<div class="col"></div>
|
||||||
<div class="col-auto">
|
<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}}
|
{{'DMP-BLUEPRINT-EDITOR.ACTIONS.SAVE' | translate}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -238,7 +238,8 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
||||||
formSubmit(): void {
|
formSubmit(): void {
|
||||||
this.formService.removeAllBackEndErrors(this.formGroup);
|
this.formService.removeAllBackEndErrors(this.formGroup);
|
||||||
this.formService.touchAllFormFields(this.formGroup);
|
this.formService.touchAllFormFields(this.formGroup);
|
||||||
if (!this.isFormValid()) {
|
if (!this.isFormValid() || !this.hasDescriptionTemplates()) {
|
||||||
|
this.checkValidity();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,7 +486,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
||||||
|
|
||||||
checkValidity() {
|
checkValidity() {
|
||||||
this.formService.touchAllFormFields(this.formGroup);
|
this.formService.touchAllFormFields(this.formGroup);
|
||||||
if (!this.isFormValid()) { return false; }
|
// if (!this.isFormValid()) { return false; }
|
||||||
let errorMessages = [];
|
let errorMessages = [];
|
||||||
if (!this.hasTitle()) {
|
if (!this.hasTitle()) {
|
||||||
errorMessages.push("Title should be set.");
|
errorMessages.push("Title should be set.");
|
||||||
|
@ -493,6 +494,12 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
||||||
if (!this.hasDescription()) {
|
if (!this.hasDescription()) {
|
||||||
errorMessages.push("Description should be set.");
|
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()) {
|
if (!this.hasDescriptionTemplates()) {
|
||||||
errorMessages.push("At least one section should have description templates.");
|
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;
|
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));
|
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 {
|
hasDescriptionTemplates(): boolean {
|
||||||
const dmpBlueprint: DmpBlueprintPersist = this.formGroup.value;
|
const dmpBlueprint: DmpBlueprintPersist = this.formGroup.value;
|
||||||
|
@ -537,7 +554,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
||||||
}
|
}
|
||||||
|
|
||||||
finalize() {
|
finalize() {
|
||||||
if (this.checkValidity()) {
|
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.formSubmit();
|
this.formSubmit();
|
||||||
|
|
Loading…
Reference in New Issue