Project

General

Profile

1
import {Component, Input,Output, EventEmitter, ViewChild} from '@angular/core';
2
import {Observable}       from 'rxjs';
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.getPublicCommunities(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.handleError("Error getting communities", err);
296
        this.loading = false;
297
        this.error = true;
298
      }
299
    );
300
  }
301
 }
302
 getCategories ()  {
303
   this.loading = true;
304
   this.categories=[];
305
   if(this.selectedCommunityId != '0'){
306
     if(!Session.isLoggedIn()){
307
       this.saveStateAndRedirectLogin();
308

    
309
     }else{
310
       this._contextService.getCategories(this.selectedCommunityId,this.properties.contextsAPI).subscribe(
311
         data => {
312

    
313
           this.categories =data;
314
           this.concepts = [];
315
           this.addCommunityInConcepts();
316
           this.filteredList = [];
317
           if (this.query !== ""){
318
             var event = {value: ""};
319
             event.value = this.query;
320
           }
321
           this.loading = false;
322
          },
323
         err => {
324
           //console.log(err);
325
           this.handleError("Error getting categories for community with id: "+this.selectedCommunityId, err);
326
           this.loading = false;
327
         }
328
       );
329
     }
330
   }
331
  }
332
  getConcepts ()  {
333
    this.loading = true;
334
    if(this.selectedCategoryId != '0'){
335
      if(!Session.isLoggedIn()){
336
        this.saveStateAndRedirectLogin();
337
      }else{
338
        this.concepts = [];
339

    
340
        this._contextService.getConcepts(this.selectedCategoryId, "",true, this.properties.contextsAPI).subscribe(
341
          data => {
342

    
343
            this.concepts =data;
344
              for(var i =0 ; i<data.length; i++){
345
                if(data[i].hasSubConcept == true){
346
                  this.getSubConcepts(data[i].id);
347
                }
348
              }
349
            this.addCommunityInConcepts();
350
            if (this.query !== ""){
351
              var event = {value: ""};
352
              event.value = this.query;
353
              //  this.filter(event);
354
             }
355
             this.loading = false;
356
           },
357
          err => {
358
            //console.log(err);
359
            this.handleError("Error getting concepts for category with id: "+this.selectedCategoryId, err);
360
            this.loading = false;
361
          }
362
        );
363
      }
364
    }else{
365
      this.concepts=[];
366
      this.loading = false;
367
    }
368
   }
369
   getSubConcepts (conceptId)  {
370
     this.loading = true;
371
     if(this.selectedCategoryId != '0'){
372
       if(!Session.isLoggedIn()){
373
         this.saveStateAndRedirectLogin();
374
       }else{
375
         this._contextService.getSubConcepts(conceptId, "",true, this.properties.contextsAPI).subscribe(
376
           data => {
377
               for(var i =0 ; i<data.length; i++){
378
                 this.concepts.push(data[i]);
379
               }
380

    
381
             if (this.query !== ""){
382
               var event = {value: ""};
383
               event.value = this.query;
384
               //  this.filter(event);
385
              }
386
              this.loading = false;
387
            },
388
           err => {
389
             //console.log(err);
390
             this.handleError("Error getting subconcepts for concept with id: "+conceptId, err);
391
             this.loading = false;
392
           }
393
         );
394
       }
395
     }else{
396
       this.concepts=[];
397
       this.loading = false;
398
     }
399
    }
400
   displaySubcategory(id)  {
401
     if(this.conceptsClassDisplay[id] != null){
402
       this.conceptsClassDisplay[id] = !this.conceptsClassDisplay[id];
403

    
404
     }else{
405
       this.conceptsClassDisplay[id] = true;
406
     }
407
   }
408
   browseConcepts (categoryId)  {
409
       if(!Session.isLoggedIn()){
410
         this.saveStateAndRedirectLogin();
411
       }else{
412
         if(this.conceptsClass[categoryId] != null){
413
           this.conceptsClassDisplay[categoryId] = !this.conceptsClassDisplay[categoryId];
414
           return;
415
         }else{
416
           this.conceptsClassDisplay[categoryId] = true;
417
         }
418
         this.conceptsClass[categoryId] = [];
419
         this.conceptsCategoryLoading[categoryId] = true;
420
         this._contextService.getConcepts(categoryId, "",false, this.properties.contextsAPI).subscribe(
421
           data => {
422
            var concepts = data;
423
              this.conceptsClass[categoryId] = [];
424
              for(var i =0 ; i<data.length; i++){
425
                  if(data[i].hasSubConcept == true){
426
                    this.browseSubConcepts(categoryId, data[i].id);
427
                  }else{
428
                    this.conceptsClass[categoryId].push(data[i]);
429
                  }
430
              }
431
               this.conceptsCategoryLoading[categoryId] = false;
432
            },
433
           err => {
434
             //console.log(err);
435
             this.handleError("Error getting concepts for category with id: "+this.selectedCategoryId, err);
436
             this.conceptsCategoryLoading[categoryId] = false;
437
           }
438
         );
439
       }
440

    
441
    }
442
    browseSubConcepts (categoryId, conceptId)  {
443

    
444
          this.conceptsCategoryLoading[categoryId] = true;
445
          this._contextService.getSubConcepts(conceptId, "",false, this.properties.contextsAPI).subscribe(
446
            data => {
447
             var concepts = data[0];
448
                this.conceptsClass[categoryId].push(concepts)
449

    
450

    
451

    
452
              this.conceptsCategoryLoading[categoryId] = false;
453
             },
454
            err => {
455
              //console.log(err);
456
              this.handleError("Error getting subconcepts for concept with id: "+conceptId, err);
457
              this.conceptsCategoryLoading[categoryId] = false;
458
            }
459
          );
460

    
461

    
462
     }
463
  communityChanged(){
464
    this.warningMessage = "";
465
    this.infoMessage = "";
466
    for(var i = 0; i< this.communities.length; i++){
467
      if(this.communities[i].id==this.selectedCommunityId){
468
        this.selectedCommunityLabel = this.communities[i].label;
469
        break;
470
      }
471
    }
472
    this.selectedCategoryId = "0";
473
    this.selectedCategoryLabel="Select Category:";
474
    if(this.selectedCommunityId != "0"){
475
      this.getCategories();
476
    }
477
  }
478
  categoryChanged(){
479
    this.warningMessage = "";
480
    this.infoMessage = "";
481
    for(var i = 0; i< this.categories.length; i++){
482
      if(this.categories[i].id==this.selectedCategoryId){
483
        this.selectedCategoryLabel = this.categories[i].label;
484
        break;
485
      }
486
    }
487
      this.getConcepts();
488
  }
489
addCommunityInConcepts(){
490
  this.concepts.push({"id":this.selectedCommunityId, "label":this.selectedCommunityLabel});
491
  if(this.autocomplete){
492
    this.autocomplete.updateList(this.concepts);
493
  }
494
}
495
saveStateAndRedirectLogin(){
496
  if(this.projects != null){
497
   localStorage.setItem(this.localStoragePrefix + "projects", JSON.stringify(this.projects));
498
 }
499
 localStorage.setItem(this.localStoragePrefix + "contexts", JSON.stringify(this.selectedList));
500
 if(this.results != null){
501
   localStorage.setItem(this.localStoragePrefix + "results", JSON.stringify(this.results));
502
 }
503
 if(this.inlineEntity != null){
504
   localStorage.setItem(this.localStoragePrefix + "inlineEntity", JSON.stringify(this.inlineEntity));
505
 }
506

    
507
  this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl":  this.router.url } });
508
}
509

    
510
  private handleError(message: string, error) {
511
      console.error("Claim context search form (component): "+message, error);
512
  }
513
}
(2-2/12)