2020-04-22 15:00:13 +02:00
|
|
|
import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
|
2020-02-13 15:44:51 +01:00
|
|
|
import {FormBuilder} from "@angular/forms";
|
|
|
|
import {EnvProperties} from "../../utils/properties/env-properties";
|
|
|
|
import {SearchCustomFilter} from "./searchUtils.class";
|
|
|
|
import {ConfigurationService} from "../../utils/configuration/configuration.service";
|
|
|
|
import {Router} from "@angular/router";
|
2020-04-22 15:00:13 +02:00
|
|
|
import {LoginErrorCodes} from "../../login/utils/guardHelper.class";
|
|
|
|
import {MatSelect} from "@angular/material";
|
2020-06-29 15:15:52 +02:00
|
|
|
import {properties} from "../../../../environments/environment";
|
2020-07-13 00:19:30 +02:00
|
|
|
import {Subscription} from "rxjs";
|
2020-02-13 15:44:51 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'entities-selection',
|
|
|
|
template: `
|
2020-06-29 15:15:52 +02:00
|
|
|
<span *ngIf="!disableSelect && show>1 && selectedEntity"
|
|
|
|
class=" entitiesSelection portal-box uk-text-small clickable" style=""
|
|
|
|
(click)="open()">
|
|
|
|
<mat-select *ngIf="!onlyresults" [(value)]="selectedEntity"
|
|
|
|
(valueChange)="entityChanged()" [disableOptionCentering]="true" [panelClass]="matPanelClass">
|
|
|
|
<mat-option *ngIf="simpleView && showAll"
|
|
|
|
value="all">All content
|
2020-03-03 15:32:43 +01:00
|
|
|
</mat-option>
|
|
|
|
<mat-option *ngIf="showResearchOutcomes" value="result">Research outcomes</mat-option>
|
|
|
|
<mat-option *ngIf="showProjects" value="project">Projects</mat-option>
|
|
|
|
<mat-option *ngIf="showDataProviders" value="dataprovider">Content providers</mat-option>
|
|
|
|
<mat-option *ngIf="showOrganizations" value="organization">Organizations</mat-option>
|
|
|
|
</mat-select>
|
2020-06-29 15:15:52 +02:00
|
|
|
<mat-select *ngIf="onlyresults" [(value)]="selectedEntity"
|
|
|
|
(valueChange)="entityChanged()" [disableOptionCentering]="true" [panelClass]="matPanelClass">
|
2020-04-22 15:00:13 +02:00
|
|
|
<mat-option
|
2020-06-29 15:15:52 +02:00
|
|
|
*ngIf="simpleView && showAll"
|
|
|
|
value="all">All research outcomes
|
2020-04-22 15:00:13 +02:00
|
|
|
</mat-option>
|
|
|
|
<mat-option *ngIf="showPublications" value="publications">Publications</mat-option>
|
|
|
|
<mat-option *ngIf="showDatasets" value="datasets">Datasets</mat-option>
|
|
|
|
<mat-option *ngIf="showSoftware" value="software">Software</mat-option>
|
|
|
|
<mat-option *ngIf="showOther" value="other">Other Research products</mat-option>
|
|
|
|
</mat-select>
|
|
|
|
|
|
|
|
</span>
|
2020-06-29 15:15:52 +02:00
|
|
|
<span *ngIf="currentEntity && disableSelect" class="entitiesSelection portal-box uk-text-small " style="">
|
2020-04-22 15:00:13 +02:00
|
|
|
<div>
|
|
|
|
<span *ngIf="currentEntity=='all'">{{onlyresults ? 'All research outcomes' : 'All content'}}</span>
|
|
|
|
<span *ngIf="currentEntity=='result'">Research outcomes</span>
|
|
|
|
<span *ngIf="currentEntity=='project'">Projects</span>
|
|
|
|
<span *ngIf="currentEntity=='dataprovider'">Content providers</span>
|
|
|
|
<span *ngIf="currentEntity=='organization'">Organizations</span>
|
|
|
|
<span *ngIf="currentEntity=='publications'">Publications</span>
|
|
|
|
<span *ngIf="currentEntity=='datasets'">Datasets</span>
|
|
|
|
<span *ngIf="currentEntity=='software'">Software</span>
|
|
|
|
<span *ngIf="currentEntity=='other'">Other Research products</span>
|
2020-04-03 18:00:19 +02:00
|
|
|
</div>
|
2020-04-22 15:00:13 +02:00
|
|
|
</span>
|
2020-06-29 15:15:52 +02:00
|
|
|
<!--<span *ngIf="onlyresults && !disableSelect">
|
|
|
|
<select *ngIf="show" [(ngModel)]="selectedEntity" class="uk-select uk-width-auto portal-box uk-text-small" (ngModelChange)="entityChanged()" >
|
|
|
|
<option
|
|
|
|
*ngIf="simpleView && (show)>1 && !(this.customFilter && this.customFilter.queryFieldName=='communityId' )"
|
|
|
|
value="all">All research outcomes
|
|
|
|
</option>
|
|
|
|
<option *ngIf="showPublications" value="publications">Publications</option>
|
|
|
|
<option *ngIf="showDatasets" value="datasets">Datasets</option>
|
|
|
|
<option *ngIf="showSoftware" value="software">Software</option>
|
|
|
|
<option *ngIf="showOther" value="other">Other Research products</option>
|
|
|
|
</select>
|
|
|
|
</span>-->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-02-13 15:44:51 +01:00
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class EntitiesSelectionComponent {
|
2020-06-29 15:15:52 +02:00
|
|
|
|
2020-02-13 15:44:51 +01:00
|
|
|
showResearchOutcomes: boolean = false;
|
2020-04-22 15:00:13 +02:00
|
|
|
showPublications: boolean = false;
|
|
|
|
showDatasets: boolean = false;
|
|
|
|
showSoftware: boolean = false;
|
|
|
|
showOther: boolean = false;
|
2020-02-13 15:44:51 +01:00
|
|
|
showProjects: boolean = false;
|
|
|
|
showDataProviders: boolean = false;
|
|
|
|
showOrganizations: boolean = false;
|
2020-06-29 15:15:52 +02:00
|
|
|
showAll: boolean = true;
|
2020-02-13 15:44:51 +01:00
|
|
|
@Input() properties: EnvProperties;
|
|
|
|
@Input() customFilter: SearchCustomFilter = null;
|
|
|
|
@Input() @Output() selectedEntity = "Research Outcomes";
|
|
|
|
@Input() currentEntity = "Research Outcomes";
|
2020-03-03 15:32:43 +01:00
|
|
|
@Input() simpleView: boolean = true;
|
|
|
|
@Input() onChangeNavigate: boolean = true;
|
2020-02-13 15:44:51 +01:00
|
|
|
@Output() selectionChange = new EventEmitter();
|
2020-04-22 15:00:13 +02:00
|
|
|
@Input() onlyresults: boolean = false;
|
2020-06-29 15:15:52 +02:00
|
|
|
@Input() matPanelClass = "matSelectionPanel";
|
|
|
|
@Input() disableSelect: boolean = false;
|
2020-04-03 18:00:19 +02:00
|
|
|
show = 0;
|
2020-06-29 15:15:52 +02:00
|
|
|
@ViewChild(MatSelect) matSelect: MatSelect;
|
2020-07-13 00:19:30 +02:00
|
|
|
|
|
|
|
subs: Subscription[] = [];
|
|
|
|
|
2020-02-13 15:44:51 +01:00
|
|
|
constructor(private _fb: FormBuilder, private config: ConfigurationService, private router: Router) {
|
2020-06-29 15:15:52 +02:00
|
|
|
|
|
|
|
|
2020-02-13 15:44:51 +01:00
|
|
|
}
|
2020-06-29 15:15:52 +02:00
|
|
|
|
|
|
|
|
2020-02-13 15:44:51 +01:00
|
|
|
ngOnInit() {
|
2020-04-03 18:00:19 +02:00
|
|
|
this.show = 0;
|
2020-03-03 15:32:43 +01:00
|
|
|
if (this.properties) {
|
2020-06-29 16:19:19 +02:00
|
|
|
if((this.customFilter && this.customFilter.queryFieldName == "communityId") || this.properties.adminToolsCommunity !== "monitor") {
|
2020-07-13 00:19:30 +02:00
|
|
|
//this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communityId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => {
|
|
|
|
this.subs.push(this.config.communityInformationState.subscribe(data => {
|
|
|
|
if(data) {
|
|
|
|
let showEntity = {};
|
|
|
|
let showPage = {};
|
|
|
|
for (let i = 0; i < data['entities'].length; i++) {
|
|
|
|
|
|
|
|
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
|
|
|
|
}
|
|
|
|
for (let i = 0; i < data['pages'].length; i++) {
|
|
|
|
showPage["" + data['pages'][i]["route"] + ""] = data['pages'][i]["isEnabled"];
|
|
|
|
}
|
2020-08-13 13:15:10 +02:00
|
|
|
this.showResearchOutcomes = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && (showEntity["publication"] || showEntity["dataset"] || showEntity["software"] || showEntity["orp"]);
|
|
|
|
this.showPublications = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && showEntity["publication"];
|
|
|
|
this.showDatasets = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && showEntity["dataset"];
|
|
|
|
this.showSoftware = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && showEntity["software"];
|
|
|
|
this.showOther = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && showEntity["orp"];
|
|
|
|
this.showProjects = showPage[this.simpleView?this.properties.searchLinkToProjects:this.properties.searchLinkToAdvancedProjects] && showEntity["project"];
|
|
|
|
this.showOrganizations = showPage[this.simpleView?this.properties.searchLinkToOrganizations:this.properties.searchLinkToAdvancedOrganizations] && showEntity["organization"];
|
|
|
|
this.showDataProviders = showPage[this.simpleView?this.properties.searchLinkToDataProviders:this.properties.searchLinkToAdvancedDataProviders] && showEntity["datasource"];
|
|
|
|
if (this.customFilter && this.customFilter.queryFieldName == "communityId" || this.properties.adminToolsCommunity === "connect") {
|
|
|
|
//for community pages: no organization in simple search, only results in advanced
|
|
|
|
this.showAll = false;
|
2020-07-13 00:19:30 +02:00
|
|
|
this.showOrganizations = false;
|
|
|
|
if (!this.simpleView) {
|
|
|
|
this.showProjects = false;
|
|
|
|
this.showDataProviders = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (this.showResearchOutcomes) {
|
|
|
|
this.show++;
|
|
|
|
}
|
|
|
|
if (this.showDataProviders) {
|
|
|
|
this.show++;
|
|
|
|
}
|
|
|
|
if (this.showOrganizations) {
|
|
|
|
this.show++;
|
|
|
|
}
|
|
|
|
if (this.showProjects) {
|
|
|
|
this.show++;
|
|
|
|
}
|
|
|
|
if (this.show == 1) {
|
|
|
|
this.disableSelect = true;
|
2020-06-29 15:15:52 +02:00
|
|
|
}
|
|
|
|
}
|
2020-07-13 00:19:30 +02:00
|
|
|
}));
|
2020-08-13 15:18:26 +02:00
|
|
|
} else if((this.customFilter && this.customFilter.queryFieldName == "community") && this.properties.adminToolsCommunity === "monitor") {
|
2020-06-29 15:15:52 +02:00
|
|
|
this.show = 1;
|
|
|
|
this.disableSelect = true;
|
2020-08-13 15:18:26 +02:00
|
|
|
} else if(this.customFilter && (this.customFilter.queryFieldName == "relfunder" || this.customFilter.queryFieldName == "funder")) {
|
2020-07-10 10:37:17 +02:00
|
|
|
/*this.showResearchOutcomes = true;
|
2020-06-29 15:15:52 +02:00
|
|
|
this.showPublications = true;
|
|
|
|
this.showDatasets = true;
|
|
|
|
this.showSoftware = true;
|
|
|
|
this.showOther = true;
|
|
|
|
this.showProjects = true;
|
|
|
|
this.showAll = false;
|
2020-07-10 10:37:17 +02:00
|
|
|
this.show = 2;*/
|
|
|
|
this.show = 1;
|
|
|
|
this.disableSelect = true;
|
2020-06-29 15:15:52 +02:00
|
|
|
} else if(this.customFilter && this.customFilter.queryFieldName == "relorganizationid") {
|
2020-07-10 10:37:17 +02:00
|
|
|
/*this.showResearchOutcomes = true;
|
2020-06-29 15:15:52 +02:00
|
|
|
this.showPublications = true;
|
|
|
|
this.showDatasets = true;
|
|
|
|
this.showSoftware = true;
|
|
|
|
this.showOther = true;
|
|
|
|
this.showProjects = true;
|
|
|
|
this.showDataProviders = true;
|
|
|
|
this.showAll = false;
|
2020-07-10 10:37:17 +02:00
|
|
|
this.show = 3;*/
|
|
|
|
this.show = 1;
|
|
|
|
this.disableSelect = true;
|
2020-06-29 15:15:52 +02:00
|
|
|
} else {
|
|
|
|
this.showResearchOutcomes = true;
|
|
|
|
this.showPublications = true;
|
|
|
|
this.showDatasets = true;
|
|
|
|
this.showSoftware = true;
|
|
|
|
this.showOther = true;
|
|
|
|
this.showProjects = true;
|
|
|
|
this.showOrganizations = true;
|
|
|
|
this.showDataProviders = true;
|
|
|
|
this.showAll = false;
|
|
|
|
this.show = 4;
|
|
|
|
}
|
2020-02-13 15:44:51 +01:00
|
|
|
}
|
|
|
|
this.selectedEntity = this.currentEntity;
|
2020-03-03 15:32:43 +01:00
|
|
|
this.selectionChange.emit({
|
|
|
|
entity: this.selectedEntity,
|
|
|
|
simpleUrl: this.getUrl(true),
|
|
|
|
advancedUrl: this.getUrl(false)
|
|
|
|
});
|
2020-02-13 15:44:51 +01:00
|
|
|
}
|
2020-07-13 00:19:30 +02:00
|
|
|
|
|
|
|
public ngOnDestroy() {
|
|
|
|
for (let sub of this.subs) {
|
|
|
|
sub.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
2020-06-29 15:15:52 +02:00
|
|
|
|
2020-03-03 15:32:43 +01:00
|
|
|
entityChanged() {
|
2020-03-05 14:21:01 +01:00
|
|
|
if (!this.simpleView || this.onChangeNavigate) {
|
|
|
|
this.router.navigate([this.getUrl(this.simpleView)]);
|
2020-03-03 15:32:43 +01:00
|
|
|
} else {
|
|
|
|
this.selectionChange.emit({
|
|
|
|
entity: this.selectedEntity,
|
|
|
|
simpleUrl: this.getUrl(true),
|
|
|
|
advancedUrl: this.getUrl(false)
|
|
|
|
});
|
2020-02-13 15:44:51 +01:00
|
|
|
}
|
2020-06-29 15:15:52 +02:00
|
|
|
|
2020-02-13 15:44:51 +01:00
|
|
|
}
|
2020-06-29 15:15:52 +02:00
|
|
|
|
2020-03-03 15:32:43 +01:00
|
|
|
getUrl(simpleView: boolean) {
|
2020-02-13 15:44:51 +01:00
|
|
|
let url = "";
|
2020-06-29 15:15:52 +02:00
|
|
|
if (!this.onlyresults) {
|
2020-04-22 15:00:13 +02:00
|
|
|
if (this.selectedEntity == "all") {
|
|
|
|
url = (simpleView ? "/search/find/" : null);
|
|
|
|
} else if (this.selectedEntity == "result") {
|
|
|
|
url = (simpleView ? this.properties.searchLinkToResults : this.properties.searchLinkToAdvancedResults);
|
|
|
|
} else if (this.selectedEntity == "project") {
|
|
|
|
url = (simpleView ? this.properties.searchLinkToProjects : this.properties.searchLinkToAdvancedProjects);
|
|
|
|
} else if (this.selectedEntity == "dataprovider") {
|
|
|
|
url = (simpleView ? this.properties.searchLinkToDataProviders : this.properties.searchLinkToAdvancedDataProviders);
|
|
|
|
} else if (this.selectedEntity == "organization") {
|
|
|
|
url = (simpleView ? this.properties.searchLinkToOrganizations : this.properties.searchLinkToAdvancedOrganizations);
|
|
|
|
}
|
2020-06-29 15:15:52 +02:00
|
|
|
} else {
|
2020-03-03 15:32:43 +01:00
|
|
|
url = (simpleView ? this.properties.searchLinkToResults : this.properties.searchLinkToAdvancedResults);
|
2020-02-13 15:44:51 +01:00
|
|
|
}
|
|
|
|
return url;
|
|
|
|
}
|
2020-06-29 15:15:52 +02:00
|
|
|
|
|
|
|
toggle() {
|
|
|
|
if (this.matSelect) {
|
2020-04-22 15:00:13 +02:00
|
|
|
this.matSelect.toggle();
|
|
|
|
}
|
|
|
|
}
|
2020-06-29 15:15:52 +02:00
|
|
|
|
|
|
|
open() {
|
|
|
|
if (this.matSelect && !this.matSelect.focused) {
|
2020-04-22 15:00:13 +02:00
|
|
|
this.matSelect.open();
|
|
|
|
}
|
|
|
|
}
|
2020-06-29 15:15:52 +02:00
|
|
|
|
2020-02-13 15:44:51 +01:00
|
|
|
}
|