Project

General

Profile

« Previous | Next » 

Revision 44421

Publication page & project PAge: add claim result inline, fix claim context - use autocomplete component, in home page add keyword to the url when user searches for a term

View differences:

modules/uoa-services-portal/trunk/portal-2/src/app/utils/staticAutoComplete2.component.ts
41 41
export class StaticAutocomplete2Component {
42 42
    @Input() placeHolderMessage = "Search for entries";
43 43
    @Input() title = "Autocomplete";
44
    @Output() addItem = new EventEmitter(); // when selected list  changes update parent component
44 45
    @Output() selectedValueChanged = new EventEmitter(); // when changed  a method for filtering will be called
45 46
    @Output() listUpdated = new EventEmitter(); // when changed  a method for filtering will be called
46 47
    @Input() public list = []; // the entries resulted after filtering function
......
49 50
    @Input() public keywordlimit = 3; // the minimum length of keyword
50 51
    @Input() public showSelected = true; // the minimum length of keyword
51 52
    @Input() public multipleSelections:boolean = true;
53
    @Input() public allowDuplicates:boolean = false;
52 54
    @Input() public selectedValue:string = '';
53 55
    @Input() public vocabularyId:string ;
54 56
    @Input() public fieldName:string ;
......
71 73
      }
72 74
    }
73 75
    ngOnInit () {
76
      console.log("auto complete init : list length"+this.list.length);
77

  
74 78
      if(this.list == undefined || this.list.length == 0){
79

  
75 80
       if(this.vocabularyId){
76 81
        this.list = this._vocabulariesService.getVocabularyByType(this.vocabularyId, this.entityName);
77 82
        this.afterListFetchedActions();
......
90 95
        );
91 96
      }
92 97
    }else{
98
      console.log("auto complete init : list length"+this.list.length);
99

  
93 100
      this.afterListFetchedActions();
94 101
    }
95 102

  
96 103
    }
104
    public updateList(list){ // used in claim context autocomplete
105
      this.list = list;
106
      this.afterListFetchedActions()
107
    }
97 108
    private afterListFetchedActions(){
98 109
      this.getSelectedNameFromGivenId();
99 110
      this.listUpdated.emit({
100 111
          value: this.list
101 112
      });
102 113
      if(this.list == null || this.list.length == 0 ){
103
        this.warningMessage = "There are no results"
104
        return
114
        this.warningMessage = "There are no results";
115
        return;
105 116
      }
106 117
      this.done = true;
107 118
      if(this.keyword != ""){
108 119
        this.filter();
109 120
      }
121

  
110 122
    }
111 123
    filter() {
112 124
      if(this.done){
......
147 159
        this.selectedValueChanged.emit({
148 160
            value: this.selectedValue
149 161
        });
162

  
163

  
150 164
      }
151 165
    }
152 166
    select(item:any){
167
      // console.log("select"+this.selected.length  + item.id + " "+ item.label);
168

  
153 169
        if(this.multipleSelections){
154 170
          var index:number =this.checkIfExists(item,this.selected);
155
           if (index > -1) {
171
           if (index > -1 && !this.allowDuplicates) {
156 172
              this.keyword = "";
157 173
              this.filtered.splice(0, this.filtered.length);
158 174
              return;
......
161 177
              this.selected.push(item);
162 178
              this.keyword = "";
163 179
              this.filtered.splice(0, this.filtered.length);
180
              this.addItem.emit({
181
                  value: item
182
              });
164 183
          }
165 184
      }else{
166 185
        this.selected.splice(0, this.selected.length);
......
174 193
        });
175 194

  
176 195
      }
196
      console.log("selected"+this.selected.length  );
197

  
177 198
    }
178 199
    private checkIfExists(item:any,list):number{
179 200

  
modules/uoa-services-portal/trunk/portal-2/src/app/services/contexts.service.ts
4 4
import {Observable}     from 'rxjs/Observable';
5 5
import {Claim}           from '../utils/entities/claim';
6 6
import {OpenaireProperties} from '../utils/properties/openaireProperties';
7
import {AutoCompleteValue} from '../searchPages/searchUtils/searchHelperClasses.class';
7 8

  
8 9
@Injectable()
9 10
export class ContextsService {
......
33 34
    let url= this.baseUrl  + 'categories/' + categoryId+ "/concepts";
34 35
      return this.http.get( url)
35 36
                    .map(request => <any> request.json().data)
36
                    .do(request => console.info("Get claims: offset = " ))
37
                    .map(res => this.parse(res.concept))
38
                    .do(res => console.info(res ))
37 39
                    .catch(this.handleError);
38 40
  }
41
  parse (data: any):AutoCompleteValue[] {
42
      var array:AutoCompleteValue[] =[]
43
      for(var i = 0; i < data.length; i++){
44
        var value:AutoCompleteValue =  new AutoCompleteValue();
45
        value.id = data[i].id;
46
        value.label = data[i].label;
47
        array.push(value);
48
      }
39 49

  
50
      return array;
51

  
52
  }
53

  
40 54
  private handleError (error: Response) {
41 55
    // in a real world app, we may send the error to some remote logging infrastructure
42 56
    // instead of just logging it to the console
modules/uoa-services-portal/trunk/portal-2/src/app/claimPages/claim-utils/claimContext.component.ts
1
import {Component, Input,Output, ElementRef, EventEmitter} from '@angular/core';
1
import {Component, Input,Output, ElementRef, EventEmitter, ViewChild} from '@angular/core';
2 2
import {Observable}       from 'rxjs/Observable';
3 3
import {ContextsService} from '../../services/contexts.service';
4 4
import {ClaimContext} from '../../utils/entities/claimEntities.class';
5
import { StaticAutocomplete2Component } from '../../utils/staticAutoComplete2.component';
5 6

  
6

  
7 7
@Component({
8 8
    selector: 'claim-contexts',
9 9
    template: `
......
32 32

  
33 33
                </ul>
34 34
              </div>
35

  
36
            <!--input id="community" type="text" class="validate filter-input form-control" placeholder="Search for contexts" [(ngModel)]=query (keyup)=filter() -->
37

  
38

  
35
              <static-autocomplete2 [(list)] = concepts  [allowDuplicates]=true [showSelected]=false [placeHolderMessage] = "'Search for Concepts'" title = "Concepts:"  [multipleSelections]=true  (addItem) = "select($event)"></static-autocomplete2>
39 36
          </div>
40
          <static-autocomplete [(keyword)] = query  [(filtered)] =filteredList [(selected)] =selectedList [showSelected]=false placeHolderMessage = "Search for contexts" title = "Contexts:" (keywordChange)="filter(query)" type="context"></static-autocomplete>
41
        </div>
37
         </div>
42 38
        <div class="panel-body"   *ngIf=" inline && showComponent ">
43 39
          <div class=" form-horizontal">
44 40
          <div    class=" form-group ">
......
63 59

  
64 60
              </ul>
65 61
            </div>
66
            <!--div class="form-group">
67
              <input id="community" type="text" class="validate filter-input input-sm form-control" placeholder="Search for contexts" [(ngModel)]=query (keyup)=filter()   >
68
            </div-->
62
            <static-autocomplete2 [(list)] = concepts  [allowDuplicates]=true [showSelected]=false [placeHolderMessage] = "'Search for Concepts'" title = "Concepts:"  [multipleSelections]=true  (addItem) = "select($event)"></static-autocomplete2>          <!--static-autocomplete [(keyword)] = query [(filtered)] =filteredList [(selected)] =selectedList [showSelected]=false placeHolderMessage = "Search for contexts" title = "Contexts:" (keywordChange)="filter($event)" type="context"></static-autocomplete-->
69 63
          </div>
70
          <static-autocomplete [(keyword)] = query [(filtered)] =filteredList [(selected)] =selectedList [showSelected]=false placeHolderMessage = "Search for contexts" title = "Contexts:" (keywordChange)="filter($event)" type="context"></static-autocomplete>
71 64
        </div>
72
      <!--div class="suggestions" *ngIf="filteredList.length > 0">
73
                <ul class="list-group" >
74
                    <li  class="list-group-item"   *ngFor=" let item of filteredList">
75
                        <a (click)="select(item)">{{item.label}}</a>
76
                    </li>
77
                </ul>
78
      </div-->
79 65

  
80 66
     <div *ngIf="warningMessage.length > 0" class="alert alert-warning" role="alert">{{warningMessage}}</div>
81 67
     <div *ngIf="infoMessage.length > 0" class="alert alert-info" role="alert">{{infoMessage}}</div>
......
90 76
@Input() public selectedCategoryId:string ="0";
91 77
@Output() cselectedCommunityChange = new EventEmitter();
92 78
@Output() selectedCategoryChange = new EventEmitter();
79
@ViewChild (StaticAutocomplete2Component) autocomplete : StaticAutocomplete2Component ;
93 80

  
94 81
public query = '';
95 82
public filteredList = [];
......
100 87

  
101 88
public categories:string[];
102 89
private selectedCategoryLabel:string ="Category:";
103
public concepts:string[];
90
public concepts = [];
104 91
public warningMessage = "";
105 92
public infoMessage = "";
106 93

  
......
111 98
    this.elementRef = myElement;
112 99
}
113 100

  
114
// filter() {
115
  // this.warningMessage = "";
116
  // this.infoMessage = "";
117
  // if(this.selectedCommunityId == "0"){
118
  //   this.warningMessage = "Please select Community";
119
  // }else if (this.query !== ""){
120
  //   this.warningMessage = "";
121
  //   this.infoMessage = "";
122
  //   if(this.selectedCategoryId == "0"){
123
  //     this.warningMessage = "Specify category for more concepts";
124
  //   }
125
  //   this.filteredList = this.concepts.filter(function(el){
126
  //         return el.label.toLowerCase().indexOf(this.query.toLowerCase()) > -1;
127
  //     }.bind(this));
128
  //     if(this.filteredList.length == 0 ){
129
  //       this.infoMessage = "No results found";
130
  //     }
131
  // }else{
132
  //     this.filteredList = [];
133
  // }
134
  //
135
// }
101
select($event){
102
    var item = $event.value;
136 103

  
137

  
138
filter($event) {
139
  var query = $event.value;
140
  this.query = $event.value;
141
  this.filteredList = this.concepts.filter(function(el){
142
         return el.label.toLowerCase().indexOf(query.toLowerCase()) > -1;
143
     }.bind(this));
144
  var list = [ ];
145
  for (var _i = 0; _i < this.filteredList.length; _i++) {
146
    let item = this.filteredList[_i];
147 104
    var context: ClaimContext= { community: this.selectedCommunityLabel, category: this.selectedCategoryLabel, concept: item };
148
    list.push(context);
149
  }
150
  this.filteredList = list;
151
}
152

  
153
select(item){
154
    this.query = "";
155
    this.filteredList = [];
156
    var context: ClaimContext= { community: this.selectedCommunityLabel, category: this.selectedCategoryLabel, concept: item };
157 105
    var found:boolean = false;
158 106
    this.warningMessage = "";
159 107
    for (var _i = 0; _i < this.selectedList.length; _i++) {
160 108
        let item = this.selectedList[_i];
161 109
        if(item.concept.id == context.concept.id){
162 110
              found=true;
163
              this.warningMessage = "Concept already in selected list";
111
              // this.warningMessage = "Concept already in selected list";
164 112
        }
165 113
     }
166 114
    if (!found) {
......
168 116
    }
169 117
}
170 118

  
171
// handleClick(event){
172
//  var clickedComponent = event.target;
173
//  var inside = false;
174
//  do {
175
//      if (clickedComponent === this.elementRef.nativeElement) {
176
//          inside = true;
177
//      }
178
//     clickedComponent = clickedComponent.parentNode;
179
//  } while (clickedComponent);
180
//   if(!inside){
181
//       this.filteredList = [];
182
//   }
183
// }
184 119
getCommunities ()  {
185 120
  this._contextService.getCommunities().subscribe(
186 121
    data => {
......
200 135
         if (this.query !== ""){
201 136
           var event = {value: ""};
202 137
           event.value = this.query;
203
            this.filter(event);
204 138
         }
205 139

  
206 140
        },
......
212 146
    if(this.selectedCategoryId != '0'){
213 147
      this._contextService.getConcepts(this.selectedCategoryId, "").subscribe(
214 148
        data => {
215
          this.concepts = data.concept;
149
          this.concepts = data;
150
          this.autocomplete.updateList(this.concepts);
216 151
          if (this.query !== ""){
217 152
            var event = {value: ""};
218 153
            event.value = this.query;
219
             this.filter(event);
154
            //  this.filter(event);
220 155
           }
221 156
         },
222 157
        err => console.error(err)
......
228 163
  communityChanged(communityId:string, communityLabel:string){
229 164
    this.warningMessage = "";
230 165
    this.infoMessage = "";
231
    this.selectedCommunityId= communityId;
232
    this.selectedCommunityLabel= communityLabel;
233
    this.getCategories();
166
    if(this.selectedCommunityId != communityId){
167
      this.selectedCommunityId = communityId;
168
      this.selectedCommunityLabel = communityLabel;
169
      this.getCategories();
170
    }
234 171

  
235 172
  }
236 173
  categoryChanged(categoryId:string, categoryLabel:string){
237 174
    this.warningMessage = "";
238 175
    this.infoMessage = "";
239
    this.selectedCategoryId = categoryId;
240
    this.selectedCategoryLabel = categoryLabel;
241
    this.getConcepts();
176
    if(this.selectedCategoryId != categoryId){
177
      this.selectedCategoryId = categoryId;
178
      this.selectedCategoryLabel = categoryLabel;
179
      this.getConcepts();
180
    }
242 181

  
243 182
  }
244 183

  
modules/uoa-services-portal/trunk/portal-2/src/app/claimPages/claim-utils/claimDataset.component.ts
122 122

  
123 123
     }
124 124
     private searchOpenaire (term: string, size : number, page : number) {
125
       this._searchDatasetsService.searchDatasets(term, null, page, size, []).subscribe(
125
       this._searchDatasetsService.searchDatasets('q='+term+'&op=and', null, page, size, []).subscribe(
126 126
                   data => {
127 127
                       if(data != null) {
128 128
                           this.openairePage=page;
modules/uoa-services-portal/trunk/portal-2/src/app/claimPages/claim-utils/claimPublication.component.ts
162 162
  }
163 163
  private searchOpenaire(term: string, size : number, page : number)  {
164 164
          this.openaireStatus = this.errorCodes.LOADING;
165
          this._searchPublicationsService.searchPublications(term, null, page, size, []).subscribe(
165
          this._searchPublicationsService.searchPublications('q='+term+'&op=and', null, page, size, []).subscribe(
166 166
            data => {
167 167
                if(data != null) {
168 168
                    this.openairePage=page;
modules/uoa-services-portal/trunk/portal-2/src/app/searchPages/find/search.component.ts
138 138
  private searchOrganizationsComponent: SearchOrganizationsComponent;
139 139
  private searchPeopleComponent: SearchPeopleComponent;
140 140

  
141
  //TODO add more viewchild for other entities
142

  
141
private subPub;private subData;private subProjects;private subOrg;private subPeople; private subDataPr;
143 142
  constructor ( private route: ActivatedRoute,
144 143
      private _searchPublicationsService: SearchPublicationsService,
145 144
      private _searchDataprovidersService: SearchDataprovidersService,
......
169 168
  private ngOnDestroy() {
170 169
    this.sub.unsubscribe();
171 170
    if(this.keyword !=null && this.keyword.length > 0){
171
        if(this.subPub){
172
          this.subPub.unsubscribe();
173
        }
174
        if(this.subData){
175
          this.subData.unsubscribe();
176
        }
177
        if(this.subProjects){
178
          this.subProjects.unsubscribe();
179
        }
180
        if(this.subOrg){
181
          this.subOrg.unsubscribe();
182
        }
183
        if(this.subPeople){
184
          this.subPeople.unsubscribe();
185
        }
186
        if(this.subDataPr){
187
          this.subDataPr.unsubscribe();
188
        }
172 189
        this.subPublicationsCount.unsubscribe();
173 190
        this.subDatasetsCount.unsubscribe();
174 191
        this.subProjectsCount.unsubscribe();
......
229 246
   private keywordChanged($event){
230 247
    this.keyword = $event.value;
231 248
    console.info("Search Find: search with keyword \"" +  this.keyword + "\"" );
249
    if(location.pathname.indexOf("search/find") ==-1){
250
      this.location.go(location.pathname+"search/find","?keyword="  + this.keyword);
251
    }else{
252
      this.location.go(location.pathname,"?keyword="  + this.keyword);
253
    }
232 254

  
233 255
    //unsubscribeSearch();
234 256

  
......
256 278

  
257 279
   private count() {
258 280
       this.subPublicationsCount = this.route.queryParams.subscribe(params => {
259
           this._searchPublicationsService.numOfSearchPublications(this.keyword).subscribe(
281
           this.subPub = this._searchPublicationsService.numOfSearchPublications(this.keyword).subscribe(
260 282
             data => {
261 283
                 this.searchPublicationsComponent.totalResults = data;
262 284
             },
......
267 289
       })
268 290

  
269 291
       this.subDatasetsCount = this.route.queryParams.subscribe(params => {
270
           this._searchDatasetsService.numOfSearchDatasets(this.keyword).subscribe(
292
           this.subData = this._searchDatasetsService.numOfSearchDatasets(this.keyword).subscribe(
271 293
             data => {
272 294
                 this.searchDatasetsComponent.totalResults = data;
273 295
             },
......
278 300
       })
279 301

  
280 302
       this.subProjectsCount = this.route.queryParams.subscribe(params => {
281
           this._searchProjectsService.numOfSearchProjects(this.keyword).subscribe(
303
          this.subProjects = this._searchProjectsService.numOfSearchProjects(this.keyword).subscribe(
282 304
             data => {
283 305
                 this.searchProjectsComponent.totalResults = data;
284 306
             },
......
291 313
       this.searchDataProvidersComponent.getNumForSearch(this.keyword);
292 314

  
293 315
       this.subOrganizationsCount = this.route.queryParams.subscribe(params => {
294
           this._searchOrganizationsService.numOfSearchOrganizations(this.keyword).subscribe(
316
            this.subOrg = this._searchOrganizationsService.numOfSearchOrganizations(this.keyword).subscribe(
295 317
             data => {
296 318
                 this.searchOrganizationsComponent.totalResults = data;
297 319
             },
......
302 324
       })
303 325

  
304 326
       this.subPeopleCount = this.route.queryParams.subscribe(params => {
305
           this._searchPeopleService.numOfSearchPeople(this.keyword).subscribe(
327
          this.subPeople =  this._searchPeopleService.numOfSearchPeople(this.keyword).subscribe(
306 328
             data => {
307 329
                 this.searchPeopleComponent.totalResults = data;
308 330
             },
modules/uoa-services-portal/trunk/portal-2/src/app/landingPages/dataset/dataset.component.html
34 34
                <div class="text-justify" [innerHTML]="datasetInfo.description"></div>
35 35
            </blockquote>
36 36

  
37
			<div class="text-right">
37
			      <div class="text-right">
38 38
            	<button (click)=" toggleClaimResult()" class = "btn btn-primary   btn-xs" >Add Research Results</button>
39 39
            </div>
40 40
            <inline-claim-result inlineType ="dataset" [inlineEntity]="result"  (datasetAdded)="resultsAdded($event,false)"  (publicationAdded)="resultsAdded($event,true)"   ></inline-claim-result>
modules/uoa-services-portal/trunk/portal-2/src/app/landingPages/project/project.component.html
53 53
                        </a>
54 54
                    </dd>
55 55
                </dl>
56
                <div class="text-right">
57
                	<button (click)=" toggleClaimResult()" class = "btn btn-primary   btn-xs" >Add Research Results</button>
58
                </div>
59
                <inline-claim-result inlineType ="project" [inlineEntity]="project"  (datasetAdded)="resultsAdded($event,false)"  (publicationAdded)="resultsAdded($event,true)"   ></inline-claim-result>
56 60

  
57 61
                <ul class="nav nav-tabs">
58 62
                    <li class="active">
......
154 158
                            [filename]="'publications.csv'">
155 159
                        </export>
156 160
                    </li>
157
                    <li class="list-group-item">
161
                    <!--li class="list-group-item">
158 162
                        <div class="text-center">
159 163
                            <a class="btn btn-primary" href="/linking">
160 164
                                Link Research Results
161 165
                            </a>
162 166
                        </div>
163
                    </li>
167
                    </li-->
164 168
                    <li class="list-group-item">
165 169
                        <div class="text-center">
166 170
                            <a class="btn btn-primary" href="/deposit">
modules/uoa-services-portal/trunk/portal-2/src/app/landingPages/publication/publication.component.ts
68 68
    this.errorMessage=""
69 69
    if(this.articleId==null || this.articleId==''){
70 70
      this.warningMessage="No valid publication id";
71
      console.info("novalid");
72
    }else{
73
console.info("do request");
74
      this._publicationService.getPublicationInfo(this.articleId).subscribe(
71
     }else{
72
       this._publicationService.getPublicationInfo(this.articleId).subscribe(
75 73
        data => {
76 74
            this.publicationInfo = data;
75
            this.result = []
76
            this.result = {id: id, type :"dataset", source : "openaire", title: this.publicationInfo.title,url: '', result: '', accessRights: this.publicationInfo.bestlicense, embargoEndDate: ''};
77 77

  
78 78
                    let bioentitiesNum = 0;
79 79
                    if(this.publicationInfo.bioentities != undefined) {
modules/uoa-services-portal/trunk/portal-2/src/app/landingPages/publication/publication.component.html
46 46
                <blockquote *ngIf="publicationInfo.description != ''">
47 47
                    <div class="text-justify" [innerHTML]="publicationInfo.description"></div>
48 48
                </blockquote>
49
                <div class="text-right">
50
                  	<button (click)=" toggleClaimResult()" class = "btn btn-primary   btn-xs" >Add Research Results</button>
51
                </div>
52
                <inline-claim-result inlineType ="publication" [inlineEntity]="result"  (datasetAdded)="resultsAdded($event,false)"  (publicationAdded)="resultsAdded($event,true)"   ></inline-claim-result>
49 53

  
50 54
                <ul class="nav nav-tabs">
51 55
                    <li class="active">

Also available in: Unified diff