|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
|
|
|
|
import { OnInit, Component, Input, EventEmitter, Output } from '@angular/core';
|
|
|
|
|
import { OnInit, Component, Input, EventEmitter, Output, ViewChild } from '@angular/core';
|
|
|
|
|
import { AbstractControl, FormGroup, Validators } from '@angular/forms';
|
|
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
|
|
|
import { GrantTabModel } from '../grant-tab/grant-tab-model';
|
|
|
|
@ -12,9 +12,9 @@ import { GrantCriteria } from '@app/core/query/grant/grant-criteria';
|
|
|
|
|
import { ProjectCriteria } from '@app/core/query/project/project-criteria';
|
|
|
|
|
import { FunderCriteria } from '@app/core/query/funder/funder-criteria';
|
|
|
|
|
import { debounceTime, filter, map, switchMap, takeUntil, tap } from 'rxjs/operators';
|
|
|
|
|
import { GrantEditorModel } from '@app/ui/grant/editor/grant-editor.model';
|
|
|
|
|
|
|
|
|
|
import { isNullOrUndefined } from '@swimlane/ngx-datatable';
|
|
|
|
|
import { SingleAutoCompleteComponent } from '@app/library/auto-complete/single/single-auto-complete.component';
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'funding-info',
|
|
|
|
|
templateUrl: './funding-info.component.html',
|
|
|
|
@ -22,6 +22,7 @@ import { isNullOrUndefined } from '@swimlane/ngx-datatable';
|
|
|
|
|
})
|
|
|
|
|
export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
@ViewChild('grantSingleAutoComplete', {static: false}) grantSingeAutoComplete :SingleAutoCompleteComponent;
|
|
|
|
|
// @Input() formGroup: FormGroup = null;
|
|
|
|
|
@Input() isUserOwner: boolean;
|
|
|
|
|
@Input() isNew: boolean;
|
|
|
|
@ -39,7 +40,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|
|
|
|
isCreateNewProject = false;
|
|
|
|
|
isCreateNewFunder = false;
|
|
|
|
|
grant: GrantTabModel;
|
|
|
|
|
forceFocus = false;
|
|
|
|
|
// forceFocus = false;
|
|
|
|
|
|
|
|
|
|
grantAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
|
|
|
|
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
|
|
|
@ -219,7 +220,6 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|
|
|
|
displayFn: (item) => item['label'] + this.getGrantIdText(item),
|
|
|
|
|
titleFn: (item) => item['label'] + this.getGrantIdText(item),
|
|
|
|
|
subtitleFn: (item) => item['source'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['source'] : (item['key'] ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item['key'] : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')),
|
|
|
|
|
forceFocus: this.forceFocus,
|
|
|
|
|
}
|
|
|
|
|
// this.forceFocus = false;
|
|
|
|
|
|
|
|
|
@ -236,7 +236,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|
|
|
|
const grantRequestItem: RequestItem<GrantCriteria> = new RequestItem();
|
|
|
|
|
grantRequestItem.criteria = new GrantCriteria();
|
|
|
|
|
grantRequestItem.criteria.like = query;
|
|
|
|
|
if (this.funderFormGroup.get('existFunder').value) {
|
|
|
|
|
if (this.funderFormGroup.get('existFunder').value && !this.isCreateNewFunder) {
|
|
|
|
|
grantRequestItem.criteria.funderReference = this.funderFormGroup.controls['existFunder'].value.reference;
|
|
|
|
|
}
|
|
|
|
|
return this.grantService.getWithExternal(grantRequestItem);
|
|
|
|
@ -272,6 +272,9 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|
|
|
|
createFunder() {
|
|
|
|
|
if (this.isNewVersion) { return };
|
|
|
|
|
this.isCreateNewFunder = !this.isCreateNewFunder;
|
|
|
|
|
if(this.isCreateNewFunder){
|
|
|
|
|
this._refreshGrants(this.grantSingeAutoComplete);
|
|
|
|
|
}
|
|
|
|
|
this.setFunderValidators();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -418,7 +421,10 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|
|
|
|
|| (funder.existFunder !== null && funder.existFunder !== undefined && funder.existFunder.id !== undefined)) {
|
|
|
|
|
this.grantformGroup.reset();
|
|
|
|
|
this.grantformGroup.enable();
|
|
|
|
|
this.forceFocus = true;
|
|
|
|
|
// this.forceFocus = true;
|
|
|
|
|
if(!this.isCreateNewFunder){
|
|
|
|
|
this._refreshGrants(this.grantSingeAutoComplete);
|
|
|
|
|
}
|
|
|
|
|
this.setGrantValidators();
|
|
|
|
|
} else {
|
|
|
|
|
this.grantformGroup.reset();
|
|
|
|
@ -434,6 +440,9 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|
|
|
|
showToggleButton() {
|
|
|
|
|
return (!this.isFinalized && this.isUserOwner) || this.isClone;
|
|
|
|
|
}
|
|
|
|
|
private _refreshGrants(autocompleteComponent:SingleAutoCompleteComponent){
|
|
|
|
|
autocompleteComponent.refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// private grantUniqueIdentifier(): AsyncValidatorFn{
|
|
|
|
|
// return (control: AbstractControl) :Observable<ValidationErrors | null> =>{
|
|
|
|
|