Associates Funder to Grant (Issue #145)
This commit is contained in:
parent
dca2b7fe84
commit
14b52e36a8
|
@ -1,6 +1,7 @@
|
|||
import { UrlListingItem } from "../../../library/url-listing/url-listing-item";
|
||||
import { GrantType } from '../../common/enum/grant-type';
|
||||
import { Status } from '../../common/enum/Status';
|
||||
import { FunderModel } from "../funder/funder";
|
||||
|
||||
export interface GrantListingModel {
|
||||
id?: string;
|
||||
|
@ -14,6 +15,7 @@ export interface GrantListingModel {
|
|||
endDate?: Date;
|
||||
description?: String;
|
||||
contentUrl?: string;
|
||||
funder?: FunderModel;
|
||||
files?: ContentFile[];
|
||||
dmps?: UrlListingItem[];
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
<mat-icon class="mr-2">work_outline</mat-icon>
|
||||
{{ 'DMP-LISTING.COLUMNS.GRANT' | translate }}
|
||||
</ng-template>
|
||||
<app-grant-tab [formGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isNew]="isNew" [isFinalized]="isFinalized"></app-grant-tab>
|
||||
<app-grant-tab [formGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('grant').get('funder')" [isNew]="isNew" [isFinalized]="isFinalized"></app-grant-tab>
|
||||
</mat-tab>
|
||||
<mat-tab *ngIf="!isNew">
|
||||
<ng-template mat-tab-label>
|
||||
|
|
|
@ -111,7 +111,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
this.dmp = new DmpEditorModel();
|
||||
this.dmp.grant = new GrantTabModel();
|
||||
this.dmp.project = new ProjectFormModel();
|
||||
this.dmp.funder = new FunderFormModel();
|
||||
this.dmp.grant.funder = new FunderFormModel();
|
||||
this.dmp.fromModel(data);
|
||||
this.formGroup = this.dmp.buildForm();
|
||||
//this.registerFormEventsForDmpProfile(this.dmp.definition);
|
||||
|
@ -148,7 +148,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
this.dmp = new DmpEditorModel();
|
||||
this.dmp.grant = new GrantTabModel();
|
||||
this.dmp.project = new ProjectFormModel();
|
||||
this.dmp.funder = new FunderFormModel();
|
||||
this.dmp.grant.funder = new FunderFormModel();
|
||||
this.dmp.fromModel(data);
|
||||
this.formGroup = this.dmp.buildForm();
|
||||
//this.registerFormEventsForDmpProfile(this.dmp.definition);
|
||||
|
@ -173,7 +173,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
this.dmp = new DmpEditorModel();
|
||||
this.dmp.grant = new GrantTabModel();
|
||||
this.dmp.project = new ProjectFormModel();
|
||||
this.dmp.funder = new FunderFormModel();
|
||||
this.dmp.grant.funder = new FunderFormModel();
|
||||
this.formGroup = this.dmp.buildForm();
|
||||
this.registerFormEventsForNewItem();
|
||||
if (this.isAuthenticated) {
|
||||
|
@ -238,7 +238,8 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
|||
}
|
||||
|
||||
public isFormValid() {
|
||||
return this.formGroup.get('label').valid && this.formGroup.get('profiles').valid && this.formGroup.get('grant').valid;
|
||||
return this.formGroup.get('label').valid && this.formGroup.get('profiles').valid &&
|
||||
(this.formGroup.get('grant').get('label').valid || this.formGroup.get('grant').get('existGrant').valid);
|
||||
}
|
||||
|
||||
onSubmit(showAddDatasetDialog?: boolean): void {
|
||||
|
|
|
@ -34,7 +34,7 @@ export class DmpEditorModel {
|
|||
public description: String;
|
||||
public grant: GrantTabModel;
|
||||
public project: ProjectFormModel;
|
||||
public funder: FunderFormModel;
|
||||
// public funder: FunderFormModel;
|
||||
public organisations: OrganizationModel[] = [];
|
||||
public researchers: ResearcherModel[] = [];
|
||||
public profiles: DmpProfile[] = [];
|
||||
|
@ -57,7 +57,7 @@ export class DmpEditorModel {
|
|||
this.description = item.description;
|
||||
this.grant.fromModel(item.grant);
|
||||
this.project.fromModel(item.project);
|
||||
this.funder.fromModel(item.funder);
|
||||
// this.funder.fromModel(item.funder);
|
||||
this.organisations = item.organisations;
|
||||
this.researchers = item.researchers;
|
||||
this.profiles = item.profiles;
|
||||
|
@ -84,7 +84,7 @@ export class DmpEditorModel {
|
|||
description: [{ value: this.description, disabled: disabled }],
|
||||
grant: this.grant.buildForm(),
|
||||
project: this.project.buildForm(),
|
||||
funder: this.funder.buildForm(),
|
||||
// funder: this.funder.buildForm(),
|
||||
organisations: [{ value: this.organisations, disabled: disabled }, context.getValidation('organisations').validators],
|
||||
researchers: [{ value: this.researchers, disabled: disabled }, context.getValidation('researchers').validators],
|
||||
profiles: [{ value: this.profiles, disabled: disabled }, context.getValidation('profiles').validators],
|
||||
|
@ -121,7 +121,7 @@ export class DmpEditorModel {
|
|||
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] });
|
||||
baseContext.validation.push({ key: 'grant', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'grant')] });
|
||||
baseContext.validation.push({ key: 'project', validators: [BackendErrorValidator(this.validationErrorModel, 'project')] });
|
||||
baseContext.validation.push({ key: 'funder', validators: [BackendErrorValidator(this.validationErrorModel, 'funder')] });
|
||||
// baseContext.validation.push({ key: 'funder', validators: [BackendErrorValidator(this.validationErrorModel, 'funder')] });
|
||||
baseContext.validation.push({ key: 'organisations', validators: [BackendErrorValidator(this.validationErrorModel, 'organisations')] });
|
||||
baseContext.validation.push({ key: 'researchers', validators: [BackendErrorValidator(this.validationErrorModel, 'researchers')] });
|
||||
baseContext.validation.push({ key: 'profiles', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'profiles')] });
|
||||
|
|
|
@ -10,7 +10,6 @@ export class FunderFormModel {
|
|||
public id: string;
|
||||
public label?: string;
|
||||
public status: Status = Status.Active;
|
||||
public definition: String;
|
||||
public existFunder: FunderModel;
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
||||
|
||||
|
@ -27,7 +26,6 @@ export class FunderFormModel {
|
|||
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
|
||||
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
|
||||
status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators],
|
||||
definition: [{ value: this.definition, disabled: disabled }, context.getValidation('definition').validators],
|
||||
existFunder: [{ value: this.existFunder, disabled: disabled }, context.getValidation('existFunder').validators],
|
||||
});
|
||||
return formGroup;
|
||||
|
@ -38,7 +36,6 @@ export class FunderFormModel {
|
|||
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: 'definition', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'definition')] });
|
||||
baseContext.validation.push({ key: 'existFunder', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'existFunder')] });
|
||||
return baseContext;
|
||||
}
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
import { Status } from "../../../../core/common/enum/Status";
|
||||
import { GrantListingModel } from "../../../../core/model/grant/grant-listing";
|
||||
import { ValidationErrorModel } from "../../../../common/forms/validation/error-model/validation-error-model";
|
||||
import { GrantEditorWizardModel } from "../../../quick-wizard/grant-editor/grant-editor-wizard-model";
|
||||
import { ValidationContext } from "../../../../common/forms/validation/validation-context";
|
||||
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
|
||||
import { BackendErrorValidator } from "../../../../common/forms/validation/custom-validator";
|
||||
import { ValidJsonValidator } from "../../../../library/auto-complete/auto-complete-custom-validator";
|
||||
import { FunderFormModel } from "./funder-form-model";
|
||||
|
||||
export class GrantTabModel {
|
||||
public id: string;
|
||||
public label?: string;
|
||||
public status: Status = Status.Active;
|
||||
public description: String;
|
||||
public funder: FunderFormModel;
|
||||
public existGrant: GrantListingModel;
|
||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
||||
|
||||
|
||||
fromModel(item: GrantListingModel): GrantTabModel {
|
||||
this.funder.fromModel(item.funder);
|
||||
this.existGrant = item;
|
||||
return this;
|
||||
}
|
||||
|
@ -29,6 +31,7 @@ export class GrantTabModel {
|
|||
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
|
||||
status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators],
|
||||
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
|
||||
funder: this.funder.buildForm(),
|
||||
existGrant: [{ value: this.existGrant, disabled: disabled }, context.getValidation('existGrant').validators],
|
||||
});
|
||||
return formGroup;
|
||||
|
@ -40,6 +43,7 @@ export class GrantTabModel {
|
|||
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
|
||||
baseContext.validation.push({ key: 'status', validators: [] });
|
||||
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] });
|
||||
baseContext.validation.push({ key: 'funder', validators: [BackendErrorValidator(this.validationErrorModel, 'funder')] });
|
||||
baseContext.validation.push({ key: 'existGrant', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'existGrant')] });
|
||||
return baseContext;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue