Filters by funder (if selected) the grant autocomplete options

This commit is contained in:
apapachristou 2019-08-27 14:03:39 +03:00
parent 098c2270fb
commit 99d3ec9998
7 changed files with 40 additions and 40 deletions

View File

@ -1,7 +1,6 @@
import { UrlListingItem } from "../../../library/url-listing/url-listing-item"; import { UrlListingItem } from "../../../library/url-listing/url-listing-item";
import { GrantType } from '../../common/enum/grant-type'; import { GrantType } from '../../common/enum/grant-type';
import { Status } from '../../common/enum/Status'; import { Status } from '../../common/enum/Status';
import { FunderModel } from "../funder/funder";
export interface GrantListingModel { export interface GrantListingModel {
id?: string; id?: string;
@ -18,6 +17,7 @@ export interface GrantListingModel {
funderId?: string; funderId?: string;
files?: ContentFile[]; files?: ContentFile[];
dmps?: UrlListingItem[]; dmps?: UrlListingItem[];
source?: string;
} }
export interface ContentFile { export interface ContentFile {

View File

@ -2,10 +2,10 @@ import { Observable } from "rxjs";
import { Injectable } from "@angular/core"; import { Injectable } from "@angular/core";
import { HttpHeaders } from "@angular/common/http"; import { HttpHeaders } from "@angular/common/http";
import { RequestItem } from "../../query/request-item"; import { RequestItem } from "../../query/request-item";
import { BaseCriteria } from "../../query/base-criteria";
import { BaseHttpService } from "../http/base-http.service"; import { BaseHttpService } from "../http/base-http.service";
import { environment } from '../../../../environments/environment'; import { environment } from '../../../../environments/environment';
import { FunderCriteria } from "../../query/funder/funder-criteria"; import { FunderCriteria } from "../../query/funder/funder-criteria";
import { FunderModel } from "../../model/funder/funder";
@Injectable() @Injectable()
export class FunderService { export class FunderService {
@ -16,8 +16,7 @@ export class FunderService {
this.actionUrl = environment.Server + 'funders/'; this.actionUrl = environment.Server + 'funders/';
} }
getWithExternal(requestItem: RequestItem<FunderCriteria>): Observable<any[]> { getWithExternal(requestItem: RequestItem<FunderCriteria>): Observable<FunderModel[]> {
return this.http.post<any[]>(this.actionUrl + 'external', requestItem, { headers: this.headers }); return this.http.post<FunderModel[]>(this.actionUrl + 'external', requestItem, { headers: this.headers });
// return this.http.post<ProjectListingModel[]>(this.actionUrl + 'external', requestItem, { headers: this.headers });
} }
} }

View File

@ -6,6 +6,7 @@ import { BaseCriteria } from "../../query/base-criteria";
import { BaseHttpService } from "../http/base-http.service"; import { BaseHttpService } from "../http/base-http.service";
import { environment } from '../../../../environments/environment'; import { environment } from '../../../../environments/environment';
import { ProjectCriteria } from "../../query/project/project-criteria"; import { ProjectCriteria } from "../../query/project/project-criteria";
import { ProjectModel } from "../../model/project/project";
@Injectable() @Injectable()
export class ProjectService { export class ProjectService {
@ -16,8 +17,7 @@ export class ProjectService {
this.actionUrl = environment.Server + 'projects/'; this.actionUrl = environment.Server + 'projects/';
} }
getWithExternal(requestItem: RequestItem<ProjectCriteria>): Observable<any[]> { getWithExternal(requestItem: RequestItem<ProjectCriteria>): Observable<ProjectModel[]> {
return this.http.post<any[]>(this.actionUrl + 'external', requestItem, { headers: this.headers }); return this.http.post<ProjectModel[]>(this.actionUrl + 'external', requestItem, { headers: this.headers });
// return this.http.post<ProjectListingModel[]>(this.actionUrl + 'external', requestItem, { headers: this.headers });
} }
} }

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')" [funderFormGroup]="formGroup.get('funder')" [isNew]="isNew" [isFinalized]="isFinalized"></app-grant-tab> <app-grant-tab [grantformGroup]="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

@ -1,5 +1,5 @@
<div class="container-fluid"> <div class="container-fluid">
<form *ngIf="formGroup" [formGroup]="formGroup"> <form *ngIf="grantformGroup" [formGroup]="grantformGroup">
<!-- Create New DMP Mode --> <!-- Create New DMP Mode -->
<div class="row"> <div class="row">
@ -40,7 +40,7 @@
<div class="row"> <div class="row">
<div class="col-6 pb-2 pl-4 pt-4" *ngIf="!isCreateNew"> <div class="col-6 pb-2 pl-4 pt-4" *ngIf="!isCreateNew">
<mat-form-field> <mat-form-field>
<app-single-auto-complete required='true' [formControl]="formGroup.get('existGrant')" placeholder="{{'DMP-EDITOR.FIELDS.GRANT' | translate}}" [configuration]="grantAutoCompleteConfiguration"> <app-single-auto-complete required='true' [formControl]="grantformGroup.get('existGrant')" placeholder="{{'DMP-EDITOR.FIELDS.GRANT' | translate}}" [configuration]="grantAutoCompleteConfiguration">
</app-single-auto-complete> </app-single-auto-complete>
</mat-form-field> </mat-form-field>
</div> </div>
@ -48,17 +48,17 @@
<!-- Create New Grant --> <!-- Create New Grant -->
<div class="col-6 pl-4 pt-4" *ngIf="isCreateNew"> <div class="col-6 pl-4 pt-4" *ngIf="isCreateNew">
<mat-form-field> <mat-form-field>
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.GRANT-LABEL' | translate}}" type="text" name="label" [formControl]="formGroup.get('label')" required> <input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.GRANT-LABEL' | translate}}" type="text" name="label" [formControl]="grantformGroup.get('label')" required>
<mat-error *ngIf="formGroup.get('label').hasError('backendError')"> <mat-error *ngIf="grantformGroup.get('label').hasError('backendError')">
{{formGroup.get('label').getError('backendError').message}}</mat-error> {{grantformGroup.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('label').hasError('required')"> <mat-error *ngIf="grantformGroup.get('label').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> {{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field> <mat-form-field>
<textarea matInput class="description-area" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.DESCRIPTION' | translate}}" [formControl]="formGroup.get('description')" required></textarea> <textarea matInput class="description-area" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.DESCRIPTION' | translate}}" [formControl]="grantformGroup.get('description')" required></textarea>
<mat-error *ngIf="formGroup.get('description').hasError('backendError')"> <mat-error *ngIf="grantformGroup.get('description').hasError('backendError')">
{{formGroup.get('description').getError('backendError').message}}</mat-error> {{grantformGroup.get('description').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('description').hasError('required')"> <mat-error *ngIf="grantformGroup.get('description').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> {{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
</div> </div>
@ -90,14 +90,14 @@
<mat-form-field> <mat-form-field>
<input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.PROJECT-LABEL' | translate}}" type="text" name="label" [formControl]="projectFormGroup.get('label')"> <input matInput placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.PROJECT-LABEL' | translate}}" type="text" name="label" [formControl]="projectFormGroup.get('label')">
<mat-error *ngIf="projectFormGroup.get('label').hasError('backendError')"> <mat-error *ngIf="projectFormGroup.get('label').hasError('backendError')">
{{formGroup.get('label').getError('backendError').message}}</mat-error> {{projectFormGroup.get('label').getError('backendError').message}}</mat-error>
<mat-error *ngIf="projectFormGroup.get('label').hasError('required')"> <mat-error *ngIf="projectFormGroup.get('label').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> {{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<mat-form-field> <mat-form-field>
<textarea matInput class="description-area" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.DESCRIPTION' | translate}}" [formControl]="projectFormGroup.get('description')"></textarea> <textarea matInput class="description-area" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.DESCRIPTION' | translate}}" [formControl]="projectFormGroup.get('description')"></textarea>
<mat-error *ngIf="projectFormGroup.get('description').hasError('backendError')"> <mat-error *ngIf="projectFormGroup.get('description').hasError('backendError')">
{{formGroup.get('description').getError('backendError').message}}</mat-error> {{projectFormGroup.get('description').getError('backendError').message}}</mat-error>
<mat-error *ngIf="projectFormGroup.get('description').hasError('required')"> <mat-error *ngIf="projectFormGroup.get('description').hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> {{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>

View File

@ -18,7 +18,7 @@ import { ProjectCriteria } from '../../../../core/query/project/project-criteria
}) })
export class GrantTabComponent implements OnInit { export class GrantTabComponent implements OnInit {
@Input() formGroup: FormGroup; @Input() grantformGroup: FormGroup;
@Input() projectFormGroup: FormGroup; @Input() projectFormGroup: FormGroup;
@Input() funderFormGroup: FormGroup; @Input() funderFormGroup: FormGroup;
@Input() isNew: boolean; @Input() isNew: boolean;
@ -48,7 +48,8 @@ export class GrantTabComponent implements OnInit {
filterFn: this.searchGrant.bind(this), filterFn: this.searchGrant.bind(this),
initialItems: (extraData) => this.searchGrant(''), initialItems: (extraData) => this.searchGrant(''),
displayFn: (item) => item['label'], displayFn: (item) => item['label'],
titleFn: (item) => item['label'] titleFn: (item) => item['label'],
subtitleFn: (item) => item ? item['source'] : null
}; };
this.projectAutoCompleteConfiguration = { this.projectAutoCompleteConfiguration = {
@ -65,7 +66,7 @@ export class GrantTabComponent implements OnInit {
titleFn: (item) => item['label'] titleFn: (item) => item['label']
} }
this.isCreateNew = (this.formGroup.get('label').value != null && this.formGroup.get('label').value.length > 0); this.isCreateNew = (this.grantformGroup.get('label').value != null && this.grantformGroup.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.funderFormGroup.get('label').value != null && this.funderFormGroup.get('label').value.length > 0); this.isCreateNewFunder = (this.funderFormGroup.get('label').value != null && this.funderFormGroup.get('label').value.length > 0);
this.setValidators(); this.setValidators();
@ -73,13 +74,13 @@ export class GrantTabComponent implements OnInit {
this.setFunderValidators(); this.setFunderValidators();
} }
searchGrant(query: string) { searchGrant(query: any) {
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) { if (this.funderFormGroup.get('existFunder').value) {
grantRequestItem.criteria.funderReference = this.funderFormGroup.value.existFunder.reference; grantRequestItem.criteria.funderReference = this.funderFormGroup.controls['existFunder'].value.reference;
} else { grantRequestItem.criteria.funderReference = ''} }
return this.grantService.getWithExternal(grantRequestItem); return this.grantService.getWithExternal(grantRequestItem);
} }
@ -114,20 +115,20 @@ export class GrantTabComponent implements OnInit {
setValidators() { setValidators() {
if (this.isCreateNew) { if (this.isCreateNew) {
this.formGroup.get('existGrant').disable(); this.grantformGroup.get('existGrant').disable();
this.formGroup.get('label').enable(); this.grantformGroup.get('label').enable();
this.formGroup.get('description').enable(); this.grantformGroup.get('description').enable();
} else if (this.isFinalized) { } else if (this.isFinalized) {
this.formGroup.get('existGrant').disable(); this.grantformGroup.get('existGrant').disable();
this.formGroup.get('label').disable(); this.grantformGroup.get('label').disable();
this.formGroup.get('description').disable(); this.grantformGroup.get('description').disable();
} }
else { else {
this.formGroup.get('existGrant').enable(); this.grantformGroup.get('existGrant').enable();
this.formGroup.get('label').disable(); this.grantformGroup.get('label').disable();
this.formGroup.get('label').reset(); this.grantformGroup.get('label').reset();
this.formGroup.get('description').disable(); this.grantformGroup.get('description').disable();
this.formGroup.get('description').reset(); this.grantformGroup.get('description').reset();
} }
} }

View File

@ -24,7 +24,7 @@
<p class="col-md-12"><b>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.ABOUT-NEW' | translate}}</b></p> <p class="col-md-12"><b>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.ABOUT-NEW' | translate}}</b></p>
<mat-form-field class="col-md-12"> <mat-form-field class="col-md-12">
<input matInput <input matInput
placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.LABEL' | translate}}" placeholder="{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.GRANT-LABEL' | translate}}"
type="text" name="label" [formControl]="formGroup.get('label')" required> type="text" name="label" [formControl]="formGroup.get('label')" required>
<mat-hint>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.LABEL-HINT' | translate}}</mat-hint> <mat-hint>{{'QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.FIRST-STEP.FIELDS.LABEL-HINT' | translate}}</mat-hint>
<mat-error *ngIf="formGroup.get('label').hasError('backendError')"> <mat-error *ngIf="formGroup.get('label').hasError('backendError')">