Dmp editor. Fix issue on selecting grant after search.
This commit is contained in:
parent
bb80cfd300
commit
d9826095bc
|
@ -32,8 +32,8 @@ export interface SingleAutoCompleteConfiguration {
|
||||||
// Selected value formating template
|
// Selected value formating template
|
||||||
selectedValueTemplate?: TemplateRef<any>;
|
selectedValueTemplate?: TemplateRef<any>;
|
||||||
|
|
||||||
// To revert: "We set the items observable on focus to avoid the request being executed on component load."
|
// // To revert: "We set the items observable on focus to avoid the request being executed on component load."
|
||||||
forceFocus?: boolean;
|
// forceFocus?: boolean;
|
||||||
|
|
||||||
autoSelectFirstOptionOnBlur?: boolean;
|
autoSelectFirstOptionOnBlur?: boolean;
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,12 +219,21 @@ export class SingleAutoCompleteComponent extends _CustomComponentMixinBase imple
|
||||||
}
|
}
|
||||||
|
|
||||||
_onInputFocus() {
|
_onInputFocus() {
|
||||||
// We set the items observable on focus to avoid the request being executed on component load.
|
if (!this._items) {
|
||||||
if (!this._items || this.forceFocus) {
|
|
||||||
this._items = this._inputSubject.pipe(
|
this._items = this._inputSubject.pipe(
|
||||||
startWith(null),
|
startWith(null),
|
||||||
debounceTime(this.requestDelay),
|
debounceTime(this.requestDelay),
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged((oldvalue, newvalue)=>{
|
||||||
|
if(oldvalue === newvalue){
|
||||||
|
if(this._refreshFlag){
|
||||||
|
this._refreshFlag = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
this._refreshFlag = false;
|
||||||
|
return false
|
||||||
|
}),
|
||||||
switchMap(query => this.filter(query)));
|
switchMap(query => this.filter(query)));
|
||||||
|
|
||||||
if (this.configuration.groupingFn) { this._groupedItems = this._items.pipe(map(items => this.configuration.groupingFn(items))); }
|
if (this.configuration.groupingFn) { this._groupedItems = this._items.pipe(map(items => this.configuration.groupingFn(items))); }
|
||||||
|
@ -328,7 +337,12 @@ export class SingleAutoCompleteComponent extends _CustomComponentMixinBase imple
|
||||||
return this.configuration.autoSelectFirstOptionOnBlur != null ? this.configuration.autoSelectFirstOptionOnBlur : false;
|
return this.configuration.autoSelectFirstOptionOnBlur != null ? this.configuration.autoSelectFirstOptionOnBlur : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
get forceFocus(): boolean {
|
// get forceFocus(): boolean {
|
||||||
return this.configuration.forceFocus != null ? this.configuration.forceFocus : false;
|
// return this.configuration.forceFocus != null ? this.configuration.forceFocus : false;
|
||||||
|
// }
|
||||||
|
public refresh(){
|
||||||
|
this._refreshFlag = true;
|
||||||
|
this._inputSubject.next(this.inputValue);
|
||||||
}
|
}
|
||||||
|
private _refreshFlag = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,11 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto d-flex align-items-center">
|
<div class="col-auto d-flex align-items-center">
|
||||||
<button *ngIf="!lockStatus" mat-raised-button class="dataset-save-btn mr-2" (click)="touchForm()" type="button">{{ 'DATASET-WIZARD.ACTIONS.VALIDATE' | translate }}</button>
|
|
||||||
<button *ngIf="!lockStatus" mat-raised-button class="dataset-save-btn mr-2" (click)="save()" type="button">{{ 'DATASET-WIZARD.ACTIONS.SAVE' | translate }}</button>
|
<button *ngIf="!lockStatus" mat-raised-button class="dataset-save-btn mr-2" (click)="save()" type="button">{{ 'DATASET-WIZARD.ACTIONS.SAVE' | translate }}</button>
|
||||||
<button *ngIf="!lockStatus" mat-raised-button class="dataset-save-btn mr-2" (click)="save(saveAnd.close)" type="button">{{ 'DATASET-WIZARD.ACTIONS.SAVE-AND-CLOSE' | translate }}</button>
|
<button *ngIf="!lockStatus" mat-raised-button class="dataset-save-btn mr-2" (click)="save(saveAnd.close)" type="button">{{ 'DATASET-WIZARD.ACTIONS.SAVE-AND-CLOSE' | translate }}</button>
|
||||||
<button *ngIf="!lockStatus" mat-raised-button class="dataset-save-btn mr-2" (click)="save(saveAnd.addNew)">{{ 'DATASET-WIZARD.ACTIONS.SAVE-AND-ADD' | translate }}</button>
|
<button *ngIf="!lockStatus" mat-raised-button class="dataset-save-btn mr-2" (click)="save(saveAnd.addNew)">{{ 'DATASET-WIZARD.ACTIONS.SAVE-AND-ADD' | translate }}</button>
|
||||||
<button *ngIf="lockStatus" mat-raised-button disabled class="dataset-save-btn cursor-default" type="button">{{ 'DMP-OVERVIEW.LOCKED' | translate}}</button>
|
<button *ngIf="lockStatus" mat-raised-button disabled class="dataset-save-btn cursor-default" type="button">{{ 'DMP-OVERVIEW.LOCKED' | translate}}</button>
|
||||||
|
<!-- <button *ngIf="!lockStatus" mat-raised-button class="dataset-save-btn mr-2" (click)="touchForm()" type="button">{{ 'DATASET-WIZARD.ACTIONS.VALIDATE' | translate }}</button> -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
<div class="grant-form">
|
<div class="grant-form">
|
||||||
<div *ngIf="!isCreateNew">
|
<div *ngIf="!isCreateNew">
|
||||||
<mat-form-field appearance="outline">
|
<mat-form-field appearance="outline">
|
||||||
<app-single-auto-complete required='true' [formControl]="grantformGroup.get('existGrant')" placeholder="{{'DMP-EDITOR.FIELDS.GRANT' | translate}}" [configuration]="grantAutoCompleteConfiguration">
|
<app-single-auto-complete #grantSingleAutoComplete 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>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { BaseComponent } from '@common/base/base.component';
|
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 { AbstractControl, FormGroup, Validators } from '@angular/forms';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { GrantTabModel } from '../grant-tab/grant-tab-model';
|
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 { ProjectCriteria } from '@app/core/query/project/project-criteria';
|
||||||
import { FunderCriteria } from '@app/core/query/funder/funder-criteria';
|
import { FunderCriteria } from '@app/core/query/funder/funder-criteria';
|
||||||
import { debounceTime, filter, map, switchMap, takeUntil, tap } from 'rxjs/operators';
|
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 { isNullOrUndefined } from '@swimlane/ngx-datatable';
|
||||||
|
import { SingleAutoCompleteComponent } from '@app/library/auto-complete/single/single-auto-complete.component';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'funding-info',
|
selector: 'funding-info',
|
||||||
templateUrl: './funding-info.component.html',
|
templateUrl: './funding-info.component.html',
|
||||||
|
@ -22,6 +22,7 @@ import { isNullOrUndefined } from '@swimlane/ngx-datatable';
|
||||||
})
|
})
|
||||||
export class FundingInfoComponent extends BaseComponent implements OnInit {
|
export class FundingInfoComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
|
@ViewChild('grantSingleAutoComplete', {static: false}) grantSingeAutoComplete :SingleAutoCompleteComponent;
|
||||||
// @Input() formGroup: FormGroup = null;
|
// @Input() formGroup: FormGroup = null;
|
||||||
@Input() isUserOwner: boolean;
|
@Input() isUserOwner: boolean;
|
||||||
@Input() isNew: boolean;
|
@Input() isNew: boolean;
|
||||||
|
@ -39,7 +40,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
||||||
isCreateNewProject = false;
|
isCreateNewProject = false;
|
||||||
isCreateNewFunder = false;
|
isCreateNewFunder = false;
|
||||||
grant: GrantTabModel;
|
grant: GrantTabModel;
|
||||||
forceFocus = false;
|
// forceFocus = false;
|
||||||
|
|
||||||
grantAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
grantAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||||
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
projectAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||||
|
@ -219,7 +220,6 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
||||||
displayFn: (item) => item['label'] + this.getGrantIdText(item),
|
displayFn: (item) => item['label'] + this.getGrantIdText(item),
|
||||||
titleFn: (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')),
|
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;
|
// this.forceFocus = false;
|
||||||
|
|
||||||
|
@ -236,7 +236,7 @@ export class FundingInfoComponent extends BaseComponent 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.get('existFunder').value) {
|
if (this.funderFormGroup.get('existFunder').value && !this.isCreateNewFunder) {
|
||||||
grantRequestItem.criteria.funderReference = this.funderFormGroup.controls['existFunder'].value.reference;
|
grantRequestItem.criteria.funderReference = this.funderFormGroup.controls['existFunder'].value.reference;
|
||||||
}
|
}
|
||||||
return this.grantService.getWithExternal(grantRequestItem);
|
return this.grantService.getWithExternal(grantRequestItem);
|
||||||
|
@ -272,6 +272,9 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
||||||
createFunder() {
|
createFunder() {
|
||||||
if (this.isNewVersion) { return };
|
if (this.isNewVersion) { return };
|
||||||
this.isCreateNewFunder = !this.isCreateNewFunder;
|
this.isCreateNewFunder = !this.isCreateNewFunder;
|
||||||
|
if(this.isCreateNewFunder){
|
||||||
|
this._refreshGrants(this.grantSingeAutoComplete);
|
||||||
|
}
|
||||||
this.setFunderValidators();
|
this.setFunderValidators();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,7 +421,10 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
||||||
|| (funder.existFunder !== null && funder.existFunder !== undefined && funder.existFunder.id !== undefined)) {
|
|| (funder.existFunder !== null && funder.existFunder !== undefined && funder.existFunder.id !== undefined)) {
|
||||||
this.grantformGroup.reset();
|
this.grantformGroup.reset();
|
||||||
this.grantformGroup.enable();
|
this.grantformGroup.enable();
|
||||||
this.forceFocus = true;
|
// this.forceFocus = true;
|
||||||
|
if(!this.isCreateNewFunder){
|
||||||
|
this._refreshGrants(this.grantSingeAutoComplete);
|
||||||
|
}
|
||||||
this.setGrantValidators();
|
this.setGrantValidators();
|
||||||
} else {
|
} else {
|
||||||
this.grantformGroup.reset();
|
this.grantformGroup.reset();
|
||||||
|
@ -434,6 +440,9 @@ export class FundingInfoComponent extends BaseComponent implements OnInit {
|
||||||
showToggleButton() {
|
showToggleButton() {
|
||||||
return (!this.isFinalized && this.isUserOwner) || this.isClone;
|
return (!this.isFinalized && this.isUserOwner) || this.isClone;
|
||||||
}
|
}
|
||||||
|
private _refreshGrants(autocompleteComponent:SingleAutoCompleteComponent){
|
||||||
|
autocompleteComponent.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
// private grantUniqueIdentifier(): AsyncValidatorFn{
|
// private grantUniqueIdentifier(): AsyncValidatorFn{
|
||||||
// return (control: AbstractControl) :Observable<ValidationErrors | null> =>{
|
// return (control: AbstractControl) :Observable<ValidationErrors | null> =>{
|
||||||
|
|
Loading…
Reference in New Issue