118 lines
4.8 KiB
TypeScript
118 lines
4.8 KiB
TypeScript
import {Component, Input, Output, EventEmitter,ViewChild} from '@angular/core';
|
|
import {JSONP_PROVIDERS} from '@angular/http';
|
|
import {Observable} from 'rxjs/Observable';
|
|
import { RouteParams, RouteConfig, ROUTER_DIRECTIVES, Router } from '@angular/router-deprecated';
|
|
import {pagingFormatterNoLoad} from '../../../common/pagingFormatterNoLoad.component';
|
|
import {PublicationTitleFormatter} from '../../../common/publicationTitleFormatter.component';
|
|
import {ClaimPublicationComponent} from './claimPublication/claimPublication.component';
|
|
import {ClaimDatasetComponent} from './claimDataset/claimDataset.component';
|
|
|
|
import {SearchDataciteService} from '../../../services/searchDatacite.service';
|
|
|
|
@Component({
|
|
selector: 'claim-result',
|
|
directives: [...ROUTER_DIRECTIVES,pagingFormatterNoLoad, PublicationTitleFormatter, ClaimPublicationComponent, ClaimDatasetComponent],
|
|
template: `
|
|
|
|
|
|
<div class="panel">
|
|
<div class="">
|
|
<form>
|
|
|
|
<!--<md-input class="demo-full-width default" placeholder="Search for Research Results" [(ngModel)]="keyword"></md-input>
|
|
|
|
<md-radio-group class="default" [(value)]="searchType">
|
|
<md-radio-button [value]="publication" [checked]="searchType === 'publication'" >Publication</md-radio-button>
|
|
<md-radio-button [value]="dataset" [checked]="searchType != 'publication'">Dataset</md-radio-button>
|
|
</md-radio-group> -->
|
|
<div class="input-group">
|
|
<span class="input-group-addon">
|
|
<input #publication name="searchType" type="radio" [checked]="searchType === 'publication'" value="publication" (click)="searchType = publication.value" />Publication
|
|
<input #dataset name="searchType" [checked]="searchType === 'dataset'" type="radio" value="dataset" (click)="searchType = dataset.value" />Dataset
|
|
</span>
|
|
<!--<div class="input-group-btn">
|
|
<button type="button" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{(searchType === 'publication')?"Publication":"Dataset"}} </button>
|
|
<ul class="dropdown-menu">
|
|
<li (click)="typeChanged('publication')" ><a >Publication</a></li>
|
|
<li (click)="typeChanged('dataset')" ><a >Dataset</a></li>
|
|
</ul>
|
|
</div> -->
|
|
|
|
<input class=" form-control" [(ngModel)]="keyword"/>
|
|
|
|
<span class="input-group-btn">
|
|
<button (click)="search()" type="submit" class="btn btn-default">Search</button>
|
|
</span>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="panel ">
|
|
<div *ngIf=" searchType=='publication' ">
|
|
<claim-publication [(keyword)]="keyword" [selectedPublications]="selectedPublications" (publicationsChange)="publicationsChanged($event)" > </claim-publication>
|
|
</div>
|
|
<div *ngIf=" searchType=='dataset' " >
|
|
<claim-dataset [(keyword)]="keyword" [(selectedDatasets)]="selectedDatasets" (datasetsChange)="datasetsChanged($event)" > </claim-dataset>
|
|
</div>
|
|
</div>
|
|
|
|
`,
|
|
providers:[JSONP_PROVIDERS, SearchDataciteService]
|
|
})
|
|
export class ClaimResultComponent {
|
|
constructor (private _searchDataciteService: SearchDataciteService,
|
|
private _routeParams: RouteParams) {
|
|
var myDate = new Date();
|
|
this.todayDate = myDate.getFullYear()+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
|
this.nextDate = (myDate.getFullYear()+100)+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
|
|
|
}
|
|
ngOnInit() {
|
|
// if(this.keyword !=null && this.keyword.length > 0){
|
|
// this.searchDatacite(this.keyword,this.size,this.page);
|
|
// }
|
|
}
|
|
@ViewChild (ClaimPublicationComponent) claimPublicationComponent : ClaimPublicationComponent ;
|
|
@ViewChild (ClaimDatasetComponent) claimDatasetComponent : ClaimDatasetComponent ;
|
|
|
|
page : number = 1;
|
|
size:number = 10;
|
|
navigateTo: string = "Search";
|
|
source: string = "datacite";
|
|
type : string = "dataset";
|
|
searchType ="publication";
|
|
@Input() public select:boolean = true ;
|
|
@Input() public keyword:string = '';
|
|
@Input() public selectedDatasets = [] ;
|
|
@Input() public selectedPublications = [] ;
|
|
@Output() datasetsChange = new EventEmitter();
|
|
@Output() publicationsChange = new EventEmitter();
|
|
|
|
todayDate = '';
|
|
nextDate = '';
|
|
search(){
|
|
if(this.searchType=='dataset'){
|
|
this.claimDatasetComponent.search(this.keyword,10,1);
|
|
}else{
|
|
this.claimPublicationComponent.search(this.keyword,10,1);
|
|
}
|
|
}
|
|
|
|
typeChanged(type:string) {
|
|
this.searchType = type;
|
|
}
|
|
publicationsChanged($event) {
|
|
this.selectedPublications=$event.value;
|
|
this.publicationsChange.emit({
|
|
value: this.selectedPublications
|
|
});
|
|
|
|
}
|
|
datasetsChanged($event) {
|
|
this.selectedDatasets=$event.value;
|
|
this.datasetsChange.emit({
|
|
value: this.selectedDatasets
|
|
});
|
|
}
|
|
}
|