1 |
61381
|
k.triantaf
|
import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
|
2 |
|
|
import {FormBuilder} from "@angular/forms";
|
3 |
|
|
import {EnvProperties} from "../../utils/properties/env-properties";
|
4 |
|
|
import {SearchCustomFilter} from "./searchUtils.class";
|
5 |
|
|
import {ConfigurationService} from "../../utils/configuration/configuration.service";
|
6 |
|
|
import {Router} from "@angular/router";
|
7 |
|
|
import { MatSelect } from "@angular/material/select";
|
8 |
|
|
import {Subscription} from "rxjs";
|
9 |
|
|
import {properties} from '../../../../environments/environment';
|
10 |
|
|
|
11 |
|
|
@Component({
|
12 |
|
|
selector: 'entities-selection',
|
13 |
|
|
template: `
|
14 |
|
|
<span *ngIf="!disableSelect && show>1 && selectedEntity"
|
15 |
|
|
class=" entitiesSelection portal-box uk-text-small clickable" style=""
|
16 |
|
|
(click)="open()">
|
17 |
|
|
<mat-select *ngIf="!onlyresults" [(value)]="selectedEntity"
|
18 |
|
|
(valueChange)="entityChanged()" [disableOptionCentering]="true" [panelClass]="matPanelClass">
|
19 |
|
|
<mat-option *ngIf="simpleView && showAll"
|
20 |
|
|
value="all">All content
|
21 |
|
|
</mat-option>
|
22 |
|
|
<mat-option *ngIf="showResearchOutcomes" value="result">Research outcomes</mat-option>
|
23 |
|
|
<mat-option *ngIf="showProjects" value="project">Projects</mat-option>
|
24 |
|
|
<mat-option *ngIf="showDataProviders" value="dataprovider">Content providers</mat-option>
|
25 |
|
|
<mat-option *ngIf="showOrganizations" value="organization">Organizations</mat-option>
|
26 |
|
|
</mat-select>
|
27 |
|
|
<mat-select *ngIf="onlyresults" [(value)]="selectedEntity"
|
28 |
|
|
(valueChange)="entityChanged()" [disableOptionCentering]="true" [panelClass]="matPanelClass">
|
29 |
|
|
<mat-option
|
30 |
|
|
*ngIf="simpleView && showAll"
|
31 |
|
|
value="all">All research outcomes
|
32 |
|
|
</mat-option>
|
33 |
|
|
<mat-option *ngIf="showPublications" value="publications">Publications</mat-option>
|
34 |
|
|
<mat-option *ngIf="showDatasets" value="datasets">Datasets</mat-option>
|
35 |
|
|
<mat-option *ngIf="showSoftware" value="software">Software</mat-option>
|
36 |
|
|
<mat-option *ngIf="showOther" value="other">Other Research products</mat-option>
|
37 |
|
|
</mat-select>
|
38 |
|
|
|
39 |
|
|
</span>
|
40 |
|
|
<span *ngIf="currentEntity && disableSelect" class="entitiesSelection portal-box uk-text-small " style="">
|
41 |
|
|
<div>
|
42 |
|
|
<span *ngIf="currentEntity=='all'">{{onlyresults ? 'All research outcomes' : 'All content'}}</span>
|
43 |
|
|
<span *ngIf="currentEntity=='result'">Research outcomes</span>
|
44 |
|
|
<span *ngIf="currentEntity=='project'">Projects</span>
|
45 |
|
|
<span *ngIf="currentEntity=='dataprovider'">Content providers</span>
|
46 |
|
|
<span *ngIf="currentEntity=='organization'">Organizations</span>
|
47 |
|
|
<span *ngIf="currentEntity=='publications'">Publications</span>
|
48 |
|
|
<span *ngIf="currentEntity=='datasets'">Datasets</span>
|
49 |
|
|
<span *ngIf="currentEntity=='software'">Software</span>
|
50 |
|
|
<span *ngIf="currentEntity=='other'">Other Research products</span>
|
51 |
|
|
</div>
|
52 |
|
|
</span>
|
53 |
|
|
<!--<span *ngIf="onlyresults && !disableSelect">
|
54 |
|
|
<select *ngIf="show" [(ngModel)]="selectedEntity" class="uk-select uk-width-auto portal-box uk-text-small" (ngModelChange)="entityChanged()" >
|
55 |
|
|
<option
|
56 |
|
|
*ngIf="simpleView && (show)>1 && !(this.customFilter && this.customFilter.queryFieldName=='communityId' )"
|
57 |
|
|
value="all">All research outcomes
|
58 |
|
|
</option>
|
59 |
|
|
<option *ngIf="showPublications" value="publications">Publications</option>
|
60 |
|
|
<option *ngIf="showDatasets" value="datasets">Datasets</option>
|
61 |
|
|
<option *ngIf="showSoftware" value="software">Software</option>
|
62 |
|
|
<option *ngIf="showOther" value="other">Other Research products</option>
|
63 |
|
|
</select>
|
64 |
|
|
</span>-->
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
`
|
70 |
|
|
})
|
71 |
|
|
|
72 |
|
|
export class EntitiesSelectionComponent {
|
73 |
|
|
|
74 |
|
|
showResearchOutcomes: boolean = false;
|
75 |
|
|
showPublications: boolean = false;
|
76 |
|
|
showDatasets: boolean = false;
|
77 |
|
|
showSoftware: boolean = false;
|
78 |
|
|
showOther: boolean = false;
|
79 |
|
|
showProjects: boolean = false;
|
80 |
|
|
showDataProviders: boolean = false;
|
81 |
|
|
showOrganizations: boolean = false;
|
82 |
|
|
showAll: boolean = true;
|
83 |
|
|
@Input() allEnable = false;
|
84 |
|
|
@Input() properties: EnvProperties = properties;
|
85 |
|
|
@Input() customFilter: SearchCustomFilter = null;
|
86 |
|
|
@Input() @Output() selectedEntity = "Research Outcomes";
|
87 |
|
|
@Input() currentEntity = "Research Outcomes";
|
88 |
|
|
@Input() simpleView: boolean = true;
|
89 |
|
|
@Input() onChangeNavigate: boolean = true;
|
90 |
|
|
@Output() selectionChange = new EventEmitter();
|
91 |
|
|
@Input() onlyresults: boolean = false;
|
92 |
|
|
@Input() matPanelClass = "matSelectionPanel";
|
93 |
|
|
@Input() disableSelect: boolean = false;
|
94 |
|
|
show = 0;
|
95 |
|
|
@ViewChild(MatSelect) matSelect: MatSelect;
|
96 |
|
|
|
97 |
|
|
subs: Subscription[] = [];
|
98 |
|
|
|
99 |
|
|
constructor(private _fb: FormBuilder, private config: ConfigurationService, private router: Router) {}
|
100 |
|
|
|
101 |
|
|
ngOnInit() {
|
102 |
|
|
this.show = 0;
|
103 |
|
|
if(!this.allEnable) {
|
104 |
|
|
if((this.customFilter && this.customFilter.queryFieldName == "communityId") || (this.properties.adminToolsCommunity !== "monitor")) {
|
105 |
|
|
//this.config.getCommunityInformation(this.properties, (this.customFilter && this.customFilter.queryFieldName == "communityId") ? this.customFilter.valueId : this.properties.adminToolsCommunity).subscribe(data => {
|
106 |
|
|
this.subs.push(this.config.communityInformationState.subscribe(data => {
|
107 |
|
|
if(data) {
|
108 |
|
|
let showEntity = {};
|
109 |
|
|
let showPage = {};
|
110 |
|
|
if(data['entities']) {
|
111 |
|
|
for (let i = 0; i < data['entities'].length; i++) {
|
112 |
|
|
|
113 |
|
|
showEntity["" + data['entities'][i]["pid"] + ""] = data['entities'][i]["isEnabled"];
|
114 |
|
|
}
|
115 |
|
|
}
|
116 |
|
|
if(data['pages']) {
|
117 |
|
|
for (let i = 0; i < data['pages'].length; i++) {
|
118 |
|
|
showPage["" + data['pages'][i]["route"] + ""] = data['pages'][i]["isEnabled"];
|
119 |
|
|
}
|
120 |
|
|
}
|
121 |
|
|
this.showResearchOutcomes = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && (showEntity["publication"] || showEntity["dataset"] || showEntity["software"] || showEntity["orp"]);
|
122 |
|
|
this.showPublications = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && showEntity["publication"];
|
123 |
|
|
this.showDatasets = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && showEntity["dataset"];
|
124 |
|
|
this.showSoftware = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && showEntity["software"];
|
125 |
|
|
this.showOther = showPage[this.simpleView?this.properties.searchLinkToResults:this.properties.searchLinkToAdvancedResults] && showEntity["orp"];
|
126 |
|
|
this.showProjects = showPage[this.simpleView?this.properties.searchLinkToProjects:this.properties.searchLinkToAdvancedProjects] && showEntity["project"];
|
127 |
|
|
this.showOrganizations = showPage[this.simpleView?this.properties.searchLinkToOrganizations:this.properties.searchLinkToAdvancedOrganizations] && showEntity["organization"];
|
128 |
|
|
this.showDataProviders = showPage[this.simpleView?this.properties.searchLinkToDataProviders:this.properties.searchLinkToAdvancedDataProviders] && showEntity["datasource"];
|
129 |
|
|
if (this.customFilter && this.customFilter.queryFieldName == "communityId" || this.properties.adminToolsCommunity === "connect") {
|
130 |
|
|
//for community pages: no organization in simple search, only results in advanced
|
131 |
|
|
this.showAll = false;
|
132 |
|
|
this.showOrganizations = false;
|
133 |
|
|
if (!this.simpleView) {
|
134 |
|
|
this.showProjects = false;
|
135 |
|
|
this.showDataProviders = false;
|
136 |
|
|
}
|
137 |
|
|
}
|
138 |
|
|
if (this.showResearchOutcomes) {
|
139 |
|
|
this.show++;
|
140 |
|
|
}
|
141 |
|
|
if (this.showDataProviders) {
|
142 |
|
|
this.show++;
|
143 |
|
|
}
|
144 |
|
|
if (this.showOrganizations) {
|
145 |
|
|
this.show++;
|
146 |
|
|
}
|
147 |
|
|
if (this.showProjects) {
|
148 |
|
|
this.show++;
|
149 |
|
|
}
|
150 |
|
|
if (this.show == 1) {
|
151 |
|
|
this.disableSelect = true;
|
152 |
|
|
}
|
153 |
|
|
}
|
154 |
|
|
}));
|
155 |
|
|
} else if((this.customFilter && this.customFilter.queryFieldName == "community") && this.properties.adminToolsCommunity === "monitor") {
|
156 |
|
|
this.show = 1;
|
157 |
|
|
this.disableSelect = true;
|
158 |
|
|
} else if(this.customFilter && (this.customFilter.queryFieldName == "relfunder" || this.customFilter.queryFieldName == "funder")) {
|
159 |
|
|
/*this.showResearchOutcomes = true;
|
160 |
|
|
this.showPublications = true;
|
161 |
|
|
this.showDatasets = true;
|
162 |
|
|
this.showSoftware = true;
|
163 |
|
|
this.showOther = true;
|
164 |
|
|
this.showProjects = true;
|
165 |
|
|
this.showAll = false;
|
166 |
|
|
this.show = 2;*/
|
167 |
|
|
this.show = 1;
|
168 |
|
|
this.disableSelect = true;
|
169 |
|
|
} else if(this.customFilter && this.customFilter.queryFieldName == "relorganizationid") {
|
170 |
|
|
/*this.showResearchOutcomes = true;
|
171 |
|
|
this.showPublications = true;
|
172 |
|
|
this.showDatasets = true;
|
173 |
|
|
this.showSoftware = true;
|
174 |
|
|
this.showOther = true;
|
175 |
|
|
this.showProjects = true;
|
176 |
|
|
this.showDataProviders = true;
|
177 |
|
|
this.showAll = false;
|
178 |
|
|
this.show = 3;*/
|
179 |
|
|
this.show = 1;
|
180 |
|
|
this.disableSelect = true;
|
181 |
|
|
} else {
|
182 |
|
|
this.showResearchOutcomes = true;
|
183 |
|
|
this.showPublications = true;
|
184 |
|
|
this.showDatasets = true;
|
185 |
|
|
this.showSoftware = true;
|
186 |
|
|
this.showOther = true;
|
187 |
|
|
this.showProjects = true;
|
188 |
|
|
this.showOrganizations = true;
|
189 |
|
|
this.showDataProviders = true;
|
190 |
|
|
this.showAll = false;
|
191 |
|
|
this.show = 4;
|
192 |
|
|
}
|
193 |
|
|
} else {
|
194 |
|
|
this.showResearchOutcomes = true;
|
195 |
|
|
this.showPublications = true;
|
196 |
|
|
this.showDatasets = true;
|
197 |
|
|
this.showSoftware = true;
|
198 |
|
|
this.showOther = true;
|
199 |
|
|
this.showProjects = true;
|
200 |
|
|
this.showOrganizations = true;
|
201 |
|
|
this.showDataProviders = true;
|
202 |
|
|
this.showAll = true;
|
203 |
|
|
this.show = 5;
|
204 |
|
|
}
|
205 |
|
|
this.selectedEntity = this.currentEntity;
|
206 |
|
|
this.selectionChange.emit({
|
207 |
|
|
entity: this.selectedEntity,
|
208 |
|
|
simpleUrl: this.getUrl(true),
|
209 |
|
|
advancedUrl: this.getUrl(false)
|
210 |
|
|
});
|
211 |
|
|
}
|
212 |
|
|
|
213 |
|
|
public ngOnDestroy() {
|
214 |
|
|
for (let sub of this.subs) {
|
215 |
|
|
sub.unsubscribe();
|
216 |
|
|
}
|
217 |
|
|
}
|
218 |
|
|
|
219 |
|
|
entityChanged() {
|
220 |
|
|
if (!this.simpleView || this.onChangeNavigate) {
|
221 |
|
|
this.router.navigate([this.getUrl(this.simpleView)], {queryParams: this.customFilter?this.customFilter.getParameters():{}});
|
222 |
|
|
} else {
|
223 |
|
|
this.selectionChange.emit({
|
224 |
|
|
entity: this.selectedEntity,
|
225 |
|
|
simpleUrl: this.getUrl(true),
|
226 |
|
|
advancedUrl: this.getUrl(false)
|
227 |
|
|
});
|
228 |
|
|
}
|
229 |
|
|
|
230 |
|
|
}
|
231 |
|
|
|
232 |
|
|
getUrl(simpleView: boolean) {
|
233 |
|
|
let url = "";
|
234 |
|
|
if (!this.onlyresults) {
|
235 |
|
|
if (this.selectedEntity == "all") {
|
236 |
|
|
url = (simpleView ? "/search/find/" : null);
|
237 |
|
|
} else if (this.selectedEntity == "result") {
|
238 |
|
|
url = (simpleView ? this.properties.searchLinkToResults : this.properties.searchLinkToAdvancedResults);
|
239 |
|
|
} else if (this.selectedEntity == "project") {
|
240 |
|
|
url = (simpleView ? this.properties.searchLinkToProjects : this.properties.searchLinkToAdvancedProjects);
|
241 |
|
|
} else if (this.selectedEntity == "dataprovider") {
|
242 |
|
|
url = (simpleView ? this.properties.searchLinkToDataProviders : this.properties.searchLinkToAdvancedDataProviders);
|
243 |
|
|
} else if (this.selectedEntity == "organization") {
|
244 |
|
|
url = (simpleView ? this.properties.searchLinkToOrganizations : this.properties.searchLinkToAdvancedOrganizations);
|
245 |
|
|
}
|
246 |
|
|
} else {
|
247 |
|
|
url = (simpleView ? this.properties.searchLinkToResults : this.properties.searchLinkToAdvancedResults);
|
248 |
|
|
}
|
249 |
|
|
return url;
|
250 |
|
|
}
|
251 |
|
|
|
252 |
|
|
toggle() {
|
253 |
|
|
if (this.matSelect) {
|
254 |
|
|
this.matSelect.toggle();
|
255 |
|
|
}
|
256 |
|
|
}
|
257 |
|
|
|
258 |
|
|
open() {
|
259 |
|
|
if (this.matSelect && !this.matSelect.focused) {
|
260 |
|
|
this.matSelect.open();
|
261 |
|
|
}
|
262 |
|
|
}
|
263 |
|
|
|
264 |
|
|
}
|