|
|
|
@ -14,7 +14,6 @@ import { FunderCriteria } from '@app/core/query/funder/funder-criteria';
|
|
|
|
|
import { debounceTime, filter, map, switchMap, takeUntil, tap } from 'rxjs/operators';
|
|
|
|
|
|
|
|
|
|
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,7 +21,6 @@ import { SingleAutoCompleteComponent } from '@app/library/auto-complete/single/s
|
|
|
|
|
})
|
|
|
|
|
export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
@ViewChild('grantSingleAutoComplete', {static: false}) grantSingeAutoComplete :SingleAutoCompleteComponent;
|
|
|
|
|
// @Input() formGroup: FormGroup = null;
|
|
|
|
|
@Input() isUserOwner: boolean;
|
|
|
|
|
@Input() isNew: boolean;
|
|
|
|
@ -236,7 +234,8 @@ 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 && !this.isCreateNewFunder) {
|
|
|
|
|
const existFunderValue = this.funderFormGroup.get('existFunder').value;
|
|
|
|
|
if (existFunderValue && !this.isCreateNewFunder && (existFunderValue.key != this._KEY)) {
|
|
|
|
|
grantRequestItem.criteria.funderReference = this.funderFormGroup.controls['existFunder'].value.reference;
|
|
|
|
|
}
|
|
|
|
|
return this.grantService.getWithExternal(grantRequestItem);
|
|
|
|
@ -272,9 +271,6 @@ 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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -417,14 +413,10 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
funderValueChanged(funder: any) {
|
|
|
|
|
if ((funder.label !== "" && funder.label !== null && funder.label !== undefined)
|
|
|
|
|
if ((funder.label !== "" && funder.label !== null && funder.label !== undefined && !isNullOrUndefined(funder.reference) && funder.reference.length )
|
|
|
|
|
|| (funder.existFunder !== null && funder.existFunder !== undefined && funder.existFunder.id !== undefined)) {
|
|
|
|
|
this.grantformGroup.reset();
|
|
|
|
|
this.grantformGroup.enable();
|
|
|
|
|
// this.forceFocus = true;
|
|
|
|
|
if(!this.isCreateNewFunder){
|
|
|
|
|
this._refreshGrants(this.grantSingeAutoComplete);
|
|
|
|
|
}
|
|
|
|
|
this.setGrantValidators();
|
|
|
|
|
} else {
|
|
|
|
|
this.grantformGroup.reset();
|
|
|
|
@ -440,124 +432,6 @@ 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> =>{
|
|
|
|
|
// return control.valueChanges.pipe(
|
|
|
|
|
// debounceTime(600),
|
|
|
|
|
// distinctUntilChanged(),
|
|
|
|
|
// mergeMap(value=>{
|
|
|
|
|
// const requestItem = new RequestItem<GrantCriteria>();
|
|
|
|
|
// requestItem.criteria = new GrantCriteria();
|
|
|
|
|
// requestItem.criteria.exactReference = value;
|
|
|
|
|
// return this.grantService.getWithExternal(requestItem);
|
|
|
|
|
// }),
|
|
|
|
|
// takeUntil(this._destroyed),
|
|
|
|
|
// map((response)=>{
|
|
|
|
|
// if(response && response.length){
|
|
|
|
|
// const internalGrants = (response as Array<any>).filter(grant=> grant.key === "Internal");
|
|
|
|
|
// if(internalGrants && internalGrants.length){
|
|
|
|
|
// return {grantIdentifierExists:true};
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// return null;
|
|
|
|
|
// // return response && response.length? {grantIdentifierExists:true} : null;
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
// ).pipe(first())
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// private funderUniqueIdentifier(): AsyncValidatorFn{
|
|
|
|
|
// return (control: AbstractControl) :Observable<ValidationErrors | null> =>{
|
|
|
|
|
|
|
|
|
|
// if(!control.valueChanges){
|
|
|
|
|
// return of(null);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// return control.valueChanges.pipe(
|
|
|
|
|
// debounceTime(600),
|
|
|
|
|
// // distinctUntilChanged(),
|
|
|
|
|
// switchMap(value=>{
|
|
|
|
|
// const requestItem = new RequestItem<FunderCriteria>();
|
|
|
|
|
// requestItem.criteria = new FunderCriteria();
|
|
|
|
|
// requestItem.criteria.exactReference = value;
|
|
|
|
|
// console.log('perasame mia fora');
|
|
|
|
|
// return this.funderService.getWithExternal(requestItem);
|
|
|
|
|
// }),
|
|
|
|
|
// takeUntil(this._destroyed),
|
|
|
|
|
// map((response)=>{
|
|
|
|
|
|
|
|
|
|
// console.log('pername map');
|
|
|
|
|
// //got response
|
|
|
|
|
// if(response && response.length){
|
|
|
|
|
// const internalFunders = (response as Array<any>).filter(funder=> funder.key === 'Internal');
|
|
|
|
|
|
|
|
|
|
// if(internalFunders && internalFunders.length){
|
|
|
|
|
// return {funderIdentifierExists:true};
|
|
|
|
|
// }
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// return null;
|
|
|
|
|
// }
|
|
|
|
|
// ),
|
|
|
|
|
// first()
|
|
|
|
|
|
|
|
|
|
// )
|
|
|
|
|
|
|
|
|
|
// // const requestItem = new RequestItem<FunderCriteria>();
|
|
|
|
|
// // requestItem.criteria = new FunderCriteria();
|
|
|
|
|
// // requestItem.criteria.exactReference = control.value;
|
|
|
|
|
// // return this.funderService.getWithExternal(requestItem).pipe(
|
|
|
|
|
// // takeUntil(this._destroyed),
|
|
|
|
|
// // map((response)=>{
|
|
|
|
|
// // if(response && response.length){
|
|
|
|
|
// // const internalFunders = (response as Array<any>).filter(funder=> funder.key === 'Internal');
|
|
|
|
|
|
|
|
|
|
// // if(internalFunders && internalFunders.length){
|
|
|
|
|
// // return {funderIdentifierExists:true};
|
|
|
|
|
// // }
|
|
|
|
|
// // return null;
|
|
|
|
|
// // }
|
|
|
|
|
|
|
|
|
|
// // return null;
|
|
|
|
|
// // })
|
|
|
|
|
// // )
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// private grantProjectIdentifier(): AsyncValidatorFn{
|
|
|
|
|
// return (control: AbstractControl) :Observable<ValidationErrors | null> =>{
|
|
|
|
|
// return control.valueChanges.pipe(
|
|
|
|
|
// debounceTime(600),
|
|
|
|
|
// distinctUntilChanged(),
|
|
|
|
|
// mergeMap(value=>{
|
|
|
|
|
// const requestItem = new RequestItem<ProjectCriteria>();
|
|
|
|
|
// requestItem.criteria = new ProjectCriteria();
|
|
|
|
|
// requestItem.criteria.exactReference = value;
|
|
|
|
|
// // return this.grantService.getWithExternal(requestItem);
|
|
|
|
|
// return this.projectService.getWithExternal(requestItem);
|
|
|
|
|
// }),
|
|
|
|
|
// takeUntil(this._destroyed),
|
|
|
|
|
// map((response)=>{
|
|
|
|
|
// if(response && response.length){
|
|
|
|
|
// const internalProjects = (response as Array<any>).filter(grant=> grant.key === "Internal");
|
|
|
|
|
// if(internalProjects && internalProjects.length){
|
|
|
|
|
// return {projectIdentifierExists:true};
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// return null;
|
|
|
|
|
// // return response && response.length? {grantIdentifierExists:true} : null;
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
// ).pipe(first())
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private consoleForm(){
|
|
|
|
|