From 93cb23b870aa4c5599d7cd2d8e73938fb366aeaf Mon Sep 17 00:00:00 2001 From: apapachristou Date: Mon, 26 Aug 2019 17:29:57 +0300 Subject: [PATCH] Adds funder on Dmp model and removes it form Grant model and adds funder criteria on grant input autocomplete --- .../src/app/core/model/grant/grant-listing.ts | 2 +- .../app/core/query/grant/grant-criteria.ts | 1 + .../ui/dmp/editor/dmp-editor.component.html | 2 +- .../app/ui/dmp/editor/dmp-editor.component.ts | 6 ++--- .../src/app/ui/dmp/editor/dmp-editor.model.ts | 9 +++---- .../dmp/editor/grant-tab/grant-tab-model.ts | 7 +++--- .../editor/grant-tab/grant-tab.component.html | 10 ++++---- .../editor/grant-tab/grant-tab.component.ts | 25 +++++++++++-------- 8 files changed, 32 insertions(+), 30 deletions(-) diff --git a/dmp-frontend/src/app/core/model/grant/grant-listing.ts b/dmp-frontend/src/app/core/model/grant/grant-listing.ts index 0334a1012..df019fb46 100644 --- a/dmp-frontend/src/app/core/model/grant/grant-listing.ts +++ b/dmp-frontend/src/app/core/model/grant/grant-listing.ts @@ -15,7 +15,7 @@ export interface GrantListingModel { endDate?: Date; description?: String; contentUrl?: string; - funder?: FunderModel; + funderId?: string; files?: ContentFile[]; dmps?: UrlListingItem[]; } diff --git a/dmp-frontend/src/app/core/query/grant/grant-criteria.ts b/dmp-frontend/src/app/core/query/grant/grant-criteria.ts index e84802ac2..587060466 100644 --- a/dmp-frontend/src/app/core/query/grant/grant-criteria.ts +++ b/dmp-frontend/src/app/core/query/grant/grant-criteria.ts @@ -4,5 +4,6 @@ import { BaseCriteria } from "../base-criteria"; export class GrantCriteria extends BaseCriteria { public periodStart: Date; public periodEnd: Date; + public funderReference: String; public grantStateType: GrantStateType; } diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html index 883c157f6..35cc45433 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html @@ -49,7 +49,7 @@ work_outline {{ 'DMP-LISTING.COLUMNS.GRANT' | translate }} - + diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts index 36ad282ed..a59d36706 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts @@ -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.grant.funder = new FunderFormModel(); + this.dmp.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.grant.funder = new FunderFormModel(); + this.dmp.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.grant.funder = new FunderFormModel(); + this.dmp.funder = new FunderFormModel(); this.formGroup = this.dmp.buildForm(); this.registerFormEventsForNewItem(); if (this.isAuthenticated) { diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.model.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.model.ts index 7bccf2cac..2eaee767b 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.model.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.model.ts @@ -8,7 +8,6 @@ import { DmpModel } from "../../../core/model/dmp/dmp"; import { DmpDynamicField } from "../../../core/model/dmp/dmp-dynamic-field"; import { DmpDynamicFieldDependency } from "../../../core/model/dmp/dmp-dynamic-field-dependency"; import { OrganizationModel } from "../../../core/model/organisation/organization"; -import { GrantListingModel } from "../../../core/model/grant/grant-listing"; import { ResearcherModel } from "../../../core/model/researcher/researcher"; import { UserModel } from "../../../core/model/user/user"; import { ValidJsonValidator } from "../../../library/auto-complete/auto-complete-custom-validator"; @@ -34,7 +33,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 +56,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 +83,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 +120,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')] }); diff --git a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab-model.ts b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab-model.ts index 48c41868e..5c94793e5 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab-model.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab-model.ts @@ -12,13 +12,12 @@ export class GrantTabModel { public label?: string; public status: Status = Status.Active; public description: String; - public funder: FunderFormModel; public existGrant: GrantListingModel; + public funderId: String; public validationErrorModel: ValidationErrorModel = new ValidationErrorModel(); fromModel(item: GrantListingModel): GrantTabModel { - this.funder.fromModel(item.funder); this.existGrant = item; return this; } @@ -31,8 +30,8 @@ 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], + funderId: [{ value: this.funderId, disabled: disabled }, context.getValidation('funderId').validators], }); 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: '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')] }); + baseContext.validation.push({ key: 'funderId', validators: [ValidJsonValidator, BackendErrorValidator(this.validationErrorModel, 'funderId')] }); return baseContext; } diff --git a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.html b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.html index 299520274..2c11660f4 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.html @@ -5,7 +5,7 @@
- +
@@ -13,10 +13,10 @@
- - - {{formGroup.get('funder').get('label').getError('backendError').message}} - + + + {{funderFormGroup.get('label').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}}
diff --git a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.ts b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.ts index 62821dc85..cde93d987 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/grant-tab/grant-tab.component.ts @@ -20,7 +20,7 @@ export class GrantTabComponent implements OnInit { @Input() formGroup: FormGroup; @Input() projectFormGroup: FormGroup; - // @Input() funderFormGroup: FormGroup; + @Input() funderFormGroup: FormGroup; @Input() isNew: boolean; @Input() isFinalized: boolean; 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.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.setProjectValidators(); this.setFunderValidators(); @@ -77,12 +77,15 @@ export class GrantTabComponent implements OnInit { const grantRequestItem: RequestItem = new RequestItem(); grantRequestItem.criteria = new GrantCriteria(); 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); } searchProject(query: string) { - const projectRequestItem: RequestItem = new RequestItem(); - projectRequestItem.criteria = new GrantCriteria(); + const projectRequestItem: RequestItem = new RequestItem(); + projectRequestItem.criteria = new ProjectCriteria(); projectRequestItem.criteria.like = query; return this.projectService.getWithExternal(projectRequestItem); } @@ -149,16 +152,16 @@ export class GrantTabComponent implements OnInit { setFunderValidators() { if (this.isCreateNewFunder) { - this.formGroup.get('funder').get('existFunder').disable(); - this.formGroup.get('funder').get('label').enable(); + this.funderFormGroup.get('existFunder').disable(); + this.funderFormGroup.get('label').enable(); } else if (this.isFinalized) { - this.formGroup.get('funder').get('existFunder').disable(); - this.formGroup.get('funder').get('label').disable(); + this.funderFormGroup.get('existFunder').disable(); + this.funderFormGroup.get('label').disable(); } else { - this.formGroup.get('funder').enable(); - this.formGroup.get('funder').get('label').disable(); - this.formGroup.get('funder').get('label').reset(); + this.funderFormGroup.enable(); + this.funderFormGroup.get('label').disable(); + this.funderFormGroup.get('label').reset(); } }