Adds funder on Dmp model and removes it form Grant model and adds funder criteria on grant input autocomplete

This commit is contained in:
apapachristou 2019-08-26 17:29:57 +03:00
parent 535ca2ed5a
commit 93cb23b870
8 changed files with 32 additions and 30 deletions

View File

@ -15,7 +15,7 @@ export interface GrantListingModel {
endDate?: Date; endDate?: Date;
description?: String; description?: String;
contentUrl?: string; contentUrl?: string;
funder?: FunderModel; funderId?: string;
files?: ContentFile[]; files?: ContentFile[];
dmps?: UrlListingItem[]; dmps?: UrlListingItem[];
} }

View File

@ -4,5 +4,6 @@ import { BaseCriteria } from "../base-criteria";
export class GrantCriteria extends BaseCriteria { export class GrantCriteria extends BaseCriteria {
public periodStart: Date; public periodStart: Date;
public periodEnd: Date; public periodEnd: Date;
public funderReference: String;
public grantStateType: GrantStateType; public grantStateType: GrantStateType;
} }

View File

@ -49,7 +49,7 @@
<mat-icon class="mr-2">work_outline</mat-icon> <mat-icon class="mr-2">work_outline</mat-icon>
{{ 'DMP-LISTING.COLUMNS.GRANT' | translate }} {{ 'DMP-LISTING.COLUMNS.GRANT' | translate }}
</ng-template> </ng-template>
<app-grant-tab [formGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [isNew]="isNew" [isFinalized]="isFinalized"></app-grant-tab> <app-grant-tab [formGroup]="formGroup.get('grant')" [projectFormGroup]="formGroup.get('project')" [funderFormGroup]="formGroup.get('funder')" [isNew]="isNew" [isFinalized]="isFinalized"></app-grant-tab>
</mat-tab> </mat-tab>
<mat-tab *ngIf="!isNew"> <mat-tab *ngIf="!isNew">
<ng-template mat-tab-label> <ng-template mat-tab-label>

View File

@ -111,7 +111,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
this.dmp = new DmpEditorModel(); this.dmp = new DmpEditorModel();
this.dmp.grant = new GrantTabModel(); this.dmp.grant = new GrantTabModel();
this.dmp.project = new ProjectFormModel(); this.dmp.project = new ProjectFormModel();
this.dmp.grant.funder = new FunderFormModel(); this.dmp.funder = new FunderFormModel();
this.dmp.fromModel(data); this.dmp.fromModel(data);
this.formGroup = this.dmp.buildForm(); this.formGroup = this.dmp.buildForm();
//this.registerFormEventsForDmpProfile(this.dmp.definition); //this.registerFormEventsForDmpProfile(this.dmp.definition);
@ -148,7 +148,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
this.dmp = new DmpEditorModel(); this.dmp = new DmpEditorModel();
this.dmp.grant = new GrantTabModel(); this.dmp.grant = new GrantTabModel();
this.dmp.project = new ProjectFormModel(); this.dmp.project = new ProjectFormModel();
this.dmp.grant.funder = new FunderFormModel(); this.dmp.funder = new FunderFormModel();
this.dmp.fromModel(data); this.dmp.fromModel(data);
this.formGroup = this.dmp.buildForm(); this.formGroup = this.dmp.buildForm();
//this.registerFormEventsForDmpProfile(this.dmp.definition); //this.registerFormEventsForDmpProfile(this.dmp.definition);
@ -173,7 +173,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
this.dmp = new DmpEditorModel(); this.dmp = new DmpEditorModel();
this.dmp.grant = new GrantTabModel(); this.dmp.grant = new GrantTabModel();
this.dmp.project = new ProjectFormModel(); this.dmp.project = new ProjectFormModel();
this.dmp.grant.funder = new FunderFormModel(); this.dmp.funder = new FunderFormModel();
this.formGroup = this.dmp.buildForm(); this.formGroup = this.dmp.buildForm();
this.registerFormEventsForNewItem(); this.registerFormEventsForNewItem();
if (this.isAuthenticated) { if (this.isAuthenticated) {

View File

@ -8,7 +8,6 @@ import { DmpModel } from "../../../core/model/dmp/dmp";
import { DmpDynamicField } from "../../../core/model/dmp/dmp-dynamic-field"; import { DmpDynamicField } from "../../../core/model/dmp/dmp-dynamic-field";
import { DmpDynamicFieldDependency } from "../../../core/model/dmp/dmp-dynamic-field-dependency"; import { DmpDynamicFieldDependency } from "../../../core/model/dmp/dmp-dynamic-field-dependency";
import { OrganizationModel } from "../../../core/model/organisation/organization"; import { OrganizationModel } from "../../../core/model/organisation/organization";
import { GrantListingModel } from "../../../core/model/grant/grant-listing";
import { ResearcherModel } from "../../../core/model/researcher/researcher"; import { ResearcherModel } from "../../../core/model/researcher/researcher";
import { UserModel } from "../../../core/model/user/user"; import { UserModel } from "../../../core/model/user/user";
import { ValidJsonValidator } from "../../../library/auto-complete/auto-complete-custom-validator"; import { ValidJsonValidator } from "../../../library/auto-complete/auto-complete-custom-validator";
@ -34,7 +33,7 @@ export class DmpEditorModel {
public description: String; public description: String;
public grant: GrantTabModel; public grant: GrantTabModel;
public project: ProjectFormModel; public project: ProjectFormModel;
// public funder: FunderFormModel; public funder: FunderFormModel;
public organisations: OrganizationModel[] = []; public organisations: OrganizationModel[] = [];
public researchers: ResearcherModel[] = []; public researchers: ResearcherModel[] = [];
public profiles: DmpProfile[] = []; public profiles: DmpProfile[] = [];
@ -57,7 +56,7 @@ export class DmpEditorModel {
this.description = item.description; this.description = item.description;
this.grant.fromModel(item.grant); this.grant.fromModel(item.grant);
this.project.fromModel(item.project); this.project.fromModel(item.project);
// this.funder.fromModel(item.funder); this.funder.fromModel(item.funder);
this.organisations = item.organisations; this.organisations = item.organisations;
this.researchers = item.researchers; this.researchers = item.researchers;
this.profiles = item.profiles; this.profiles = item.profiles;
@ -84,7 +83,7 @@ export class DmpEditorModel {
description: [{ value: this.description, disabled: disabled }], description: [{ value: this.description, disabled: disabled }],
grant: this.grant.buildForm(), grant: this.grant.buildForm(),
project: this.project.buildForm(), project: this.project.buildForm(),
// funder: this.funder.buildForm(), funder: this.funder.buildForm(),
organisations: [{ value: this.organisations, disabled: disabled }, context.getValidation('organisations').validators], organisations: [{ value: this.organisations, disabled: disabled }, context.getValidation('organisations').validators],
researchers: [{ value: this.researchers, disabled: disabled }, context.getValidation('researchers').validators], researchers: [{ value: this.researchers, disabled: disabled }, context.getValidation('researchers').validators],
profiles: [{ value: this.profiles, disabled: disabled }, context.getValidation('profiles').validators], profiles: [{ value: this.profiles, disabled: disabled }, context.getValidation('profiles').validators],
@ -121,7 +120,7 @@ export class DmpEditorModel {
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] }); 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: 'grant', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'grant')] });
baseContext.validation.push({ key: 'project', validators: [BackendErrorValidator(this.validationErrorModel, 'project')] }); 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: 'organisations', validators: [BackendErrorValidator(this.validationErrorModel, 'organisations')] });
baseContext.validation.push({ key: 'researchers', validators: [BackendErrorValidator(this.validationErrorModel, 'researchers')] }); baseContext.validation.push({ key: 'researchers', validators: [BackendErrorValidator(this.validationErrorModel, 'researchers')] });
baseContext.validation.push({ key: 'profiles', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'profiles')] }); baseContext.validation.push({ key: 'profiles', validators: [Validators.required, ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'profiles')] });

View File

@ -12,13 +12,12 @@ export class GrantTabModel {
public label?: string; public label?: string;
public status: Status = Status.Active; public status: Status = Status.Active;
public description: String; public description: String;
public funder: FunderFormModel;
public existGrant: GrantListingModel; public existGrant: GrantListingModel;
public funderId: String;
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
fromModel(item: GrantListingModel): GrantTabModel { fromModel(item: GrantListingModel): GrantTabModel {
this.funder.fromModel(item.funder);
this.existGrant = item; this.existGrant = item;
return this; return this;
} }
@ -31,8 +30,8 @@ export class GrantTabModel {
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators], label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators], status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators],
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').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], existGrant: [{ value: this.existGrant, disabled: disabled }, context.getValidation('existGrant').validators],
funderId: [{ value: this.funderId, disabled: disabled }, context.getValidation('funderId').validators],
}); });
return formGroup; return formGroup;
} }
@ -43,8 +42,8 @@ export class GrantTabModel {
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] }); baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'label')] });
baseContext.validation.push({ key: 'status', validators: [] }); baseContext.validation.push({ key: 'status', validators: [] });
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'description')] }); 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')] }); 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; return baseContext;
} }

View File

@ -5,7 +5,7 @@
<div class="row"> <div class="row">
<div class="col-6 pb-2 pl-4 pt-4" *ngIf="!isCreateNewFunder"> <div class="col-6 pb-2 pl-4 pt-4" *ngIf="!isCreateNewFunder">
<mat-form-field> <mat-form-field>
<app-single-auto-complete [formControl]="formGroup.get('funder').get('existFunder')" placeholder="{{'DMP-EDITOR.FIELDS.FUNDER' | translate}}" [configuration]="funderAutoCompleteConfiguration"> <app-single-auto-complete [formControl]="funderFormGroup.get('existFunder')" placeholder="{{'DMP-EDITOR.FIELDS.FUNDER' | translate}}" [configuration]="funderAutoCompleteConfiguration">
</app-single-auto-complete> </app-single-auto-complete>
</mat-form-field> </mat-form-field>
</div> </div>
@ -13,10 +13,10 @@
<!-- Create New Funder --> <!-- Create New Funder -->
<div class="col-6 pl-4 pt-4" *ngIf="isCreateNewFunder"> <div class="col-6 pl-4 pt-4" *ngIf="isCreateNewFunder">
<mat-form-field> <mat-form-field>
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.FUNDER-LABEL' | translate}}" type="text" name="label" [formControl]="formGroup.get('funder').get('label')" required> <input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.FUNDER-LABEL' | translate}}" type="text" name="label" [formControl]="funderFormGroup.get('label')" required>
<mat-error *ngIf="formGroup.get('funder').get('label').hasError('backendError')"> <mat-error *ngIf="funderFormGroup.get('label').hasError('backendError')">
{{formGroup.get('funder').get('label').getError('backendError').message}}</mat-error> {{funderFormGroup.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('funder').get('label').hasError('required')"> <mat-error *ngIf="funderFormGroup.get('label').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> {{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>

View File

@ -20,7 +20,7 @@ export class GrantTabComponent implements OnInit {
@Input() formGroup: FormGroup; @Input() formGroup: FormGroup;
@Input() projectFormGroup: FormGroup; @Input() projectFormGroup: FormGroup;
// @Input() funderFormGroup: FormGroup; @Input() funderFormGroup: FormGroup;
@Input() isNew: boolean; @Input() isNew: boolean;
@Input() isFinalized: boolean; @Input() isFinalized: boolean;
isCreateNew = false; isCreateNew = false;
@ -67,7 +67,7 @@ export class GrantTabComponent implements OnInit {
this.isCreateNew = (this.formGroup.get('label').value != null && this.formGroup.get('label').value.length > 0); this.isCreateNew = (this.formGroup.get('label').value != null && this.formGroup.get('label').value.length > 0);
this.isCreateNewProject = (this.projectFormGroup.get('label').value != null && this.projectFormGroup.get('label').value.length > 0); this.isCreateNewProject = (this.projectFormGroup.get('label').value != null && this.projectFormGroup.get('label').value.length > 0);
this.isCreateNewFunder = (this.formGroup.get('funder').get('label').value != null && this.formGroup.get('funder').get('label').value.length > 0); this.isCreateNewFunder = (this.funderFormGroup.get('label').value != null && this.funderFormGroup.get('label').value.length > 0);
this.setValidators(); this.setValidators();
this.setProjectValidators(); this.setProjectValidators();
this.setFunderValidators(); this.setFunderValidators();
@ -77,12 +77,15 @@ export class GrantTabComponent implements OnInit {
const grantRequestItem: RequestItem<GrantCriteria> = new RequestItem(); const grantRequestItem: RequestItem<GrantCriteria> = new RequestItem();
grantRequestItem.criteria = new GrantCriteria(); grantRequestItem.criteria = new GrantCriteria();
grantRequestItem.criteria.like = query; grantRequestItem.criteria.like = query;
if (this.funderFormGroup.value.existFunder.reference) {
grantRequestItem.criteria.funderReference = this.funderFormGroup.value.existFunder.reference;
} else { grantRequestItem.criteria.funderReference = ''}
return this.grantService.getWithExternal(grantRequestItem); return this.grantService.getWithExternal(grantRequestItem);
} }
searchProject(query: string) { searchProject(query: string) {
const projectRequestItem: RequestItem<GrantCriteria> = new RequestItem(); const projectRequestItem: RequestItem<ProjectCriteria> = new RequestItem();
projectRequestItem.criteria = new GrantCriteria(); projectRequestItem.criteria = new ProjectCriteria();
projectRequestItem.criteria.like = query; projectRequestItem.criteria.like = query;
return this.projectService.getWithExternal(projectRequestItem); return this.projectService.getWithExternal(projectRequestItem);
} }
@ -149,16 +152,16 @@ export class GrantTabComponent implements OnInit {
setFunderValidators() { setFunderValidators() {
if (this.isCreateNewFunder) { if (this.isCreateNewFunder) {
this.formGroup.get('funder').get('existFunder').disable(); this.funderFormGroup.get('existFunder').disable();
this.formGroup.get('funder').get('label').enable(); this.funderFormGroup.get('label').enable();
} else if (this.isFinalized) { } else if (this.isFinalized) {
this.formGroup.get('funder').get('existFunder').disable(); this.funderFormGroup.get('existFunder').disable();
this.formGroup.get('funder').get('label').disable(); this.funderFormGroup.get('label').disable();
} }
else { else {
this.formGroup.get('funder').enable(); this.funderFormGroup.enable();
this.formGroup.get('funder').get('label').disable(); this.funderFormGroup.get('label').disable();
this.formGroup.get('funder').get('label').reset(); this.funderFormGroup.get('label').reset();
} }
} }