{{onlyresults ? 'All research outcomes' : 'All content'}}
Research outcomes
Projects
Content providers
Organizations
Publications
Datasets
Software
Other Research products
`
})
export class EntitiesSelectionComponent {
showResearchOutcomes: boolean = false;
showPublications: boolean = false;
showDatasets: boolean = false;
showSoftware: boolean = false;
showOther: boolean = false;
showProjects: boolean = false;
showDataProviders: boolean = false;
showOrganizations: boolean = false;
showAll: boolean = true;
@Input() allEnable = false;
@Input() properties: EnvProperties = properties;
@Input() customFilter: SearchCustomFilter = null;
@Input() @Output() selectedEntity = "Research Outcomes";
@Input() currentEntity = "Research Outcomes";
@Input() simpleView: boolean = true;
@Input() onChangeNavigate: boolean = true;
@Output() selectionChange = new EventEmitter();
@Input() onlyresults: boolean = false;
@Input() matPanelClass = "matSelectionPanel";
@Input() disableSelect: boolean = false;
show = 0;
@ViewChild(MatSelect) matSelect: MatSelect;
subs: Subscription[] = [];
constructor(private _fb: FormBuilder, private config: ConfigurationService, private router: Router) {}
ngOnInit() {
this.show = 0;
if(!this.allEnable) {
if((this.customFilter && this.customFilter.queryFieldName == "communityId") || (this.properties.adminToolsCommunity !== "monitor")) {
//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 = {};
if(data['entities']) {
for (let i = 0; i < data['entities'].length; i++) {
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
}
}
if(data['pages']) {
for (let i = 0; i < data['pages'].length; i++) {
showPage["" + data['pages'][i]["route"] + ""] = data['pages'][i]["isEnabled"];
}
}
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;
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;
}
}
}));
} else if((this.customFilter && this.customFilter.queryFieldName == "community") && this.properties.adminToolsCommunity === "monitor") {
this.show = 1;
this.disableSelect = true;
} else if(this.customFilter && (this.customFilter.queryFieldName == "relfunder" || this.customFilter.queryFieldName == "funder")) {
/*this.showResearchOutcomes = true;
this.showPublications = true;
this.showDatasets = true;
this.showSoftware = true;
this.showOther = true;
this.showProjects = true;
this.showAll = false;
this.show = 2;*/
this.show = 1;
this.disableSelect = true;
} else if(this.customFilter && this.customFilter.queryFieldName == "relorganizationid") {
/*this.showResearchOutcomes = true;
this.showPublications = true;
this.showDatasets = true;
this.showSoftware = true;
this.showOther = true;
this.showProjects = true;
this.showDataProviders = true;
this.showAll = false;
this.show = 3;*/
this.show = 1;
this.disableSelect = true;
} 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;
}
} 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 = true;
this.show = 5;
}
this.selectedEntity = this.currentEntity;
this.selectionChange.emit({
entity: this.selectedEntity,
simpleUrl: this.getUrl(true),
advancedUrl: this.getUrl(false)
});
}
public ngOnDestroy() {
for (let sub of this.subs) {
sub.unsubscribe();
}
}
entityChanged() {
if (!this.simpleView || this.onChangeNavigate) {
this.router.navigate([this.getUrl(this.simpleView)], {queryParams: this.customFilter?this.customFilter.getParameters():{}});
} else {
this.selectionChange.emit({
entity: this.selectedEntity,
simpleUrl: this.getUrl(true),
advancedUrl: this.getUrl(false)
});
}
}
getUrl(simpleView: boolean) {
let url = "";
if (!this.onlyresults) {
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);
}
} else {
url = (simpleView ? this.properties.searchLinkToResults : this.properties.searchLinkToAdvancedResults);
}
return url;
}
toggle() {
if (this.matSelect) {
this.matSelect.toggle();
}
}
open() {
if (this.matSelect && !this.matSelect.focused) {
this.matSelect.open();
}
}
}