1
|
import {Component, Input,Output, EventEmitter, ViewChild} from '@angular/core';
|
2
|
import {Observable} from 'rxjs/Observable';
|
3
|
import { Router} from '@angular/router';
|
4
|
import {ContextsService} from './service/contexts.service';
|
5
|
import {ClaimContext} from './claimEntities.class';
|
6
|
import { StaticAutoCompleteComponent } from '../../utils/staticAutoComplete/staticAutoComplete.component';
|
7
|
declare var UIkit:any;
|
8
|
import {Session} from '../../login/utils/helper.class';
|
9
|
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
|
10
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
11
|
|
12
|
@Component({
|
13
|
// moduleId: module.id,
|
14
|
selector: 'claim-contexts-search-form',
|
15
|
template: `
|
16
|
<div [class]="((inlineClaim)?'':' uk-card uk-card-default uk-padding uk-padding-medium ')+ 'uk-animation' " >
|
17
|
<!--div class="uk-text-lead">Select community:</div>
|
18
|
<div clas="uk-margin-left">
|
19
|
<div *ngIf="selectedCommunityId" >
|
20
|
<div class="uk-text-bold">My community:</div>
|
21
|
<div class="uk-margin-left">
|
22
|
<span>
|
23
|
{{selectedCommunityLabel}}
|
24
|
</span>
|
25
|
<a *ngIf="!isSelected(selectedCommunityId)" (click)="addNewContext(selectedCommunityLabel,null,{'id':selectedCommunityId, 'label':selectedCommunityLabel})" class="uk-icon-button icon-button-small uk-icon">
|
26
|
<span class="uk-icon">
|
27
|
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="plus" ratio="0.8"><rect x="9" y="1" width="1" height="17"></rect><rect x="1" y="9" width="17" height="1"></rect></svg>
|
28
|
</span> </a>
|
29
|
<span *ngIf="isSelected(selectedCommunityId)" class="uk-label uk-label-success uk-margin-small-top">Added</span>
|
30
|
</div>
|
31
|
</div>
|
32
|
<hr *ngIf="selectedCommunityId">
|
33
|
<div *ngIf="selectedCommunityId" class="uk-text-bold">Other communities:</div>
|
34
|
<div class="uk-child-width-1-3@m uk-margin-left uk-grid-match uk-grid">
|
35
|
<ng-container *ngFor="let community of communities">
|
36
|
<div *ngIf="community.id != selectedCommunityId">
|
37
|
<div>
|
38
|
<span>
|
39
|
{{community.label}}
|
40
|
</span>
|
41
|
<a *ngIf="!isSelected(community.id)" (click)="addNewContext(community.label,null,{'id':community.id, 'label':community.label})" class="uk-icon-button icon-button-small uk-icon">
|
42
|
<span class="uk-icon">
|
43
|
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="plus" ratio="0.8"><rect x="9" y="1" width="1" height="17"></rect><rect x="1" y="9" width="17" height="1"></rect></svg>
|
44
|
</span> </a>
|
45
|
<span *ngIf="isSelected(community.id)" class="uk-label uk-label-success uk-margin-small-top">Added</span>
|
46
|
</div>
|
47
|
</div>
|
48
|
</ng-container >
|
49
|
</div>
|
50
|
</div-->
|
51
|
|
52
|
<div class="uk-grid uk-margin-top uk-animation-fade">
|
53
|
<div class="uk-width-expand">
|
54
|
<!--div class="uk-text-lead">More options:</div-->
|
55
|
<div class="uk-text-large">Select a community <helper div="link-context-form" tooltip=true></helper> </div>
|
56
|
<select [(ngModel)]="selectedCommunityId" (ngModelChange)="communityChanged()" class="uk-margin-large-bottom uk-select uk-width-medium " name="select_funder" >
|
57
|
<option value="0" >Select community</option>
|
58
|
<option *ngFor="let community of communities" [value]="community.id" >{{community.label}}</option>
|
59
|
</select>
|
60
|
<div class="uk-text-large">and then</div>
|
61
|
<div class=" uk-margin-left uk-margin-left">
|
62
|
<div class=" uk-text-bold">search for community concepts</div>
|
63
|
<table class="uk-margin-remove uk-width-1-1 uk-table uk-table-responsive" ><tr>
|
64
|
<tr>
|
65
|
<td *ngIf="selectedCommunityId != '0' && categories.length > 0" class="uk-width-medium">
|
66
|
<select [(ngModel)]="selectedCategoryId" (ngModelChange)="categoryChanged()" class="uk-select uk-width-medium " name="select_funder" >
|
67
|
<option value="0" >Select category</option>
|
68
|
<option *ngFor="let category of categories" [value]="category.id" >{{category.label}}</option>
|
69
|
</select>
|
70
|
</td><td >
|
71
|
<static-autocomplete [(properties)]=properties [(list)] = concepts [allowDuplicates]=true [showSelected]=false [placeHolderMessage] = "'Concept name'" title = "Concepts" [multipleSelections]=true (addItem) = "select($event)" > </static-autocomplete>
|
72
|
</td></tr>
|
73
|
|
74
|
</table>
|
75
|
</div>
|
76
|
<div *ngIf="loading" class="uk-alert uk-alert-primary" role="alert">Loading communities information...</div>
|
77
|
<div *ngIf="error" class="uk-alert uk-alert-warning" role="alert">An error occured while loading communities...</div>
|
78
|
<div class="uk-text-large ">or</div>
|
79
|
<div class=" uk-text-bold uk-margin-bottom uk-margin-left">browse through community categories:
|
80
|
<button uk-toggle="target: #browse; animation: uk-animation-fade" class="uk-button portal-button"> Browse </button>
|
81
|
</div>
|
82
|
<div class="uk-margin-left">
|
83
|
|
84
|
<div id="browse" class=" uk-margin-small">
|
85
|
<!--a uk-toggle="target: #browse; animation: uk-animation-fade" class="uk-float-right"><span class="uk-icon">
|
86
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="1"><path fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path></svg>
|
87
|
</span></a-->
|
88
|
<div *ngIf="selectedCommunityId =='0'" class="uk-alert uk-alert-warning" >Please select community first...</div>
|
89
|
<div *ngIf="selectedCommunityId !='0'" class="uk-panel uk-panel-scrollable">
|
90
|
<ul class="uk-list ">
|
91
|
<li>
|
92
|
<span (click)="displaySubcategory(selectedCommunityId)" >
|
93
|
<span *ngIf="!conceptsClassDisplay[selectedCommunityId]" class="uk-icon"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="1"> <polygon points="8 5 13 10 8 15"></polygon></svg></span>
|
94
|
|
95
|
<span *ngIf="conceptsClassDisplay[selectedCommunityId]" class="uk-icon">
|
96
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="1"> <polygon points="5 7 15 7 10 12"></polygon></svg></span>{{selectedCommunityLabel}}
|
97
|
</span>
|
98
|
<a *ngIf="!isSelected(selectedCommunityId)" (click)="addNewContext(selectedCommunityLabel,null,{'id':selectedCommunityId, 'label':selectedCommunityLabel})" class="uk-icon-button icon-button-small uk-icon">
|
99
|
<span class="uk-icon">
|
100
|
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="plus" ratio="0.8"><rect x="9" y="1" width="1" height="17"></rect><rect x="1" y="9" width="17" height="1"></rect></svg>
|
101
|
</span> </a>
|
102
|
<span *ngIf="isSelected(selectedCommunityId)" class="uk-label uk-label-success uk-margin-small-top">Added</span>
|
103
|
<ul *ngIf="conceptsClassDisplay[selectedCommunityId]" class="uk-animation-fade" >
|
104
|
<li *ngFor="let category of categories" >
|
105
|
<span (click)="browseConcepts(category.id)" >
|
106
|
<span *ngIf="!conceptsClassDisplay[category.id]" class="uk-icon"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="1"> <polygon points="8 5 13 10 8 15"></polygon></svg></span>
|
107
|
|
108
|
<span *ngIf="conceptsClassDisplay[category.id]" class="uk-icon">
|
109
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="1"> <polygon points="5 7 15 7 10 12"></polygon></svg></span>
|
110
|
{{category.label}}</span><a *ngIf="!isSelected(category.id)" (click)="addNewContext(selectedCommunityLabel,category.label,{'id':category.id, 'label':category.label})" class="uk-icon-button icon-button-small" >
|
111
|
<span class="uk-icon">
|
112
|
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="plus" ratio="0.8"><rect x="9" y="1" width="1" height="17"></rect><rect x="1" y="9" width="17" height="1"></rect></svg>
|
113
|
</span></a>
|
114
|
<span *ngIf="isSelected(category.id)" class="uk-label uk-label-success uk-margin-small-top">Added</span>
|
115
|
<div *ngIf="conceptsCategoryLoading[category.id]" class="uk-alert uk-alert-primary" role="alert">Loading category information...</div>
|
116
|
|
117
|
<ul *ngIf="conceptsClass[category.id] && conceptsClassDisplay[category.id]" class="uk-list uk-animation-fade" id="ul_{{category.id}}" >
|
118
|
<li *ngFor="let concept1 of conceptsClass[category.id]" >
|
119
|
<span (click)="displaySubcategory(concept1.id)" >
|
120
|
<span *ngIf="!conceptsClassDisplay[concept1.id] && concept1.concepts" class="uk-icon"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="1"> <polygon points="8 5 13 10 8 15"></polygon></svg></span>
|
121
|
|
122
|
<span *ngIf="conceptsClassDisplay[concept1.id] && concept1.concepts" class="uk-icon">
|
123
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="1"> <polygon points="5 7 15 7 10 12"></polygon></svg></span>
|
124
|
{{concept1.label}}
|
125
|
</span>
|
126
|
<a *ngIf="!isSelected(concept1.id)" (click)="addNewContext(selectedCommunityLabel,category.label,concept1)" class="uk-icon-button icon-button-small"><span class="uk-icon">
|
127
|
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="plus" ratio="0.8"><rect x="9" y="1" width="1" height="17"></rect><rect x="1" y="9" width="17" height="1"></rect></svg>
|
128
|
</span></a>
|
129
|
<span *ngIf="isSelected(concept1.id)" class="uk-label uk-label-success uk-margin-small-top">Added</span>
|
130
|
<ul *ngIf="concept1.concepts && conceptsClassDisplay[concept1.id] " class="uk-animation-fade" >
|
131
|
<li *ngFor="let concept2 of concept1.concepts"><span (click)="displaySubcategory(concept2.id)" >
|
132
|
<span *ngIf="!conceptsClassDisplay[concept2.id] && concept2.concepts" class="uk-icon"><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="1"> <polygon points="8 5 13 10 8 15"></polygon></svg></span>
|
133
|
|
134
|
<span *ngIf="conceptsClassDisplay[concept2.id] && concept2.concepts" class="uk-icon">
|
135
|
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="1"> <polygon points="5 7 15 7 10 12"></polygon></svg></span>
|
136
|
{{concept2.label}}</span>
|
137
|
<a *ngIf="!isSelected(concept2.id)" (click)="addNewContext(selectedCommunityLabel,category.label,concept2)" class="uk-icon-button icon-button-small"><span class="uk-icon">
|
138
|
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="plus" ratio="0.8"><rect x="9" y="1" width="1" height="17"></rect><rect x="1" y="9" width="17" height="1"></rect></svg>
|
139
|
</span></a>
|
140
|
<span *ngIf="isSelected(concept2.id)" class="uk-label uk-label-success uk-margin-small-top">Added</span>
|
141
|
<ul *ngIf="concept2.concepts && conceptsClassDisplay[concept2.id] " class="uk-animation-fade" >
|
142
|
<li *ngFor="let concept3 of concept2.concepts">{{concept3.label}}
|
143
|
<a *ngIf="!isSelected(concept3.id)" (click)="addNewContext(selectedCommunityLabel,category.label,concept3)" class="uk-icon-button icon-button-small"><span class="uk-icon">
|
144
|
<svg width="16" height="16" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="plus" ratio="0.8"><rect x="9" y="1" width="1" height="17"></rect><rect x="1" y="9" width="17" height="1"></rect></svg>
|
145
|
</span></a>
|
146
|
<span *ngIf="isSelected(concept3.id)" class="uk-label uk-label-success uk-margin-small-top">Added</span>
|
147
|
</li>
|
148
|
</ul>
|
149
|
</li>
|
150
|
</ul>
|
151
|
</li>
|
152
|
</ul>
|
153
|
</li>
|
154
|
</ul>
|
155
|
</ul>
|
156
|
</div>
|
157
|
</div>
|
158
|
</div>
|
159
|
<div *ngIf="warningMessage.length > 0" class="uk-alert uk-alert-warning" role="alert">{{warningMessage}}</div>
|
160
|
<div *ngIf="infoMessage.length > 0" class="uk-alert uk-alert-primary" role="alert">{{infoMessage}}</div>
|
161
|
</div>
|
162
|
|
163
|
</div>
|
164
|
<!--a *ngIf="simpleView" class="uk-float-right " (click)="simpleView=!simpleView">More options <span class="uk-icon">
|
165
|
<svg height="20" icon="chevron-right" ratio="1" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"><polyline fill="none" points="7 4 13 10 7 16" stroke="#000" stroke-width="1.03"></polyline></svg>
|
166
|
</span>
|
167
|
</a>
|
168
|
<a *ngIf="!simpleView" class="uk-float-right " (click)="simpleView=!simpleView">Less options <span class="uk-icon">
|
169
|
<svg height="20" icon="chevron-right" ratio="1" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"><polyline fill="none" points="7 4 13 10 7 16" stroke="#000" stroke-width="1.03"></polyline></svg>
|
170
|
</span>
|
171
|
</a-->
|
172
|
|
173
|
</div>
|
174
|
|
175
|
`
|
176
|
|
177
|
})
|
178
|
export class ClaimContextSearchFormComponent {
|
179
|
// @Input() public inline:boolean = false ; // for claimed started from landing pages
|
180
|
public showComponent:boolean = true ; // for claimed started from landing pages
|
181
|
@Input() public selectedList;
|
182
|
//The following need to be kept in case we have to save the current state
|
183
|
@Input() public projects;
|
184
|
@Input() public results;
|
185
|
@Input() public inlineEntity;
|
186
|
@Input() public properties:EnvProperties;
|
187
|
@Input() communityId:string= null;
|
188
|
@Input() public inlineClaim:boolean=false;
|
189
|
|
190
|
public selectedCommunityId:string = "0";
|
191
|
public selectedCategoryId:string ="0";
|
192
|
// @Output() contextSelected = new EventEmitter();
|
193
|
|
194
|
@ViewChild (StaticAutoCompleteComponent) autocomplete : StaticAutoCompleteComponent ;
|
195
|
|
196
|
public query = '';
|
197
|
public filteredList = [];
|
198
|
public communities:any;
|
199
|
public selectedCommunityLabel:string = "Community:";
|
200
|
|
201
|
public categories:any;
|
202
|
public selectedCategoryLabel:string ="Category:";
|
203
|
public concepts = [];
|
204
|
public conceptsClass = [];
|
205
|
public conceptsClassDisplay = [];
|
206
|
public conceptsCategoryLoading = [];
|
207
|
public warningMessage = "";
|
208
|
public infoMessage = "";
|
209
|
public loading:boolean = false;
|
210
|
public error:boolean = false;
|
211
|
public simpleView:boolean = true;
|
212
|
@Input() localStoragePrefix:string = "";
|
213
|
|
214
|
ngOnInit() {
|
215
|
this.getCommunities();
|
216
|
}
|
217
|
constructor(private _contextService: ContextsService,private router: Router) {
|
218
|
|
219
|
}
|
220
|
|
221
|
select($event){
|
222
|
var item = $event.value;
|
223
|
this.addNewContext( this.selectedCommunityLabel, this.selectedCategoryLabel, item);
|
224
|
}
|
225
|
isSelected(id):boolean{
|
226
|
for (var _i = 0; _i < this.selectedList.length; _i++) {
|
227
|
let item = this.selectedList[_i];
|
228
|
if(item.concept.id == id){
|
229
|
return true;
|
230
|
// this.warningMessage = "Concept already in selected list";
|
231
|
}
|
232
|
}
|
233
|
return false;
|
234
|
}
|
235
|
addNewContext(community,category,concept, notify=true){
|
236
|
if(this.selectedList.length > 50){
|
237
|
UIkit.notification({
|
238
|
message : 'Your basket exceeds the number of allowed concepts (50)',
|
239
|
status : 'warning',
|
240
|
timeout : 1500,
|
241
|
pos : 'top-center'
|
242
|
});
|
243
|
return;
|
244
|
}
|
245
|
var context: ClaimContext= { community: community, category: category, concept: concept };
|
246
|
var found:boolean = false;
|
247
|
this.warningMessage = "";
|
248
|
if (!this.isSelected(context.concept.id)) {
|
249
|
|
250
|
this.selectedList.push(context);
|
251
|
if(notify){
|
252
|
UIkit.notification({
|
253
|
message : 'A new concept added in your basket.',
|
254
|
status : 'primary',
|
255
|
timeout : 1500,
|
256
|
pos : 'top-center'
|
257
|
});
|
258
|
}
|
259
|
localStorage.setItem(this.localStoragePrefix + "contexts", JSON.stringify(this.selectedList));
|
260
|
}else{
|
261
|
if(notify){
|
262
|
UIkit.notification({
|
263
|
message : 'The concept is already in your basket.',
|
264
|
status : 'warning',
|
265
|
timeout : 1500,
|
266
|
pos : 'top-center'
|
267
|
});
|
268
|
}
|
269
|
}
|
270
|
}
|
271
|
|
272
|
getCommunities () {
|
273
|
if(!Session.isLoggedIn()){
|
274
|
this.saveStateAndRedirectLogin();
|
275
|
|
276
|
}else{
|
277
|
this.loading = true;
|
278
|
this._contextService.getCommunities(this.properties.contextsAPI).subscribe(
|
279
|
data => {
|
280
|
this.communities = data;
|
281
|
if(this.communities.length > 0){
|
282
|
this.communities.sort((n1,n2)=> n1.label > n2.label);
|
283
|
}
|
284
|
this.loading = false;
|
285
|
if(this.communityId != null){
|
286
|
//preselect community
|
287
|
this.selectedCommunityId = this.communityId;
|
288
|
this.communityChanged()
|
289
|
this.addNewContext(this.selectedCommunityLabel,null,{'id':this.selectedCommunityId, 'label':this.selectedCommunityLabel}, false)
|
290
|
|
291
|
}
|
292
|
},
|
293
|
err => {
|
294
|
console.log(err);
|
295
|
this.loading = false;
|
296
|
this.error = true;
|
297
|
}
|
298
|
);
|
299
|
}
|
300
|
}
|
301
|
getCategories () {
|
302
|
this.loading = true;
|
303
|
this.categories=[];
|
304
|
if(this.selectedCommunityId != '0'){
|
305
|
if(!Session.isLoggedIn()){
|
306
|
this.saveStateAndRedirectLogin();
|
307
|
|
308
|
}else{
|
309
|
this._contextService.getCategories(this.selectedCommunityId,this.properties.contextsAPI).subscribe(
|
310
|
data => {
|
311
|
|
312
|
this.categories =data;
|
313
|
this.concepts = [];
|
314
|
this.addCommunityInConcepts();
|
315
|
this.filteredList = [];
|
316
|
if (this.query !== ""){
|
317
|
var event = {value: ""};
|
318
|
event.value = this.query;
|
319
|
}
|
320
|
this.loading = false;
|
321
|
},
|
322
|
err => {
|
323
|
console.log(err);
|
324
|
this.loading = false;
|
325
|
}
|
326
|
);
|
327
|
}
|
328
|
}
|
329
|
}
|
330
|
getConcepts () {
|
331
|
this.loading = true;
|
332
|
if(this.selectedCategoryId != '0'){
|
333
|
if(!Session.isLoggedIn()){
|
334
|
this.saveStateAndRedirectLogin();
|
335
|
}else{
|
336
|
this.concepts = [];
|
337
|
|
338
|
this._contextService.getConcepts(this.selectedCategoryId, "",true, this.properties.contextsAPI).subscribe(
|
339
|
data => {
|
340
|
|
341
|
this.concepts =data;
|
342
|
console.log(data);
|
343
|
for(var i =0 ; i<data.length; i++){
|
344
|
if(data[i].hasSubConcept == true){
|
345
|
this.getSubConcepts(data[i].id);
|
346
|
}
|
347
|
}
|
348
|
this.addCommunityInConcepts();
|
349
|
if (this.query !== ""){
|
350
|
var event = {value: ""};
|
351
|
event.value = this.query;
|
352
|
// this.filter(event);
|
353
|
}
|
354
|
this.loading = false;
|
355
|
},
|
356
|
err => {
|
357
|
console.log(err);
|
358
|
this.loading = false;
|
359
|
}
|
360
|
);
|
361
|
}
|
362
|
}else{
|
363
|
this.concepts=[];
|
364
|
this.loading = false;
|
365
|
}
|
366
|
}
|
367
|
getSubConcepts (conceptId) {
|
368
|
this.loading = true;
|
369
|
if(this.selectedCategoryId != '0'){
|
370
|
if(!Session.isLoggedIn()){
|
371
|
this.saveStateAndRedirectLogin();
|
372
|
}else{
|
373
|
this._contextService.getSubConcepts(conceptId, "",true, this.properties.contextsAPI).subscribe(
|
374
|
data => {
|
375
|
console.log(data);
|
376
|
for(var i =0 ; i<data.length; i++){
|
377
|
this.concepts.push(data[i]);
|
378
|
}
|
379
|
|
380
|
if (this.query !== ""){
|
381
|
var event = {value: ""};
|
382
|
event.value = this.query;
|
383
|
// this.filter(event);
|
384
|
}
|
385
|
this.loading = false;
|
386
|
},
|
387
|
err => {
|
388
|
console.log(err);
|
389
|
this.loading = false;
|
390
|
}
|
391
|
);
|
392
|
}
|
393
|
}else{
|
394
|
this.concepts=[];
|
395
|
this.loading = false;
|
396
|
}
|
397
|
}
|
398
|
displaySubcategory(id) {
|
399
|
if(this.conceptsClassDisplay[id] != null){
|
400
|
this.conceptsClassDisplay[id] = !this.conceptsClassDisplay[id];
|
401
|
|
402
|
}else{
|
403
|
this.conceptsClassDisplay[id] = true;
|
404
|
}
|
405
|
}
|
406
|
browseConcepts (categoryId) {
|
407
|
if(!Session.isLoggedIn()){
|
408
|
this.saveStateAndRedirectLogin();
|
409
|
}else{
|
410
|
if(this.conceptsClass[categoryId] != null){
|
411
|
this.conceptsClassDisplay[categoryId] = !this.conceptsClassDisplay[categoryId];
|
412
|
return;
|
413
|
}else{
|
414
|
this.conceptsClassDisplay[categoryId] = true;
|
415
|
}
|
416
|
this.conceptsClass[categoryId] = [];
|
417
|
this.conceptsCategoryLoading[categoryId] = true;
|
418
|
this._contextService.getConcepts(categoryId, "",false, this.properties.contextsAPI).subscribe(
|
419
|
data => {
|
420
|
var concepts = data;
|
421
|
this.conceptsClass[categoryId] = [];
|
422
|
for(var i =0 ; i<data.length; i++){
|
423
|
if(data[i].hasSubConcept == true){
|
424
|
this.browseSubConcepts(categoryId, data[i].id);
|
425
|
}else{
|
426
|
this.conceptsClass[categoryId].push(data[i]);
|
427
|
}
|
428
|
}
|
429
|
this.conceptsCategoryLoading[categoryId] = false;
|
430
|
},
|
431
|
err => {
|
432
|
console.log(err);
|
433
|
this.conceptsCategoryLoading[categoryId] = false;
|
434
|
}
|
435
|
);
|
436
|
}
|
437
|
|
438
|
}
|
439
|
browseSubConcepts (categoryId, conceptId) {
|
440
|
|
441
|
this.conceptsCategoryLoading[categoryId] = true;
|
442
|
this._contextService.getSubConcepts(conceptId, "",false, this.properties.contextsAPI).subscribe(
|
443
|
data => {
|
444
|
var concepts = data[0];
|
445
|
this.conceptsClass[categoryId].push(concepts)
|
446
|
console.log("Data"+concepts);
|
447
|
|
448
|
|
449
|
|
450
|
console.log(this.conceptsClass[categoryId]);
|
451
|
this.conceptsCategoryLoading[categoryId] = false;
|
452
|
},
|
453
|
err => {
|
454
|
console.log(err);
|
455
|
this.conceptsCategoryLoading[categoryId] = false;
|
456
|
}
|
457
|
);
|
458
|
|
459
|
|
460
|
}
|
461
|
communityChanged(){
|
462
|
console.log(this.selectedCommunityId +" ");
|
463
|
this.warningMessage = "";
|
464
|
this.infoMessage = "";
|
465
|
for(var i = 0; i< this.communities.length; i++){
|
466
|
if(this.communities[i].id==this.selectedCommunityId){
|
467
|
this.selectedCommunityLabel = this.communities[i].label;
|
468
|
break;
|
469
|
}
|
470
|
}
|
471
|
this.selectedCategoryId = "0";
|
472
|
this.selectedCategoryLabel="Select Category:";
|
473
|
if(this.selectedCommunityId != "0"){
|
474
|
this.getCategories();
|
475
|
}
|
476
|
}
|
477
|
categoryChanged(){
|
478
|
this.warningMessage = "";
|
479
|
this.infoMessage = "";
|
480
|
for(var i = 0; i< this.categories.length; i++){
|
481
|
if(this.categories[i].id==this.selectedCategoryId){
|
482
|
this.selectedCategoryLabel = this.categories[i].label;
|
483
|
break;
|
484
|
}
|
485
|
}
|
486
|
this.getConcepts();
|
487
|
}
|
488
|
addCommunityInConcepts(){
|
489
|
this.concepts.push({"id":this.selectedCommunityId, "label":this.selectedCommunityLabel});
|
490
|
if(this.autocomplete){
|
491
|
this.autocomplete.updateList(this.concepts);
|
492
|
}
|
493
|
}
|
494
|
saveStateAndRedirectLogin(){
|
495
|
if(this.projects != null){
|
496
|
localStorage.setItem(this.localStoragePrefix + "projects", JSON.stringify(this.projects));
|
497
|
}
|
498
|
localStorage.setItem(this.localStoragePrefix + "contexts", JSON.stringify(this.selectedList));
|
499
|
if(this.results != null){
|
500
|
localStorage.setItem(this.localStoragePrefix + "results", JSON.stringify(this.results));
|
501
|
}
|
502
|
if(this.inlineEntity != null){
|
503
|
localStorage.setItem(this.localStoragePrefix + "inlineEntity", JSON.stringify(this.inlineEntity));
|
504
|
}
|
505
|
|
506
|
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url } });
|
507
|
}
|
508
|
}
|