fixed dmp editor first step validation.3
This commit is contained in:
parent
b4f54bc330
commit
5519c6890f
|
@ -41,6 +41,7 @@ export class DescriptionBaseFieldsEditorComponent extends BaseComponent {
|
||||||
private loadDescriptionTemplates(): void {
|
private loadDescriptionTemplates(): void {
|
||||||
const dmpDescriptionTemplates: DmpDescriptionTemplate[] = this.description.dmp.dmpDescriptionTemplates.filter(x => x.sectionId == this.description.dmpDescriptionTemplate.sectionId && x.isActive == IsActive.Active);
|
const dmpDescriptionTemplates: DmpDescriptionTemplate[] = this.description.dmp.dmpDescriptionTemplates.filter(x => x.sectionId == this.description.dmpDescriptionTemplate.sectionId && x.isActive == IsActive.Active);
|
||||||
const currentVersionsOfDescriptionTemplates = dmpDescriptionTemplates.map(x => x.currentDescriptionTemplate);
|
const currentVersionsOfDescriptionTemplates = dmpDescriptionTemplates.map(x => x.currentDescriptionTemplate);
|
||||||
|
//Check if the used tempalte in included in the current list. If not add it.
|
||||||
if (this.description.descriptionTemplate && currentVersionsOfDescriptionTemplates.find(x => x.id == this.description?.descriptionTemplate?.id) == null) {
|
if (this.description.descriptionTemplate && currentVersionsOfDescriptionTemplates.find(x => x.id == this.description?.descriptionTemplate?.id) == null) {
|
||||||
if (this.description.status === 0) {
|
if (this.description.status === 0) {
|
||||||
this.openDeprecatedDescriptionTemplateDialog();
|
this.openDeprecatedDescriptionTemplateDialog();
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="heading2 col-12">{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}} *</div>
|
<div class="heading2 col-12">{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}} *</div>
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<rich-text-editor-component [form]="formGroup.get('description')" placeholder="{{'DMP-EDITOR.PLACEHOLDER.DESCRIPTION' | translate}}" [required]="true" [formTouchObservable]="formTouchObservable">
|
<rich-text-editor-component [form]="formGroup.get('description')" placeholder="{{'DMP-EDITOR.PLACEHOLDER.DESCRIPTION' | translate}}" [required]="true">
|
||||||
</rich-text-editor-component>
|
</rich-text-editor-component>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -62,10 +62,10 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
|
||||||
|
|
||||||
isNew = true;
|
isNew = true;
|
||||||
isDeleted = false;
|
isDeleted = false;
|
||||||
|
goToNextStep = true;
|
||||||
item: Dmp;
|
item: Dmp;
|
||||||
selectedBlueprint: DmpBlueprint;
|
selectedBlueprint: DmpBlueprint;
|
||||||
step: number = 0;
|
step: number = 0;
|
||||||
formTouchEvent: EventEmitter<any> = new EventEmitter<any>();
|
|
||||||
|
|
||||||
//Enums
|
//Enums
|
||||||
descriptionStatusEnum = DescriptionStatus;
|
descriptionStatusEnum = DescriptionStatus;
|
||||||
|
@ -219,7 +219,7 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
|
||||||
this.formGroup.disable();
|
this.formGroup.disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.item != null) {
|
if (this.item != null && this.goToNextStep) {
|
||||||
this.nextStep();
|
this.nextStep();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -335,28 +335,25 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
selectDefaultBlueprint(): void {
|
selectDefaultBlueprint(): void {
|
||||||
if (!(this.formGroup.get('label').value && this.formGroup.get('description').value)) {
|
|
||||||
this.formGroup.get('label').markAsTouched();
|
|
||||||
this.formTouchEvent.emit(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.dmpBlueprintService.getSingle(this.configurationService.defaultBlueprintId, DmpEditorResolver.blueprintLookupFields()).pipe(takeUntil(this._destroyed)).subscribe(data => {
|
this.dmpBlueprintService.getSingle(this.configurationService.defaultBlueprintId, DmpEditorResolver.blueprintLookupFields()).pipe(takeUntil(this._destroyed)).subscribe(data => {
|
||||||
this.selectedBlueprint = data;
|
this.selectedBlueprint = data;
|
||||||
this.formGroup.get('blueprint').setValue(this.selectedBlueprint.id);
|
this.formGroup.get('blueprint').setValue(this.selectedBlueprint.id);
|
||||||
this.buildFormAfterBlueprintSelection();
|
|
||||||
this.nextStep();
|
const goToNextStep: boolean = this.formGroup.get('label').valid && this.formGroup.get('description').valid;
|
||||||
|
this.buildFormAfterBlueprintSelection(goToNextStep);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildFormAfterBlueprintSelection() {
|
private buildFormAfterBlueprintSelection(goToNextStep: boolean = true) {
|
||||||
const dmp: Dmp = {
|
const dmp: Dmp = {
|
||||||
label: this.formGroup.get('label').value,
|
label: this.formGroup.get('label').value,
|
||||||
description: this.formGroup.get('description').value,
|
description: this.formGroup.get('description').value,
|
||||||
blueprint: this.selectedBlueprint,
|
blueprint: this.selectedBlueprint,
|
||||||
status: DmpStatus.Draft
|
status: DmpStatus.Draft
|
||||||
}
|
}
|
||||||
|
|
||||||
this.prepareForm(dmp);
|
this.prepareForm(dmp);
|
||||||
|
this.goToNextStep = true; //reset
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue