[WIP] Browse RFOs/RPOs: tweaks on search functionality
This commit is contained in:
parent
5f33f0f351
commit
e998bb61e2
|
@ -5,7 +5,7 @@
|
|||
</ng-container>
|
||||
<ng-container *ngIf="!showLoading && stakeholders?.length">
|
||||
<div class="uk-flex uk-flex-middle uk-flex-center uk-position-relative">
|
||||
<div search-input [(value)]="keyword" (searchEmitter)="keywordChanged()" searchInputClass="border-bottom" iconPosition="left"
|
||||
<div search-input *ngIf="keywordControl" [searchControl]="keywordControl" searchInputClass="border-bottom" iconPosition="left"
|
||||
placeholder="Search for {{typeAsLabel}} {{entities.stakeholders}}" [disabled]="showLoading" class="uk-width-1-2@m uk-width-1-1">
|
||||
</div>
|
||||
<div class="uk-flex uk-flex-middle uk-position-right">
|
||||
|
|
|
@ -6,6 +6,8 @@ import {Option} from "../../openaireLibrary/sharedComponents/input/input.compone
|
|||
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
|
||||
import {LayoutService} from "src/app/openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
|
||||
import {StakeholderBaseComponent} from "../../openaireLibrary/monitor-admin/utils/stakeholder-base.component";
|
||||
import {FormBuilder, FormControl} from "@angular/forms";
|
||||
import {debounceTime, distinctUntilChanged} from "rxjs/operators";
|
||||
|
||||
@Component({
|
||||
selector: 'browse-stakeholder',
|
||||
|
@ -26,17 +28,21 @@ export class BrowseStakeholderComponent extends StakeholderBaseComponent impleme
|
|||
currentPage: number = 1;
|
||||
pageSize: number = 10;
|
||||
parameters = {};
|
||||
keyword: string = '';
|
||||
keywordControl: FormControl;
|
||||
|
||||
constructor(protected _route: ActivatedRoute,
|
||||
protected _router: Router,
|
||||
private stakeholderService: StakeholderService,
|
||||
private layoutService: LayoutService,
|
||||
private cdr: ChangeDetectorRef) {
|
||||
private cdr: ChangeDetectorRef,
|
||||
private fb: FormBuilder) {
|
||||
super();
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
console.log(this._route.snapshot.queryParams.keyword);
|
||||
this.keywordControl = this.fb.control(this._route.snapshot.queryParams.keyword);
|
||||
console.log(this.keywordControl.value);
|
||||
this.subscriptions.push(this.layoutService.isMobile.subscribe(isMobile => {
|
||||
this.isMobile = isMobile;
|
||||
this.cdr.detectChanges();
|
||||
|
@ -54,28 +60,24 @@ export class BrowseStakeholderComponent extends StakeholderBaseComponent impleme
|
|||
this.stakeholders = stakeholders;
|
||||
this.filteredStakeholders = stakeholders;
|
||||
this.filteredStakeholders.sort((a, b) => a['name'].localeCompare(b['name']));
|
||||
this.filtering(this.keywordControl.value);
|
||||
this.showLoading = false;
|
||||
}));
|
||||
this._route.queryParams.subscribe(params => {
|
||||
this.parameters = Object.assign({}, params);
|
||||
this.keyword = params['keyword'] ? params['keyword'] : '';
|
||||
this.filtering(this.keyword);
|
||||
})
|
||||
this.subscriptions.push(this.keywordControl.valueChanges.pipe(debounceTime(200), distinctUntilChanged()).subscribe(value => {
|
||||
this.filtering(value);
|
||||
if(value?.length > 0) {
|
||||
this.parameters['keyword'] = value;
|
||||
} else {
|
||||
delete this.parameters['keyword']
|
||||
}
|
||||
this._router.navigate([], {queryParams: this.parameters});
|
||||
}));
|
||||
}
|
||||
|
||||
private navigateToError() {
|
||||
this._router.navigate([this.properties.errorLink], {queryParams: {'page': this._router.url}});
|
||||
}
|
||||
|
||||
keywordChanged() {
|
||||
if(this.keyword?.length > 0) {
|
||||
this.parameters['keyword'] = this.keyword;
|
||||
} else {
|
||||
delete this.parameters['keyword'];
|
||||
}
|
||||
this._router.navigate([], {queryParams: this.parameters} );
|
||||
}
|
||||
|
||||
private filtering(value) {
|
||||
if(!value){
|
||||
this.filteredStakeholders = this.stakeholders;
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6bb1e61b059bef1bff3bfb0611b0df46f7840426
|
||||
Subproject commit d1b2d5e585722751792d12645d17f820cd6a7860
|
|
@ -1 +1 @@
|
|||
Subproject commit 928dfa11bd4aeadb30c2d72d408c7b7206d6598e
|
||||
Subproject commit 2dadcf85926bc0f11fff22ed94dc197ddd8587c6
|
Loading…
Reference in New Issue