Fixes bug on /quick-wizard: stepper tab DMP Profile disabled

This commit is contained in:
apapachristou 2019-11-12 12:06:37 +02:00
parent 9a694e167b
commit caefd0ccc5
7 changed files with 45 additions and 25 deletions

View File

@ -40,7 +40,7 @@ export class GrantTabModel {
baseContext.validation.push({ key: 'id', validators: [] });
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
baseContext.validation.push({ key: 'status', validators: [] });
baseContext.validation.push({ key: 'description', validators: [BackendErrorValidator(this.validationErrorModel, 'description')] });
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] });
baseContext.validation.push({ key: 'existGrant', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'existGrant')] });
baseContext.validation.push({ key: 'funderId', validators: [ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'funderId')] });
return baseContext;

View File

@ -6,7 +6,7 @@
<div class="row" *ngIf="!isNew">
<p class="col-md-12"><b>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.ABOUT-FUNDER' | translate}}</b></p>
<mat-form-field class="col-md-12 mt-2">
<app-single-auto-complete required='true' [formControl]="funderFormGroup.get('existFunder')" (optionSelected)="onFunderSelected($event)" (optionRemoved)="onFunderRemoved($event)" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.SELECT-FUNDER' | translate}}" [configuration]="funderAutoCompleteConfiguration">
<app-single-auto-complete [required]='true' [formControl]="funderFormGroup.get('existFunder')" (optionSelected)="onFunderSelected()" (optionRemoved)="onFunderRemoved()" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.SELECT-FUNDER' | translate}}" [configuration]="funderAutoCompleteConfiguration">
</app-single-auto-complete>
<mat-hint>{{'DMP-EDITOR.FIELDS.EXTERNAL-SOURCE-HINT' | translate}}</mat-hint>
</mat-form-field>

View File

@ -16,6 +16,7 @@ export class FunderEditorWizardComponent implements OnInit {
isNew = false;
funder: FunderFormModel;
funderLabelCleared = true;
@Input() funderFormGroup: FormGroup;
@Input() grantformGroup: FormGroup;
funderAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
@ -64,22 +65,40 @@ export class FunderEditorWizardComponent implements OnInit {
}
}
onFunderSelected(event: any) {
this.grantformGroup.get('existGrant').enable();
onFunderSelected() {
if (this.grantformGroup.get('existGrant').disabled) {
this.grantformGroup.get('existGrant').enable();
this.grantformGroup.get('label').disable();
this.grantformGroup.get('description').disable();
} else {
this.grantformGroup.get('existGrant').disable();
this.grantformGroup.get('label').enable();
this.grantformGroup.get('description').enable();
}
}
onFunderRemoved(event: any) {
this.grantformGroup.get('existGrant').disable();
this.grantformGroup.get('existGrant').reset();
onFunderRemoved() {
if (this.grantformGroup.get('existGrant').enabled) {
this.grantformGroup.get('existGrant').disable();
this.grantformGroup.get('existGrant').reset();
this.grantformGroup.get('label').enable();
this.grantformGroup.get('description').enable();
} else {
this.grantformGroup.get('existGrant').enable();
this.grantformGroup.get('label').disable();
this.grantformGroup.get('label').reset();
this.grantformGroup.get('description').disable();
this.grantformGroup.get('description').reset();
}
}
controlModified(event: any) {
if (event) {
this.grantformGroup.get('existGrant').enable();
}
else {
this.grantformGroup.get('existGrant').disable();
this.grantformGroup.get('existGrant').reset();
if (event && this.funderLabelCleared) {
this.funderLabelCleared = false;
this.onFunderSelected();
} else if (!event) {
this.funderLabelCleared = true;
this.onFunderRemoved();
}
}

View File

@ -10,7 +10,7 @@
<div class="row" *ngIf="!isNew">
<p class="col-md-12"><b>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.ABOUT-GRANT' | translate}}</b></p>
<mat-form-field class="col-md-12 mt-2">
<app-single-auto-complete required='true' [formControl]="grantformGroup.get('existGrant')" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.SELECT-GRANT' | translate}}" [configuration]="grantAutoCompleteConfiguration">
<app-single-auto-complete [required]='true' [formControl]="grantformGroup.get('existGrant')" (optionSelected)="onGrantSelected()" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.SELECT-GRANT' | translate}}" [configuration]="grantAutoCompleteConfiguration">
</app-single-auto-complete>
<mat-hint>{{'DMP-EDITOR.FIELDS.EXTERNAL-SOURCE-HINT' | translate}}</mat-hint>
<mat-error *ngIf="grantformGroup.hasError('backendError')">
@ -53,9 +53,8 @@
</div>
<div class="row">
<div class="col"></div>
<button mat-raised-button class="col-auto" color="primary" type="button" *ngIf="!isNew" [disabled]="isFunderFormInvalid()" (click)="create()">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.CREATE-NEW-GRANT' | translate}}</button>
<button mat-raised-button class="col-auto" color="primary" type="button" *ngIf="isNew" (click)="create()">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.EXIST-GRANT' | translate}}</button>
<button mat-raised-button class="col-auto" color="primary" type="button" *ngIf="isNew" [disabled]="isFunderFormInvalid()" (click)="create()">{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.ACTIONS.EXIST-GRANT' | translate}}</button>
<div class="col"></div>
</div>

View File

@ -1,5 +1,5 @@
import {of as observableOf, Observable } from 'rxjs';
import { of as observableOf, Observable } from 'rxjs';
import { Component, Input, OnInit } from '@angular/core';
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
import { MatSnackBar } from '@angular/material/snack-bar';
@ -34,7 +34,6 @@ export class GrantEditorWizardComponent extends BaseComponent implements OnInit,
constructor(
public snackBar: MatSnackBar,
private route: ActivatedRoute,
public router: Router,
public language: TranslateService,
private grantService: GrantService
@ -67,11 +66,11 @@ export class GrantEditorWizardComponent extends BaseComponent implements OnInit,
if (this.funderFormGroup && this.funderFormGroup.get('funder')) {
this.grantformGroup.get('existGrant').enable();
this.grantformGroup.get('label').disable();
this.grantformGroup.get('description').disable();
} else {
this.grantformGroup.get('existGrant').disable();
}
this.grantformGroup.get('label').disable();
this.grantformGroup.get('description').disable();
// this.route.params
// .pipe(takeUntil(this._destroyed))
@ -180,4 +179,9 @@ export class GrantEditorWizardComponent extends BaseComponent implements OnInit,
this.grantformGroup.get('description').reset();
}
}
onGrantSelected() {
this.grantformGroup.get('label').disable();
this.grantformGroup.get('description').disable();
}
}

View File

@ -10,9 +10,7 @@
<ng-template matStepLabel>
{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.TITLE' | translate}}
</ng-template>
<div *ngIf="formGroup.get('funder')">
<app-quick-wizard-funder-editor-component class="col-12" [funderFormGroup]="formGroup.get('funder')" [grantformGroup]="formGroup.get('grant')"></app-quick-wizard-funder-editor-component>
</div>
<app-quick-wizard-funder-editor-component class="col-12" [funderFormGroup]="formGroup.get('funder')" [grantformGroup]="formGroup.get('grant')"></app-quick-wizard-funder-editor-component>
<app-quick-wizard-grant-editor-component class="col-12" [grantformGroup]="formGroup.get('grant')" [funderFormGroup]="formGroup.get('funder')"></app-quick-wizard-grant-editor-component>
<div *ngIf="formGroup.get('project')">
<app-quick-wizard-project-editor-component class="col-12" [formGroup]="formGroup.get('project')"></app-quick-wizard-project-editor-component>
@ -27,7 +25,7 @@
</ng-template>
<ng-container *ngIf="formGroup.get('grant').valid">
<div>
<app-quick-wizard-dmp-editor-component class="col-12" [formGroup]="formGroup.get('dmp')" [datasetFormGroup]="formGroup.get('datasets')" [dmpLabel]=" getGrantLabel()">
<app-quick-wizard-dmp-editor-component class="col-12" [formGroup]="formGroup.get('dmp')" [datasetFormGroup]="formGroup.get('datasets')" [dmpLabel]="getGrantLabel()">
</app-quick-wizard-dmp-editor-component>
</div>
<div class="navigation-buttons-container">

View File

@ -43,7 +43,6 @@ export class QuickWizardEditorComponent extends CheckDeactivateBaseComponent imp
constructor(
public snackBar: MatSnackBar,
private route: ActivatedRoute,
public router: Router,
public language: TranslateService,
public datasetService: DatasetService,
@ -228,4 +227,5 @@ export class QuickWizardEditorComponent extends CheckDeactivateBaseComponent imp
canDeactivate(): boolean {
return this.isSubmitted || !this.formGroup.dirty;
}
}