2020-03-16 14:09:46 +01:00
|
|
|
import {Component, Input} from '@angular/core';
|
|
|
|
|
|
|
|
import {FetchProjects} from '../../utils/fetchEntitiesClasses/fetchProjects.class';
|
|
|
|
|
|
|
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
|
|
|
import {StringUtils} from '../../utils/string-utils.class';
|
|
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
|
|
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
import {AlertModal} from "../../utils/modal/alert";
|
2022-05-04 11:47:51 +02:00
|
|
|
import {OpenaireEntities} from '../../utils/properties/searchFields';
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'projectsInModal',
|
|
|
|
template: `
|
2022-07-07 09:54:12 +02:00
|
|
|
<div *ngIf="fetchProjects.funders.length > 1" class="uk-margin-medium-bottom">
|
|
|
|
<ng-container *ngFor="let filter of fetchProjects.filters">
|
|
|
|
<div class="uk-inline">
|
|
|
|
<dropdown-filter #dropdownFilter dropdownClass="uk-width-large uk-padding-small uk-margin-medium-bottom"
|
2023-07-26 10:49:50 +02:00
|
|
|
[name]="filter.title" [count]="filter.countSelectedValues" [isMobile]="isMobile">
|
2022-07-07 09:54:12 +02:00
|
|
|
<div class="uk-padding-small uk-overflow-auto uk-height-max-large uk-height-min-medium">
|
|
|
|
<search-filter [filter]="filter"
|
|
|
|
[showResultCount]=true filterValuesNum="0"
|
|
|
|
(onFilterChange)="filterChange($event)" [actionRoute]="false">
|
|
|
|
</search-filter>
|
|
|
|
</div>
|
|
|
|
</dropdown-filter>
|
|
|
|
</div>
|
|
|
|
</ng-container>
|
|
|
|
</div>
|
2022-05-06 11:27:23 +02:00
|
|
|
<errorMessages [status]="[fetchProjects.searchUtils.status]" [type]="openaireEntities.PROJECTS"
|
2020-03-20 15:52:34 +01:00
|
|
|
tab_error_class=true></errorMessages>
|
|
|
|
<div *ngIf="fetchProjects.searchUtils.status == errorCodes.DONE">
|
2022-06-16 18:37:31 +02:00
|
|
|
<results-and-pages [type]="openaireEntities.PROJECTS"
|
2022-05-04 11:47:51 +02:00
|
|
|
[page]="page" [pageSize]="size"
|
|
|
|
[totalResults]="fetchProjects.searchUtils.totalResults">
|
|
|
|
</results-and-pages>
|
2020-05-26 17:42:02 +02:00
|
|
|
<search-result [results]="fetchProjects.results"
|
|
|
|
[status]="fetchProjects.searchUtils.status"
|
|
|
|
[type]="'project'"
|
2023-04-20 19:06:53 +02:00
|
|
|
[showLoading]="true" [properties]="properties" [prevPath]="prevPath">
|
2020-05-26 17:42:02 +02:00
|
|
|
</search-result>
|
2022-05-04 11:47:51 +02:00
|
|
|
<paging-no-load *ngIf="fetchProjects.searchUtils.totalResults > size"
|
|
|
|
(pageChange)="pageChange($event)"
|
|
|
|
[currentPage]="page"
|
|
|
|
[size]="size"
|
|
|
|
[totalResults]="fetchProjects.searchUtils.totalResults">
|
|
|
|
</paging-no-load>
|
2020-03-16 14:09:46 +01:00
|
|
|
</div>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class ProjectsInModalComponent {
|
2023-04-20 19:06:53 +02:00
|
|
|
@Input() prevPath: string = "";
|
2020-03-16 14:09:46 +01:00
|
|
|
@Input() fetchProjects: FetchProjects;
|
|
|
|
@Input() organizationId: string = "";
|
|
|
|
@Input() properties: EnvProperties;
|
|
|
|
@Input() modal: AlertModal;
|
2023-07-26 10:49:50 +02:00
|
|
|
@Input() isMobile: boolean = false;
|
2020-03-16 14:09:46 +01:00
|
|
|
public page: number = 1;
|
2020-05-27 12:47:40 +02:00
|
|
|
public size: number = 5;
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
public routerHelper: RouterHelper = new RouterHelper();
|
|
|
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
|
|
|
|
|
|
|
private filterQuery: string = "";
|
2022-05-04 11:47:51 +02:00
|
|
|
|
|
|
|
public openaireEntities = OpenaireEntities;
|
2023-07-26 10:49:50 +02:00
|
|
|
|
2020-03-16 14:09:46 +01:00
|
|
|
ngOnInit() {
|
|
|
|
if (this.organizationId) {
|
|
|
|
if (this.fetchProjects.searchUtils.totalResults > 0) {
|
|
|
|
this.search(false, "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private search(refine: boolean, filterQuery: string) {
|
|
|
|
var refineFields: string [] = ["funder"];
|
|
|
|
this.fetchProjects.getResultsForOrganizations(this.organizationId, filterQuery, this.page, this.size, (refine) ? refineFields : [], this.properties);
|
2022-06-16 18:37:31 +02:00
|
|
|
this.scrollToTabTop("projects");
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public pageChange($event) {
|
|
|
|
this.page = $event.value;
|
|
|
|
this.search(false, this.filterQuery);
|
|
|
|
}
|
2022-06-16 18:37:31 +02:00
|
|
|
|
|
|
|
scrollToTabTop(tabId:string){
|
|
|
|
setTimeout(() => {
|
|
|
|
window.scrollTo({
|
|
|
|
top: document.getElementById(tabId) ? document.getElementById(tabId).offsetTop - 250 : 250,
|
|
|
|
behavior: 'smooth'
|
|
|
|
});
|
|
|
|
}, 200);
|
|
|
|
}
|
2020-03-16 14:09:46 +01:00
|
|
|
|
|
|
|
public filterChange($event) {
|
2022-06-16 18:37:31 +02:00
|
|
|
this.page = 1;
|
2020-03-16 14:09:46 +01:00
|
|
|
this.updateFilters();
|
|
|
|
//this.search(true, this.filterQuery);
|
|
|
|
this.search(false, this.filterQuery);
|
|
|
|
}
|
|
|
|
|
|
|
|
private updateFilters() {
|
|
|
|
this.filterQuery = "";
|
|
|
|
for (let filter of this.fetchProjects.filters) {
|
2022-06-23 16:30:45 +02:00
|
|
|
filter.countSelectedValues = 0;
|
2020-03-16 14:09:46 +01:00
|
|
|
var filterLimits = "";
|
|
|
|
for (let value of filter.values) {
|
|
|
|
if (value.selected == true) {
|
|
|
|
//filterLimits+=((filterLimits.length == 0)?'':',') +'"'+ StringUtils.URIEncode(value.id)+'"';
|
|
|
|
filterLimits += ((filterLimits.length == 0) ? '' : ' or ') + filter.filterId + ' exact ';
|
|
|
|
filterLimits += '"' + StringUtils.URIEncode(value.id) + '"';
|
2022-06-23 16:30:45 +02:00
|
|
|
filter.countSelectedValues++;
|
2020-03-16 14:09:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filterLimits.length > 0) {
|
|
|
|
//this.filterQuery+=' and '+filter.filterId + ' exact '+ filterLimits + ' ';
|
|
|
|
this.filterQuery += ' and ( ' + filterLimits + ' ) ';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
//console.log("Filter Changed"+this.filterQuery);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|