Refactoring claims | new direct linking component | use datepicker as a local component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@46501 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
0348364b13
commit
2de6b6e712
|
@ -106,7 +106,7 @@ export function gethtmlProjectReportModule() {
|
||||||
return System.import('./landingPages/htmlProjectReport/htmlProjectReport.module' + (process.env.AOT ? '.ngfactory' : ''))
|
return System.import('./landingPages/htmlProjectReport/htmlProjectReport.module' + (process.env.AOT ? '.ngfactory' : ''))
|
||||||
.then(mod => mod[(process.env.AOT ? 'HtmlProjectReportModuleNgFactory' : 'HtmlProjectReportModule')]);
|
.then(mod => mod[(process.env.AOT ? 'HtmlProjectReportModuleNgFactory' : 'HtmlProjectReportModule')]);
|
||||||
}
|
}
|
||||||
/*export function getMyClaimsModule() {
|
export function getMyClaimsModule() {
|
||||||
return System.import('./claims/myClaims/myClaims.module' + (process.env.AOT ? '.ngfactory' : ''))
|
return System.import('./claims/myClaims/myClaims.module' + (process.env.AOT ? '.ngfactory' : ''))
|
||||||
.then(mod => mod[(process.env.AOT ? 'MyClaimsModuleNgFactory' : 'MyClaimsModule')]);
|
.then(mod => mod[(process.env.AOT ? 'MyClaimsModuleNgFactory' : 'MyClaimsModule')]);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,11 @@ export function getLinkingModule() {
|
||||||
export function getBulkLinkingModule() {
|
export function getBulkLinkingModule() {
|
||||||
return System.import('./claims/linking/bulkLinking.module' + (process.env.AOT ? '.ngfactory' : ''))
|
return System.import('./claims/linking/bulkLinking.module' + (process.env.AOT ? '.ngfactory' : ''))
|
||||||
.then(mod => mod[(process.env.AOT ? 'BulkLinkingModuleNgFactory' : 'BulkLinkingModule')]);
|
.then(mod => mod[(process.env.AOT ? 'BulkLinkingModuleNgFactory' : 'BulkLinkingModule')]);
|
||||||
}*/
|
}
|
||||||
|
export function getDirectLinkingModule() {
|
||||||
|
return System.import('./claims/directLinking/directLinking.module' + (process.env.AOT ? '.ngfactory' : ''))
|
||||||
|
.then(mod => mod[(process.env.AOT ? 'DirectLinkingModuleNgFactory' : 'DirectLinkingModule')]);
|
||||||
|
}
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
RouterModule.forChild([
|
RouterModule.forChild([
|
||||||
|
@ -164,10 +168,11 @@ export function getBulkLinkingModule() {
|
||||||
{ path: 'search/advanced/projects', loadChildren: getAdvancedSearchProjectsModule },
|
{ path: 'search/advanced/projects', loadChildren: getAdvancedSearchProjectsModule },
|
||||||
{ path: 'search/advanced/people', loadChildren: getAdvancedSearchPeopleModule },
|
{ path: 'search/advanced/people', loadChildren: getAdvancedSearchPeopleModule },
|
||||||
{ path: 'project-report', loadChildren: gethtmlProjectReportModule },
|
{ path: 'project-report', loadChildren: gethtmlProjectReportModule },
|
||||||
// { path: 'myclaims', loadChildren: getMyClaimsModule },
|
/*{ path: 'myclaims', loadChildren: getMyClaimsModule },
|
||||||
// { path: 'claims', loadChildren: getClaimsAdminModule },
|
{ path: 'claims', loadChildren: getClaimsAdminModule },
|
||||||
// { path: 'participate/bulk-claim', loadChildren: getBulkLinkingModule },
|
{ path: 'participate/bulk-claim', loadChildren: getBulkLinkingModule },
|
||||||
// { path: 'participate/claim', loadChildren: getLinkingModule },
|
{ path: 'participate/claim', loadChildren: getLinkingModule },
|
||||||
|
{ path: 'participate/direct-claim', loadChildren: getDirectLinkingModule },*/
|
||||||
])
|
])
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
|
@ -7,87 +7,43 @@ declare var UIkit:any;
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
// moduleId: module.id,
|
// moduleId: module.id,
|
||||||
selector: 'claim-contexts',
|
selector: 'claim-contexts-search-form',
|
||||||
template: `
|
template: `
|
||||||
<div class="panel-body" *ngIf="!inline">
|
|
||||||
|
|
||||||
<div class="uk-form" >
|
<div class="uk-form uk-animation uk-panel uk-panel-box uk-panel-box-default " >
|
||||||
|
<div>Search for Communities:</div>
|
||||||
<!--button class="btn btn-success dropdown-toggle" type="button" id="communityDropDown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<table>
|
||||||
{{selectedCommunityLabel}}
|
<tr>
|
||||||
|
<td >
|
||||||
</button>
|
<select class="custom-select-mini" name="select_funder" >
|
||||||
<ul class="dropdown-menu" aria-labelledby="communityDropDown">
|
|
||||||
<li (click)="communityChanged('0','Community:')"><a >Community:</a></li>
|
|
||||||
<li *ngIf="communities" (click)="communityChanged(communities.id, communities.label)" ><a >{{communities.label}}</a></li>
|
|
||||||
|
|
||||||
</ul-->
|
|
||||||
<table ><tr><td >
|
|
||||||
<select name="select_funder" >
|
|
||||||
<option value="0" (click)="communityChanged('0','Community:')">Select Community:</option>
|
<option value="0" (click)="communityChanged('0','Community:')">Select Community:</option>
|
||||||
<option *ngIf="communities" (click)="communityChanged(communities.id, communities.label)" [value]="communities.id" >{{communities.label}}</option>
|
<option *ngIf="communities" (click)="communityChanged(communities.id, communities.label)" [value]="communities.id" >{{communities.label}}</option>
|
||||||
</select>
|
</select>
|
||||||
</td><td >
|
</td>
|
||||||
<!--button class="btn btn-success dropdown-toggle" type="button" id="categoryDropDown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<td><select class="custom-select-mini" name="select_funder" >
|
||||||
{{selectedCategoryLabel}}
|
|
||||||
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu" aria-labelledby="categoryDropDown">
|
|
||||||
<li (click)="categoryChanged('0','Category:')"><a >Category:</a></li>
|
|
||||||
<li *ngFor="let category of categories" (click)="categoryChanged(category.id, category.label)" ><a >{{category.label}}</a></li>
|
|
||||||
|
|
||||||
</ul-->
|
|
||||||
<select name="select_funder" >
|
|
||||||
<option value="0" (click)="categoryChanged('0','Category:')">Select Community:</option>
|
<option value="0" (click)="categoryChanged('0','Category:')">Select Community:</option>
|
||||||
<option *ngFor="let category of categories" (click)="categoryChanged(category.id, category.label)" [value]="category.id" >{{category.label}}</option>
|
<option *ngFor="let category of categories" (click)="categoryChanged(category.id, category.label)" [value]="category.id" >{{category.label}}</option>
|
||||||
</select>
|
</select>
|
||||||
</td><td >
|
</td><td >
|
||||||
<static-autocomplete [(list)] = concepts [allowDuplicates]=true [showSelected]=false [placeHolderMessage] = "'Search for Concepts'" title = "Concepts:" [multipleSelections]=true (addItem) = "select($event)" > </static-autocomplete>
|
<static-autocomplete [(list)] = concepts [allowDuplicates]=true [showSelected]=false [placeHolderMessage] = "'Type keywords...'" title = "Concepts:" [multipleSelections]=true (addItem) = "select($event)" > </static-autocomplete>
|
||||||
</td></tr></table>
|
</td></tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
<div *ngIf="warningMessage.length > 0" class="alert alert-warning" role="alert">{{warningMessage}}</div>
|
||||||
|
<div *ngIf="infoMessage.length > 0" class="alert alert-info" role="alert">{{infoMessage}}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="panel-body" *ngIf=" inline && showComponent ">
|
|
||||||
<div class=" form-horizontal">
|
|
||||||
<div class=" form-group ">
|
|
||||||
<button class="btn btn-xs btn-success dropdown-toggle" type="button" id="communityDropDown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
||||||
{{selectedCommunityLabel}}
|
|
||||||
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu custom-hidden-dropdown-menu" aria-labelledby="communityDropDown">
|
|
||||||
<li (click)="communityChanged('0','Community:')"><a >Community:</a></li>
|
|
||||||
<li *ngIf="communities" (click)="communityChanged(communities.id, communities.label)" ><a >{{communities.label}}</a></li>
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="form-group ">
|
|
||||||
<button class="btn btn-xs btn-success dropdown-toggle" type="button" id="categoryDropDown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
||||||
{{selectedCategoryLabel}}
|
|
||||||
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu custom-hidden-dropdown-menu" aria-labelledby="categoryDropDown">
|
|
||||||
<li (click)="categoryChanged('0','Category:')"><a >Category:</a></li>
|
|
||||||
<li *ngFor="let category of categories" (click)="categoryChanged(category.id, category.label)" ><a >{{category.label}}</a></li>
|
|
||||||
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<static-autocomplete [(list)] = concepts [allowDuplicates]=true [showSelected]=false [placeHolderMessage] = "'Search for Concepts'" title = "Concepts:" [multipleSelections]=true (addItem) = "select($event)" > </static-autocomplete>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div *ngIf="warningMessage.length > 0" class="alert alert-warning" role="alert">{{warningMessage}}</div>
|
|
||||||
<div *ngIf="infoMessage.length > 0" class="alert alert-info" role="alert">{{infoMessage}}</div>
|
|
||||||
`
|
`
|
||||||
|
|
||||||
})
|
})
|
||||||
export class ClaimContextComponent {
|
export class ClaimContextSearchFormComponent {
|
||||||
@Input() public inline:boolean = false ; // for claimed started from landing pages
|
// @Input() public inline:boolean = false ; // for claimed started from landing pages
|
||||||
@Input() public showComponent:boolean = true ; // for claimed started from landing pages
|
public showComponent:boolean = true ; // for claimed started from landing pages
|
||||||
@Input() public selectedList = [];
|
@Input() public selectedList = [];
|
||||||
@Input() public selectedCommunityId:string = "0";
|
public selectedCommunityId:string = "0";
|
||||||
@Input() public selectedCategoryId:string ="0";
|
public selectedCategoryId:string ="0";
|
||||||
@Output() cselectedCommunityChange = new EventEmitter();
|
@Output() contextSelected = new EventEmitter();
|
||||||
@Output() selectedCategoryChange = new EventEmitter();
|
|
||||||
@ViewChild (StaticAutoCompleteComponent) autocomplete : StaticAutoCompleteComponent ;
|
@ViewChild (StaticAutoCompleteComponent) autocomplete : StaticAutoCompleteComponent ;
|
||||||
|
|
||||||
public query = '';
|
public query = '';
|
||||||
|
@ -123,6 +79,9 @@ select($event){
|
||||||
}
|
}
|
||||||
// var UIkit:any;
|
// var UIkit:any;
|
||||||
if (!found) {
|
if (!found) {
|
||||||
|
this.contextSelected.emit({
|
||||||
|
value: true
|
||||||
|
});
|
||||||
this.selectedList.push(context);
|
this.selectedList.push(context);
|
||||||
UIkit.notify({
|
UIkit.notify({
|
||||||
message : 'A context is selected.',
|
message : 'A context is selected.',
|
|
@ -1,7 +1,7 @@
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
|
|
||||||
import { SharedModule } from '../../shared/shared.module';
|
import { SharedModule } from '../../shared/shared.module';
|
||||||
import { ClaimContextComponent } from './claimContext.component';
|
import { ClaimContextSearchFormComponent } from './claimContextSearchForm.component';
|
||||||
import{ContextsServiceModule} from './service/contextsService.module';
|
import{ContextsServiceModule} from './service/contextsService.module';
|
||||||
import {StaticAutocompleteModule} from '../../utils/staticAutoComplete/staticAutoComplete.module';
|
import {StaticAutocompleteModule} from '../../utils/staticAutoComplete/staticAutoComplete.module';
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import { ClaimContextComponent } from './claimContext.component';
|
||||||
|
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
ClaimContextComponent
|
ClaimContextSearchFormComponent
|
||||||
], exports: [ClaimContextComponent ]
|
], exports: [ClaimContextSearchFormComponent ]
|
||||||
})
|
})
|
||||||
export class ClaimContextModule { }
|
export class ClaimContextSearchFormModule { }
|
|
@ -1,247 +0,0 @@
|
||||||
import { Component, Input, Output, EventEmitter} from '@angular/core';
|
|
||||||
import { SearchDataciteService } from '../claim-utils/service/searchDatacite.service';
|
|
||||||
import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
|
||||||
import {ClaimResult} from '../claim-utils/claimEntities.class';
|
|
||||||
import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
|
||||||
import{DOI} from '../../utils/string-utils.class';
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'claim-dataset',
|
|
||||||
template: `
|
|
||||||
|
|
||||||
<!--div *ngIf="warningMessage.length > 0" class="uk-alert uk-alert-warning" role="alert">{{warningMessage}}</div>
|
|
||||||
<div *ngIf="infoMessage.length > 0" class="uk-alert uk-alert-info" role="alert">{{infoMessage}}</div-->
|
|
||||||
|
|
||||||
<div class="uk-margin-top ">
|
|
||||||
<div class="">
|
|
||||||
|
|
||||||
<ul class="uk-tab" data-uk-switcher="{connect:'#claimsearchtabs'}">
|
|
||||||
<li class="active"><a data-toggle="tab" href="#datacite">Datacite ({{(dataciteResultsNum==null)?'0':dataciteResultsNum}})</a></li>
|
|
||||||
<li><a data-toggle="tab" href="#openaire">Openaire ({{(openaireResultsNum==null)?'0':openaireResultsNum}})</a></li>
|
|
||||||
</ul>
|
|
||||||
<ul id="claimsearchtabs" class="uk-switcher">
|
|
||||||
<li id="datacite" class="tab-pane fade in active">
|
|
||||||
<div class = "uk-margin-top">
|
|
||||||
<div *ngIf="dataciteResultsNum != null && dataciteResultsNum > 0" class="uk-clearfix">
|
|
||||||
<div class="uk-float-right">
|
|
||||||
<paging-no-load [currentPage]="datacitePage" [totalResults]="dataciteResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="datacitePageChange($event)"> </paging-no-load>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="dataciteResultsNum == null || dataciteResultsNum == 0" class="uk-alert uk-alert-info" role="alert">No results found</div>
|
|
||||||
<div >
|
|
||||||
<ul *ngIf="dataciteResults.length > 0 " class="uk-list uk-list-line">
|
|
||||||
<li *ngFor=" let item of dataciteResults " [class]="(isSelected(item.doi))?'uk-block-muted':''" >
|
|
||||||
<div >
|
|
||||||
<a *ngIf="item.doi" target="_blank" href="{{'http://dx.doi.org/'+item.doi}}" ><span class="uk-icon-external-link custom-icon" ></span> {{item.title}}</a>
|
|
||||||
<span *ngIf="!item.doi" >{{item.title}}</span>
|
|
||||||
<button class="uk-button uk-align-right" *ngIf="!isSelected(item.doi)" (click)="add(item, item.doi,'dataset','datacite',item.title,'http://dx.doi.org/'+item.doi, null,'OPEN')"><i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<span *ngIf="item.publisher" class="uk-article-meta">Publisher: {{item.publisher}}</span>
|
|
||||||
<div *ngIf="item.creator" class="uk-article-meta">Authors: <span *ngFor="let author of item.creator let i = index">{{author}}{{(i < (item.creator.length-1))?"; ":""}}</span></div>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li id="openaire" class="tab-pane fade">
|
|
||||||
<div class = "uk-margin-top">
|
|
||||||
<div *ngIf="openaireResultsNum != null && openaireResultsNum > 0" class="uk-clearfix">
|
|
||||||
<div class="uk-float-right">
|
|
||||||
<paging-no-load [currentPage]="openairePage" [totalResults]="openaireResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="openairePageChange($event)"> </paging-no-load>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div >
|
|
||||||
<ul *ngIf="openaireResults.length > 0 " class="uk-list uk-list-line">
|
|
||||||
<li *ngFor=" let result of openaireResults " [class]="(isSelected(result.id))?'uk-block-muted':''">
|
|
||||||
<div >
|
|
||||||
<a *ngIf="result['title'].url" target="_blank" [href]="result['title'].url" >{{result['title'].name}}</a>
|
|
||||||
<span *ngIf="!result['title'].url" >{{result['title'].name}}</span>
|
|
||||||
|
|
||||||
|
|
||||||
<button class="uk-button uk-align-right" *ngIf="!isSelected(result.id)"
|
|
||||||
(click)="add(result, result.id, 'dataset', 'openaire', result['title'].name, result['title'].url, result.year, result['title'].accessMode)"> <i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
|
||||||
</div>
|
|
||||||
<span *ngIf="result.publisher" class="uk-article-meta">Publisher: {{result.publisher}}</span><span *ngIf="(result.year)" class="uk-article-meta">({{result.year}})</span>
|
|
||||||
<div *ngIf="result.authors" class="uk-article-meta">Authors: <span *ngFor="let author of result.authors let i = index">{{author.name}}{{(i < (result.authors.length-1))?"; ":""}}</span></div>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<div *ngIf="openaireResults.length == 0" class = "uk-alert uk-alert-info " > No results found </div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
`
|
|
||||||
})
|
|
||||||
export class ClaimDatasetComponent {
|
|
||||||
constructor (private _searchDataciteService: SearchDataciteService, private _searchDatasetsService:SearchDatasetsService){
|
|
||||||
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.search(this.keyword,this.size,1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Input() public select:boolean = true ;
|
|
||||||
@Input() public keyword:string = '';
|
|
||||||
@Input() public selectedDatasets = [] ;
|
|
||||||
@Output() datasetsChange = new EventEmitter();
|
|
||||||
public size:number = 10;
|
|
||||||
public navigateTo: string = "Search";
|
|
||||||
public source: string = "datacite";
|
|
||||||
public type : string = "dataset";
|
|
||||||
public errorCodes:ErrorCodes = new ErrorCodes();
|
|
||||||
|
|
||||||
dataciteResults=[];
|
|
||||||
dataciteResultsNum:number = null;
|
|
||||||
// dataciteResultsNum : Observable<number> = null;
|
|
||||||
dataciteStatus = this.errorCodes.NONE;
|
|
||||||
datacitePage : number = 1;
|
|
||||||
|
|
||||||
openaireResults=[];
|
|
||||||
openaireResultsNum:number = 0 ;
|
|
||||||
openaireStatus = this.errorCodes.NONE;
|
|
||||||
openairePage : number = 1;
|
|
||||||
|
|
||||||
public warningMessage = "";
|
|
||||||
public infoMessage = "";
|
|
||||||
|
|
||||||
public todayDate = '';
|
|
||||||
public nextDate = '';
|
|
||||||
public DOIs:string[] = [];
|
|
||||||
|
|
||||||
public search(term: string, size : number, page : number){
|
|
||||||
this.DOIs = DOI.getDOIsFromString(term);
|
|
||||||
this.searchDatacite(term,10,1);
|
|
||||||
this.searchOpenaire(term,10,1);
|
|
||||||
}
|
|
||||||
private searchDatacite (term: string, size : number, page : number) {
|
|
||||||
this.getDataciteResults(term,size,page);
|
|
||||||
this.warningMessage = "";
|
|
||||||
this.infoMessage = "";
|
|
||||||
|
|
||||||
}
|
|
||||||
private searchOpenaire (term: string, size : number, page : number) {
|
|
||||||
if(this.DOIs.length > 0 ){
|
|
||||||
this.openaireStatus = this.errorCodes.LOADING;
|
|
||||||
this._searchDatasetsService.searchDatasetsByDois(this.DOIs, null, page, size, []).subscribe(
|
|
||||||
data => {
|
|
||||||
if(data != null) {
|
|
||||||
this.openairePage=page;
|
|
||||||
this.openaireResultsNum = data[0];
|
|
||||||
this.openaireResults = data[1];
|
|
||||||
this.openaireStatus = this.errorCodes.DONE;
|
|
||||||
if(this.openaireResultsNum == 0){
|
|
||||||
this.openaireStatus = this.errorCodes.NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
this.openaireStatus = this.errorCodes.ERROR;
|
|
||||||
console.log(err.status);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}else{
|
|
||||||
this._searchDatasetsService.searchDatasets('q='+term+'', null, page, size, []).subscribe(
|
|
||||||
data => {
|
|
||||||
if(data != null) {
|
|
||||||
this.openairePage=page;
|
|
||||||
this.openaireResultsNum = data[0];
|
|
||||||
this.openaireResults = data[1];
|
|
||||||
this.openaireStatus = this.errorCodes.DONE;
|
|
||||||
if(this.openaireResultsNum == 0){
|
|
||||||
this.openaireStatus = this.errorCodes.NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
this.openaireStatus = this.errorCodes.ERROR;
|
|
||||||
console.log(err.status);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
this.warningMessage = "";
|
|
||||||
this.infoMessage = "";
|
|
||||||
|
|
||||||
}
|
|
||||||
private getDataciteResults (term: string, size : number, page : number) {
|
|
||||||
this._searchDataciteService.searchDataciteResults(term, size, page).subscribe(
|
|
||||||
data => {
|
|
||||||
this.dataciteResults = data.docs;
|
|
||||||
this.datacitePage=page;
|
|
||||||
this.dataciteResultsNum = data.numFound;
|
|
||||||
this.dataciteStatus = this.errorCodes.DONE;
|
|
||||||
|
|
||||||
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
this.dataciteStatus = this.errorCodes.ERROR;
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
add(item, itemId,itemType,itemSource,itemTitle, itemUrl, date, accessmode){
|
|
||||||
console.log(' adding dataset '+ itemSource+" "+ itemTitle);
|
|
||||||
var result: ClaimResult ;
|
|
||||||
if(itemSource == 'datacite'){
|
|
||||||
result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date : date};
|
|
||||||
}else if (itemSource == 'openaire'){
|
|
||||||
//TODO put right access rights
|
|
||||||
result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessmode, embargoEndDate: this.nextDate, date : date};
|
|
||||||
}
|
|
||||||
var found:boolean = this.isSelected( result.id);
|
|
||||||
this.warningMessage = "";
|
|
||||||
if (!found) {
|
|
||||||
this.selectedDatasets.push(result);
|
|
||||||
this.datasetsChange.emit({
|
|
||||||
value: this.selectedDatasets
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
this.warningMessage = "Dataset already in selected list";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
datacitePageChange($event) {
|
|
||||||
this.datacitePage=$event.value;
|
|
||||||
this.dataciteResults=[];
|
|
||||||
this.searchDatacite(this.keyword,10,this.datacitePage);
|
|
||||||
this.warningMessage = "";
|
|
||||||
this.infoMessage = "";
|
|
||||||
|
|
||||||
}
|
|
||||||
openairePageChange($event) {
|
|
||||||
this.openairePage=$event.value;
|
|
||||||
this.openaireResults=[];
|
|
||||||
this.searchOpenaire(this.keyword,10,this.openairePage);
|
|
||||||
this.warningMessage = "";
|
|
||||||
this.infoMessage = "";
|
|
||||||
|
|
||||||
}
|
|
||||||
isSelected(id:string){
|
|
||||||
|
|
||||||
var found:boolean = false;
|
|
||||||
this.warningMessage = "";
|
|
||||||
for (var _i = 0; _i < this.selectedDatasets.length; _i++) {
|
|
||||||
let item = this.selectedDatasets[_i];
|
|
||||||
if(item.id == id){
|
|
||||||
found=true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return found;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -7,46 +7,47 @@ import { Subject } from 'rxjs/Subject';
|
||||||
import {ClaimProject} from './claimEntities.class';
|
import {ClaimProject} from './claimEntities.class';
|
||||||
declare var UIkit:any;
|
declare var UIkit:any;
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'claim-projects',
|
selector: 'claim-projects-search-form',
|
||||||
// styleUrls: ['/autoComplete.component.css'],
|
// styleUrls: ['/autoComplete.component.css'],
|
||||||
|
|
||||||
template: `
|
template: `
|
||||||
<div class="panel-body" >
|
<div>
|
||||||
<form class="uk-form " [class.form-inline]="!inline">
|
<form class="uk-form uk-animation uk-panel uk-panel-box uk-panel-box-default " >
|
||||||
<table ><tr><td >
|
<table ><tr>
|
||||||
<select [(ngModel)]="selectedFunderId" name="select_funder" >
|
<td >
|
||||||
|
Search for projects:
|
||||||
|
</td>
|
||||||
|
<td >
|
||||||
|
<select class="custom-select-mini" [(ngModel)]="selectedFunderId" name="select_funder" >
|
||||||
<option value="0" (click)="funderChanged('0','Select funder:')">Select funder:</option>
|
<option value="0" (click)="funderChanged('0','Select funder:')">Select funder:</option>
|
||||||
<option *ngFor="let funder of funders" [value]="funder.id" (click)="funderChanged(funder.id,funder.name)">{{funder.name}}</option>
|
<option *ngFor="let funder of funders" [value]="funder.id" (click)="funderChanged(funder.id,funder.name)">{{funder.name}}</option>
|
||||||
</select></td><td >
|
</select></td><td >
|
||||||
<entities-autocomplete fieldId="project" entityType="project" [funderId]="selectedFunderId" [allowDuplicates]=true [showSelected]=false [placeHolderMessage] = "'Search for Projects'" title = "Projects:" [multipleSelections]=true (addItem) = "select($event)" ></entities-autocomplete>
|
<entities-autocomplete entityType="project" [funderId]="selectedFunderId" [allowDuplicates]=true [showSelected]=false [placeHolderMessage] = "'Type Keywords..'" title = "Projects:" [multipleSelections]=true (addItem) = "select($event)" ></entities-autocomplete>
|
||||||
</td></tr></table>
|
</td></tr></table>
|
||||||
|
</form>
|
||||||
</form>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<modal-loading [message]= "'Loading...'"></modal-loading>
|
<modal-loading [message]= "'Loading...'"></modal-loading>
|
||||||
<!--div *ngIf="warningMessage.length > 0" class="alert alert-warning" role="alert">{{warningMessage}}</div>
|
<!--div *ngIf="warningMessage.length > 0" class="alert alert-warning" role="alert">{{warningMessage}}</div>
|
||||||
<div *ngIf="infoMessage.length > 0" class="alert alert-info" role="alert">{{infoMessage}}</div-->
|
<div *ngIf="infoMessage.length > 0" class="alert alert-info" role="alert">{{infoMessage}}</div-->
|
||||||
|
|
||||||
|
</div>
|
||||||
`
|
`
|
||||||
|
|
||||||
})
|
})
|
||||||
export class ClaimProjectsComponent {
|
export class ClaimProjectsSearchFormComponent {
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.getFunders();
|
this.getFunders();
|
||||||
}
|
}
|
||||||
@ViewChild (ModalLoading) loading : ModalLoading ;
|
@ViewChild (ModalLoading) loading : ModalLoading ;
|
||||||
|
|
||||||
@Input() public inline: boolean = false ; // for claimed started from landing pages
|
// @Input() public inline: boolean = false ; // for claimed started from landing pages
|
||||||
public query = '';
|
public query = '';
|
||||||
@Input() public selectedProjects=[] ;
|
@Input() public selectedProjects=[] ;
|
||||||
public elementRef;
|
public elementRef;
|
||||||
|
|
||||||
public funders:string[];
|
public funders:string[];
|
||||||
@Input() public selectedFunderId:string ="0";
|
public selectedFunderId:string ="0";
|
||||||
selectedFunderName:string ="Select funder:";
|
selectedFunderName:string ="Select funder:";
|
||||||
@Output() cselectedFunderChange = new EventEmitter();
|
@Output() projectSelected = new EventEmitter();
|
||||||
|
|
||||||
public projects:string[];
|
public projects:string[];
|
||||||
public warningMessage = "";
|
public warningMessage = "";
|
||||||
|
@ -116,6 +117,9 @@ select(item){
|
||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
this.selectedProjects.push(project);
|
this.selectedProjects.push(project);
|
||||||
|
this.projectSelected.emit({
|
||||||
|
value: true
|
||||||
|
});
|
||||||
UIkit.notify({
|
UIkit.notify({
|
||||||
message : 'A project "'+item.projectName+'" is selected.',
|
message : 'A project "'+item.projectName+'" is selected.',
|
||||||
status : 'info',
|
status : 'info',
|
|
@ -3,7 +3,7 @@ import { NgModule } from '@angular/core';
|
||||||
import { SharedModule } from '../../shared/shared.module';
|
import { SharedModule } from '../../shared/shared.module';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
|
||||||
import {ClaimProjectsComponent} from './claimProject.component';
|
import {ClaimProjectsSearchFormComponent} from './claimProjectSearchForm.component';
|
||||||
import {LoadingModalModule} from '../../utils/modal/loadingModal.module';
|
import {LoadingModalModule} from '../../utils/modal/loadingModal.module';
|
||||||
|
|
||||||
import {ProjectServiceModule} from '../../landingPages/project/projectService.module';
|
import {ProjectServiceModule} from '../../landingPages/project/projectService.module';
|
||||||
|
@ -17,9 +17,9 @@ import {EntitiesAutocompleteModule} from '../../utils/entitiesAutoComplete/entit
|
||||||
providers:[
|
providers:[
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
ClaimProjectsComponent
|
ClaimProjectsSearchFormComponent
|
||||||
|
|
||||||
],
|
],
|
||||||
exports: [ClaimProjectsComponent ]
|
exports: [ClaimProjectsSearchFormComponent ]
|
||||||
})
|
})
|
||||||
export class ClaimProjectModule { }
|
export class ClaimProjectsSearchFormModule { }
|
|
@ -1,121 +0,0 @@
|
||||||
|
|
||||||
<div class="uk-margin-top">
|
|
||||||
|
|
||||||
|
|
||||||
<ul class="uk-tab" data-uk-switcher="{connect:'#claimsearchtabs'}">
|
|
||||||
<li class="active"><a data-toggle="tab" href="#crossref">Crossref ({{(crossrefResultsNum)?crossrefResultsNum:0}})</a></li>
|
|
||||||
<li><a data-toggle="tab" href="#openaire">Openaire ({{ (openaireResultsNum)?openaireResultsNum:0 }})</a></li>
|
|
||||||
<li><a data-toggle="tab" href="#orcid">Orcid ({{ (orcidResultsNum)?orcidResultsNum:0}})</a></li>
|
|
||||||
</ul>
|
|
||||||
<ul id="claimsearchtabs" class="uk-switcher">
|
|
||||||
<li id="crossref" >
|
|
||||||
<div class="uk-margin-top" >
|
|
||||||
<div *ngIf="crossrefStatus == errorCodes.LOADING" class="uk-alert uk-alert-info" role="alert">Loading...</div>
|
|
||||||
<div *ngIf="crossrefStatus != errorCodes.LOADING && crossrefResults.length == 0" class="uk-alert uk-alert-info" role="alert">No Results found</div>
|
|
||||||
<div *ngIf="crossrefStatus == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
|
|
||||||
<div *ngIf="crossrefStatus == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
|
|
||||||
<div *ngIf="crossrefResultsNum != null && crossrefResultsNum > 0" class="uk-clearfix">
|
|
||||||
<div class="uk-float-right">
|
|
||||||
<paging-no-load [currentPage]="crossrefPage" [totalResults]="crossrefResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="crossrefPageChange($event)"> </paging-no-load>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div >
|
|
||||||
<ul *ngIf="crossrefResults.length > 0 " class="uk-list uk-list-line">
|
|
||||||
<li *ngFor=" let item of crossrefResults " [class]="(isSelected(item.DOI))?'uk-block-muted':''">
|
|
||||||
<div >
|
|
||||||
<a *ngIf="item.URL" target="_blank" href="{{item.URL}}" ><span class="uk-icon-external-link custom-icon" ></span> {{item.title}}</a>
|
|
||||||
<span *ngIf="!item.URL" >{{item.title}}</span>
|
|
||||||
<button class="uk-button uk-align-right" *ngIf="!isSelected(item.DOI)" (click)="add(item, item.DOI, 'crossref', 'publication', item.URL, item.title, item.created['date-time'],'OPEN')"><i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
|
||||||
</div>
|
|
||||||
<span *ngIf="item.publisher" class="uk-article-meta">Publisher: {{item.publisher}}</span><span class="uk-article-meta" *ngIf="(item['published-print'] && item['published-print']['date-parts'] && item['published-print']['date-parts'][0])">({{(item['published-print']['date-parts'][0][0])?item['published-print']['date-parts'][0][0]:item['published-print']['date-parts'][0]}})</span>
|
|
||||||
<div *ngIf="item.author" class="uk-article-meta">Authors: <span *ngFor="let author of item.author let i = index">{{author.family}} {{author.given}}{{(i < (item.author.length-1))?"; ":""}}</span></div>
|
|
||||||
<div *ngIf="item.editor" class="uk-article-meta">Editors: <span *ngFor="let author of item.editor let i = index">{{author.family}} {{author.given}}{{(i < (item.editor.length-1))?"; ":""}}</span></div>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li id="openaire" >
|
|
||||||
<div class = "uk-margin-top">
|
|
||||||
<div *ngIf="openaireStatus == errorCodes.LOADING" class="uk-alert uk-alert-info" role="alert">Loading...</div>
|
|
||||||
<div *ngIf="openaireStatus == errorCodes.NONE" class="uk-alert uk-alert-info" role="alert">No Results found</div>
|
|
||||||
<div *ngIf="openaireStatus == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
|
|
||||||
<div *ngIf="openaireStatus == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
|
|
||||||
<div *ngIf="openaireResultsNum != null && openaireResultsNum > 0" class="uk-clearfix">
|
|
||||||
<div class="uk-float-right">
|
|
||||||
<paging-no-load [currentPage]="openairePage" [totalResults]="openaireResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="openairePageChange($event)"> </paging-no-load>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div >
|
|
||||||
<ul *ngIf="openaireResults.length > 0 " class="uk-list uk-list-line">
|
|
||||||
<li *ngFor=" let result of openaireResults " [class]="(isSelected(result.id))?'uk-block-muted':''">
|
|
||||||
<div >
|
|
||||||
<a *ngIf="result['title'].url" target="_blank" [href]="result['title'].url" >{{result['title'].name}}</a>
|
|
||||||
<span *ngIf="!result['title'].url" >{{result['title'].name}}</span>
|
|
||||||
<button *ngIf="!isSelected(result.id)" (click)="add(result, result.id, 'openaire', 'publication', result['title'].url, result['title'].name, result.year,result['title'].accessMode)" class="uk-button uk-align-right"><i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
|
||||||
</div>
|
|
||||||
<span *ngIf="result.publisher" class="uk-article-meta">Publisher: {{result.publisher}}</span><span class="uk-article-meta" *ngIf="(result.year)">({{result.year}})</span>
|
|
||||||
<div *ngIf="result.authors" class="uk-article-meta">Authors: <span *ngFor="let author of result.authors let i = index">{{author.name}}{{(i < (result.authors.length-1))?"; ":""}}</span></div>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li id="orcid" class="tab-pane fade">
|
|
||||||
<div class="uk-margin-top" >
|
|
||||||
<div *ngIf="orcidStatus == errorCodes.LOADING" class="uk-alert uk-alert-info" role="alert">Loading...</div>
|
|
||||||
<div *ngIf="orcidStatus == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
|
|
||||||
<div *ngIf="orcidStatus == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
|
|
||||||
<div *ngIf="orcidStatus == errorCodes.NONE && (!authorIds ||authorIds.length == 0)" class = "uk-alert uk-alert-info " > No results found </div>
|
|
||||||
|
|
||||||
<div *ngIf="orcidResultsNum != null" class="panel-body">
|
|
||||||
<div class = "uk-alert uk-alert-warning " > Not the right author? Choose one of these:
|
|
||||||
|
|
||||||
<span class="dropdown">
|
|
||||||
<!--button class=" uk-button dropdown-toggle" type= "button" data-toggle="dropdown" id="orcidDropDown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
|
||||||
Selected: {{authorGivenName}} {{authorFamilyName}}
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu " aria-labelledby="orcidDropDown">
|
|
||||||
<li *ngFor=" let item of authorIds let i = index" > <a (click)="getOrcidResultsById(i)" >
|
|
||||||
{{authorGivenNames[i]}} {{authorFamilyNames[i]}} : {{item}} </a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
</ul-->
|
|
||||||
<select [(ngModel)]="authorId" name="select_author" >authorIds
|
|
||||||
<option *ngFor=" let item of authorIds let i = index" [value]="authorIds[i]" (click)="getOrcidResultsById(i)" >{{authorGivenNames[i]}} {{authorFamilyNames[i]}} : {{item}} </option>
|
|
||||||
</select>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<span>Results for
|
|
||||||
<a target="_blank" href="http://orcid.org/{{authorId}}"><span class="uk-icon-external-link custom-icon" ></span> {{authorGivenName}} {{authorFamilyName}} - {{authorId}} </a> :
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<div *ngIf=" ((orcidResultsNum >0) && (totalPages > 1) && ( 0 < page && page <= totalPages )) " class="uk-clearfix">
|
|
||||||
<div class="uk-float-right">
|
|
||||||
<paging-no-load [currentPage]="orcidPage" [totalResults]="orcidResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="orcidPageChange($event)"> </paging-no-load>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div >
|
|
||||||
<ul *ngIf="orcidResultsNum >0 && orcidResultsToShow.length > 0 " class="uk-list uk-list-line">
|
|
||||||
<li *ngFor=" let item of orcidResultsToShow " [class]="(isSelected(authorId+'-'+item['put-code']))?'uk-block-muted':''">
|
|
||||||
<div>
|
|
||||||
<span *ngIf="!item.URL" >{{item['work-title']['title'].value}}</span>
|
|
||||||
<button class="uk-button uk-align-right" *ngIf="!isSelected(authorId+item['put-code'])" (click)="add(item,authorId+'-'+item['put-code'],'orcid', 'publication', '', item['work-title']['title'].value, item['publication-date']?item['publication-date'].year.value :null,'OPEN')"><i aria-hidden="true" class= " uk-icon-plus clickable"></i></button>
|
|
||||||
</div>
|
|
||||||
<span *ngIf="item['journal-title'] && item['journal-title'].value " class="uk-article-meta">Journal: {{item['journal-title'].value}}</span><span class="uk-article-meta" *ngIf="(item['publication-date']&&item['publication-date'].year&&item['publication-date'].year.value)"> ({{item['publication-date'].year.value}})</span>
|
|
||||||
<div *ngIf="item.contributors" class="uk-article-meta">Authors: <span *ngFor="let author of item.contributors let i = index">{{author}}{{(i < (item.contributors.length-1))?"; ":""}}</span></div>
|
|
||||||
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<div *ngIf="orcidResultsNum == 0" class = "uk-alert uk-alert-info " > No results found </div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
|
@ -1,401 +0,0 @@
|
||||||
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
|
||||||
import { ActivatedRoute } from '@angular/router';
|
|
||||||
import {SearchCrossrefService} from '../claim-utils/service/searchCrossref.service';
|
|
||||||
import {SearchOrcidService} from '../claim-utils/service/searchOrcid.service';
|
|
||||||
import {SearchPublicationsService} from '../../services/searchPublications.service';
|
|
||||||
import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
|
||||||
import {ClaimResult} from '../claim-utils/claimEntities.class';
|
|
||||||
import{DOI} from '../../utils/string-utils.class';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'claim-publication',
|
|
||||||
templateUrl: 'claimPublication.component.html',
|
|
||||||
|
|
||||||
})
|
|
||||||
export class ClaimPublicationComponent {
|
|
||||||
constructor (private _searchCrossrefService: SearchCrossrefService,private _searchOrcidService: SearchOrcidService, private _searchPublicationsService: SearchPublicationsService,
|
|
||||||
private route: ActivatedRoute) {
|
|
||||||
var myDate = new Date();
|
|
||||||
this.todayDate = myDate.getFullYear()+ "-" +(myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
|
||||||
this.nextDate = (myDate.getFullYear()+100)+ "-01-01" ;
|
|
||||||
|
|
||||||
}
|
|
||||||
ngOnInit() {
|
|
||||||
this.sub = this.route.params.subscribe(params => {
|
|
||||||
if(this.keyword !=null && this.keyword.length > 0){
|
|
||||||
this.search(this.keyword);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
ngOnDestroy() {
|
|
||||||
this.sub.unsubscribe();
|
|
||||||
}
|
|
||||||
@Input() public keyword:string = "";
|
|
||||||
@Input() public select:boolean = true ;
|
|
||||||
@Input() public selectedPublications = [] ;
|
|
||||||
@Output() publicationsChange = new EventEmitter();
|
|
||||||
sub: any;
|
|
||||||
size:number = 10;
|
|
||||||
source: string = "crossref";
|
|
||||||
type : string = "publication";
|
|
||||||
errorCodes:ErrorCodes = new ErrorCodes();
|
|
||||||
|
|
||||||
crossrefResults=[];
|
|
||||||
crossrefResultsNum : number = null;
|
|
||||||
crossrefPage : number = 1;
|
|
||||||
crossrefStatus:number = this.errorCodes.NONE;
|
|
||||||
|
|
||||||
openaireResults = [];
|
|
||||||
openaireResultsNum: number ;
|
|
||||||
openairePage : number = 1;
|
|
||||||
openaireStatus:number = this.errorCodes.NONE;
|
|
||||||
|
|
||||||
orcidResults: string[];
|
|
||||||
orcidResultsNum: number ;
|
|
||||||
totalPages: number;
|
|
||||||
orcidResultsToShow: string[];
|
|
||||||
orcidPage : number = 1;
|
|
||||||
orcidStatus:number = this.errorCodes.NONE;
|
|
||||||
authorId: string;
|
|
||||||
authorGivenName: string;
|
|
||||||
authorFamilyName: string;
|
|
||||||
|
|
||||||
authorIds: string[];
|
|
||||||
authorGivenNames: string[];
|
|
||||||
authorFamilyNames: string[];
|
|
||||||
|
|
||||||
authorsNum : number ;
|
|
||||||
|
|
||||||
public warningMessage = "";
|
|
||||||
public infoMessage = "";
|
|
||||||
|
|
||||||
todayDate = '';
|
|
||||||
nextDate = '';
|
|
||||||
private DOIs:string[] = [];
|
|
||||||
|
|
||||||
public search(term: string){
|
|
||||||
this.warningMessage = "";
|
|
||||||
this.infoMessage = "";
|
|
||||||
this.DOIs = DOI.getDOIsFromString(term);
|
|
||||||
this.getCrossrefResults(term, this.size,1);
|
|
||||||
this.searchOrcid(term);
|
|
||||||
this.searchOpenaire(term, this.size, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private getCrossrefResults (term: string, size : number, page : number) {
|
|
||||||
this.crossrefStatus = this.errorCodes.LOADING;
|
|
||||||
if( this.DOIs.length > 0 ){
|
|
||||||
this._searchCrossrefService.searchCrossrefByDOIs(this.DOIs).subscribe(
|
|
||||||
data => {
|
|
||||||
if(data != null) {
|
|
||||||
this.crossrefResults = data.items;
|
|
||||||
this.crossrefPage=page;
|
|
||||||
this.crossrefResultsNum = data['total-results'];
|
|
||||||
if(data.items == 0){
|
|
||||||
this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe(
|
|
||||||
data => {
|
|
||||||
if(data != null) {
|
|
||||||
this.crossrefResults = data.items;
|
|
||||||
this.crossrefPage=page;
|
|
||||||
this.crossrefResultsNum = data['total-results'];
|
|
||||||
this.crossrefStatus = this.errorCodes.DONE;
|
|
||||||
|
|
||||||
}else{
|
|
||||||
this.crossrefStatus = this.errorCodes.ERROR;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
err =>{
|
|
||||||
console.log(err.status);
|
|
||||||
this.crossrefStatus = this.errorCodes.ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
);
|
|
||||||
}else{
|
|
||||||
this.crossrefStatus = this.errorCodes.DONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
//console.log(err);
|
|
||||||
this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe(
|
|
||||||
data => {
|
|
||||||
this.crossrefResults = data.items;
|
|
||||||
this.crossrefPage=page;
|
|
||||||
this.crossrefResultsNum = data['total-results'];
|
|
||||||
this.crossrefStatus = this.errorCodes.DONE;
|
|
||||||
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
console.log(err.status);
|
|
||||||
this.crossrefStatus = this.errorCodes.ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
}else{
|
|
||||||
|
|
||||||
|
|
||||||
this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe(
|
|
||||||
data => {
|
|
||||||
if(data != null) {
|
|
||||||
this.crossrefResults = data.items;
|
|
||||||
this.crossrefPage=page;
|
|
||||||
this.crossrefResultsNum = data['total-results'];
|
|
||||||
this.crossrefStatus = this.errorCodes.DONE;
|
|
||||||
|
|
||||||
}else{
|
|
||||||
this.crossrefStatus = this.errorCodes.ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
console.log(err.status);
|
|
||||||
this.crossrefStatus = this.errorCodes.ERROR;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private searchOpenaire(term: string, size : number, page : number) {
|
|
||||||
|
|
||||||
if(this.DOIs.length > 0 ){
|
|
||||||
this.openaireStatus = this.errorCodes.LOADING;
|
|
||||||
this._searchPublicationsService.searchPublicationsByDois(this.DOIs, null, page, size, []).subscribe(
|
|
||||||
data => {
|
|
||||||
if(data != null) {
|
|
||||||
this.openairePage=page;
|
|
||||||
this.openaireResultsNum = data[0];
|
|
||||||
this.openaireResults = data[1];
|
|
||||||
this.openaireStatus = this.errorCodes.DONE;
|
|
||||||
if(this.openaireResultsNum == 0){
|
|
||||||
this.openaireStatus = this.errorCodes.NONE;
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
this.openaireStatus = this.errorCodes.ERROR;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
this.openaireStatus = this.errorCodes.ERROR;
|
|
||||||
console.log(err.status);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}else{
|
|
||||||
this.openaireStatus = this.errorCodes.LOADING;
|
|
||||||
this._searchPublicationsService.searchPublications('q='+term, null, page, size, []).subscribe(
|
|
||||||
data => {
|
|
||||||
if(data != null) {
|
|
||||||
this.openairePage=page;
|
|
||||||
this.openaireResultsNum = data[0];
|
|
||||||
this.openaireResults = data[1];
|
|
||||||
this.openaireStatus = this.errorCodes.DONE;
|
|
||||||
if(this.openaireResultsNum == 0){
|
|
||||||
this.openaireStatus = this.errorCodes.NONE;
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
this.openaireStatus = this.errorCodes.ERROR;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
this.openaireStatus = this.errorCodes.ERROR;
|
|
||||||
console.log(err.status);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private searchOrcid (term: string) {
|
|
||||||
if(this.DOIs.length > 0){
|
|
||||||
this.orcidStatus = this.errorCodes.NONE;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.orcidStatus = this.errorCodes.LOADING;
|
|
||||||
this.authorIds = new Array<string>();
|
|
||||||
this.authorGivenNames = new Array<string>();
|
|
||||||
this.authorFamilyNames = new Array<string>();
|
|
||||||
|
|
||||||
this.getOrcidAuthor(term);
|
|
||||||
|
|
||||||
console.info('searchOrcid in searchOrcid file');
|
|
||||||
}
|
|
||||||
|
|
||||||
private readData(data: any) {
|
|
||||||
this.authorIds.push(data[2].path);
|
|
||||||
|
|
||||||
if(data[0] != null) {
|
|
||||||
this.authorGivenNames.push(data[0].value);
|
|
||||||
} else {
|
|
||||||
this.authorGivenNames.push("");
|
|
||||||
}
|
|
||||||
if(data[1] != null) {
|
|
||||||
this.authorFamilyNames.push(data[1].value);
|
|
||||||
} else {
|
|
||||||
this.authorFamilyNames.push("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private getOrcidAuthor (term: string) {
|
|
||||||
this.orcidResultsNum = null;
|
|
||||||
|
|
||||||
//passing structures in order to fill them in service
|
|
||||||
this._searchOrcidService.searchOrcidAuthor(term, this.authorIds,
|
|
||||||
this.authorGivenNames, this.authorFamilyNames).subscribe(
|
|
||||||
data => {
|
|
||||||
if(data != null && data == true) {
|
|
||||||
this.getOrcidResultsById(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.orcidStatus = this.errorCodes.NONE;
|
|
||||||
|
|
||||||
},
|
|
||||||
err => this.errorHandler(err, term)
|
|
||||||
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private errorHandler(err: any, term: string) {
|
|
||||||
if(err.status == 404){
|
|
||||||
this.getOrcidAuthors(term);
|
|
||||||
} else {
|
|
||||||
this.orcidStatus = this.errorCodes.ERROR;
|
|
||||||
console.log(err.status);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private getOrcidAuthors (term: string) {
|
|
||||||
this.orcidResultsNum = null;
|
|
||||||
|
|
||||||
//passing structures in order to fill them in service
|
|
||||||
this._searchOrcidService.searchOrcidAuthors(term, this.authorIds,
|
|
||||||
this.authorGivenNames, this.authorFamilyNames).subscribe(
|
|
||||||
data => {
|
|
||||||
if(data != null && data == true) {
|
|
||||||
this.getOrcidResultsById(0);
|
|
||||||
}else{
|
|
||||||
this.orcidStatus = this.errorCodes.ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
this.orcidStatus = this.errorCodes.ERROR;
|
|
||||||
console.log(err.status);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private getOrcidResultsById (index:number) {
|
|
||||||
if(this.authorIds.length > index) {
|
|
||||||
this.orcidStatus = this.errorCodes.LOADING;
|
|
||||||
let id = this.authorIds[index];
|
|
||||||
this.authorGivenName = this.authorGivenNames[index];
|
|
||||||
this.authorFamilyName = this.authorFamilyNames[index];
|
|
||||||
this.authorId = id;
|
|
||||||
console.info("getOrcidResultsById: "+id);
|
|
||||||
this._searchOrcidService.searchOrcidPublications(id).subscribe(
|
|
||||||
data => {
|
|
||||||
if(data != null) {
|
|
||||||
this.orcidResults=data['orcid-work'];
|
|
||||||
this.orcidResultsNum = data['orcid-work'].length;
|
|
||||||
this.orcidPage = 1;
|
|
||||||
if((this.orcidResultsNum % this.size) == 0){
|
|
||||||
this.totalPages=parseInt(''+(this.orcidResultsNum/this.size));
|
|
||||||
} else{
|
|
||||||
this.totalPages=parseInt(''+(this.orcidResultsNum/this.size+1));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.orcidResultsToShow = this.orcidResults.slice(0,10);
|
|
||||||
|
|
||||||
this.orcidStatus = this.errorCodes.DONE;
|
|
||||||
if(this.orcidResultsNum == 0){
|
|
||||||
this.orcidStatus = this.errorCodes.NONE;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.orcidResultsNum = 0;
|
|
||||||
this.totalPages=0;
|
|
||||||
this.orcidStatus = this.errorCodes.NONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
console.log(err.status);
|
|
||||||
this.orcidStatus = this.errorCodes.ERROR;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private add(item, id, itemSource, itemType, itemUrl, itemTitle, date, accessMode){
|
|
||||||
var result: ClaimResult ;
|
|
||||||
if(itemSource == 'crossref'){
|
|
||||||
date = (date == null) ? null : date.substring(0,10);
|
|
||||||
result = {id: id, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date: date};
|
|
||||||
}else if (itemSource == 'orcid'){
|
|
||||||
date = (date == null) ? null : date + "-01.-01"
|
|
||||||
result = {id:id, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date: date};
|
|
||||||
}else if (itemSource == 'openaire'){
|
|
||||||
//TODO put right access rights
|
|
||||||
result = {id:id, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessMode, embargoEndDate: null, date: date};
|
|
||||||
|
|
||||||
}
|
|
||||||
console.info("Added result:"+result.date);
|
|
||||||
var found:boolean = this.isSelected(result.id);
|
|
||||||
this.warningMessage = "";
|
|
||||||
if (!found) {
|
|
||||||
this.selectedPublications.push(result);
|
|
||||||
this.publicationsChange.emit({
|
|
||||||
value: this.selectedPublications
|
|
||||||
});
|
|
||||||
}else{
|
|
||||||
this.warningMessage = "Publication already in selected list";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
private remove(item){
|
|
||||||
this.warningMessage = "";
|
|
||||||
this.infoMessage = "";
|
|
||||||
var index:number =this.selectedPublications.indexOf(item);
|
|
||||||
item.selected=false;
|
|
||||||
if (index > -1) {
|
|
||||||
this.selectedPublications.splice(index, 1);
|
|
||||||
this.publicationsChange.emit({
|
|
||||||
value: this.selectedPublications
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
private crossrefPageChange($event) {
|
|
||||||
this.crossrefPage=$event.value;
|
|
||||||
this.crossrefResults=[];
|
|
||||||
console.log("Crossref chaenged "+this.crossrefPage);
|
|
||||||
this.getCrossrefResults(this.keyword,this.size,this.crossrefPage);
|
|
||||||
}
|
|
||||||
private orcidPageChange($event) {
|
|
||||||
this.orcidPage=$event.value;
|
|
||||||
this.orcidResultsToShow=[];
|
|
||||||
this.orcidResultsToShow = this.orcidResults.slice(($event.value-1)*this.size, $event.value*this.size);
|
|
||||||
}
|
|
||||||
private openairePageChange($event) {
|
|
||||||
this.openairePage=$event.value;
|
|
||||||
this.searchOpenaire(this.keyword,this.size,this.openairePage);
|
|
||||||
}
|
|
||||||
|
|
||||||
private isSelected(id:string){
|
|
||||||
|
|
||||||
var found:boolean = false;
|
|
||||||
this.warningMessage = "";
|
|
||||||
for (var _i = 0; _i < this.selectedPublications.length; _i++) {
|
|
||||||
let item = this.selectedPublications[_i];
|
|
||||||
if(item.id == id){
|
|
||||||
found=true;
|
|
||||||
this.warningMessage = "Publication already in selected list";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return found;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,107 +0,0 @@
|
||||||
import {Component, Input, Output, EventEmitter, ViewChild} from '@angular/core';
|
|
||||||
import {ClaimPublicationComponent} from './claimPublication.component';
|
|
||||||
import {ClaimDatasetComponent} from './claimDataset.component';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'claim-result',
|
|
||||||
template: `
|
|
||||||
|
|
||||||
|
|
||||||
<div class="panel">
|
|
||||||
<div class="">
|
|
||||||
<form class="uk-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">
|
|
||||||
<label><input #publication name="searchType" type="radio" [checked]="searchType === 'publication'" value="publication" (click)="searchType = publication.value" />Publication</label>
|
|
||||||
<label><input #dataset name="searchType" [checked]="searchType === 'dataset'" type="radio" value="dataset" (click)="searchType = dataset.value" />Dataset</label>
|
|
||||||
</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" name="keyword"/>
|
|
||||||
|
|
||||||
<span class="input-group-btn">
|
|
||||||
<button (click)="search()" type="submit" class="uk-button">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>
|
|
||||||
|
|
||||||
`,
|
|
||||||
})
|
|
||||||
export class ClaimResultComponent {
|
|
||||||
constructor () {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,182 @@
|
||||||
|
<form class="uk-form uk-panel uk-panel-box uk-panel-box-default">
|
||||||
|
<div class="input-group">
|
||||||
|
<input class=" form-control" [(ngModel)]="keyword" name="keyword" placeholder="Type keywords..."/>
|
||||||
|
<span class="input-group-btn">
|
||||||
|
<button (click)="search()" type="submit" class="uk-button">Search</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<div *ngIf="keyword && keyword.length > 0 " class="uk-margin-top ">
|
||||||
|
<ul class="uk-tab" data-uk-switcher="{connect:'#claimsearchtabs'}">
|
||||||
|
<li class="active"><a data-toggle="tab" >Crossref ({{(crossrefResultsNum)?crossrefResultsNum:0}})</a></li>
|
||||||
|
<li><a data-toggle="tab" >Openaire ({{ (openairePubsNum)?openairePubsNum:0 }})</a></li>
|
||||||
|
<li><a data-toggle="tab" >Orcid ({{ (orcidResultsNum)?orcidResultsNum:0}})</a></li>
|
||||||
|
<li class="active"><a data-toggle="tab" >Datacite ({{(dataciteResultsNum==null)?'0':dataciteResultsNum}})</a></li>
|
||||||
|
<li><a data-toggle="tab" >Openaire ({{(openaireDataNum==null)?'0':openaireDataNum}})</a></li>
|
||||||
|
</ul>
|
||||||
|
<ul id="claimsearchtabs" class="uk-switcher">
|
||||||
|
<li id="crossref" >
|
||||||
|
<div class="uk-margin-top" >
|
||||||
|
<div *ngIf="crossrefStatus == errorCodes.LOADING" class="uk-alert uk-alert-info" role="alert">Loading...</div>
|
||||||
|
<div *ngIf="crossrefStatus != errorCodes.LOADING && crossrefResults.length == 0" class="uk-alert uk-alert-info" role="alert">No Results found</div>
|
||||||
|
<div *ngIf="crossrefStatus == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
|
||||||
|
<div *ngIf="crossrefStatus == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
|
||||||
|
<div *ngIf="crossrefResultsNum != null && crossrefResultsNum > 0" class="uk-clearfix">
|
||||||
|
<div class="uk-float-right">
|
||||||
|
<paging-no-load [currentPage]="crossrefPage" [totalResults]="crossrefResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="crossrefPageChange($event)"> </paging-no-load>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div >
|
||||||
|
<ul *ngIf="crossrefResults.length > 0 " class="uk-list uk-list-line">
|
||||||
|
<li *ngFor=" let item of crossrefResults " [class]="(isSelected(item.DOI))?'uk-block-muted':''">
|
||||||
|
<div >
|
||||||
|
<a *ngIf="item.URL" target="_blank" href="{{item.URL}}" ><span class="uk-icon-external-link" ></span> {{item.title}}</a>
|
||||||
|
<span *ngIf="!item.URL" >{{item.title}}</span>
|
||||||
|
<button class="uk-button uk-align-right" *ngIf="!isSelected(item.DOI)" (click)="add(item, item.DOI, 'crossref', 'publication', item.URL, item.title, item.created['date-time'],'OPEN')"><i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
||||||
|
</div>
|
||||||
|
<span *ngIf="item.publisher" class="uk-article-meta">Publisher: {{item.publisher}}</span><span class="uk-article-meta" *ngIf="(item['published-print'] && item['published-print']['date-parts'] && item['published-print']['date-parts'][0])">({{(item['published-print']['date-parts'][0][0])?item['published-print']['date-parts'][0][0]:item['published-print']['date-parts'][0]}})</span>
|
||||||
|
<div *ngIf="item.author" class="uk-article-meta">Authors: <span *ngFor="let author of item.author let i = index">{{author.family}} {{author.given}}{{(i < (item.author.length-1))?"; ":""}}</span></div>
|
||||||
|
<div *ngIf="item.editor" class="uk-article-meta">Editors: <span *ngFor="let author of item.editor let i = index">{{author.family}} {{author.given}}{{(i < (item.editor.length-1))?"; ":""}}</span></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li id="openairePubs" >
|
||||||
|
<div class = "uk-margin-top">
|
||||||
|
<div *ngIf="openairePubsStatus == errorCodes.LOADING" class="uk-alert uk-alert-info" role="alert">Loading...</div>
|
||||||
|
<div *ngIf="openairePubsStatus == errorCodes.NONE" class="uk-alert uk-alert-info" role="alert">No Results found</div>
|
||||||
|
<div *ngIf="openairePubsStatus == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
|
||||||
|
<div *ngIf="openairePubsStatus == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
|
||||||
|
<div *ngIf="openairePubsNum != null && openairePubsNum > 0" class="uk-clearfix">
|
||||||
|
<div class="uk-float-right">
|
||||||
|
<paging-no-load [currentPage]="openairePubsPage" [totalResults]="openairePubsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="openairePubsPageChange($event)"> </paging-no-load>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div >
|
||||||
|
<ul *ngIf="openairePubs.length > 0 " class="uk-list uk-list-line">
|
||||||
|
<li *ngFor=" let result of openairePubs " [class]="(isSelected(result.id))?'uk-block-muted':''">
|
||||||
|
<div >
|
||||||
|
<a *ngIf="result['title'].url" target="_blank" [href]="result['title'].url" >{{result['title'].name}}</a>
|
||||||
|
<span *ngIf="!result['title'].url" >{{result['title'].name}}</span>
|
||||||
|
<button *ngIf="!isSelected(result.id)" (click)="add(result, result.id, 'openaire', 'publication', result['title'].url, result['title'].name, result.year,result['title'].accessMode)" class="uk-button uk-align-right"><i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
||||||
|
</div>
|
||||||
|
<span *ngIf="result.publisher" class="uk-article-meta">Publisher: {{result.publisher}}</span><span class="uk-article-meta" *ngIf="(result.year)">({{result.year}})</span>
|
||||||
|
<div *ngIf="result.authors" class="uk-article-meta">Authors: <span *ngFor="let author of result.authors let i = index">{{author.name}}{{(i < (result.authors.length-1))?"; ":""}}</span></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li id="orcid" class="tab-pane fade">
|
||||||
|
<div class="uk-margin-top" >
|
||||||
|
<div *ngIf="orcidStatus == errorCodes.LOADING" class="uk-alert uk-alert-info" role="alert">Loading...</div>
|
||||||
|
<div *ngIf="orcidStatus == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
|
||||||
|
<div *ngIf="orcidStatus == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
|
||||||
|
<div *ngIf="orcidStatus == errorCodes.NONE && (!authorIds ||authorIds.length == 0)" class = "uk-alert uk-alert-info " > No results found </div>
|
||||||
|
|
||||||
|
<div *ngIf="orcidResultsNum != null" class="panel-body">
|
||||||
|
<div class = "uk-alert uk-alert-warning " > Not the right author? Choose one of these:
|
||||||
|
|
||||||
|
<span class="dropdown">
|
||||||
|
|
||||||
|
<select [(ngModel)]="authorId" name="select_author" >authorIds
|
||||||
|
<option *ngFor=" let item of authorIds let i = index" [value]="authorIds[i]" (click)="getOrcidResultsById(i)" >{{authorGivenNames[i]}} {{authorFamilyNames[i]}} : {{item}} </option>
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<span>Results for
|
||||||
|
<a target="_blank" href="http://orcid.org/{{authorId}}"><span class="uk-icon-external-link" ></span> {{authorGivenName}} {{authorFamilyName}} - {{authorId}} </a> :
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<div *ngIf=" ((orcidResultsNum >0) && (totalPages > 1) && ( 0 < page && page <= totalPages )) " class="uk-clearfix">
|
||||||
|
<div class="uk-float-right">
|
||||||
|
<paging-no-load [currentPage]="orcidPage" [totalResults]="orcidResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="orcidPageChange($event)"> </paging-no-load>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div >
|
||||||
|
<ul *ngIf="orcidResultsNum >0 && orcidResultsToShow.length > 0 " class="uk-list uk-list-line">
|
||||||
|
<li *ngFor=" let item of orcidResultsToShow " [class]="(isSelected(authorId+'-'+item['put-code']))?'uk-block-muted':''">
|
||||||
|
<div>
|
||||||
|
<span *ngIf="!item.URL" >{{item['work-title']['title'].value}}</span>
|
||||||
|
<button class="uk-button uk-align-right" *ngIf="!isSelected(authorId+item['put-code'])" (click)="add(item,authorId+'-'+item['put-code'],'orcid', 'publication', '', item['work-title']['title'].value, item['publication-date']?item['publication-date'].year.value :null,'OPEN')"><i aria-hidden="true" class= " uk-icon-plus clickable"></i></button>
|
||||||
|
</div>
|
||||||
|
<span *ngIf="item['journal-title'] && item['journal-title'].value " class="uk-article-meta">Journal: {{item['journal-title'].value}}</span><span class="uk-article-meta" *ngIf="(item['publication-date']&&item['publication-date'].year&&item['publication-date'].year.value)"> ({{item['publication-date'].year.value}})</span>
|
||||||
|
<div *ngIf="item.contributors" class="uk-article-meta">Authors: <span *ngFor="let author of item.contributors let i = index">{{author}}{{(i < (item.contributors.length-1))?"; ":""}}</span></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div *ngIf="orcidResultsNum == 0" class = "uk-alert uk-alert-info " > No results found </div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li id="datacite" class="tab-pane fade in active">
|
||||||
|
<div *ngIf="dataciteStatus == errorCodes.LOADING" class="uk-alert uk-alert-info" role="alert">Loading...</div>
|
||||||
|
<div *ngIf="dataciteStatus == errorCodes.NONE" class="uk-alert uk-alert-info" role="alert">No Results found</div>
|
||||||
|
<div *ngIf="dataciteStatus == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
|
||||||
|
<div *ngIf="dataciteStatus == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
|
||||||
|
<div class = "uk-margin-top">
|
||||||
|
<div *ngIf="dataciteResultsNum != null && dataciteResultsNum > 0" class="uk-clearfix">
|
||||||
|
<div class="uk-float-right">
|
||||||
|
<paging-no-load [currentPage]="datacitePage" [totalResults]="dataciteResultsNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="datacitePageChange($event)"> </paging-no-load>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--div *ngIf="dataciteResultsNum == null || dataciteResultsNum == 0" class="uk-alert uk-alert-info" role="alert">No results found</div-->
|
||||||
|
<div >
|
||||||
|
<ul *ngIf="dataciteResults.length > 0 " class="uk-list uk-list-line">
|
||||||
|
<li *ngFor=" let item of dataciteResults " [class]="(isSelected(item.doi))?'uk-block-muted':''" >
|
||||||
|
<div >
|
||||||
|
<a *ngIf="item.doi" target="_blank" href="{{'http://dx.doi.org/'+item.doi}}" ><span class="uk-icon-external-link" ></span> {{item.title}}</a>
|
||||||
|
<span *ngIf="!item.doi" >{{item.title}}</span>
|
||||||
|
<button class="uk-button uk-align-right" *ngIf="!isSelected(item.doi)" (click)="add(item, item.doi,'datacite','dataset', 'http://dx.doi.org/'+item.doi, item.title, null,'OPEN')"><i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<span *ngIf="item.publisher" class="uk-article-meta">Publisher: {{item.publisher}}</span>
|
||||||
|
<div *ngIf="item.creator" class="uk-article-meta">Authors: <span *ngFor="let author of item.creator let i = index">{{author}}{{(i < (item.creator.length-1))?"; ":""}}</span></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<li id="openaireData" class="tab-pane fade">
|
||||||
|
<div *ngIf="openaireDataStatus == errorCodes.LOADING" class="uk-alert uk-alert-info" role="alert">Loading...</div>
|
||||||
|
<div *ngIf="openaireDataStatus == errorCodes.NONE" class="uk-alert uk-alert-info" role="alert">No Results found</div>
|
||||||
|
<div *ngIf="openaireDataStatus == errorCodes.ERROR" class="uk-alert uk-alert-warning" role="alert">An Error Occured</div>
|
||||||
|
<div *ngIf="openaireDataStatus == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger" role="alert">Service not available</div>
|
||||||
|
<div class = "uk-margin-top">
|
||||||
|
<div *ngIf="openaireDataNum != null && openaireDataNum > 0" class="uk-clearfix">
|
||||||
|
<div class="uk-float-right">
|
||||||
|
<paging-no-load [currentPage]="openaireDataPage" [totalResults]="openaireDataNum" [navigateTo]="navigateTo" [term]="keyword" [size]="size" (pageChange)="openaireDataPageChange($event)"> </paging-no-load>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div >
|
||||||
|
<ul *ngIf="openaireData.length > 0 " class="uk-list uk-list-line">
|
||||||
|
<li *ngFor=" let result of openaireData " [class]="(isSelected(result.id))?'uk-block-muted':''">
|
||||||
|
<div >
|
||||||
|
<a *ngIf="result['title'].url" target="_blank" [href]="result['title'].url" >{{result['title'].name}}</a>
|
||||||
|
<span *ngIf="!result['title'].url" >{{result['title'].name}}</span>
|
||||||
|
|
||||||
|
|
||||||
|
<button class="uk-button uk-align-right" *ngIf="!isSelected(result.id)"
|
||||||
|
(click)="add(result, result.id, 'openaire','dataset', result['title'].url, result['title'].name, result.year, result['title'].accessMode)"> <i aria-hidden="true" class= "uk-icon-plus clickable"></i></button>
|
||||||
|
</div>
|
||||||
|
<span *ngIf="result.publisher" class="uk-article-meta">Publisher: {{result.publisher}}</span><span *ngIf="(result.year)" class="uk-article-meta">({{result.year}})</span>
|
||||||
|
<div *ngIf="result.authors" class="uk-article-meta">Authors: <span *ngFor="let author of result.authors let i = index">{{author.name}}{{(i < (result.authors.length-1))?"; ":""}}</span></div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<!--div *ngIf="openaireData.length == 0" class = "uk-alert uk-alert-info " > No results found </div-->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
|
@ -0,0 +1,531 @@
|
||||||
|
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
||||||
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
import {SearchCrossrefService} from '../claim-utils/service/searchCrossref.service';
|
||||||
|
import {SearchOrcidService} from '../claim-utils/service/searchOrcid.service';
|
||||||
|
import {SearchPublicationsService} from '../../services/searchPublications.service';
|
||||||
|
import { SearchDataciteService } from '../claim-utils/service/searchDatacite.service';
|
||||||
|
import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
||||||
|
|
||||||
|
import { ErrorCodes} from '../../utils/properties/openaireProperties';
|
||||||
|
import {ClaimResult} from '../claim-utils/claimEntities.class';
|
||||||
|
import{DOI} from '../../utils/string-utils.class';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'claim-result-search-form',
|
||||||
|
templateUrl: 'claimResultSearchForm.component.html',
|
||||||
|
|
||||||
|
})
|
||||||
|
export class ClaimResultSearchFormComponent {
|
||||||
|
constructor (private _searchDataciteService: SearchDataciteService, private _searchDatasetsService:SearchDatasetsService,
|
||||||
|
private _searchCrossrefService: SearchCrossrefService,private _searchOrcidService: SearchOrcidService, private _searchPublicationsService: SearchPublicationsService,
|
||||||
|
private route: ActivatedRoute) {
|
||||||
|
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.search();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 selectedResults = [] ;
|
||||||
|
// @Output() datasetsChange = new EventEmitter();
|
||||||
|
// @Output() publicationsChange = new EventEmitter();
|
||||||
|
|
||||||
|
@Output() resultsChange = new EventEmitter();
|
||||||
|
|
||||||
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
||||||
|
|
||||||
|
dataciteResults=[];
|
||||||
|
dataciteResultsNum:number = null;
|
||||||
|
// dataciteResultsNum : Observable<number> = null;
|
||||||
|
dataciteStatus = this.errorCodes.NONE;
|
||||||
|
datacitePage : number = 1;
|
||||||
|
|
||||||
|
openaireData=[];
|
||||||
|
openaireDataNum:number = 0 ;
|
||||||
|
openaireDataStatus = this.errorCodes.NONE;
|
||||||
|
openaireDataPage : number = 1;
|
||||||
|
|
||||||
|
public warningMessage = "";
|
||||||
|
public infoMessage = "";
|
||||||
|
|
||||||
|
public todayDate = '';
|
||||||
|
public nextDate = '';
|
||||||
|
public DOIs:string[] = [];
|
||||||
|
sub: any;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
crossrefResults=[];
|
||||||
|
crossrefResultsNum : number = null;
|
||||||
|
crossrefPage : number = 1;
|
||||||
|
crossrefStatus:number = this.errorCodes.NONE;
|
||||||
|
|
||||||
|
openairePubs = [];
|
||||||
|
openairePubsNum: number ;
|
||||||
|
openairePubsPage : number = 1;
|
||||||
|
openairePubsStatus:number = this.errorCodes.NONE;
|
||||||
|
|
||||||
|
orcidResults: string[];
|
||||||
|
orcidResultsNum: number ;
|
||||||
|
totalPages: number;
|
||||||
|
orcidResultsToShow: string[];
|
||||||
|
orcidPage : number = 1;
|
||||||
|
orcidStatus:number = this.errorCodes.NONE;
|
||||||
|
authorId: string;
|
||||||
|
authorGivenName: string;
|
||||||
|
authorFamilyName: string;
|
||||||
|
|
||||||
|
authorIds: string[];
|
||||||
|
authorGivenNames: string[];
|
||||||
|
authorFamilyNames: string[];
|
||||||
|
|
||||||
|
authorsNum : number ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
search(){
|
||||||
|
this.warningMessage = "";
|
||||||
|
this.infoMessage = "";
|
||||||
|
this.DOIs = DOI.getDOIsFromString(this.keyword);
|
||||||
|
this.getCrossrefResults(this.keyword, this.size,1);
|
||||||
|
this.searchOrcid(this.keyword);
|
||||||
|
this.searchOpenairePubs(this.keyword, this.size, 1);
|
||||||
|
this.searchDatacite(this.keyword,10,1);
|
||||||
|
this.searchOpenaireData(this.keyword,10,1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private getCrossrefResults (term: string, size : number, page : number) {
|
||||||
|
this.crossrefStatus = this.errorCodes.LOADING;
|
||||||
|
if( this.DOIs.length > 0 ){
|
||||||
|
this._searchCrossrefService.searchCrossrefByDOIs(this.DOIs).subscribe(
|
||||||
|
data => {
|
||||||
|
if(data != null) {
|
||||||
|
this.crossrefResults = data.items;
|
||||||
|
this.crossrefPage=page;
|
||||||
|
this.crossrefResultsNum = data['total-results'];
|
||||||
|
if(data.items == 0){
|
||||||
|
this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe(
|
||||||
|
data => {
|
||||||
|
if(data != null) {
|
||||||
|
this.crossrefResults = data.items;
|
||||||
|
this.crossrefPage=page;
|
||||||
|
this.crossrefResultsNum = data['total-results'];
|
||||||
|
this.crossrefStatus = this.errorCodes.DONE;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
this.crossrefStatus = this.errorCodes.ERROR;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
err =>{
|
||||||
|
console.log(err.status);
|
||||||
|
this.crossrefStatus = this.errorCodes.ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
this.crossrefStatus = this.errorCodes.DONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
//console.log(err);
|
||||||
|
this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe(
|
||||||
|
data => {
|
||||||
|
this.crossrefResults = data.items;
|
||||||
|
this.crossrefPage=page;
|
||||||
|
this.crossrefResultsNum = data['total-results'];
|
||||||
|
this.crossrefStatus = this.errorCodes.DONE;
|
||||||
|
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
console.log(err.status);
|
||||||
|
this.crossrefStatus = this.errorCodes.ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
|
||||||
|
this._searchCrossrefService.searchCrossrefResults(term, size, page).subscribe(
|
||||||
|
data => {
|
||||||
|
if(data != null) {
|
||||||
|
this.crossrefResults = data.items;
|
||||||
|
this.crossrefPage=page;
|
||||||
|
this.crossrefResultsNum = data['total-results'];
|
||||||
|
this.crossrefStatus = this.errorCodes.DONE;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
this.crossrefStatus = this.errorCodes.ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
console.log(err.status);
|
||||||
|
this.crossrefStatus = this.errorCodes.ERROR;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private searchOpenairePubs(term: string, size : number, page : number) {
|
||||||
|
|
||||||
|
if(this.DOIs.length > 0 ){
|
||||||
|
this.openairePubsStatus = this.errorCodes.LOADING;
|
||||||
|
this._searchPublicationsService.searchPublicationsByDois(this.DOIs, null, page, size, []).subscribe(
|
||||||
|
data => {
|
||||||
|
if(data != null) {
|
||||||
|
this.openairePubsPage=page;
|
||||||
|
this.openairePubsNum = data[0];
|
||||||
|
this.openairePubs = data[1];
|
||||||
|
this.openairePubsStatus = this.errorCodes.DONE;
|
||||||
|
if(this.openairePubsNum == 0){
|
||||||
|
this.openairePubsStatus = this.errorCodes.NONE;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
this.openairePubsStatus = this.errorCodes.ERROR;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
this.openairePubsStatus = this.errorCodes.ERROR;
|
||||||
|
console.log(err.status);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
this.openairePubsStatus = this.errorCodes.LOADING;
|
||||||
|
this._searchPublicationsService.searchPublications('q='+term, null, page, size, []).subscribe(
|
||||||
|
data => {
|
||||||
|
if(data != null) {
|
||||||
|
this.openairePubsPage=page;
|
||||||
|
this.openairePubsNum = data[0];
|
||||||
|
this.openairePubs = data[1];
|
||||||
|
this.openairePubsStatus = this.errorCodes.DONE;
|
||||||
|
if(this.openairePubsNum == 0){
|
||||||
|
this.openairePubsStatus = this.errorCodes.NONE;
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
this.openairePubsStatus = this.errorCodes.ERROR;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
this.openairePubsStatus = this.errorCodes.ERROR;
|
||||||
|
console.log(err.status);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private searchOrcid (term: string) {
|
||||||
|
if(this.DOIs.length > 0){
|
||||||
|
this.orcidStatus = this.errorCodes.NONE;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.orcidStatus = this.errorCodes.LOADING;
|
||||||
|
this.authorIds = new Array<string>();
|
||||||
|
this.authorGivenNames = new Array<string>();
|
||||||
|
this.authorFamilyNames = new Array<string>();
|
||||||
|
|
||||||
|
this.getOrcidAuthor(term);
|
||||||
|
|
||||||
|
console.info('searchOrcid in searchOrcid file');
|
||||||
|
}
|
||||||
|
|
||||||
|
private readData(data: any) {
|
||||||
|
this.authorIds.push(data[2].path);
|
||||||
|
|
||||||
|
if(data[0] != null) {
|
||||||
|
this.authorGivenNames.push(data[0].value);
|
||||||
|
} else {
|
||||||
|
this.authorGivenNames.push("");
|
||||||
|
}
|
||||||
|
if(data[1] != null) {
|
||||||
|
this.authorFamilyNames.push(data[1].value);
|
||||||
|
} else {
|
||||||
|
this.authorFamilyNames.push("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private getOrcidAuthor (term: string) {
|
||||||
|
this.orcidResultsNum = null;
|
||||||
|
|
||||||
|
//passing structures in order to fill them in service
|
||||||
|
this._searchOrcidService.searchOrcidAuthor(term, this.authorIds,
|
||||||
|
this.authorGivenNames, this.authorFamilyNames).subscribe(
|
||||||
|
data => {
|
||||||
|
if(data != null && data == true) {
|
||||||
|
this.getOrcidResultsById(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.orcidStatus = this.errorCodes.NONE;
|
||||||
|
|
||||||
|
},
|
||||||
|
err => this.errorHandler(err, term)
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private errorHandler(err: any, term: string) {
|
||||||
|
if(err.status == 404){
|
||||||
|
this.getOrcidAuthors(term);
|
||||||
|
} else {
|
||||||
|
this.orcidStatus = this.errorCodes.ERROR;
|
||||||
|
console.log(err.status);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private getOrcidAuthors (term: string) {
|
||||||
|
this.orcidResultsNum = null;
|
||||||
|
|
||||||
|
//passing structures in order to fill them in service
|
||||||
|
this._searchOrcidService.searchOrcidAuthors(term, this.authorIds,
|
||||||
|
this.authorGivenNames, this.authorFamilyNames).subscribe(
|
||||||
|
data => {
|
||||||
|
if(data != null && data == true) {
|
||||||
|
this.getOrcidResultsById(0);
|
||||||
|
}else{
|
||||||
|
this.orcidStatus = this.errorCodes.ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
this.orcidStatus = this.errorCodes.ERROR;
|
||||||
|
console.log(err.status);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private getOrcidResultsById (index:number) {
|
||||||
|
if(this.authorIds.length > index) {
|
||||||
|
this.orcidStatus = this.errorCodes.LOADING;
|
||||||
|
let id = this.authorIds[index];
|
||||||
|
this.authorGivenName = this.authorGivenNames[index];
|
||||||
|
this.authorFamilyName = this.authorFamilyNames[index];
|
||||||
|
this.authorId = id;
|
||||||
|
console.info("getOrcidResultsById: "+id);
|
||||||
|
this._searchOrcidService.searchOrcidPublications(id).subscribe(
|
||||||
|
data => {
|
||||||
|
if(data != null) {
|
||||||
|
this.orcidResults=data['orcid-work'];
|
||||||
|
this.orcidResultsNum = data['orcid-work'].length;
|
||||||
|
this.orcidPage = 1;
|
||||||
|
if((this.orcidResultsNum % this.size) == 0){
|
||||||
|
this.totalPages=parseInt(''+(this.orcidResultsNum/this.size));
|
||||||
|
} else{
|
||||||
|
this.totalPages=parseInt(''+(this.orcidResultsNum/this.size+1));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.orcidResultsToShow = this.orcidResults.slice(0,10);
|
||||||
|
|
||||||
|
this.orcidStatus = this.errorCodes.DONE;
|
||||||
|
if(this.orcidResultsNum == 0){
|
||||||
|
this.orcidStatus = this.errorCodes.NONE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.orcidResultsNum = 0;
|
||||||
|
this.totalPages=0;
|
||||||
|
this.orcidStatus = this.errorCodes.NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
console.log(err.status);
|
||||||
|
this.orcidStatus = this.errorCodes.ERROR;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Is it USED???
|
||||||
|
private remove(item){
|
||||||
|
this.warningMessage = "";
|
||||||
|
this.infoMessage = "";
|
||||||
|
var index:number =this.selectedResults.indexOf(item);
|
||||||
|
item.selected=false;
|
||||||
|
if (index > -1) {
|
||||||
|
this.selectedResults.splice(index, 1);
|
||||||
|
// this.publicationsChange.emit({
|
||||||
|
// value: this.selectedResults
|
||||||
|
// });
|
||||||
|
}
|
||||||
|
|
||||||
|
}*/
|
||||||
|
private crossrefPageChange($event) {
|
||||||
|
this.crossrefPage=$event.value;
|
||||||
|
this.crossrefResults=[];
|
||||||
|
console.log("Crossref chaenged "+this.crossrefPage);
|
||||||
|
this.getCrossrefResults(this.keyword,this.size,this.crossrefPage);
|
||||||
|
}
|
||||||
|
private orcidPageChange($event) {
|
||||||
|
this.orcidPage=$event.value;
|
||||||
|
this.orcidResultsToShow=[];
|
||||||
|
this.orcidResultsToShow = this.orcidResults.slice(($event.value-1)*this.size, $event.value*this.size);
|
||||||
|
}
|
||||||
|
private openairePubsPageChange($event) {
|
||||||
|
this.openairePubsPage=$event.value;
|
||||||
|
this.searchOpenairePubs(this.keyword,this.size,this.openairePubsPage);
|
||||||
|
}
|
||||||
|
datacitePageChange($event) {
|
||||||
|
this.datacitePage=$event.value;
|
||||||
|
this.dataciteResults=[];
|
||||||
|
this.searchDatacite(this.keyword,10,this.datacitePage);
|
||||||
|
this.warningMessage = "";
|
||||||
|
this.infoMessage = "";
|
||||||
|
|
||||||
|
}
|
||||||
|
openaireDataPageChange($event) {
|
||||||
|
this.openaireDataPage=$event.value;
|
||||||
|
this.openaireData=[];
|
||||||
|
this.searchOpenaireData(this.keyword,10,this.openaireDataPage);
|
||||||
|
this.warningMessage = "";
|
||||||
|
this.infoMessage = "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private isSelected(id:string){
|
||||||
|
|
||||||
|
var found:boolean = false;
|
||||||
|
this.warningMessage = "";
|
||||||
|
for (var _i = 0; _i < this.selectedResults.length; _i++) {
|
||||||
|
let item = this.selectedResults[_i];
|
||||||
|
if(item.id == id){
|
||||||
|
found=true;
|
||||||
|
this.warningMessage = "Publication already in selected list";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return found;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
// isSelected(id:string){
|
||||||
|
//
|
||||||
|
// var found:boolean = false;
|
||||||
|
// this.warningMessage = "";
|
||||||
|
// for (var _i = 0; _i < this.selectedResults.length; _i++) {
|
||||||
|
// let item = this.selectedResults[_i];
|
||||||
|
// if(item.id == id){
|
||||||
|
// found=true;
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return found;
|
||||||
|
// }
|
||||||
|
private searchDatacite (term: string, size : number, page : number) {
|
||||||
|
this.getDataciteResults(term,size,page);
|
||||||
|
this.warningMessage = "";
|
||||||
|
this.infoMessage = "";
|
||||||
|
|
||||||
|
}
|
||||||
|
private searchOpenaireData (term: string, size : number, page : number) {
|
||||||
|
if(this.DOIs.length > 0 ){
|
||||||
|
this.openaireDataStatus = this.errorCodes.LOADING;
|
||||||
|
this._searchDatasetsService.searchDatasetsByDois(this.DOIs, null, page, size, []).subscribe(
|
||||||
|
data => {
|
||||||
|
if(data != null) {
|
||||||
|
this.openaireDataPage=page;
|
||||||
|
this.openaireDataNum = data[0];
|
||||||
|
this.openaireData = data[1];
|
||||||
|
this.openaireDataStatus = this.errorCodes.DONE;
|
||||||
|
if(this.openaireDataNum == 0){
|
||||||
|
this.openaireDataStatus = this.errorCodes.NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
this.openaireDataStatus = this.errorCodes.ERROR;
|
||||||
|
console.log(err.status);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
this._searchDatasetsService.searchDatasets('q='+term+'', null, page, size, []).subscribe(
|
||||||
|
data => {
|
||||||
|
if(data != null) {
|
||||||
|
this.openaireDataPage=page;
|
||||||
|
this.openaireDataNum = data[0];
|
||||||
|
this.openaireData = data[1];
|
||||||
|
this.openaireDataStatus = this.errorCodes.DONE;
|
||||||
|
if(this.openaireDataNum == 0){
|
||||||
|
this.openaireDataStatus = this.errorCodes.NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
this.openaireDataStatus = this.errorCodes.ERROR;
|
||||||
|
console.log(err.status);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
this.warningMessage = "";
|
||||||
|
this.infoMessage = "";
|
||||||
|
|
||||||
|
}
|
||||||
|
private getDataciteResults (term: string, size : number, page : number) {
|
||||||
|
this._searchDataciteService.searchDataciteResults(term, size, page).subscribe(
|
||||||
|
data => {
|
||||||
|
this.dataciteResults = data.docs;
|
||||||
|
this.datacitePage=page;
|
||||||
|
this.dataciteResultsNum = data.numFound;
|
||||||
|
this.dataciteStatus = this.errorCodes.DONE;
|
||||||
|
|
||||||
|
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
this.dataciteStatus = this.errorCodes.ERROR;
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
add(item, itemId,itemSource,itemType, itemUrl, itemTitle, date, accessmode){
|
||||||
|
console.log(' adding ' + itemType + " From " + itemSource+" "+ itemTitle);
|
||||||
|
var result: ClaimResult ;
|
||||||
|
if(itemSource == 'datacite'){
|
||||||
|
result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date : date};
|
||||||
|
}else if (itemSource == 'openaire'){
|
||||||
|
//TODO put right access rights
|
||||||
|
// result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessMode, embargoEndDate: this.nextDate, date: date};
|
||||||
|
result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: accessmode, embargoEndDate: this.nextDate, date : date};
|
||||||
|
}else if(itemSource == 'crossref'){
|
||||||
|
date = (date == null) ? null : date.substring(0,10);
|
||||||
|
result = {id: itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date: date};
|
||||||
|
}else if (itemSource == 'orcid'){
|
||||||
|
date = (date == null) ? null : date + "-01.-01"
|
||||||
|
result = {id:itemId, type :itemType, source : itemSource, title: itemTitle,url: itemUrl, result: item, accessRights: 'OPEN', embargoEndDate: this.nextDate, date: date};
|
||||||
|
}
|
||||||
|
var found:boolean = this.isSelected( result.id);
|
||||||
|
|
||||||
|
this.warningMessage = "";
|
||||||
|
if (!found) {
|
||||||
|
this.selectedResults.push(result);
|
||||||
|
this.resultsChange.emit({
|
||||||
|
value: this.selectedResults
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
this.warningMessage = "Dataset already in selected list";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Pag
|
||||||
|
}
|
|
@ -2,10 +2,7 @@ import { NgModule } from '@angular/core';
|
||||||
|
|
||||||
import { SharedModule } from '../../shared/shared.module';
|
import { SharedModule } from '../../shared/shared.module';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
|
import {ClaimResultSearchFormComponent} from './claimResultSearchForm.component';
|
||||||
import {ClaimPublicationComponent} from './claimPublication.component';
|
|
||||||
import {ClaimDatasetComponent} from './claimDataset.component';
|
|
||||||
import {ClaimResultComponent} from './claimResult.component';
|
|
||||||
|
|
||||||
import {SearchDataciteService} from './service/searchDatacite.service';
|
import {SearchDataciteService} from './service/searchDatacite.service';
|
||||||
import {SearchCrossrefServiceModule} from './service/searchCrossrefService.module';
|
import {SearchCrossrefServiceModule} from './service/searchCrossrefService.module';
|
||||||
|
@ -23,9 +20,9 @@ import {PagingModule } from '../../utils/paging.module';
|
||||||
SearchDataciteService, SearchOrcidService
|
SearchDataciteService, SearchOrcidService
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
ClaimPublicationComponent, ClaimDatasetComponent, ClaimResultComponent
|
ClaimResultSearchFormComponent
|
||||||
|
|
||||||
],
|
],
|
||||||
exports: [ClaimResultComponent ]
|
exports: [ClaimResultSearchFormComponent ]
|
||||||
})
|
})
|
||||||
export class ClaimResultModule { }
|
export class ClaimResultSearchFormModule { }
|
|
@ -16,10 +16,10 @@ export class ClaimsService {
|
||||||
this.baseUrl = OpenaireProperties.getClaimsAPIURL();
|
this.baseUrl = OpenaireProperties.getClaimsAPIURL();
|
||||||
}
|
}
|
||||||
|
|
||||||
private getClaimRequest(size : number, page : number, url :string):any {
|
private getClaimRequest(size : number, page : number, url :string, fromCache:boolean):any {
|
||||||
console.info('ClaimsService: Claims request: '+url);
|
console.info('ClaimsService: Claims request: '+url);
|
||||||
let key = url;
|
let key = url;
|
||||||
if (this._cache.has(key)) {
|
if (fromCache && this._cache.has(key)) {
|
||||||
return Observable.of(this._cache.get(key));
|
return Observable.of(this._cache.get(key));
|
||||||
}
|
}
|
||||||
return this.http.get( url)
|
return this.http.get( url)
|
||||||
|
@ -34,31 +34,31 @@ export class ClaimsService {
|
||||||
console.info('ClaimsService: getClaims ' );
|
console.info('ClaimsService: getClaims ' );
|
||||||
console.info('ClaimsService: Types : '+types );
|
console.info('ClaimsService: Types : '+types );
|
||||||
let url = this.baseUrl +"claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
let url = this.baseUrl +"claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
||||||
return this.getClaimRequest(size,page,url);
|
return this.getClaimRequest(size,page,url,true);
|
||||||
|
|
||||||
}
|
}
|
||||||
getClaimsByUser( size : number, page : number, user:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
getClaimsByUser( size : number, page : number, user:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
||||||
console.info('ClaimsService: getClaims for user : '+user);
|
console.info('ClaimsService: getClaims for user : '+user);
|
||||||
let url = this.baseUrl +"users/"+user+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
let url = this.baseUrl +"users/"+user+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
||||||
return this.getClaimRequest(size,page,url);
|
return this.getClaimRequest(size,page,url,false);
|
||||||
|
|
||||||
}
|
}
|
||||||
getClaimsBycontext( size : number, page : number, contextId:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
getClaimsBycontext( size : number, page : number, contextId:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
||||||
console.info('ClaimsService: getClaims for context : '+contextId);
|
console.info('ClaimsService: getClaims for context : '+contextId);
|
||||||
let url = this.baseUrl +"contexts/"+contextId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
let url = this.baseUrl +"contexts/"+contextId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
||||||
return this.getClaimRequest(size,page,url);
|
return this.getClaimRequest(size,page,url,true);
|
||||||
|
|
||||||
}
|
}
|
||||||
getClaimsByResult( size : number, page : number, resultId:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
getClaimsByResult( size : number, page : number, resultId:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
||||||
console.info('ClaimsService: getClaims for result : '+resultId);
|
console.info('ClaimsService: getClaims for result : '+resultId);
|
||||||
let url = this.baseUrl +"results/"+resultId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
let url = this.baseUrl +"results/"+resultId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
||||||
return this.getClaimRequest(size,page,url);
|
return this.getClaimRequest(size,page,url,true);
|
||||||
|
|
||||||
}
|
}
|
||||||
getClaimsByProject( size : number, page : number, projectId:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
getClaimsByProject( size : number, page : number, projectId:string, keyword:string, sortby: string, descending: boolean, types: string):any {
|
||||||
console.info('ClaimsService: getClaims for project : '+projectId);
|
console.info('ClaimsService: getClaims for project : '+projectId);
|
||||||
let url = this.baseUrl +"projects/"+projectId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
let url = this.baseUrl +"projects/"+projectId+"/claims"+"?offset="+(size*(page-1) + "&limit="+size)+"&keyword="+keyword+"&sortby="+sortby+"&descending="+descending+"&"+types;
|
||||||
return this.getClaimRequest(size,page,url);
|
return this.getClaimRequest(size,page,url,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteClaimById(claimId:string):any{
|
deleteClaimById(claimId:string):any{
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
import { RouterModule } from '@angular/router';
|
||||||
|
|
||||||
|
import { DirectLinkingComponent } from './directLinking.component';
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
RouterModule.forChild([
|
||||||
|
{ path: '', component: DirectLinkingComponent},
|
||||||
|
|
||||||
|
])
|
||||||
|
]
|
||||||
|
})
|
||||||
|
export class DirectLinkingRoutingModule { }
|
|
@ -0,0 +1,204 @@
|
||||||
|
import {Component, Input} from '@angular/core';
|
||||||
|
import {Observable} from 'rxjs/Observable';
|
||||||
|
import {ActivatedRoute, Router} from '@angular/router';
|
||||||
|
import {EntitiesSearchService} from '../../utils/entitiesAutoComplete/entitySearch.service';
|
||||||
|
import {ClaimProject, ClaimResult} from '../claim-utils/claimEntities.class';
|
||||||
|
import {SearchPublicationsService} from '../../services/searchPublications.service';
|
||||||
|
import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'directLinking',
|
||||||
|
template: `
|
||||||
|
<div class="container uk-margin-top">
|
||||||
|
<div class="page-header">
|
||||||
|
<h1>Linking</h1>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="validInput != null && !validInput" class="uk-alert uk-alert-warning" role="alert">No valid arguments provided in order to start linking openAIRE entities. </div>
|
||||||
|
<div *ngIf="validInput != null && validInput">
|
||||||
|
<div class="uk-text-large">
|
||||||
|
{{(type=="project")?'Project':' Research result'}}:
|
||||||
|
</div>
|
||||||
|
<!-- inline result -->
|
||||||
|
<div *ngIf="displayedResult != null && (type =='publication' || type =='dataset' )" class="uk-panel uk-panel-box uk-panel-box-default">
|
||||||
|
<div class="uk-width-1-1" >
|
||||||
|
<div>
|
||||||
|
<a *ngIf="displayedResult.url" target="_blank" href="{{displayedResult.url}}" ><span class="uk-icon-external-link" ></span> {{displayedResult.title}}</a>
|
||||||
|
<span *ngIf="!displayedResult.url" >{{displayedResult.title}}</span>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="displayedResult.result.authors && displayedResult.result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of displayedResult.result.authors let i = index">{{author.name}}{{(i < (displayedResult.result.authors.length-1))?"; ":""}}</span></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- inline project -->
|
||||||
|
<div *ngIf=" type == 'project' && projects.length > 0 " class="uk-panel uk-panel-box uk-panel-box-default">
|
||||||
|
{{projects[0].funderName}} | {{projects[0].projectName}} {{(projects[0].projectAcronym)?'('+projects[0].projectAcronym+')':''}}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- search for entity -->
|
||||||
|
|
||||||
|
<div class = "uk-margin-top">
|
||||||
|
|
||||||
|
<div *ngIf=" linkTo =='context' " >
|
||||||
|
<claim-selected-contexts [contexts]="contexts" [show]="show" [linkType]=linkType
|
||||||
|
(showChange)="showChange($event)" > </claim-selected-contexts>
|
||||||
|
</div>
|
||||||
|
<div *ngIf=" linkTo =='project' " >
|
||||||
|
<claim-selected-projects [projects]="projects" [show]="show" [linkType]=linkType
|
||||||
|
(showChange)="showChange($event)" > </claim-selected-projects>
|
||||||
|
</div>
|
||||||
|
<claim-selected-results *ngIf=" linkTo =='result' " title="to link with Research Results" [results]="results" [showSearch]="show=='claim'? false: true" [showAccessRights]="show=='claim'? true: false"
|
||||||
|
bulkMode=false>
|
||||||
|
</claim-selected-results>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div *ngIf=" show == 'claim' " class="uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 uk-grid">
|
||||||
|
<div class="uk-width-1-1 ">
|
||||||
|
<claim-insert [contexts]="contexts" [results]="results" [projects]="projects" [inlineEntity] = "inlineResult" [show] = "show"
|
||||||
|
(showChange)="showChange($event)" ></claim-insert>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ul *ngIf="linkTo == 'result'" class="uk-pagination">
|
||||||
|
<li class="uk-pagination-previous" *ngIf="show == 'claim'" (click)="show='result';"><a><i class="uk-icon-angle-left"></i> Previous</a></li>
|
||||||
|
<li class="uk-pagination-next" *ngIf="show != 'claim'"(click)="show='claim';"><a>Next <i class="uk-icon-angle-right"></i></a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
`
|
||||||
|
|
||||||
|
})
|
||||||
|
export class DirectLinkingComponent {
|
||||||
|
contexts=[];
|
||||||
|
projects=[];
|
||||||
|
|
||||||
|
results = [];
|
||||||
|
|
||||||
|
linkType:string ="project"; // link type (selected in home page) : project, context, software, etc
|
||||||
|
/* url Parameters for inline linking */
|
||||||
|
id:string = null; //entity id
|
||||||
|
type:string = null; // entity type (publication or dataset)
|
||||||
|
linkTo:string = null; // entity type (project or context or result)
|
||||||
|
|
||||||
|
entityTypes=["dataset", "publication", "project","context"];
|
||||||
|
inlineResult:ClaimResult =null;
|
||||||
|
displayedResult:ClaimResult =null;
|
||||||
|
sub:any =null;
|
||||||
|
show:string="claim"; //{claim,result}
|
||||||
|
validInput:boolean = null;//'true;
|
||||||
|
constructor ( private _router: Router, private route: ActivatedRoute, private entitySearch:EntitiesSearchService, private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService) {
|
||||||
|
|
||||||
|
}
|
||||||
|
ngOnInit() {
|
||||||
|
this.sub = this.route.queryParams.subscribe(params => {
|
||||||
|
this.id = params['id'];
|
||||||
|
this.type = params['type'];
|
||||||
|
this.linkTo = params['linkTo'];
|
||||||
|
if(this.type!=null && this.linkTo!=null){
|
||||||
|
this.type = (this.entityTypes.indexOf(this.type) != -1)? this.type:'publication';
|
||||||
|
this.linkTo = (this.entityTypes.indexOf(this.linkTo) != -1 || this.linkTo == "result")? this.linkTo:'project';
|
||||||
|
this.show = (this.linkTo != "result")?"claim":"result";
|
||||||
|
this.linkType = this.linkTo;
|
||||||
|
var isInlineResult:boolean = false; // is a link result - result
|
||||||
|
if((this.type == "publication" || this.type == "dataset") && ((this.linkTo == "publication" || this.linkTo == "dataset") || this.linkTo == "result" )){
|
||||||
|
isInlineResult = true;
|
||||||
|
}
|
||||||
|
if(this.type == "project"){
|
||||||
|
this.linkType = "project";
|
||||||
|
this.getProjectById(this.id);
|
||||||
|
}else if(this.type == "publication"){
|
||||||
|
this.getPublicationById(this.id,isInlineResult);
|
||||||
|
}else if(this.type == "dataset"){
|
||||||
|
this.getDatasetById(this.id,isInlineResult);
|
||||||
|
}else{
|
||||||
|
this.validInput = this.isValidInput(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
this.validInput = this.isValidInput(null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
isValidInput(result){
|
||||||
|
if(result == null){
|
||||||
|
return false;
|
||||||
|
}else if(this.type == "project" && this.linkTo != "result"){
|
||||||
|
return false;
|
||||||
|
}else if(["dataset","publication"].indexOf(this.type) != -1 && (["project","context","result"].indexOf(this.linkTo) == -1)){
|
||||||
|
return false;
|
||||||
|
}else if(["project","dataset","publication"].indexOf(this.type) == -1){
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getProjectById(id:string){
|
||||||
|
this.sub = this.entitySearch.fetchByType(id,"project").subscribe(
|
||||||
|
data => {
|
||||||
|
console.log(data);
|
||||||
|
var item =data[0];
|
||||||
|
var project: ClaimProject = { funderId: item.funderId,funderName: item.funderName, projectId: id, projectName: item.projectName , projectAcronym: item.projectAcronym, startDate: item.startDate, endDate: item.endDate };
|
||||||
|
this.projects.push( project);
|
||||||
|
this.validInput = this.isValidInput(project);
|
||||||
|
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
this.validInput = this.isValidInput(null);
|
||||||
|
console.log("An error occured")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getPublicationById(id:string, isInlineResult:boolean){
|
||||||
|
|
||||||
|
this.sub = this.publicationsSearch.searchPublicationById(id).subscribe(
|
||||||
|
data => {
|
||||||
|
var item =data[0];
|
||||||
|
var result: ClaimResult = {id: id, type :"publication", source : "openaire", title: item['title'].name, url: item['title'].url, result: item, accessRights:item['title'].accessMode, embargoEndDate: null, date: item.year};
|
||||||
|
this.displayedResult = result;
|
||||||
|
if(isInlineResult){
|
||||||
|
this.inlineResult = result;
|
||||||
|
}else{
|
||||||
|
this.results.push( result);
|
||||||
|
}
|
||||||
|
this.validInput = this.isValidInput(result);
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
this.validInput = this.isValidInput(null);
|
||||||
|
console.log("An error occured")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getDatasetById(id:string, isInlineResult:boolean){
|
||||||
|
this.sub = this.datasetsSearch.searchDatasetById(id).subscribe(
|
||||||
|
data => {
|
||||||
|
var item =data[0];
|
||||||
|
var result: ClaimResult = {id: id, type : "dataset", source : "openaire", title: item['title'].name, url: item['title'].url, result: item, accessRights:item['title'].accessMode, embargoEndDate: null, date: item.year};
|
||||||
|
this.displayedResult = result;
|
||||||
|
if(isInlineResult){
|
||||||
|
this.inlineResult = result;
|
||||||
|
}else{
|
||||||
|
this.results.push( result);
|
||||||
|
}
|
||||||
|
this.validInput = this.isValidInput(result);
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
this.validInput = this.isValidInput(null);
|
||||||
|
console.log("An error occured")
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
resultsChange($event) {
|
||||||
|
this.results=$event.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
projectsChange($event) {
|
||||||
|
this.projects=$event.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
import { NgModule } from '@angular/core';
|
||||||
|
|
||||||
|
import { SharedModule } from '../../shared/shared.module';
|
||||||
|
import { DirectLinkingComponent } from './directLinking.component';
|
||||||
|
import { DirectLinkingRoutingModule } from './directLinking-routing.module';
|
||||||
|
|
||||||
|
import {SelectedProjectsModule} from '../linking/selected/selectedProjects.module';
|
||||||
|
import {SelectedContextsModule} from '../linking/selected/selectedContexts.module';
|
||||||
|
import {SelectedPublicationsModule} from '../linking/selected/selectedResults.module';
|
||||||
|
import {InsertClaimsModule} from '../linking/insertClaim/insertClaim.module';
|
||||||
|
|
||||||
|
import {EntitySearchServiceModule} from '../../utils/entitiesAutoComplete/entitySearchService.module';
|
||||||
|
import {PublicationsServiceModule} from '../../services/publicationsService.module';
|
||||||
|
import {DatasetsServiceModule} from '../../services/datasetsService.module';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [
|
||||||
|
SharedModule,
|
||||||
|
DirectLinkingRoutingModule,SelectedProjectsModule, SelectedContextsModule, SelectedPublicationsModule, InsertClaimsModule,
|
||||||
|
EntitySearchServiceModule, PublicationsServiceModule, DatasetsServiceModule
|
||||||
|
|
||||||
|
|
||||||
|
],
|
||||||
|
declarations: [
|
||||||
|
DirectLinkingComponent
|
||||||
|
], exports:[DirectLinkingComponent]
|
||||||
|
})
|
||||||
|
export class DirectLinkingModule { }
|
|
@ -1,94 +0,0 @@
|
||||||
import {Component, Input, ViewChild, Output, EventEmitter} from '@angular/core';
|
|
||||||
import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'inline-claim-context',
|
|
||||||
template: `
|
|
||||||
|
|
||||||
|
|
||||||
<div *ngIf="showComp" class="panel-body well well-lg">
|
|
||||||
<div class="row" >
|
|
||||||
<claim-contexts [selectedList]="contexts" (contextsChange)="contextsChange($event)" inline=true [showComponent]="showComp" > </claim-contexts>
|
|
||||||
|
|
||||||
<claim-selected-contexts [contexts]="contexts"
|
|
||||||
(showChange)="showChange($event)" inline=true [hideType]="inlineType" > </claim-selected-contexts>
|
|
||||||
</div>
|
|
||||||
<claim-insert (showChange)="showChange($event)" inline=true [contexts]="contexts" [publications]="publications" [datasets]="datasets" showButton=false ></claim-insert>
|
|
||||||
<button (click)="insert()" [class]="(enableButton)?'btn btn-xs btn-primary':'btn btn-primary btn-xs disabled'" style="float:right">Finish </button>
|
|
||||||
<button (click)="cancel()" [class]="(enableButton)?'btn btn-xs btn-default ':'btn btn-xs btn-default disabled'" style="float:left">Cancel </button>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
|
|
||||||
})
|
|
||||||
export class InlineClaimContextComponent {
|
|
||||||
constructor ( ) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Input() public inlineEntity:any;
|
|
||||||
@Input() public inlineType:string;
|
|
||||||
|
|
||||||
|
|
||||||
contexts=[];
|
|
||||||
publications;
|
|
||||||
datasets;
|
|
||||||
public show = 'context';
|
|
||||||
public showComp:boolean = false;
|
|
||||||
public enableButton:boolean=true;
|
|
||||||
public keyword: string = "";
|
|
||||||
|
|
||||||
@Output() contextAdded = new EventEmitter();
|
|
||||||
|
|
||||||
@ViewChild (ClaimInsertComponent) claimInsert : ClaimInsertComponent ;
|
|
||||||
ngOnInit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
showChange($event) {
|
|
||||||
this.show=$event.value;
|
|
||||||
if(this.show == "end"){
|
|
||||||
//TODO
|
|
||||||
this.contextAdded.emit({
|
|
||||||
value: this.contexts
|
|
||||||
});
|
|
||||||
this.contexts = [];
|
|
||||||
this.showComponent();
|
|
||||||
|
|
||||||
}else if(this.show == "error"){
|
|
||||||
this.showComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public toggle(){
|
|
||||||
if(!this.showComp){
|
|
||||||
this.showComponent();
|
|
||||||
}else{
|
|
||||||
this.hideComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private showComponent(){
|
|
||||||
this.showComp=true;
|
|
||||||
this.enableButton = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
private hideComponent(){
|
|
||||||
this.showComp=false;
|
|
||||||
}
|
|
||||||
private insert(){
|
|
||||||
this.claimInsert.publications = [];
|
|
||||||
this.claimInsert.publications.push(this.inlineEntity);
|
|
||||||
this.publications = [];
|
|
||||||
this.publications.push(this.inlineEntity);
|
|
||||||
console.info(" result: :targetId: " +this.publications[0].id + "targetType :"+ this.publications[0].type+" targetCollectedFrom:"+ this.publications[0].source+ "targetAccessRights :"+this.publications[0].accessRights+ " targetEmbargoEndDate:"+this.publications[0].embargoEndDate);
|
|
||||||
this.enableButton = false;
|
|
||||||
if (!this.claimInsert.validateInsertions()){
|
|
||||||
this.enableButton = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
private cancel(){
|
|
||||||
this.contexts = [];
|
|
||||||
|
|
||||||
this.hideComponent();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,107 +0,0 @@
|
||||||
import {Component, Input, ViewChild, Output, EventEmitter} from '@angular/core';
|
|
||||||
import {Observable} from 'rxjs/Observable';
|
|
||||||
import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'inline-claim-project',
|
|
||||||
template: `
|
|
||||||
|
|
||||||
|
|
||||||
<div *ngIf="showComp" class="panel-body well well-lg">
|
|
||||||
<div class="row" >
|
|
||||||
<claim-projects [selectedProjects]="projects" (projectsChange)="projectsChange($event)" inline=true > </claim-projects>
|
|
||||||
|
|
||||||
<claim-selected-projects [projects]="projects"
|
|
||||||
(showChange)="showChange($event)" inline=true [hideType]="inlineType" > </claim-selected-projects>
|
|
||||||
</div>
|
|
||||||
<claim-insert (showChange)="showChange($event)" inline=true [projects]="projects" [publications]="publications" [datasets]="datasets" showButton=false ></claim-insert>
|
|
||||||
<button (click)="insert()" [class]="(enableButton)?'btn btn-xs btn-primary':'btn btn-primary btn-xs disabled'" style="float:right">Finish </button>
|
|
||||||
<button (click)="cancel()" [class]="(enableButton)?'btn btn-xs btn-default ':'btn btn-xs btn-default disabled'" style="float:left">Cancel </button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
`
|
|
||||||
|
|
||||||
})
|
|
||||||
export class InlineClaimProjectComponent {
|
|
||||||
constructor () {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Input() public inlineEntity:any;
|
|
||||||
@Input() public inlineType:string;
|
|
||||||
|
|
||||||
|
|
||||||
public projects=[];
|
|
||||||
public publications;
|
|
||||||
public datasets;
|
|
||||||
public show = 'project';
|
|
||||||
public showComp:boolean = false;
|
|
||||||
public enableButton:boolean=true;
|
|
||||||
public keyword: string = "";
|
|
||||||
|
|
||||||
@Output() projectAdded = new EventEmitter();
|
|
||||||
|
|
||||||
@ViewChild (ClaimInsertComponent) claimInsert : ClaimInsertComponent ;
|
|
||||||
ngOnInit() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
showChange($event) {
|
|
||||||
this.show=$event.value;
|
|
||||||
if(this.show == "end"){
|
|
||||||
//TODO
|
|
||||||
this.projectAdded.emit({
|
|
||||||
value: this.projects
|
|
||||||
});
|
|
||||||
this.projects = [];
|
|
||||||
this.showComponent();
|
|
||||||
}else if(this.show == "error"){
|
|
||||||
this.showComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public toggle(){
|
|
||||||
console.info("TOOGLE pr ");
|
|
||||||
if(!this.showComp){
|
|
||||||
console.info("TOOGLE show ");
|
|
||||||
this.showComponent();
|
|
||||||
}else{
|
|
||||||
console.info("TOOGLE hide ");
|
|
||||||
this.hideComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private showComponent(){
|
|
||||||
this.showComp=true;
|
|
||||||
this.enableButton = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
private hideComponent(){
|
|
||||||
this.showComp=false;
|
|
||||||
}
|
|
||||||
private insert(){
|
|
||||||
if(this.inlineType === 'dataset'){
|
|
||||||
this.datasets = [];
|
|
||||||
this.datasets.push(this.inlineEntity);
|
|
||||||
this.claimInsert.datasets = [];
|
|
||||||
this.claimInsert.datasets.push(this.inlineEntity);
|
|
||||||
}else if(this.inlineType === 'publication'){
|
|
||||||
this.claimInsert.publications = [];
|
|
||||||
this.claimInsert.publications.push(this.inlineEntity);
|
|
||||||
this.publications = [];
|
|
||||||
this.publications.push(this.inlineEntity);
|
|
||||||
console.info(" result: :targetId: " +this.publications[0].id + "targetType :"+ this.publications[0].type+" targetCollectedFrom:"+ this.publications[0].source+ "targetAccessRights :"+this.publications[0].accessRights+ " targetEmbargoEndDate:"+this.publications[0].embargoEndDate);
|
|
||||||
}
|
|
||||||
this.enableButton = false;
|
|
||||||
if (!this.claimInsert.validateInsertions()){
|
|
||||||
this.enableButton = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
private cancel(){
|
|
||||||
this.projects = [];
|
|
||||||
|
|
||||||
this.hideComponent();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,117 +0,0 @@
|
||||||
import {Component, Input, ViewChild, Output, EventEmitter} from '@angular/core';
|
|
||||||
import {Observable} from 'rxjs/Observable';
|
|
||||||
import {ClaimInsertComponent} from '../linking/insertClaim/insertClaim.component';
|
|
||||||
// import {ClaimResultComponent} from '../linking/claimResult/claimResult.component';
|
|
||||||
// import {ClaimSelectedResultsComponent} from '../linking/selected/selectedResults.component';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'inline-claim-result',
|
|
||||||
template: `
|
|
||||||
|
|
||||||
|
|
||||||
<div *ngIf="showComp" class="panel-body well well-lg">
|
|
||||||
<div class="row" >
|
|
||||||
<claim-result [selectedDatasets]="datasets" [selectedPublications]="publications" (datasetsChange)="datasetsChange($event)" (publicationsChange)="publicationsChange($event)" inline=true > </claim-result>
|
|
||||||
|
|
||||||
<!-- ClaimSelectedResultsComponent -->
|
|
||||||
<claim-selected-results [publications]="publications" [datasets]="datasets"
|
|
||||||
(datasetsChange)="datasetsChange($event)" (publicationsChange)="publicationsChange($event)"
|
|
||||||
(showChange)="showChange($event)" inline=true [hideType]="hideType" [showAccessRights]=true > </claim-selected-results>
|
|
||||||
</div>
|
|
||||||
<claim-insert (showChange)="showChange($event)" inline=true [publications]="publications" [datasets]="datasets" showButton=false [inlineEntity]="inlineEntity" ></claim-insert>
|
|
||||||
<button (click)="insert()" [class]="(enableButton)?'btn btn-xs btn-primary':'btn btn-primary btn-xs disabled'" style="float:right">Finish </button>
|
|
||||||
<button (click)="cancel()" [class]="(enableButton)?'btn btn-xs btn-default ':'btn btn-xs btn-default disabled'" style="float:left">Cancel </button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
`
|
|
||||||
|
|
||||||
})
|
|
||||||
export class InlineClaimResultComponent {
|
|
||||||
constructor () {
|
|
||||||
|
|
||||||
}
|
|
||||||
// This is the component from the landing page
|
|
||||||
@Input() public inlineEntity:any;
|
|
||||||
@Input() public inlineType:string;
|
|
||||||
public hideType:string;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public publications = [];
|
|
||||||
public datasets = [];
|
|
||||||
public show = 'project';
|
|
||||||
public showComp:boolean = false;
|
|
||||||
public enableButton:boolean=true;
|
|
||||||
public keyword: string = "";
|
|
||||||
|
|
||||||
@Output() datasetAdded = new EventEmitter();
|
|
||||||
@Output() publicationAdded = new EventEmitter();
|
|
||||||
|
|
||||||
@ViewChild (ClaimInsertComponent) claimInsert : ClaimInsertComponent ;
|
|
||||||
ngOnInit() {
|
|
||||||
console.info("Inline entity:"+this.inlineEntity.id);
|
|
||||||
this.hideType = this.inlineType;
|
|
||||||
if(this.inlineType == 'dataset' || this.inlineType == 'publication' ){
|
|
||||||
this.hideType = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
datasetsChange($event) {
|
|
||||||
this.datasets=$event.value;
|
|
||||||
console.log($event.value);
|
|
||||||
}
|
|
||||||
publicationsChange($event) {
|
|
||||||
this.publications=$event.value;
|
|
||||||
console.log($event.value);
|
|
||||||
}
|
|
||||||
showChange($event) {
|
|
||||||
this.show=$event.value;
|
|
||||||
if(this.show == "end"){
|
|
||||||
this.datasetAdded.emit({
|
|
||||||
value: this.datasets
|
|
||||||
});
|
|
||||||
this.publicationAdded.emit({
|
|
||||||
value: this.publications
|
|
||||||
});
|
|
||||||
this.datasets = [];
|
|
||||||
this.publications = [];
|
|
||||||
this.showComponent();
|
|
||||||
}else if(this.show == "error"){
|
|
||||||
this.showComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public toggle(){
|
|
||||||
if(!this.showComp){
|
|
||||||
this.showComponent();
|
|
||||||
}else{
|
|
||||||
this.hideComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private showComponent(){
|
|
||||||
this.showComp=true;
|
|
||||||
this.enableButton = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
private hideComponent(){
|
|
||||||
this.showComp=false;
|
|
||||||
}
|
|
||||||
private insert(){
|
|
||||||
if(this.inlineType === 'project'){ //TODO check if neccessary
|
|
||||||
this.claimInsert.projects = [];
|
|
||||||
this.claimInsert.projects.push(this.inlineEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.enableButton = false;
|
|
||||||
if (!this.claimInsert.validateInsertions()){
|
|
||||||
this.enableButton = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
private cancel(){
|
|
||||||
this.datasets = [];
|
|
||||||
this.publications = [];
|
|
||||||
this.hideComponent();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -31,12 +31,10 @@ export class ClaimInsertComponent {
|
||||||
|
|
||||||
@Input() public contexts;
|
@Input() public contexts;
|
||||||
@Input() public projects;
|
@Input() public projects;
|
||||||
@Input() public publications;
|
@Input() public results;
|
||||||
@Input() public datasets;
|
|
||||||
@Input() public showButton:boolean = true;
|
@Input() public showButton:boolean = true;
|
||||||
@Input() show='claim';
|
@Input() show='claim';
|
||||||
@Input() inline: boolean = false; // link from landing page?
|
@Input() inlineEntity = null; // the entity from the landing page
|
||||||
@Input() inlineEntity; // the entity from the landing page
|
|
||||||
@Output() showChange = new EventEmitter();
|
@Output() showChange = new EventEmitter();
|
||||||
|
|
||||||
@ViewChild (ModalLoading) loading : ModalLoading ;
|
@ViewChild (ModalLoading) loading : ModalLoading ;
|
||||||
|
@ -65,12 +63,12 @@ private insert(){
|
||||||
var user="argirok@di.uoa.gr"
|
var user="argirok@di.uoa.gr"
|
||||||
this.loading.open();
|
this.loading.open();
|
||||||
var claims = [];
|
var claims = [];
|
||||||
if(this.publications){
|
if(this.results){
|
||||||
console.info("publications: "+this.publications.length);
|
console.info("results: "+this.results.length);
|
||||||
|
|
||||||
for (var i = 0; i < this.publications.length; i++) {
|
for (var i = 0; i < this.results.length; i++) {
|
||||||
|
|
||||||
var result=this.publications[i];
|
var result=this.results[i];
|
||||||
if(this.contexts){
|
if(this.contexts){
|
||||||
for (var j = 0; j < this.contexts.length; j++) {
|
for (var j = 0; j < this.contexts.length; j++) {
|
||||||
var context = this.contexts[j];
|
var context = this.contexts[j];
|
||||||
|
@ -85,37 +83,14 @@ private insert(){
|
||||||
claims.push(projectClaim);
|
claims.push(projectClaim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.inline && this.inlineEntity){
|
if(this.inlineEntity != null){
|
||||||
var resultClaim = this.createResultClaim(this.inlineEntity, result, user);
|
var resultClaim = this.createResultClaim(this.inlineEntity, result, user);
|
||||||
claims.push(resultClaim);
|
claims.push(resultClaim);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.datasets){
|
|
||||||
for (var i = 0; i < this.datasets.length; i++) {
|
|
||||||
var result=this.datasets[i];
|
|
||||||
if(this.contexts){
|
|
||||||
for (var j = 0; j < this.contexts.length; j++) {
|
|
||||||
var context = this.contexts[j];
|
|
||||||
var claim = this.createContextClaim(result, context, user);
|
|
||||||
claims.push(claim);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(this.projects){
|
|
||||||
for (var k = 0; k < this.projects.length; k++) {
|
|
||||||
var project = this.projects[k];
|
|
||||||
var projectClaim = this.createProjectClaim(result, project, user);
|
|
||||||
claims.push(projectClaim);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(this.inline && this.inlineEntity){
|
|
||||||
var resultClaim = this.createResultClaim(this.inlineEntity, result, user);
|
|
||||||
claims.push(resultClaim);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.info("try to insert "+claims.length+" claims");
|
console.info("try to insert "+claims.length+" claims");
|
||||||
this.claimService.insertBulkClaims(claims).subscribe(
|
this.claimService.insertBulkClaims(claims).subscribe(
|
||||||
data => {
|
data => {
|
||||||
|
@ -133,9 +108,9 @@ private insert(){
|
||||||
private validate(){
|
private validate(){
|
||||||
this.warningMessage = "";
|
this.warningMessage = "";
|
||||||
this.errorMessage = "";
|
this.errorMessage = "";
|
||||||
if(this.datasets && this.datasets.length == 0 && this.publications && this.publications.length == 0){
|
if( this.results && this.results.length == 0){
|
||||||
this.warningMessage = "There are no publications or datasets selected.";
|
this.warningMessage = "There are no research results selected.";
|
||||||
}else if((!this.contexts|| this.contexts.length==0 )&&(!this.projects|| this.projects.length==0 )&& ( !this.inlineEntity)){
|
}else if((!this.contexts|| this.contexts.length==0 )&&(!this.projects|| this.projects.length==0 )&& ( this.inlineEntity == null)){
|
||||||
this.warningMessage = "There are no projects or concepts to link.";
|
this.warningMessage = "There are no projects or concepts to link.";
|
||||||
// }else if (this.inline && !this.inlineEntity){
|
// }else if (this.inline && !this.inlineEntity){
|
||||||
// this.errorMessage = "No inline entity";
|
// this.errorMessage = "No inline entity";
|
||||||
|
@ -150,21 +125,9 @@ private validateDates(){
|
||||||
for (var k = 0; k < this.projects.length; k++) {
|
for (var k = 0; k < this.projects.length; k++) {
|
||||||
var project = this.projects[k];
|
var project = this.projects[k];
|
||||||
console.info(project.startDate+" "+project.endDate + " "+project.projectAcronym);
|
console.info(project.startDate+" "+project.endDate + " "+project.projectAcronym);
|
||||||
if(this.publications){
|
if(this.results){
|
||||||
for (var i = 0; i < this.publications.length; i++) {
|
for (var i = 0; i < this.results.length; i++) {
|
||||||
var result = this.publications[i];
|
var result = this.results[i];
|
||||||
if(result.date && result.date != null){
|
|
||||||
console.info("Date :"+ result.date + " & embargoEndDate :" +result.embargoEndDate );
|
|
||||||
if((project.startDate && result.date < project.startDate) || ( project.endDate && result.date > project.endDate) ){
|
|
||||||
this.confirmOpen();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(this.datasets){
|
|
||||||
for (var i = 0; i < this.datasets.length; i++) {
|
|
||||||
var result = this.datasets[i];
|
|
||||||
if(result.date && result.date != null){
|
if(result.date && result.date != null){
|
||||||
console.info("Date :"+ result.date + " & embargoEndDate :" +result.embargoEndDate );
|
console.info("Date :"+ result.date + " & embargoEndDate :" +result.embargoEndDate );
|
||||||
if((project.startDate && result.date < project.startDate) || ( project.endDate && result.date > project.endDate) ){
|
if((project.startDate && result.date < project.startDate) || ( project.endDate && result.date > project.endDate) ){
|
||||||
|
@ -178,9 +141,9 @@ private validateDates(){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.publications){
|
if(this.results){
|
||||||
for (var i = 0; i < this.publications.length; i++) {
|
for (var i = 0; i < this.results.length; i++) {
|
||||||
var result = this.publications[i];
|
var result = this.results[i];
|
||||||
if(result.date && result.date != null){
|
if(result.date && result.date != null){
|
||||||
console.info("Date :"+ result.date + " & embargoEndDate :" +result.embargoEndDate );
|
console.info("Date :"+ result.date + " & embargoEndDate :" +result.embargoEndDate );
|
||||||
if((result.embargoEndDate && result.embargoEndDate != null) && result.date >result.embargoEndDate ){
|
if((result.embargoEndDate && result.embargoEndDate != null) && result.date >result.embargoEndDate ){
|
||||||
|
@ -190,28 +153,17 @@ private validateDates(){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(this.datasets){
|
|
||||||
for (var i = 0; i < this.datasets.length; i++) {
|
|
||||||
var result = this.datasets[i];
|
|
||||||
if(result.date && result.date != null){
|
|
||||||
console.info("Date :"+ result.date + " & embargoEndDate :" +result.embargoEndDate );
|
|
||||||
if((result.embargoEndDate && result.embargoEndDate != null) && result.date >result.embargoEndDate ){
|
|
||||||
this.confirmOpen();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private afterclaimsInsertion(insertedIds, errorInClaims){
|
private afterclaimsInsertion(insertedIds, errorInClaims){
|
||||||
this.loading.close();
|
this.loading.close();
|
||||||
if(errorInClaims.length == 0 && insertedIds.length > 0 ){
|
if(errorInClaims.length == 0 && insertedIds.length > 0 ){
|
||||||
if(this.inline){
|
// if(this.inline){
|
||||||
this.show = "end";
|
// this.show = "end";
|
||||||
}else{
|
// }else{
|
||||||
this._router.navigate( ['/myclaims'] );
|
this._router.navigate( ['/myclaims'] );
|
||||||
}
|
// }
|
||||||
this.showChange.emit({
|
this.showChange.emit({
|
||||||
value: this.show
|
value: this.show
|
||||||
});
|
});
|
||||||
|
@ -223,12 +175,12 @@ private errorsInClaimsInsertion(insertedIds, errorInClaims){
|
||||||
this.errorMessage = "An Error Occured.";
|
this.errorMessage = "An Error Occured.";
|
||||||
this.loading.close();
|
this.loading.close();
|
||||||
this.error = true;
|
this.error = true;
|
||||||
if(this.inline){
|
// if(this.inline){
|
||||||
this.show = "error";
|
// this.show = "error";
|
||||||
this.showChange.emit({
|
// this.showChange.emit({
|
||||||
value: this.show
|
// value: this.show
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@ import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
||||||
<div class="container uk-margin-top">
|
<div class="container uk-margin-top">
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<div *ngIf=" bulkMode " class="uk-float-right uk-badge uk-badge-notification">
|
<div *ngIf=" bulkMode " class="uk-float-right uk-badge uk-badge-notification">
|
||||||
<span class="uk-text-center uk-margin-top">Bulk mode</span>
|
<span class="uk-text-center uk-margin-top uk-text-medium"> <i class="uk-icon-upload"></i> Bulk mode</span>
|
||||||
</div>
|
</div>
|
||||||
<h1>Link research resutls</h1>
|
<h1>Linking</h1>
|
||||||
</div>
|
</div>
|
||||||
<linking-home *ngIf=" show == 'home' " [bulkMode]="bulkMode" (linkTypeChange)="linkTypeChange($event)" ></linking-home>
|
<linking-home *ngIf=" show == 'home' " [bulkMode]="bulkMode" (linkTypeChange)="linkTypeChange($event)" ></linking-home>
|
||||||
|
|
||||||
|
@ -28,71 +28,36 @@ import {SearchDatasetsService} from '../../services/searchDatasets.service';
|
||||||
<li *ngIf="bulkMode " [class]="(show == 'claim' )?'uk-active':''"><span *ngIf="show == 'claim'">Upload & Link</span><a *ngIf="show != 'claim'" (click)="showChangedType('claim')">Upload & Link</a> </li>
|
<li *ngIf="bulkMode " [class]="(show == 'claim' )?'uk-active':''"><span *ngIf="show == 'claim'">Upload & Link</span><a *ngIf="show != 'claim'" (click)="showChangedType('claim')">Upload & Link</a> </li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div *ngIf=" show != 'claim' && show != 'myclaims' " class="uk-grid" >
|
<!--div *ngIf=" show != 'claim' && show != 'myclaims' " class="uk-grid" -->
|
||||||
<div *ngIf=" show=='result' && !bulkMode " class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2">
|
<!-- Research Results -->
|
||||||
<claim-result [selectedDatasets]="datasets" [selectedPublications]="publications" (datasetsChange)="datasetsChange($event)" (publicationsChange)="publicationsChange($event)" > </claim-result>
|
<div class="uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1">
|
||||||
</div>
|
<claim-selected-results title= "Research Results" [results]="results" [bulkMode]="bulkMode" [showSearch]="show=='claim'|| bulkMode? false: true" [showAccessRights]="show=='claim' || bulkMode? true: false">
|
||||||
<div *ngIf=" show=='project' " class="uk-width-1-1" >
|
</claim-selected-results>
|
||||||
<claim-projects [selectedProjects]="projects" > </claim-projects>
|
|
||||||
</div>
|
|
||||||
<div *ngIf=" show=='software' " class="uk-width-1-1">
|
|
||||||
<p>TODO software</p>
|
|
||||||
</div>
|
|
||||||
<div *ngIf=" show == 'context'" class="uk-width-1-1" >
|
|
||||||
<claim-contexts [selectedList]="contexts" > </claim-contexts>
|
|
||||||
</div>
|
</div>
|
||||||
|
<bulk-claim *ngIf=" bulkMode " [publications]="results" > </bulk-claim>
|
||||||
|
|
||||||
<div [class]="( show=='result' && !bulkMode)?'uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 ':'uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 uk-margin-top uk-grid'">
|
<!-- link with Projects & Contexts -->
|
||||||
<div [class]="( show=='result' && !bulkMode)?'uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 ':'uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2 '">
|
<div class="uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 uk-grid">
|
||||||
<claim-selected-contexts [contexts]="contexts" [show]="show"
|
<div class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2 ">
|
||||||
|
<claim-selected-contexts [contexts]="contexts" [show]="show"[linkType]=linkType
|
||||||
(showChange)="showChange($event)" > </claim-selected-contexts>
|
(showChange)="showChange($event)" > </claim-selected-contexts>
|
||||||
</div>
|
</div>
|
||||||
<div [class]="( show=='result' && !bulkMode)?'uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 ':'uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2 '">
|
<div class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2 ">
|
||||||
<claim-selected-projects [projects]="projects" [show]="show"
|
<claim-selected-projects [projects]="projects" [show]="show" [linkType]=linkType
|
||||||
(showChange)="showChange($event)" > </claim-selected-projects>
|
(showChange)="showChange($event)" > </claim-selected-projects>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div [class]="( show=='result' && !bulkMode)?'uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 ':'uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2'">
|
|
||||||
<claim-selected-publications [publications]="publications" [linkToResults]="(bulkMode)?false:true" [bulkMode]="bulkMode">
|
|
||||||
</claim-selected-publications>
|
|
||||||
</div>
|
|
||||||
<div [class]="( show=='result' && !bulkMode)?'uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 ':'uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2 '">
|
|
||||||
<claim-selected-datasets [datasets]="datasets" [linkToResults]="(bulkMode)?false:true" [bulkMode]="bulkMode"> </claim-selected-datasets>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div *ngIf=" show == 'claim' " class="uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 uk-grid">
|
<div *ngIf=" show == 'claim' " class="uk-width-small-1-1 uk-width-medium-1-1 uk-width-large-1-1 uk-grid">
|
||||||
|
|
||||||
<div class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2">
|
|
||||||
<claim-selected-contexts [contexts]="contexts" [show]="show" (showChange)="showChange($event)" > </claim-selected-contexts>
|
|
||||||
</div>
|
|
||||||
<div class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2">
|
|
||||||
<claim-selected-projects [projects]="projects" [show]="show"
|
|
||||||
(showChange)="showChange($event)" > </claim-selected-projects>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<bulk-claim *ngIf=" bulkMode " [publications]="publications" > </bulk-claim>
|
|
||||||
<div class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2">
|
|
||||||
<claim-selected-publications [publications]="publications" [showAccessRights]=true
|
|
||||||
[linkToResults]="(bulkMode)?false:true" [bulkMode]="bulkMode">
|
|
||||||
</claim-selected-publications>
|
|
||||||
</div>
|
|
||||||
<div class="uk-width-small-1-1 uk-width-medium-1-2 uk-width-large-1-2 uk-width-xlarge-1-2">
|
|
||||||
<claim-selected-datasets [datasets]="datasets" [showAccessRights]=true
|
|
||||||
[linkToResults]="(bulkMode)?false:true" [bulkMode]="bulkMode">
|
|
||||||
</claim-selected-datasets>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="uk-width-1-1 ">
|
<div class="uk-width-1-1 ">
|
||||||
<claim-insert [contexts]="contexts" [publications]="publications" [datasets]="datasets" [projects]="projects" [show] = "show"
|
<claim-insert [contexts]="contexts" [results]="results" [projects]="projects" [show] = "show"
|
||||||
(showChange)="showChange($event)" ></claim-insert>
|
(showChange)="showChange($event)" ></claim-insert>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul *ngIf="show != 'home'" class="uk-pagination">
|
<ul *ngIf="show != 'home'" class="uk-pagination">
|
||||||
<li class="uk-pagination-previous" (click)="prev()"><a><i class="uk-icon-angle-left"></i> Previous</a></li>
|
<li class="uk-pagination-previous" (click)="prev()"><a><i class="uk-icon-angle-left"></i> Previous</a></li>
|
||||||
<li class="uk-pagination-next" *ngIf="show != 'claim'" (click)="next()"><a>Next <i class="uk-icon-angle-right"></i></a></li>
|
<li class="uk-pagination-next" *ngIf="show != 'claim' " (click)="next()"><a>Next <i class="uk-icon-angle-right"></i></a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -109,144 +74,61 @@ export class LinkingGenericComponent {
|
||||||
step:number = 1;
|
step:number = 1;
|
||||||
contexts=[];
|
contexts=[];
|
||||||
projects=[];
|
projects=[];
|
||||||
publications=[];
|
results = [];
|
||||||
datasets=[];
|
|
||||||
show = "home";
|
show = "home";
|
||||||
date='8-6-2016';
|
date='8-6-2016';
|
||||||
keyword: string = "";
|
keyword: string = "";
|
||||||
linkType:string ="project"; // link type (selected in home page) : project, context, software, etc
|
linkType:string ="project"; // link type (selected in home page) : project, context, software, etc
|
||||||
/* Parameters for inline linking */
|
/* url Parameters for inline linking */
|
||||||
id:string = null; //entity id
|
id:string = null; //entity id
|
||||||
type:string = null; // entity type (publication or dataset)
|
type:string = null; // entity type (publication or dataset)
|
||||||
linkTo:string = null; // entity type (project or context)
|
linkTo:string = null; // entity type (project or context or result)
|
||||||
|
|
||||||
entityTypes=["dataset", "publication", "project","context"];
|
entityTypes=["dataset", "publication", "project","context"];
|
||||||
inlineSearchResult:ClaimResult =null;
|
inlineResult:ClaimResult =null;
|
||||||
sub:any =null;
|
sub:any =null;
|
||||||
constructor ( private _router: Router, private route: ActivatedRoute, private entitySearch:EntitiesSearchService, private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService) {
|
constructor ( private _router: Router, private route: ActivatedRoute, private entitySearch:EntitiesSearchService, private publicationsSearch:SearchPublicationsService, private datasetsSearch:SearchDatasetsService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.sub = this.route.queryParams.subscribe(params => {
|
|
||||||
this.id = params['id'];
|
|
||||||
this.type = params['type'];
|
|
||||||
this.linkTo = params['linkTo'];
|
|
||||||
if(this.type!=null && this.linkTo!=null){
|
|
||||||
this.type = (this.entityTypes.indexOf(this.type) != -1)? this.type:'publication';
|
|
||||||
this.linkTo = (this.entityTypes.indexOf(this.linkTo) != -1 || this.linkTo == "result")? this.linkTo:'project';
|
|
||||||
this.show = this.linkTo;
|
|
||||||
this.linkType = this.linkTo;
|
|
||||||
var isInlineSearchResult:boolean = false;
|
|
||||||
if((this.type == "publication" || this.type == "dataset") && (this.linkTo == "publication" || this.linkTo == "dataset")){
|
|
||||||
isInlineSearchResult = true;
|
|
||||||
}
|
|
||||||
if(this.type == "project"){
|
|
||||||
this.linkType = "project";
|
|
||||||
this.getProjectById(this.id);
|
|
||||||
}else if(this.type == "publication"){
|
|
||||||
this.getPublicationById(this.id,isInlineSearchResult);
|
|
||||||
}else if(this.type == "dataset"){
|
|
||||||
this.getDatasetById(this.id,isInlineSearchResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getProjectById(id:string){
|
|
||||||
this.sub = this.entitySearch.fetchByType(id,"project").subscribe(
|
|
||||||
data => {
|
|
||||||
console.log(data);
|
|
||||||
var item =data[0];
|
|
||||||
var project: ClaimProject = { funderId: item.funderId,funderName: item.funderName, projectId: id, projectName: item.projectName , projectAcronym: item.projectAcronym, startDate: item.startDate, endDate: item.endDate };
|
|
||||||
this.projects.push( project);
|
|
||||||
|
|
||||||
},
|
|
||||||
err => console.log("An error occured"));
|
|
||||||
}
|
|
||||||
getPublicationById(id:string, isInlineSearchResult:boolean){
|
|
||||||
|
|
||||||
this.sub = this.publicationsSearch.searchPublicationById(id).subscribe(
|
|
||||||
data => {
|
|
||||||
var item =data[0];
|
|
||||||
|
|
||||||
var result: ClaimResult = {id: id, type :"publication", source : "openaire", title: item['title'].name, url: item['title'].url, result: item, accessRights:item['title'].accessMode, embargoEndDate: null, date: item.year};
|
|
||||||
if(isInlineSearchResult){
|
|
||||||
this.inlineSearchResult = result;
|
|
||||||
}else{
|
|
||||||
this.publications.push( result);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
err => console.log("An error occured"));
|
|
||||||
}
|
|
||||||
getDatasetById(id:string, isInlineSearchResult:boolean){
|
|
||||||
this.sub = this.datasetsSearch.searchDatasetById(id).subscribe(
|
|
||||||
data => {
|
|
||||||
var item =data[0];
|
|
||||||
console.log(item);
|
|
||||||
var result: ClaimResult = {id: id, type : "dataset", source : "openaire", title: item['title'].name, url: item['title'].url, result: item, accessRights:item['title'].accessMode, embargoEndDate: null, date: item.year};
|
|
||||||
if(isInlineSearchResult){
|
|
||||||
this.inlineSearchResult = result;
|
|
||||||
}else{
|
|
||||||
this.datasets.push( result);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
err => console.log("An error occured"));
|
|
||||||
|
|
||||||
}
|
|
||||||
next(){
|
next(){
|
||||||
|
|
||||||
if((this.show == 'project' || this.show == 'context' || this.show == 'software')){
|
if((this.show == 'result' && this.keyword == '')||(this.show == 'dataset' || this.show == 'publication')){
|
||||||
if(!this.bulkMode){
|
|
||||||
this.show='result';
|
|
||||||
}else{
|
|
||||||
this.show='claim';
|
|
||||||
}
|
|
||||||
}else if((this.show == 'result' && this.keyword == '')||(this.show == 'dataset' || this.show == 'publication')){
|
|
||||||
this.show='claim';
|
this.show='claim';
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prev(){
|
prev(){
|
||||||
if(this.show == 'result'){
|
if(this.show == 'result'){
|
||||||
this.show = this.linkType;
|
this.show = 'home'//this.linkType;
|
||||||
}else if(this.show == 'context' || this.show == 'project' || this.show == 'software' ){
|
|
||||||
this.show='home';
|
} else if(this.show == 'claim'){
|
||||||
} else if(this.show == 'claim'){
|
|
||||||
if(!this.bulkMode){
|
if(!this.bulkMode){
|
||||||
this.show='result';
|
this.show='result';
|
||||||
}else{
|
}else{
|
||||||
this.show = this.linkType;
|
this.show = "home";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goto(term: string) {
|
|
||||||
this._router.navigate( ['Search', { keyword: term }] );
|
|
||||||
|
resultsChange($event) {
|
||||||
|
this.results=$event.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sourceTypeChange($event) {
|
|
||||||
this.sourceType=$event.value;
|
|
||||||
console.log($event.value);
|
|
||||||
}
|
|
||||||
targetTypeChange($event) {
|
|
||||||
this.targetType=$event.value;
|
|
||||||
console.log($event.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
publicationsChange($event) {
|
|
||||||
this.publications=$event.value;
|
|
||||||
}
|
|
||||||
datasetsChange($event) {
|
|
||||||
this.datasets=$event.value;
|
|
||||||
}
|
|
||||||
projectsChange($event) {
|
projectsChange($event) {
|
||||||
this.projects=$event.value;
|
this.projects=$event.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
linkTypeChange($event) {
|
linkTypeChange($event) {
|
||||||
|
|
||||||
this.linkType =$event.value;
|
this.linkType =$event.value;
|
||||||
this.show=$event.value;
|
this.show="result";
|
||||||
|
if(this.bulkMode){
|
||||||
|
this.show="claim";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
showChange($event) {
|
showChange($event) {
|
||||||
|
|
|
@ -3,13 +3,7 @@ import { NgModule } from '@angular/core';
|
||||||
import { SharedModule } from '../../shared/shared.module';
|
import { SharedModule } from '../../shared/shared.module';
|
||||||
import {SelectedProjectsModule} from './selected/selectedProjects.module';
|
import {SelectedProjectsModule} from './selected/selectedProjects.module';
|
||||||
import {SelectedContextsModule} from './selected/selectedContexts.module';
|
import {SelectedContextsModule} from './selected/selectedContexts.module';
|
||||||
import {SelectedPublicationsModule} from './selected/selectedPublications.module';
|
import {SelectedPublicationsModule} from './selected/selectedResults.module';
|
||||||
import {SelectedDatasetsModule} from './selected/selectedDatasets.module';
|
|
||||||
// import {SelectedModule} from './selected/selectedResults.module';
|
|
||||||
|
|
||||||
import {ClaimProjectModule} from '../claim-utils/claimProject.module';
|
|
||||||
import {ClaimResultModule} from '../claim-utils/claimResult.module';
|
|
||||||
import {ClaimContextModule} from '../claim-utils/claimContext.module';
|
|
||||||
|
|
||||||
import {InsertClaimsModule} from './insertClaim/insertClaim.module';
|
import {InsertClaimsModule} from './insertClaim/insertClaim.module';
|
||||||
import {BulkClaimModule} from './bulkClaim/bulkClaim.module';
|
import {BulkClaimModule} from './bulkClaim/bulkClaim.module';
|
||||||
|
@ -23,8 +17,8 @@ import {DatasetsServiceModule} from '../../services/datasetsService.module';
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
SharedModule, SelectedProjectsModule, SelectedContextsModule,
|
SharedModule, SelectedProjectsModule, SelectedContextsModule,
|
||||||
SelectedPublicationsModule, SelectedDatasetsModule,
|
SelectedPublicationsModule,
|
||||||
ClaimProjectModule, ClaimResultModule, ClaimContextModule, InsertClaimsModule, BulkClaimModule,
|
InsertClaimsModule, BulkClaimModule,
|
||||||
EntitySearchServiceModule, PublicationsServiceModule, DatasetsServiceModule
|
EntitySearchServiceModule, PublicationsServiceModule, DatasetsServiceModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
|
|
|
@ -8,19 +8,13 @@ import {Observable} from 'rxjs/Observable';
|
||||||
|
|
||||||
<div class="uk-grid">
|
<div class="uk-grid">
|
||||||
<div class="uk-width-1-2"> <div class="uk-panel uk-panel-box uk-text-center uk-margin-top ">
|
<div class="uk-width-1-2"> <div class="uk-panel uk-panel-box uk-text-center uk-margin-top ">
|
||||||
<a (click)="select('project')">
|
<a (click)="select('project')"><span class="uk-text-large">Link with project</span></a>
|
||||||
<h4 class="card-title">Link with project</h4>
|
<p class="card-text">Link your research result with funded projects.</p>
|
||||||
<p class="card-text">Link your research result with funded projects.</p>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
</div></div>
|
</div></div>
|
||||||
|
|
||||||
|
|
||||||
<div class="uk-width-1-2"> <div class="uk-panel uk-panel-box uk-text-center uk-margin-top ">
|
<div class="uk-width-1-2"> <div class="uk-panel uk-panel-box uk-text-center uk-margin-top ">
|
||||||
<a (click)="select('context')" >
|
<a (click)="select('context')" ><span class="uk-text-large">Link with Community</span> </a>
|
||||||
<h4 class="card-title">Link with Community</h4>
|
<p class="card-text">Link your research result with research communities.</p>
|
||||||
<p class="card-text">Link your research result with research communities.</p>
|
|
||||||
</a>
|
|
||||||
</div> </div>
|
</div> </div>
|
||||||
<!--div class="uk-width-1-2"> <div class="uk-panel uk-panel-box uk-text-center uk-margin-top ">
|
<!--div class="uk-width-1-2"> <div class="uk-panel uk-panel-box uk-text-center uk-margin-top ">
|
||||||
<a (click)="select('software')" >
|
<a (click)="select('software')" >
|
||||||
|
@ -28,11 +22,20 @@ import {Observable} from 'rxjs/Observable';
|
||||||
<p class="card-text">Link your research result with software.</p>
|
<p class="card-text">Link your research result with software.</p>
|
||||||
</a>
|
</a>
|
||||||
</div> </div-->
|
</div> </div-->
|
||||||
<div class="uk-width-1-2" *ngIf=" !bulkMode "> <div class="uk-panel uk-panel-box uk-text-center uk-margin-top ">
|
<div class="uk-width-1-2" *ngIf=" !bulkMode ">
|
||||||
<a href="/bulk-linking" > <h4 class="card-title">Bulk mode linking</h4>
|
<div class="uk-panel uk-panel-box uk-text-center uk-margin-top ">
|
||||||
<p class="card-text">Link Research Results to projects,contects, etc, providing a CSV file with research results' DOIs</p>
|
<a href="/participate/bulk-claim" > <span class="uk-text-large"><i class="uk-icon-upload"> </i> Bulk mode linking</span></a>
|
||||||
</a>
|
<p class="card-text">Link Research Results to projects & communities, providing a CSV file with research results' DOIs</p>
|
||||||
</div> </div>
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="uk-width-1-2" *ngIf=" bulkMode ">
|
||||||
|
<div class="uk-panel uk-panel-box uk-text-center uk-margin-top ">
|
||||||
|
<a href="/participate/claim" > <span class="uk-text-large"><i class="uk-icon-search"></i>Linking</span></a>
|
||||||
|
<p class="card-text">Search for Research Results and link them to projects & communities</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -3,14 +3,14 @@ import {ClaimContext} from '../../claim-utils/claimEntities.class';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'claim-selected-contexts',
|
selector: 'claim-selected-contexts',
|
||||||
template: `
|
template: `
|
||||||
<div [class]="componentClass" >
|
|
||||||
<!-- Contexts -->
|
<!-- Contexts -->
|
||||||
<!--div *ngIf=" !(inline && hideType == 'context') && contexts" class="concepts" -->
|
|
||||||
<div *ngIf=" !(inline && hideType == 'context') " class="uk-accordion" data-uk-accordion="{showfirst:false}">
|
<div *ngIf="this.linkType == 'context'" class="uk-accordion" data-uk-accordion="{showfirst:true}">
|
||||||
<h3 class="uk-accordion-title"><i class="uk-icon-caret-square-o-right"></i> Concepts ({{(contexts.length)}})
|
<h3 class="uk-accordion-title"><i class="uk-icon-caret-square-o-right"></i> to link with Communities ({{(contexts.length)}})</h3>
|
||||||
<!--span *ngIf=" !inline" title="Add More Concepts" (click)="showType('context')" aria-hidden="true" style="float:right;cursor: pointer;"><i class="uk-icon-plus"></i></span-->
|
|
||||||
</h3>
|
|
||||||
<div class="uk-accordion-content" >
|
<div class="uk-accordion-content" >
|
||||||
|
<div class="uk-clearfix"><button *ngIf=" !showsearch " (click)="showsearch = true;" class="uk-button uk-animation uk-float-right">Add more <i class="uk-icon-plus"></i></button></div>
|
||||||
|
<claim-contexts-search-form *ngIf=" showsearch " [selectedList]="contexts" (contextSelected)="contextSelected($event)" > </claim-contexts-search-form>
|
||||||
<ul class="uk-list uk-list-line">
|
<ul class="uk-list uk-list-line">
|
||||||
<li class="list-group-item" *ngFor="let context of contexts" >
|
<li class="list-group-item" *ngFor="let context of contexts" >
|
||||||
<span >{{context.community }} > {{context.category}} > {{context.concept.label}} </span>
|
<span >{{context.community }} > {{context.category}} > {{context.concept.label}} </span>
|
||||||
|
@ -21,9 +21,24 @@ import {ClaimContext} from '../../claim-utils/claimEntities.class';
|
||||||
<span *ngIf="contexts.length == 0 " class="uk-alert uk-alert-primary">There are no contexts</span>
|
<span *ngIf="contexts.length == 0 " class="uk-alert uk-alert-primary">There are no contexts</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div *ngIf="this.linkType != 'context'" class="uk-accordion" data-uk-accordion="{showfirst:false}">
|
||||||
|
<h3 class="uk-accordion-title"><i class="uk-icon-caret-square-o-right"></i> Concepts ({{(contexts.length)}})</h3>
|
||||||
|
<div class="uk-accordion-content" >
|
||||||
|
<div class="uk-clearfix"><button *ngIf=" !showsearch " (click)="showsearch = true;" class="uk-button uk-float-right">Add more <i class="uk-icon-plus"></i></button></div>
|
||||||
|
<claim-contexts-search-form *ngIf=" showsearch " [selectedList]="contexts" (contextSelected)="contextSelected($event)" > </claim-contexts-search-form>
|
||||||
|
<ul class="uk-list uk-list-line">
|
||||||
|
<li class="list-group-item" *ngFor="let context of contexts" >
|
||||||
|
<span >{{context.community }} > {{context.category}} > {{context.concept.label}} </span>
|
||||||
|
<span (click)="removeContext(context)" aria-hidden="true" class="uk-button "><i class="uk-icon-remove"></i></span>
|
||||||
|
|
||||||
</div>
|
</li>
|
||||||
`
|
</ul>
|
||||||
|
<div *ngIf="contexts.length == 0 " class="uk-alert uk-alert-primary">There are no communities to link with.</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
`
|
||||||
})
|
})
|
||||||
export class ClaimSelectedContextsComponent {
|
export class ClaimSelectedContextsComponent {
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -31,16 +46,23 @@ export class ClaimSelectedContextsComponent {
|
||||||
this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
||||||
this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
||||||
//2015-05-01
|
//2015-05-01
|
||||||
|
if(this.linkType == "context"){
|
||||||
|
this.showsearch = true
|
||||||
|
}else{
|
||||||
|
this.showsearch = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Input() contexts:ClaimContext[];
|
@Input() contexts:ClaimContext[];
|
||||||
@Input() componentClass:string = ""; //"" or "col-sm-6" for horizontal display (besides projects)
|
@Input() componentClass:string = ""; //"" or "col-sm-6" for horizontal display (besides projects)
|
||||||
@Input() show='home';
|
@Input() show='home';
|
||||||
@Input() inline:boolean = false;
|
@Input() linkType:string = "project";
|
||||||
|
|
||||||
@Input() hideType;
|
@Input() hideType;
|
||||||
@Input() bulkMode:boolean = false;
|
@Input() bulkMode:boolean = false;
|
||||||
@Output() showChange = new EventEmitter();
|
@Output() showChange = new EventEmitter();
|
||||||
|
showsearch:boolean = false;
|
||||||
|
|
||||||
todayDate = '';
|
todayDate = '';
|
||||||
nextDate = '';
|
nextDate = '';
|
||||||
|
@ -59,8 +81,11 @@ export class ClaimSelectedContextsComponent {
|
||||||
var index:number =this.contexts.indexOf(item);
|
var index:number =this.contexts.indexOf(item);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
this.contexts.splice(index, 1);
|
this.contexts.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
contextSelected($event) {
|
||||||
|
this.showsearch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,11 @@ import { NgModule } from '@angular/core';
|
||||||
|
|
||||||
import { SharedModule } from '../../../shared/shared.module';
|
import { SharedModule } from '../../../shared/shared.module';
|
||||||
import {ClaimSelectedContextsComponent} from './selectedContexts.component';
|
import {ClaimSelectedContextsComponent} from './selectedContexts.component';
|
||||||
|
import {ClaimContextSearchFormModule} from '../../claim-utils/claimContextSearchForm.module';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
SharedModule,
|
SharedModule, ClaimContextSearchFormModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
ClaimSelectedContextsComponent
|
ClaimSelectedContextsComponent
|
||||||
|
|
|
@ -1,141 +0,0 @@
|
||||||
import {Component, Input,Output, EventEmitter,ViewChild} from '@angular/core';
|
|
||||||
import {AlertModal} from '../../../utils/modal/alert';
|
|
||||||
import {ClaimResult} from '../../claim-utils/claimEntities.class';
|
|
||||||
@Component({
|
|
||||||
selector: 'claim-selected-datasets',
|
|
||||||
template: `
|
|
||||||
|
|
||||||
<div *ngIf=" !(inline && ( hideType == 'dataset' ))" class="uk-accordion " data-uk-accordion="{showfirst:false}" >
|
|
||||||
<h3 class="uk-accordion-title" > <i class="uk-icon-caret-square-o-right"></i> Research Data ({{(datasets.length)}}) </h3>
|
|
||||||
<div class="uk-accordion-content" >
|
|
||||||
|
|
||||||
<span *ngIf="datasets.length == 0 " class="uk-alert uk-alert-primary">There are no selected research data</span>
|
|
||||||
|
|
||||||
<ul *ngIf="datasets.length > 0 " class="uk-list uk-list-line">
|
|
||||||
<li *ngFor="let dataset of datasets" >
|
|
||||||
<div class="uk-grid">
|
|
||||||
|
|
||||||
<div [ngClass]="showAccessRights?'uk-width-7-10':'uk-width-1-1'">
|
|
||||||
<div>
|
|
||||||
<span *ngIf="showAccessRights" (click)="removeDataset(dataset)" aria-hidden="true" class="uk-button "><i class="uk-icon-remove"></i></span>
|
|
||||||
<a *ngIf="dataset.url" target="_blank" href="{{dataset.url}}" ><span class="uk-icon-external-link custom-icon" ></span> {{dataset.title}}</a>
|
|
||||||
<span *ngIf="!dataset.url" >{{dataset.title}}</span>
|
|
||||||
<span *ngIf="!showAccessRights" (click)="removeDataset(dataset)" aria-hidden="true" class="uk-button"><i class="uk-icon-remove"></i></span>
|
|
||||||
</div>
|
|
||||||
<span *ngIf="dataset.result.publisher" class="uk-article-meta">Publisher: {{dataset.result.publisher}}</span><span *ngIf="dataset.date" class="uk-article-meta">({{dataset.date.substring(0,4)}})</span>
|
|
||||||
<div *ngIf="dataset.result.authors" class="uk-article-meta">Authors: <span *ngFor="let author of dataset.result.authors let i = index">{{author.name}}{{(i < (dataset.result.authors.length-1))?"; ":""}}</span></div>
|
|
||||||
<div *ngIf="dataset.result.creator" class="uk-article-meta">Authors: <span *ngFor="let author of dataset.result.creator let i = index">{{author}}{{(i < (dataset.result.creator.length-1))?"; ":""}}</span></div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div *ngIf="showAccessRights" class = "uk-width-3-10">
|
|
||||||
<span *ngIf="showAccessRights && dataset.source != 'openaire'" class="dropdown">
|
|
||||||
<select [(ngModel)]="dataset.accessRights" name="{{'select_rights_'+dataset.id}}" >
|
|
||||||
<option *ngFor="let type of accessTypes" [value]="type" (click)="accessRightsTypeChanged(type,dataset)">{{type}}</option>
|
|
||||||
</select>
|
|
||||||
<input *ngIf="dataset.accessRights== 'EMBARGO'" class="uk-form-width-small" id="{{'date'+dataset.id}}" type="text" data-uk-datepicker="{format:'YYYY-MM-DD'}">
|
|
||||||
|
|
||||||
<!--button class="uk-button dropdown-toggle" type="button" id="{{'dropdown'+dataset.id}}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
|
||||||
{{dataset.accessRights}}
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu" [attr.aria-labelledby]="'dropdown'+dataset.id">
|
|
||||||
<li *ngFor="let type of accessTypes" ><a (click)="accessRightsTypeChanged(type,dataset) " >{{type}} </a></li>
|
|
||||||
</ul>
|
|
||||||
<input *ngIf="dataset.accessRights== 'EMBARGO'" type="date" id="{{'date'+dataset.id}}" name="" [min]="todayDate" (keyup)="dateChanged($event,dataset)" [value]="dataset.embargoEndDate"-->
|
|
||||||
</span>
|
|
||||||
<span *ngIf="showAccessRights && dataset.source == 'openaire' " >
|
|
||||||
<button class="uk-button disabled " type="button" >
|
|
||||||
{{dataset.accessRights}}
|
|
||||||
</button>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<modal-alert (alertOutput)="confirmClose($event)"> </modal-alert>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
`
|
|
||||||
})
|
|
||||||
export class ClaimSelectedDatasetsComponent {
|
|
||||||
ngOnInit() {
|
|
||||||
var myDate = new Date();
|
|
||||||
this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
|
||||||
this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
|
||||||
//2015-05-01
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Input() datasets: ClaimResult[];
|
|
||||||
@Input() showAccessRights:boolean = false;
|
|
||||||
@Input() inline:boolean = false;
|
|
||||||
@Input() hideType;
|
|
||||||
@Input() bulkMode:boolean = false;
|
|
||||||
@Input() linkToResults:boolean = true;
|
|
||||||
@Output() datasetsChange = new EventEmitter();
|
|
||||||
|
|
||||||
todayDate = '';
|
|
||||||
nextDate = '';
|
|
||||||
@ViewChild(AlertModal) alertApplyAll;
|
|
||||||
public commonAccessRights = "OPEN"; // for access rights- changes when user apply a change to every result
|
|
||||||
public commonEmbargoEndDate; // for access rights: embargoEndDate - changes when user apply a change to every result
|
|
||||||
|
|
||||||
removeDataset(item:any){
|
|
||||||
var index:number =this.datasets.indexOf(item);
|
|
||||||
if (index > -1) {
|
|
||||||
this.datasets.splice(index, 1);
|
|
||||||
}
|
|
||||||
this.datasetsChange.emit({
|
|
||||||
value: this.datasets
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
accessTypes = ["OPEN","CLOSED","EMBARGO","RESTRICTED"];
|
|
||||||
|
|
||||||
dateChanged (event:any, item:any) {
|
|
||||||
item.embargoEndDate = event.target.value ;
|
|
||||||
|
|
||||||
this.confirmOpen();
|
|
||||||
}
|
|
||||||
/* The following methods:
|
|
||||||
*typeChanged
|
|
||||||
*confirmOpen
|
|
||||||
*confirmClose
|
|
||||||
implement the functionality: change accessRights of a publication - apply to all if asked */
|
|
||||||
accessRightsTypeChanged (type:any, item:any) {
|
|
||||||
item.accessRights = type;
|
|
||||||
if(this.datasets.length > 1 ){
|
|
||||||
this.commonAccessRights = type;
|
|
||||||
if(this.commonAccessRights == "EMBARGO"){
|
|
||||||
this.commonEmbargoEndDate = item.embargoEndDate;
|
|
||||||
}
|
|
||||||
this.confirmOpen();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
confirmOpen(){
|
|
||||||
this.alertApplyAll.cancelButton = true;
|
|
||||||
this.alertApplyAll.okButton = true;
|
|
||||||
this.alertApplyAll.alertTitle = "Change access rights";
|
|
||||||
this.alertApplyAll.message = "Do you wish to apply the change to every dataset?";
|
|
||||||
this.alertApplyAll.okButtonText = "Yes";
|
|
||||||
this.alertApplyAll.cancelButtonText = "No";
|
|
||||||
this.alertApplyAll.open();
|
|
||||||
}
|
|
||||||
confirmClose(data){
|
|
||||||
for (var i = 0; i < this.datasets.length; i++) {
|
|
||||||
if(this.datasets[i].source != 'openaire' ){
|
|
||||||
this.datasets[i].accessRights = this.commonAccessRights;
|
|
||||||
if(this.commonAccessRights == "EMBARGO"){
|
|
||||||
this.datasets[i].embargoEndDate = this.commonEmbargoEndDate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
import { NgModule } from '@angular/core';
|
|
||||||
|
|
||||||
import { SharedModule } from '../../../shared/shared.module';
|
|
||||||
import {ClaimSelectedDatasetsComponent} from './selectedDatasets.component';
|
|
||||||
import {AlertModalModule} from '../../../utils/modal/alertModal.module';
|
|
||||||
@NgModule({
|
|
||||||
imports: [
|
|
||||||
SharedModule, AlertModalModule
|
|
||||||
],
|
|
||||||
declarations: [
|
|
||||||
ClaimSelectedDatasetsComponent
|
|
||||||
], exports:[ClaimSelectedDatasetsComponent]
|
|
||||||
})
|
|
||||||
export class SelectedDatasetsModule { }
|
|
|
@ -6,16 +6,14 @@ import {RouterHelper} from '../../../utils/routerHelper.class';
|
||||||
selector: 'claim-selected-projects',
|
selector: 'claim-selected-projects',
|
||||||
template: `
|
template: `
|
||||||
|
|
||||||
<div *ngIf=" !(inline && hideType == 'project') " class="uk-accordion" data-uk-accordion="{showfirst:false}">
|
<div *ngIf="this.linkType == 'project'" class="uk-accordion" data-uk-accordion="{showfirst:true}">
|
||||||
<h3 class="uk-accordion-title"><i class="uk-icon-caret-square-o-right"></i> Projects ({{(projects.length)}})
|
<h3 class="uk-accordion-title"><i class="uk-icon-caret-square-o-right"></i> to link with Projects ({{(projects.length)}})
|
||||||
|
|
||||||
</h3>
|
</h3>
|
||||||
<!--div *ngIf=" !(inline && hideType == 'project') && projects.length > 0 " class="projects" >
|
|
||||||
<ul class="uk-list">
|
|
||||||
<li class="list-group-item list-group-item-info">Selected Projects ({{(projects.length)}})
|
|
||||||
<span *ngIf=" !inline " title="Add More Projects" (click)="showType('project')" aria-hidden="true" style="float:right;cursor: pointer;"><i class="uk-icon-plus"></i></span>
|
|
||||||
</li-->
|
|
||||||
<div class="uk-accordion-content">
|
<div class="uk-accordion-content">
|
||||||
|
<div class="uk-clearfix"><button *ngIf=" !showsearch " (click)="showsearch = true;" class="uk-button uk-float-right uk-animation ">Add more <i class="uk-icon-plus"></i></button></div>
|
||||||
|
<claim-projects-search-form *ngIf=" showsearch " [selectedProjects]="projects" (projectSelected)="projectSelected($event)" > </claim-projects-search-form>
|
||||||
<ul class="uk-list uk-list-line">
|
<ul class="uk-list uk-list-line">
|
||||||
<li class="list-group-item" *ngFor="let project of projects">
|
<li class="list-group-item" *ngFor="let project of projects">
|
||||||
<a [queryParams]="routerHelper.createQueryParam('projectId',project.projectId)" routerLinkActive="router-link-active" routerLink="/search/project" >{{project.funderName}} | {{project.projectName}} {{(project.projectAcronym)?'('+project.projectAcronym+')':''}} <!--[{{project.startDate}} - {{project.endDate}}]--></a>
|
<a [queryParams]="routerHelper.createQueryParam('projectId',project.projectId)" routerLinkActive="router-link-active" routerLink="/search/project" >{{project.funderName}} | {{project.projectName}} {{(project.projectAcronym)?'('+project.projectAcronym+')':''}} <!--[{{project.startDate}} - {{project.endDate}}]--></a>
|
||||||
|
@ -25,6 +23,23 @@ import {RouterHelper} from '../../../utils/routerHelper.class';
|
||||||
<span *ngIf="projects.length == 0 " class="uk-alert uk-alert-primary">There are no projects</span>
|
<span *ngIf="projects.length == 0 " class="uk-alert uk-alert-primary">There are no projects</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div *ngIf="this.linkType != 'project'" class="uk-accordion" data-uk-accordion="{showfirst:false}">
|
||||||
|
<h3 class="uk-accordion-title"><i class="uk-icon-caret-square-o-right"></i> Projects ({{(projects.length)}})
|
||||||
|
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<div class="uk-accordion-content">
|
||||||
|
<button *ngIf=" !showsearch " (click)="showsearch = true;" class="uk-button ">Add more <i class="uk-icon-plus"></i></button>
|
||||||
|
<claim-projects-search-form *ngIf=" showsearch " [selectedProjects]="projects" (projectSelected)="projectSelected($event)" > </claim-projects-search-form>
|
||||||
|
<ul class="uk-list uk-list-line">
|
||||||
|
<li class="list-group-item" *ngFor="let project of projects">
|
||||||
|
<a [queryParams]="routerHelper.createQueryParam('projectId',project.projectId)" routerLinkActive="router-link-active" routerLink="/search/project" >{{project.funderName}} | {{project.projectName}} {{(project.projectAcronym)?'('+project.projectAcronym+')':''}} <!--[{{project.startDate}} - {{project.endDate}}]--></a>
|
||||||
|
<span (click)="removeProject(project)" aria-hidden="true" class="uk-button "><i class="uk-icon-remove"></i></span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div *ngIf="projects.length == 0 " class="uk-alert uk-alert-primary">There are no projects to link with.</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
`
|
`
|
||||||
})
|
})
|
||||||
|
@ -35,19 +50,24 @@ ngOnInit() {
|
||||||
var myDate = new Date();
|
var myDate = new Date();
|
||||||
this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
||||||
this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
||||||
|
if(this.linkType == "project"){
|
||||||
|
this.showsearch = true
|
||||||
|
}else{
|
||||||
|
this.showsearch = false;
|
||||||
|
}
|
||||||
//2015-05-01
|
//2015-05-01
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Input() projects: ClaimProject[];
|
@Input() projects: ClaimProject[];
|
||||||
@Input() show='home';
|
@Input() show='home';
|
||||||
@Input() inline:boolean = false;
|
@Input() linkType:string = "project";
|
||||||
@Input() hideType;
|
@Input() hideType;
|
||||||
@Input() bulkMode:boolean = false;
|
@Input() bulkMode:boolean = false;
|
||||||
@Input() linkToResults:boolean = true;
|
@Input() linkToResults:boolean = true;
|
||||||
@Output() projectsChange = new EventEmitter();
|
@Output() projectsChange = new EventEmitter();
|
||||||
|
|
||||||
@Output() showChange = new EventEmitter();
|
@Output() showChange = new EventEmitter();
|
||||||
|
showsearch:boolean = false;
|
||||||
|
|
||||||
todayDate = '';
|
todayDate = '';
|
||||||
nextDate = '';
|
nextDate = '';
|
||||||
|
@ -70,5 +90,9 @@ if(type != this.show){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
projectSelected($event) {
|
||||||
|
this.showsearch = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
|
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
|
|
||||||
import { SharedModule } from '../../../shared/shared.module';
|
import { SharedModule } from '../../../shared/shared.module';
|
||||||
import {ClaimSelectedProjectsComponent} from './selectedProjects.component';
|
import {ClaimSelectedProjectsComponent} from './selectedProjects.component';
|
||||||
|
import {ClaimProjectsSearchFormModule} from '../../claim-utils/claimProjectSearchForm.module';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
SharedModule, RouterModule
|
SharedModule, RouterModule, ClaimProjectsSearchFormModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
ClaimSelectedProjectsComponent
|
ClaimSelectedProjectsComponent
|
||||||
|
|
|
@ -1,148 +0,0 @@
|
||||||
import {Component, Input,Output, EventEmitter, ViewChild} from '@angular/core';
|
|
||||||
import {AlertModal} from '../../../utils/modal/alert';
|
|
||||||
import {ClaimResult} from '../../claim-utils/claimEntities.class';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'claim-selected-publications',
|
|
||||||
template: `
|
|
||||||
<div class =" ">
|
|
||||||
<div *ngIf=" !(inline && hideType == 'publication' ) " class="uk-accordion " data-uk-accordion="{showfirst:false}" >
|
|
||||||
<h3 class="uk-accordion-title" ><i class="uk-icon-caret-square-o-right"></i> Publications ({{(publications.length)}}) </h3>
|
|
||||||
<div class="uk-accordion-content" >
|
|
||||||
<span *ngIf="publications.length == 0 " class="uk-alert uk-alert-primary">There are no selected publications</span>
|
|
||||||
|
|
||||||
<ul *ngIf="publications.length > 0 " class="uk-list uk-list-line">
|
|
||||||
<li *ngFor="let pub of publications" >
|
|
||||||
<div class="uk-grid">
|
|
||||||
<div [ngClass]="showAccessRights?'uk-width-7-10':'uk-width-1-1'" >
|
|
||||||
<div>
|
|
||||||
<span *ngIf="showAccessRights" (click)="removePublication(pub)" aria-hidden="true" class="uk-button"><i class="uk-icon-remove"></i></span>
|
|
||||||
<a *ngIf="pub.url" target="_blank" href="{{pub.url}}" ><span class="uk-icon-external-link custom-icon" ></span> {{pub.title}}</a>
|
|
||||||
<span *ngIf="!pub.url" >{{pub.title}}</span>
|
|
||||||
<span *ngIf="!showAccessRights" (click)="removePublication(pub)" aria-hidden="true" class="uk-button "><i class="uk-icon-remove"></i></span>
|
|
||||||
</div>
|
|
||||||
<!-- Crossref -->
|
|
||||||
<span *ngIf="pub.result.publisher" class="uk-article-meta">Publisher: {{pub.result.publisher}}</span><span *ngIf="pub.date" class="uk-article-meta" >({{pub.date.substring(0,4)}})</span>
|
|
||||||
<div *ngIf="pub.result.author && pub.result.author.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.author let i = index">{{author.family}} {{author.given}}{{(i < (pub.result.author.length-1))?"; ":""}}</span></div>
|
|
||||||
<div *ngIf="pub.result.editor && pub.result.editor.length" class="uk-article-meta">Editors: <span *ngFor="let author of pub.result.editor let i = index">{{author.family}} {{author.given}}{{(i < (pub.result.editor.length-1))?"; ":""}}</span></div>
|
|
||||||
|
|
||||||
<!-- Openaire -->
|
|
||||||
<div *ngIf="pub.result.authors && pub.result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.authors let i = index">{{author.name}}{{(i < (pub.result.authors.length-1))?"; ":""}}</span></div>
|
|
||||||
|
|
||||||
<!-- Orcid -->
|
|
||||||
<span *ngIf="pub.result['journal-title'] && pub.result['journal-title'].value " class="uk-article-meta">Journal: {{pub.result['journal-title'].value}}</span>
|
|
||||||
<div *ngIf="pub.result.contributors && pub.result.contributors.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.contributors let i = index">{{author}}{{(i < (pub.result.contributors.length-1))?"; ":""}}</span></div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div *ngIf="showAccessRights && pub.source != 'openaire' " class = "uk-width-3-10">
|
|
||||||
<span *ngIf="showAccessRights && pub.source != 'openaire' " class="dropdown">
|
|
||||||
<select [(ngModel)]="pub.accessRights" name="{{'select_rights_'+pub.id}}" >
|
|
||||||
<option *ngFor="let type of accessTypes" [value]="type" (click)="accessRightsTypeChanged(type,pub)">{{type}}</option>
|
|
||||||
</select>
|
|
||||||
<input *ngIf="pub.accessRights== 'EMBARGO'" class="uk-form-width-small" id="{{'date'+pub.id}}" type="text" data-uk-datepicker="{format:'YYYY-MM-DD'}">
|
|
||||||
|
|
||||||
</span>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div *ngIf="showAccessRights && pub.source == 'openaire' " class = "uk-width-3-10">
|
|
||||||
<span >
|
|
||||||
<button class="uk-button disabled " type="button" >
|
|
||||||
{{pub.accessRights}}
|
|
||||||
</button>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<modal-alert (alertOutput)="confirmClose($event)">
|
|
||||||
</modal-alert>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
`
|
|
||||||
|
|
||||||
})
|
|
||||||
export class ClaimSelectedPublicationsComponent {
|
|
||||||
ngOnInit() {
|
|
||||||
var myDate = new Date();
|
|
||||||
this.todayDate=( myDate.getFullYear()+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
|
||||||
this.nextDate= ( (myDate.getFullYear()+100)+ "-" +myDate.getMonth() + 1) + "-" + myDate.getDate() ;
|
|
||||||
//2015-05-01
|
|
||||||
}
|
|
||||||
|
|
||||||
@Input() publications: ClaimResult[];
|
|
||||||
@Input() showAccessRights:boolean = false;
|
|
||||||
@Input() inline:boolean = false;
|
|
||||||
@Input() hideType;
|
|
||||||
@Input() bulkMode:boolean = false;
|
|
||||||
@Input() linkToResults:boolean = true;
|
|
||||||
@Output()publicationsChange = new EventEmitter();
|
|
||||||
|
|
||||||
@Output() showChange = new EventEmitter();
|
|
||||||
|
|
||||||
todayDate = '';
|
|
||||||
nextDate = '';
|
|
||||||
@ViewChild(AlertModal) alertApplyAll;
|
|
||||||
|
|
||||||
public commonAccessRights = "OPEN"; // for access rights- changes when user apply a change to every result
|
|
||||||
public commonEmbargoEndDate; // for access rights: embargoEndDate - changes when user apply a change to every result
|
|
||||||
|
|
||||||
removePublication(item:any){
|
|
||||||
var index:number =this.publications.indexOf(item);
|
|
||||||
if (index > -1) {
|
|
||||||
this.publications.splice(index, 1);
|
|
||||||
}
|
|
||||||
this.publicationsChange.emit({
|
|
||||||
value: this.publications
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
accessTypes = ["OPEN","CLOSED","EMBARGO","RESTRICTED"];
|
|
||||||
|
|
||||||
dateChanged (event:any, item:any) {
|
|
||||||
item.embargoEndDate = event.target.value ;
|
|
||||||
}
|
|
||||||
publicationsChanged($event) {
|
|
||||||
this.publications=$event.value;
|
|
||||||
this.publicationsChange.emit({
|
|
||||||
value: this.publications
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/* The following methods:
|
|
||||||
*typeChanged
|
|
||||||
*confirmOpen
|
|
||||||
*confirmClose
|
|
||||||
implement the functionality: change accessRights of a publication - apply to all if asked */
|
|
||||||
accessRightsTypeChanged (type:any, item:any) {
|
|
||||||
item.accessRights = type;
|
|
||||||
if(this.publications.length > 1 ){
|
|
||||||
this.commonAccessRights = type;
|
|
||||||
if(this.commonAccessRights == "EMBARGO"){
|
|
||||||
this.commonEmbargoEndDate = item.embargoEndDate;
|
|
||||||
}
|
|
||||||
this.confirmOpen();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
confirmOpen(){
|
|
||||||
this.alertApplyAll.cancelButton = true;
|
|
||||||
this.alertApplyAll.okButton = true;
|
|
||||||
this.alertApplyAll.alertTitle = "Change access rights";
|
|
||||||
this.alertApplyAll.message = "Do you wish to apply the change to every publication?";
|
|
||||||
this.alertApplyAll.okButtonText = "Yes";
|
|
||||||
this.alertApplyAll.cancelButtonText = "No";
|
|
||||||
this.alertApplyAll.open();
|
|
||||||
}
|
|
||||||
confirmClose(data){
|
|
||||||
for (var i = 0; i < this.publications.length; i++) {
|
|
||||||
if(this.publications[i].source != 'openaire' ){
|
|
||||||
this.publications[i].accessRights = this.commonAccessRights;
|
|
||||||
if(this.commonAccessRights == "EMBARGO"){
|
|
||||||
this.publications[i].embargoEndDate = this.commonEmbargoEndDate;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,14 +0,0 @@
|
||||||
import { NgModule } from '@angular/core';
|
|
||||||
|
|
||||||
import { SharedModule } from '../../../shared/shared.module';
|
|
||||||
import {ClaimSelectedPublicationsComponent} from './selectedPublications.component';
|
|
||||||
import {AlertModalModule} from '../../../utils/modal/alertModal.module';
|
|
||||||
@NgModule({
|
|
||||||
imports: [
|
|
||||||
SharedModule, AlertModalModule
|
|
||||||
],
|
|
||||||
declarations: [
|
|
||||||
ClaimSelectedPublicationsComponent
|
|
||||||
], exports:[ClaimSelectedPublicationsComponent]
|
|
||||||
})
|
|
||||||
export class SelectedPublicationsModule { }
|
|
|
@ -0,0 +1,179 @@
|
||||||
|
import {Component, Input,Output, EventEmitter, ViewChild} from '@angular/core';
|
||||||
|
import {AlertModal} from '../../../utils/modal/alert';
|
||||||
|
import {ClaimResult} from '../../claim-utils/claimEntities.class';
|
||||||
|
import {IMyOptions, IMyDateModel} from 'mydatepicker';
|
||||||
|
import {Dates} from '../../../utils/string-utils.class';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'claim-selected-results',
|
||||||
|
template: `
|
||||||
|
|
||||||
|
|
||||||
|
<div class="uk-accordion " data-uk-accordion="{showfirst:true}" >
|
||||||
|
<h3 class="uk-accordion-title" ><i class="uk-icon-caret-square-o-right"></i> {{title}} ({{results.length}}) </h3>
|
||||||
|
<div class="uk-accordion-content uk-grid uk-width-1-1" >
|
||||||
|
|
||||||
|
<div *ngIf="showSearch " class="uk-width-1-2">
|
||||||
|
<claim-result-search-form [selectedResults]="results" (resultsChange)="resultsChanged($event)" > </claim-result-search-form>
|
||||||
|
</div>
|
||||||
|
<div [ngClass]="showAccessRights && !showSearch?'uk-width-1-1':'uk-width-1-2'">
|
||||||
|
<!--div class="uk-clearfix"><button *ngIf=" !showSearch " (click)="showSearch = true;" class="uk-button uk-float-right uk-animation ">Add more <i class="uk-icon-plus"></i></button></div-->
|
||||||
|
<div *ngIf="results.length == 0 " class="uk-alert uk-alert-primary">There are no selected research results</div>
|
||||||
|
|
||||||
|
<ul *ngIf="results.length > 0 " class="uk-list uk-list-line">
|
||||||
|
<li *ngFor="let pub of results" >
|
||||||
|
<div class="uk-grid">
|
||||||
|
<div [ngClass]="showAccessRights?'uk-width-7-10':'uk-width-1-1'" >
|
||||||
|
<div>
|
||||||
|
<span *ngIf="showAccessRights" (click)="removePublication(pub)" aria-hidden="true" class="uk-button"><i class="uk-icon-remove"></i></span>
|
||||||
|
<a *ngIf="pub.url" target="_blank" href="{{pub.url}}" ><span class="uk-icon-external-link" ></span> {{pub.title}}</a>
|
||||||
|
<span *ngIf="!pub.url" >{{pub.title}}</span>
|
||||||
|
<span *ngIf="!showAccessRights" (click)="removePublication(pub)" aria-hidden="true" class="uk-button "><i class="uk-icon-remove"></i></span>
|
||||||
|
</div>
|
||||||
|
<!-- Crossref -->
|
||||||
|
<span *ngIf="pub.result.publisher" class="uk-article-meta">Publisher: {{pub.result.publisher}}</span><span *ngIf="pub.date" class="uk-article-meta" >({{pub.date.substring(0,4)}})</span>
|
||||||
|
<div *ngIf="pub.result.author && pub.result.author.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.author let i = index">{{author.family}} {{author.given}}{{(i < (pub.result.author.length-1))?"; ":""}}</span></div>
|
||||||
|
<div *ngIf="pub.result.editor && pub.result.editor.length" class="uk-article-meta">Editors: <span *ngFor="let author of pub.result.editor let i = index">{{author.family}} {{author.given}}{{(i < (pub.result.editor.length-1))?"; ":""}}</span></div>
|
||||||
|
|
||||||
|
<!-- Openaire -->
|
||||||
|
<div *ngIf="pub.result.authors && pub.result.authors.length >0 " class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.authors let i = index">{{author.name}}{{(i < (pub.result.authors.length-1))?"; ":""}}</span></div>
|
||||||
|
|
||||||
|
<!-- Orcid -->
|
||||||
|
<span *ngIf="pub.result['journal-title'] && pub.result['journal-title'].value " class="uk-article-meta">Journal: {{pub.result['journal-title'].value}}</span>
|
||||||
|
<div *ngIf="pub.result.contributors && pub.result.contributors.length > 0" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.contributors let i = index">{{author}}{{(i < (pub.result.contributors.length-1))?"; ":""}}</span></div>
|
||||||
|
<!-- Datacite -->
|
||||||
|
<div *ngIf="pub.result.creator" class="uk-article-meta">Authors: <span *ngFor="let author of pub.result.creator let i = index">{{author}}{{(i < (pub.result.creator.length-1))?"; ":""}}</span></div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div *ngIf="showAccessRights && pub.source != 'openaire' " class = "uk-width-3-10">
|
||||||
|
<span *ngIf="showAccessRights && pub.source != 'openaire' " class="dropdown">
|
||||||
|
<select [(ngModel)]="pub.accessRights" name="{{'select_rights_'+pub.id}}" >
|
||||||
|
<option *ngFor="let type of accessTypes" [value]="type" (click)="accessRightsTypeChanged(type,pub)">{{type}}</option>
|
||||||
|
</select>
|
||||||
|
<!--input *ngIf="pub.accessRights== 'EMBARGO'" class="uk-form-width-small" id="{{'date'+pub.id}}" type="text" data-uk-datepicker="{format:'YYYY-MM-DD'}"-->
|
||||||
|
<my-date-picker *ngIf="pub.accessRights== 'EMBARGO'" name="{{'date'+pub.id}}" [options]="myDatePickerOptions"
|
||||||
|
[(ngModel)]="nextDate" (dateChanged)="onDateChanged($event,pub)" ></my-date-picker>
|
||||||
|
|
||||||
|
<select [(ngModel)]="pub.type" name="{{'select_type_'+pub.id}}" >
|
||||||
|
<option [value]="'publication'" >Publication</option>
|
||||||
|
<option [value]="'dataset'" >Dataset</option>
|
||||||
|
</select>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div *ngIf="showAccessRights && pub.source == 'openaire' " class = "uk-width-3-10">
|
||||||
|
<span >
|
||||||
|
<button class="uk-button disabled " type="button" >
|
||||||
|
{{pub.accessRights}}
|
||||||
|
</button>
|
||||||
|
<button class="uk-button disabled " type="button" >
|
||||||
|
{{pub.type}}
|
||||||
|
</button>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
<modal-alert (alertOutput)="confirmClose($event)">
|
||||||
|
</modal-alert>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
`
|
||||||
|
|
||||||
|
})
|
||||||
|
export class ClaimSelectedResultsComponent {
|
||||||
|
ngOnInit() {
|
||||||
|
var myDate = new Date();
|
||||||
|
this.nextDate = { date: { year: myDate.getFullYear()+10, month: (myDate.getMonth()+1), day: myDate.getDate() } };
|
||||||
|
//2015-05-01
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Input() results: ClaimResult[];
|
||||||
|
@Input() title:string = "Research Results";
|
||||||
|
@Input() showAccessRights:boolean = false;
|
||||||
|
@Input() bulkMode:boolean = false;
|
||||||
|
@Output()resultsChange = new EventEmitter();
|
||||||
|
@Input() showSearch:boolean = false;
|
||||||
|
nextDate = {};
|
||||||
|
@ViewChild(AlertModal) alertApplyAll;
|
||||||
|
|
||||||
|
public commonAccessRights = "OPEN"; // for access rights- changes when user apply a change to every result
|
||||||
|
public commonEmbargoEndDate; // for access rights: embargoEndDate - changes when user apply a change to every result
|
||||||
|
accessTypes = ["OPEN","CLOSED","EMBARGO","RESTRICTED"];
|
||||||
|
private myDatePickerOptions: IMyOptions = {
|
||||||
|
// other options...
|
||||||
|
dateFormat: 'yyyy-mm-dd',
|
||||||
|
selectionTxtFontSize: '15px',
|
||||||
|
height:'28px',
|
||||||
|
width: '100%',
|
||||||
|
editableDateField: false,
|
||||||
|
showClearDateBtn: false
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
removePublication(item:any){
|
||||||
|
var index:number =this.results.indexOf(item);
|
||||||
|
if (index > -1) {
|
||||||
|
this.results.splice(index, 1);
|
||||||
|
}
|
||||||
|
this.resultsChange.emit({
|
||||||
|
value: this.results
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
onDateChanged (event:any, item:any) {
|
||||||
|
item.embargoEndDate = Dates.getDateFromString(event.formatted);
|
||||||
|
if(this.results.length > 1 ){
|
||||||
|
this.commonAccessRights = "EMBARGO";
|
||||||
|
this.commonEmbargoEndDate = item.embargoEndDate;
|
||||||
|
this.confirmOpen();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
resultsChanged($event) {
|
||||||
|
this.results=$event.value;
|
||||||
|
this.resultsChange.emit({
|
||||||
|
value: this.results
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/* The following methods:
|
||||||
|
*typeChanged
|
||||||
|
*confirmOpen
|
||||||
|
*confirmClose
|
||||||
|
implement the functionality: change accessRights of a publication - apply to all if asked */
|
||||||
|
accessRightsTypeChanged (type:any, item:any) {
|
||||||
|
item.accessRights = type;
|
||||||
|
if(this.results.length > 1 ){
|
||||||
|
this.commonAccessRights = type;
|
||||||
|
if(this.commonAccessRights != "EMBARGO"){
|
||||||
|
this.commonEmbargoEndDate = item.embargoEndDate;
|
||||||
|
this.confirmOpen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
confirmOpen(){
|
||||||
|
this.alertApplyAll.cancelButton = true;
|
||||||
|
this.alertApplyAll.okButton = true;
|
||||||
|
this.alertApplyAll.alertTitle = "Change access rights";
|
||||||
|
this.alertApplyAll.message = "Do you wish to apply the change to every result?";
|
||||||
|
this.alertApplyAll.okButtonText = "Yes";
|
||||||
|
this.alertApplyAll.cancelButtonText = "No";
|
||||||
|
this.alertApplyAll.open();
|
||||||
|
}
|
||||||
|
confirmClose(data){
|
||||||
|
for (var i = 0; i < this.results.length; i++) {
|
||||||
|
if(this.results[i].source != 'openaire' ){
|
||||||
|
this.results[i].accessRights = this.commonAccessRights;
|
||||||
|
if(this.commonAccessRights == "EMBARGO"){
|
||||||
|
this.results[i].embargoEndDate = this.commonEmbargoEndDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,17 +1,17 @@
|
||||||
import { NgModule } from '@angular/core';
|
import { NgModule } from '@angular/core';
|
||||||
|
|
||||||
import { SharedModule } from '../../../shared/shared.module';
|
import { SharedModule } from '../../../shared/shared.module';
|
||||||
import {SelectedDatasetsModule} from './selectedDatasets.module';
|
import {ClaimSelectedResultsComponent} from './selectedResults.component';
|
||||||
import {SelectedPublicationsModule} from './selectedPublications.module';
|
import {AlertModalModule} from '../../../utils/modal/alertModal.module';
|
||||||
// import {ClaimSelectedResultsComponent} from './selectedResults.component';
|
import {ClaimResultSearchFormModule} from '../../claim-utils/claimResultSearchForm.module';
|
||||||
|
import { MyDatePickerModule } from '../../../utils/my-date-picker/my-date-picker.module';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
SharedModule, SelectedDatasetsModule, SelectedPublicationsModule
|
SharedModule, AlertModalModule, ClaimResultSearchFormModule, MyDatePickerModule
|
||||||
],
|
],
|
||||||
declarations: [
|
declarations: [
|
||||||
// ClaimSelectedResultsComponent
|
ClaimSelectedResultsComponent
|
||||||
], exports:[
|
], exports:[ClaimSelectedResultsComponent]
|
||||||
// ClaimSelectedResultsComponent
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
export class SelectedResultsModule { }
|
export class SelectedPublicationsModule { }
|
||||||
|
|
|
@ -45,7 +45,7 @@ import {RouterHelper} from '../utils/routerHelper.class';
|
||||||
<!--a [href] = "linkToSearchDataproviders">
|
<!--a [href] = "linkToSearchDataproviders">
|
||||||
View all {{fetchDataproviders.searchUtils.totalResults}} results <i class="uk-icon-angle-double-right"></i>
|
View all {{fetchDataproviders.searchUtils.totalResults}} results <i class="uk-icon-angle-double-right"></i>
|
||||||
</a-->
|
</a-->
|
||||||
|
|
||||||
<a [queryParams]="routerHelper.createQueryParams(['organizationId', 'or'], [organizationId, 'and'])"
|
<a [queryParams]="routerHelper.createQueryParams(['organizationId', 'or'], [organizationId, 'and'])"
|
||||||
routerLinkActive="router-link-active" [routerLink]="linkToSearchDataproviders">
|
routerLinkActive="router-link-active" [routerLink]="linkToSearchDataproviders">
|
||||||
View all {{fetchDataproviders.searchUtils.totalResults}} results <i class="uk-icon-angle-double-right"></i>
|
View all {{fetchDataproviders.searchUtils.totalResults}} results <i class="uk-icon-angle-double-right"></i>
|
||||||
|
@ -197,9 +197,9 @@ export class DepositResultComponent {
|
||||||
|
|
||||||
goToDeposit() {
|
goToDeposit() {
|
||||||
if(this.requestFor == "Publications") {
|
if(this.requestFor == "Publications") {
|
||||||
this._router.navigate( ['deposit-publications'] );
|
this._router.navigate( ['participate/deposit-publications'] );
|
||||||
} else if(this.requestFor == "Research Data") {
|
} else if(this.requestFor == "Research Data") {
|
||||||
this._router.navigate( ['deposit-datasets'] );
|
this._router.navigate( ['participate/deposit-datasets'] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,10 @@
|
||||||
<div class="uk-text-justify">{{datasetInfo.description}}</div>
|
<div class="uk-text-justify">{{datasetInfo.description}}</div>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
|
<div class="uk-clearfix uk-margin-top uk-margin-bottom">
|
||||||
|
|
||||||
|
<!--a class="uk-float-right uk-button" [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[articleId,'publication','result'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" > <i class="uk-icon-link"></i> Links to research Results</a-->
|
||||||
|
</div>
|
||||||
<ul class="uk-tab" data-uk-switcher="{connect:'#tab-content'}">
|
<ul class="uk-tab" data-uk-switcher="{connect:'#tab-content'}">
|
||||||
<li class="uk-active">
|
<li class="uk-active">
|
||||||
<a>
|
<a>
|
||||||
|
@ -205,7 +208,7 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</dd>
|
</dd>
|
||||||
<!--dd><a [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[datasetId,'dataset','project'])" routerLinkActive="router-link-active" routerLink="/participate/claim" > <i class="uk-icon-link"></i> Add links to projects</a></dd-->
|
<!--dd><a [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[datasetId,'dataset','project'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" > <i class="uk-icon-link"></i> Add links to projects</a></dd-->
|
||||||
<dd *ngIf="showAllFundedBy" class="uk-text-right">
|
<dd *ngIf="showAllFundedBy" class="uk-text-right">
|
||||||
<a class="uk-text-muted" (click)="showAllFundedBy = !showAllFundedBy;">
|
<a class="uk-text-muted" (click)="showAllFundedBy = !showAllFundedBy;">
|
||||||
View less
|
View less
|
||||||
|
@ -235,7 +238,7 @@
|
||||||
<span *ngIf="item['labelConcept'] != null">: {{item['labelConcept']}}</span>
|
<span *ngIf="item['labelConcept'] != null">: {{item['labelConcept']}}</span>
|
||||||
</mark>
|
</mark>
|
||||||
</dd>
|
</dd>
|
||||||
<!--dd><a [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[datasetId,'dataset','context'])" routerLinkActive="router-link-active" routerLink="/participate/claim" > <i class="uk-icon-link"></i> Add links to contexts</a></dd-->
|
<!--dd><a [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[datasetId,'dataset','context'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" > <i class="uk-icon-link"></i> Add links to contexts</a></dd-->
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -234,10 +234,10 @@
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
<!--li>
|
<!--li>
|
||||||
<a [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[projectId,'project','result'])" routerLinkActive="router-link-active" routerLink="/participate/claim" > <i class="uk-icon-link"></i>
|
<a [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[projectId,'project','result'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" > <i class="uk-icon-link"></i>
|
||||||
Link to research results
|
Link to research results
|
||||||
</a>
|
</a-->
|
||||||
</li-->
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a routerLinkActive="router-link-active" routerLink="/participate/deposit-publications">
|
<a routerLinkActive="router-link-active" routerLink="/participate/deposit-publications">
|
||||||
Deposit Publications
|
Deposit Publications
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
|
|
||||||
<!--div class="uk-clearfix uk-margin-top uk-margin-bottom">
|
<!--div class="uk-clearfix uk-margin-top uk-margin-bottom">
|
||||||
|
|
||||||
<a class="uk-float-right uk-button" [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[articleId,'publication','publication'])" routerLinkActive="router-link-active" routerLink="/participate/claim" > <i class="uk-icon-link"></i> Links to research Results</a>
|
<a class="uk-float-right uk-button" [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[articleId,'publication','result'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" > <i class="uk-icon-link"></i> Links to research Results</a>
|
||||||
</div-->
|
</div-->
|
||||||
|
|
||||||
<ul class="uk-tab" data-uk-switcher="{connect: '#tab-content'}">
|
<ul class="uk-tab" data-uk-switcher="{connect: '#tab-content'}">
|
||||||
|
@ -495,7 +495,7 @@
|
||||||
View more
|
View more
|
||||||
</a>
|
</a>
|
||||||
</dd>
|
</dd>
|
||||||
<!--dd><a [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[articleId,'publication','project'])" routerLinkActive="router-link-active" routerLink="/participate/claim" > <i class="uk-icon-link"></i> Add links to projects</a></dd-->
|
<!--dd><a [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[articleId,'publication','project'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" > <i class="uk-icon-link"></i> Add links to projects</a></dd-->
|
||||||
</dl>
|
</dl>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
@ -514,7 +514,7 @@
|
||||||
<span *ngIf="item['labelConcept'] != null">: {{item['labelConcept']}}</span>
|
<span *ngIf="item['labelConcept'] != null">: {{item['labelConcept']}}</span>
|
||||||
</mark>
|
</mark>
|
||||||
</dd>
|
</dd>
|
||||||
<!--dd><a [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[articleId,'publication','context'])" routerLinkActive="router-link-active" routerLink="/participate/claim" > <i class="uk-icon-link"></i> Add links to contexts</a></dd-->
|
<!--dd><a [queryParams]="routerHelper.createQueryParams(['id','type','linkTo'],[articleId,'publication','context'])" routerLinkActive="router-link-active" routerLink="/participate/direct-claim" > <i class="uk-icon-link"></i> Add links to contexts</a></dd-->
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { NgModule} from '@angular/core';
|
import { NgModule} from '@angular/core';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { MyDatePickerModule } from 'mydatepicker';
|
import { MyDatePickerModule } from '../../utils/my-date-picker/my-date-picker.module';
|
||||||
import {DateFilterComponent} from './dateFilter.component';
|
import {DateFilterComponent} from './dateFilter.component';
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { Directive, ElementRef, Renderer, AfterViewInit, Input } from "@angular/core";
|
||||||
|
|
||||||
|
@Directive({
|
||||||
|
selector: "[mydpfocus]"
|
||||||
|
})
|
||||||
|
|
||||||
|
export class FocusDirective implements AfterViewInit {
|
||||||
|
@Input("mydpfocus") value: string;
|
||||||
|
|
||||||
|
constructor(private el: ElementRef, private renderer: Renderer) {}
|
||||||
|
|
||||||
|
// Focus to element: if value 0 = don't set focus, 1 = set only focus, 2 = set focus and set cursor position
|
||||||
|
ngAfterViewInit() {
|
||||||
|
if (this.value === "0") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.renderer.invokeElementMethod(this.el.nativeElement, "focus", []);
|
||||||
|
|
||||||
|
// Set cursor position at the end of text if input element
|
||||||
|
if (this.value === "2") {
|
||||||
|
let len = this.el.nativeElement.value.length;
|
||||||
|
this.el.nativeElement.setSelectionRange(len, len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
import { Directive, ElementRef, Renderer, Input, HostListener } from "@angular/core";
|
||||||
|
import { IMyInputAutoFill } from "../interfaces/my-input-auto-fill.interface";
|
||||||
|
|
||||||
|
@Directive({
|
||||||
|
selector: "[myinputautofill]"
|
||||||
|
})
|
||||||
|
|
||||||
|
export class InputAutoFillDirective {
|
||||||
|
@Input("myinputautofill") opts: IMyInputAutoFill;
|
||||||
|
|
||||||
|
constructor(private el: ElementRef, private rndr: Renderer) {}
|
||||||
|
|
||||||
|
@HostListener("keyup", ["$event"]) onKeyUp(evt: KeyboardEvent) {
|
||||||
|
if (!this.opts.enabled || evt.keyCode === 8 || evt.keyCode === 46) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let val: string = this.getInputValue();
|
||||||
|
let ews: boolean = this.endsWith(val, this.opts.separator);
|
||||||
|
let parts: Array<string> = val.split(this.opts.separator);
|
||||||
|
let idx: number = parts.length - 1;
|
||||||
|
|
||||||
|
if (val.indexOf(this.opts.separator + this.opts.separator) !== -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ews && (val.length === this.getPartLength(0) || val.length === this.getPartLength(0) + this.getPartLength(1) + this.opts.separator.length)) {
|
||||||
|
this.setInputValue(val + this.opts.separator);
|
||||||
|
}
|
||||||
|
else if (ews && parts[idx - 1].length < this.getPartLength(idx - 1) && this.isNumber(parts[idx - 1]) && (this.isDay(idx - 1) || this.isMonth(idx - 1))) {
|
||||||
|
this.setInputValue(this.insertPos(val, val.length - 2, "0"));
|
||||||
|
}
|
||||||
|
else if (parts[idx].length < this.getPartLength(idx) && this.isNumber(parts[idx]) && (Number(parts[idx]) > 3 && this.isDay(idx) || Number(parts[idx]) > 1 && this.isMonth(idx))) {
|
||||||
|
this.setInputValue(this.insertPos(val, val.length - 1, "0") + (idx < 2 ? this.opts.separator : ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private endsWith(val: string, suffix: string): boolean {
|
||||||
|
return val.indexOf(suffix, val.length - suffix.length) !== -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private insertPos(str: string, idx: number, val: string): string {
|
||||||
|
return str.substr(0, idx) + val + str.substr(idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
private getPartLength(idx: number): number {
|
||||||
|
return this.opts.formatParts[idx].length;
|
||||||
|
}
|
||||||
|
|
||||||
|
private isNumber(val: string): boolean {
|
||||||
|
return val.match(/[1-9]/) !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private isDay(idx: number): boolean {
|
||||||
|
return this.opts.formatParts[idx].indexOf("d") !== -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
private isMonth(idx: number): boolean {
|
||||||
|
return this.opts.formatParts[idx].indexOf("m") !== -1 && this.opts.formatParts[idx].length === 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
private getInputValue(): string {
|
||||||
|
return this.el.nativeElement.value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private setInputValue(val: string): void {
|
||||||
|
this.rndr.setElementProperty(this.el.nativeElement, "value", val);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
export * from "./services/my-date-picker.locale.service";
|
||||||
|
export * from "./services/my-date-picker.util.service";
|
||||||
|
export * from "./directives/my-date-picker.focus.directive";
|
||||||
|
export * from "./directives/my-date-picker.input.auto.fill.directive";
|
||||||
|
export * from "./my-date-picker.component";
|
||||||
|
export * from "./my-date-picker.module";
|
||||||
|
export * from "./interfaces/index";
|
|
@ -0,0 +1,15 @@
|
||||||
|
export * from "./my-date.interface";
|
||||||
|
export * from "./my-date-range.interface";
|
||||||
|
export * from "./my-day-labels.interface";
|
||||||
|
export * from "./my-month-labels.interface";
|
||||||
|
export * from "./my-month.interface";
|
||||||
|
export * from "./my-calendar-day.interface";
|
||||||
|
export * from "./my-week.interface";
|
||||||
|
export * from "./my-options.interface";
|
||||||
|
export * from "./my-locale.interface";
|
||||||
|
export * from "./my-date-model.interface";
|
||||||
|
export * from "./my-input-field-changed.interface";
|
||||||
|
export * from "./my-input-focus-blur.interface";
|
||||||
|
export * from "./my-weekday.interface";
|
||||||
|
export * from "./my-calendar-view-changed.interface";
|
||||||
|
export * from "./my-input-auto-fill.interface";
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { IMyDate } from "./my-date.interface";
|
||||||
|
|
||||||
|
export interface IMyCalendarDay {
|
||||||
|
dateObj: IMyDate;
|
||||||
|
cmo: number;
|
||||||
|
currDay: boolean;
|
||||||
|
dayNbr: number;
|
||||||
|
disabled: boolean;
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { IMyWeekday } from "./my-weekday.interface";
|
||||||
|
|
||||||
|
export interface IMyCalendarViewChanged {
|
||||||
|
year: number;
|
||||||
|
month: number;
|
||||||
|
first: IMyWeekday;
|
||||||
|
last: IMyWeekday;
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { IMyDate } from "./my-date.interface";
|
||||||
|
|
||||||
|
export interface IMyDateModel {
|
||||||
|
date: IMyDate;
|
||||||
|
jsdate: Date;
|
||||||
|
formatted: string;
|
||||||
|
epoc: number;
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
import { IMyDate } from "./my-date.interface";
|
||||||
|
|
||||||
|
export interface IMyDateRange {
|
||||||
|
begin: IMyDate;
|
||||||
|
end: IMyDate;
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface IMyDate {
|
||||||
|
year: number;
|
||||||
|
month: number;
|
||||||
|
day: number;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
export interface IMyDayLabels {
|
||||||
|
[day: string]: string;
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface IMyInputAutoFill {
|
||||||
|
separator: string;
|
||||||
|
formatParts: Array<string>;
|
||||||
|
enabled: boolean;
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface IMyInputFieldChanged {
|
||||||
|
value: string;
|
||||||
|
dateFormat: string;
|
||||||
|
valid: boolean;
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
export interface IMyInputFocusBlur {
|
||||||
|
reason: number;
|
||||||
|
value: string;
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { IMyOptions } from "./my-options.interface";
|
||||||
|
|
||||||
|
export interface IMyLocales {
|
||||||
|
[lang: string]: IMyOptions;
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
export interface IMyMonthLabels {
|
||||||
|
[month: number]: string;
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface IMyMonth {
|
||||||
|
monthTxt: string;
|
||||||
|
monthNbr: number;
|
||||||
|
year: number;
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
import { IMyDayLabels } from "./my-day-labels.interface";
|
||||||
|
import { IMyMonthLabels } from "./my-month-labels.interface";
|
||||||
|
import { IMyDate } from "./my-date.interface";
|
||||||
|
import { IMyDateRange } from "./my-date-range.interface";
|
||||||
|
|
||||||
|
export interface IMyOptions {
|
||||||
|
dayLabels?: IMyDayLabels;
|
||||||
|
monthLabels?: IMyMonthLabels;
|
||||||
|
dateFormat?: string;
|
||||||
|
showTodayBtn?: boolean;
|
||||||
|
todayBtnTxt?: string;
|
||||||
|
firstDayOfWeek?: string;
|
||||||
|
sunHighlight?: boolean;
|
||||||
|
markCurrentDay?: boolean;
|
||||||
|
disableUntil?: IMyDate;
|
||||||
|
disableSince?: IMyDate;
|
||||||
|
disableDays?: Array<IMyDate>;
|
||||||
|
enableDays?: Array<IMyDate>;
|
||||||
|
disableDateRange?: IMyDateRange;
|
||||||
|
disableWeekends?: boolean;
|
||||||
|
showWeekNumbers?: boolean;
|
||||||
|
height?: string;
|
||||||
|
width?: string;
|
||||||
|
selectionTxtFontSize?: string;
|
||||||
|
inline?: boolean;
|
||||||
|
showClearDateBtn?: boolean;
|
||||||
|
alignSelectorRight?: boolean;
|
||||||
|
openSelectorTopOfInput?: boolean;
|
||||||
|
indicateInvalidDate?: boolean;
|
||||||
|
editableDateField?: boolean;
|
||||||
|
editableMonthAndYear?: boolean;
|
||||||
|
disableHeaderButtons?: boolean;
|
||||||
|
minYear?: number;
|
||||||
|
maxYear?: number;
|
||||||
|
componentDisabled?: boolean;
|
||||||
|
inputValueRequired?: boolean;
|
||||||
|
showSelectorArrow?: boolean;
|
||||||
|
showInputField?: boolean;
|
||||||
|
openSelectorOnInputClick?: boolean;
|
||||||
|
inputAutoFill?: boolean;
|
||||||
|
ariaLabelInputField?: string;
|
||||||
|
ariaLabelClearDate?: string;
|
||||||
|
ariaLabelOpenCalendar?: string;
|
||||||
|
ariaLabelPrevMonth?: string;
|
||||||
|
ariaLabelNextMonth?: string;
|
||||||
|
ariaLabelPrevYear?: string;
|
||||||
|
ariaLabelNextYear?: string;
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
import { IMyCalendarDay } from "./my-calendar-day.interface";
|
||||||
|
|
||||||
|
export interface IMyWeek {
|
||||||
|
week: Array<IMyCalendarDay>;
|
||||||
|
weekNbr: number;
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
export interface IMyWeekday {
|
||||||
|
number: number;
|
||||||
|
weekday: string;
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,57 @@
|
||||||
|
<div class="mydp" [ngStyle]="{'width': getComponentWidth(), 'border': opts.inline ? 'none' : null}">
|
||||||
|
<div class="selectiongroup" *ngIf="!opts.inline">
|
||||||
|
<input *ngIf="opts.showInputField" ngtype="text" class="selection" [attr.aria-label]="opts.ariaLabelInputField" (click)="opts.openSelectorOnInputClick&&!opts.editableDateField&&openBtnClicked()" [attr.maxlength]="opts.dateFormat.length" [ngClass]="{'invaliddate': invalidDate&&opts.indicateInvalidDate}"
|
||||||
|
placeholder="{{placeholder}}" [myinputautofill]="autoFillOpts" [ngStyle]="{'height': opts.height, 'line-height': opts.height, 'font-size': opts.selectionTxtFontSize, 'border': 'none', 'padding-right': selectionDayTxt.length>0&&opts.showClearDateBtn ? '60px' : '30px'}"
|
||||||
|
(keyup)="userDateInput($event)" [value]="selectionDayTxt" (focus)="opts.editableDateField&&onFocusInput($event)" (blur)="opts.editableDateField&&lostFocusInput($event)" [disabled]="opts.componentDisabled" [readonly]="!opts.editableDateField" [required]="opts.inputValueRequired">
|
||||||
|
<div class="selbtngroup" [style.height]="opts.height">
|
||||||
|
<button type="button" [attr.aria-label]="opts.ariaLabelClearDate" class="btnclear" *ngIf="selectionDayTxt.length>0&&opts.showClearDateBtn" (click)="removeBtnClicked()" [ngClass]="{'btnclearenabled': !opts.componentDisabled, 'btncleardisabled': opts.componentDisabled, 'btnleftborder': opts.showInputField}" [disabled]="opts.componentDisabled">
|
||||||
|
<span class="mydpicon icon-mydpremove"></span>
|
||||||
|
</button>
|
||||||
|
<button type="button" [attr.aria-label]="opts.ariaLabelOpenCalendar" class="btnpicker" (click)="openBtnClicked()" [ngClass]="{'btnpickerenabled': !opts.componentDisabled, 'btnpickerdisabled': opts.componentDisabled, 'btnleftborder': opts.showInputField||selectionDayTxt.length>0&&opts.showClearDateBtn}" [disabled]="opts.componentDisabled">
|
||||||
|
<span class="mydpicon icon-mydpcalendar"></span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="selector" *ngIf="showSelector||opts.inline" [mydpfocus]="opts.inline?'0':'1'" [ngStyle]="{'bottom': getSelectorTopPosition()}" [ngClass]="{'inlinedp': opts.inline, 'alignselectorright': opts.alignSelectorRight, 'selectorarrow': opts.showSelectorArrow&&!opts.inline, 'selectorarrowleft': opts.showSelectorArrow&&!opts.alignSelectorRight&&!opts.inline, 'selectorarrowright': opts.showSelectorArrow&&opts.alignSelectorRight&&!opts.inline}" tabindex="0">
|
||||||
|
<table class="header">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<div style="float:left">
|
||||||
|
<div class="headerbtncell"><button type="button" [attr.aria-label]="opts.ariaLabelPrevMonth" class="headerbtn mydpicon icon-mydpleft" (click)="prevMonth()" [disabled]="prevMonthDisabled" [ngClass]="{'headerbtnenabled': !prevMonthDisabled, 'headerbtndisabled': prevMonthDisabled}"></button></div>
|
||||||
|
<div class="headermonthtxt">
|
||||||
|
<input type="text" *ngIf="editMonth" class="monthinput" maxlength="10" [mydpfocus]="2" [value]="visibleMonth.monthTxt" (keyup)="userMonthInput($event)" (click)="$event.stopPropagation()" [ngClass]="{'invalidmonth': invalidMonth}">
|
||||||
|
<button class="headerlabelbtn" type="button" [ngClass]="{'monthlabel': opts.editableMonthAndYear}" *ngIf="!editMonth" (click)="opts.editableMonthAndYear&&editMonthClicked($event)" tabindex="{{opts.editableMonthAndYear?'0':'-1'}}">{{visibleMonth.monthTxt}}</button>
|
||||||
|
</div>
|
||||||
|
<div class="headerbtncell"><button type="button" [attr.aria-label]="opts.ariaLabelNextMonth" class="headerbtn mydpicon icon-mydpright" (click)="nextMonth()" [disabled]="nextMonthDisabled" [ngClass]="{'headerbtnenabled': !nextMonthDisabled, 'headerbtndisabled': nextMonthDisabled}"></button></div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td *ngIf="opts.showTodayBtn">
|
||||||
|
<button type="button" class="headertodaybtn" (click)="todayClicked()" [disabled]="disableTodayBtn" [ngClass]="{'headertodaybtnenabled': !disableTodayBtn, 'headertodaybtndisabled': disableTodayBtn}">{{opts.todayBtnTxt}}</button>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div style="float:right">
|
||||||
|
<div class="headerbtncell"><button type="button" [attr.aria-label]="opts.ariaLabelPrevYear" class="headerbtn mydpicon icon-mydpleft" (click)="prevYear()" [disabled]="prevYearDisabled" [ngClass]="{'headerbtnenabled': !prevYearDisabled, 'headerbtndisabled': prevYearDisabled}"></button></div>
|
||||||
|
<div class="headeryeartxt">
|
||||||
|
<input type="text" *ngIf="editYear" class="yearinput" maxlength="4" [mydpfocus]="2" [value]="visibleMonth.year" (keyup)="userYearInput($event)" (click)="$event.stopPropagation()" [ngClass]="{'invalidyear': invalidYear}">
|
||||||
|
<button class="headerlabelbtn" type="button" [ngClass]="{'yearlabel': opts.editableMonthAndYear}" *ngIf="!editYear" (click)="opts.editableMonthAndYear&&editYearClicked($event)" tabindex="{{opts.editableMonthAndYear?'0':'-1'}}">{{visibleMonth.year}}</button>
|
||||||
|
</div>
|
||||||
|
<div class="headerbtncell"><button type="button" [attr.aria-label]="opts.ariaLabelNextYear" class="headerbtn mydpicon icon-mydpright" (click)="nextYear()" [disabled]="nextYearDisabled" [ngClass]="{'headerbtnenabled': !nextYearDisabled, 'headerbtndisabled': nextYearDisabled}"></button></div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<table class="caltable">
|
||||||
|
<thead><tr><th class="weekdaytitle weekdaytitleweeknbr" *ngIf="opts.showWeekNumbers&&opts.firstDayOfWeek==='mo'">#</th><th class="weekdaytitle" scope="col" *ngFor="let d of weekDays">{{d}}</th></tr></thead>
|
||||||
|
<tbody>
|
||||||
|
<tr *ngFor="let w of dates">
|
||||||
|
<td class="daycell daycellweeknbr" *ngIf="opts.showWeekNumbers&&opts.firstDayOfWeek==='mo'">{{w.weekNbr}}</td>
|
||||||
|
<td class="daycell" *ngFor="let d of w.week" [ngClass]="{'currmonth':d.cmo===CURR_MONTH&&!d.disabled, 'selectedday':selectedDate.day===d.dateObj.day && selectedDate.month===d.dateObj.month && selectedDate.year===d.dateObj.year && d.cmo===CURR_MONTH, 'disabled': d.disabled, 'tablesingleday': d.cmo===CURR_MONTH&&!d.disabled}" (click)="!d.disabled&&cellClicked(d);$event.stopPropagation()" (keydown)="cellKeyDown($event, d)" tabindex="0">
|
||||||
|
<div [ngClass]="{'prevmonth':d.cmo===PREV_MONTH,'currmonth':d.cmo===CURR_MONTH,'nextmonth':d.cmo===NEXT_MONTH,'sunday':d.dayNbr === 0 && opts.sunHighlight}">
|
||||||
|
<span [ngClass]="{'currday':d.currDay&&opts.markCurrentDay, 'sundayDim': opts.sunHighlight && d.dayNbr === 0 && (d.cmo===PREV_MONTH || d.cmo===NEXT_MONTH || d.disabled)}">{{d.dateObj.day}}</span>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,677 @@
|
||||||
|
import { Component, Input, Output, EventEmitter, OnChanges, SimpleChanges, ElementRef, ViewEncapsulation, ChangeDetectorRef, Renderer, forwardRef } from "@angular/core";
|
||||||
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from "@angular/forms";
|
||||||
|
import { IMyDate, IMyDateRange, IMyMonth, IMyCalendarDay, IMyWeek, IMyDayLabels, IMyMonthLabels, IMyOptions, IMyDateModel, IMyInputAutoFill, IMyInputFieldChanged, IMyCalendarViewChanged, IMyInputFocusBlur } from "./interfaces/index";
|
||||||
|
import { LocaleService } from "./services/my-date-picker.locale.service";
|
||||||
|
import { UtilService } from "./services/my-date-picker.util.service";
|
||||||
|
|
||||||
|
// webpack1_
|
||||||
|
declare var require: any;
|
||||||
|
const myDpStyles: string = require("./my-date-picker.component.css");
|
||||||
|
const myDpTpl: string = require("./my-date-picker.component.html");
|
||||||
|
// webpack2_
|
||||||
|
|
||||||
|
export const MYDP_VALUE_ACCESSOR: any = {
|
||||||
|
provide: NG_VALUE_ACCESSOR,
|
||||||
|
useExisting: forwardRef(() => MyDatePicker),
|
||||||
|
multi: true
|
||||||
|
};
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: "my-date-picker",
|
||||||
|
styles: [myDpStyles],
|
||||||
|
template: myDpTpl,
|
||||||
|
providers: [LocaleService, UtilService, MYDP_VALUE_ACCESSOR],
|
||||||
|
encapsulation: ViewEncapsulation.None
|
||||||
|
})
|
||||||
|
|
||||||
|
export class MyDatePicker implements OnChanges, ControlValueAccessor {
|
||||||
|
@Input() options: any;
|
||||||
|
@Input() locale: string;
|
||||||
|
@Input() defaultMonth: string;
|
||||||
|
@Input() selDate: string;
|
||||||
|
@Input() placeholder: string;
|
||||||
|
@Input() selector: number;
|
||||||
|
@Output() dateChanged: EventEmitter<IMyDateModel> = new EventEmitter<IMyDateModel>();
|
||||||
|
@Output() inputFieldChanged: EventEmitter<IMyInputFieldChanged> = new EventEmitter<IMyInputFieldChanged>();
|
||||||
|
@Output() calendarViewChanged: EventEmitter<IMyCalendarViewChanged> = new EventEmitter<IMyCalendarViewChanged>();
|
||||||
|
@Output() calendarToggle: EventEmitter<number> = new EventEmitter<number>();
|
||||||
|
@Output() inputFocusBlur: EventEmitter<IMyInputFocusBlur> = new EventEmitter<IMyInputFocusBlur>();
|
||||||
|
|
||||||
|
onChangeCb: (_: any) => void = () => { };
|
||||||
|
onTouchedCb: () => void = () => { };
|
||||||
|
|
||||||
|
showSelector: boolean = false;
|
||||||
|
visibleMonth: IMyMonth = {monthTxt: "", monthNbr: 0, year: 0};
|
||||||
|
selectedMonth: IMyMonth = {monthTxt: "", monthNbr: 0, year: 0};
|
||||||
|
selectedDate: IMyDate = {year: 0, month: 0, day: 0};
|
||||||
|
weekDays: Array<string> = [];
|
||||||
|
dates: Array<IMyWeek> = [];
|
||||||
|
selectionDayTxt: string = "";
|
||||||
|
invalidDate: boolean = false;
|
||||||
|
disableTodayBtn: boolean = false;
|
||||||
|
dayIdx: number = 0;
|
||||||
|
weekDayOpts: Array<string> = ["su", "mo", "tu", "we", "th", "fr", "sa"];
|
||||||
|
autoFillOpts: IMyInputAutoFill = {separator: "", formatParts: [], enabled: true};
|
||||||
|
|
||||||
|
editMonth: boolean = false;
|
||||||
|
invalidMonth: boolean = false;
|
||||||
|
editYear: boolean = false;
|
||||||
|
invalidYear: boolean = false;
|
||||||
|
|
||||||
|
prevMonthDisabled: boolean = false;
|
||||||
|
nextMonthDisabled: boolean = false;
|
||||||
|
prevYearDisabled: boolean = false;
|
||||||
|
nextYearDisabled: boolean = false;
|
||||||
|
|
||||||
|
PREV_MONTH: number = 1;
|
||||||
|
CURR_MONTH: number = 2;
|
||||||
|
NEXT_MONTH: number = 3;
|
||||||
|
|
||||||
|
MIN_YEAR: number = 1000;
|
||||||
|
MAX_YEAR: number = 9999;
|
||||||
|
|
||||||
|
// Default options
|
||||||
|
opts: IMyOptions = {
|
||||||
|
dayLabels: <IMyDayLabels> {},
|
||||||
|
monthLabels: <IMyMonthLabels> {},
|
||||||
|
dateFormat: <string> "",
|
||||||
|
showTodayBtn: <boolean> true,
|
||||||
|
todayBtnTxt: <string> "",
|
||||||
|
firstDayOfWeek: <string> "",
|
||||||
|
sunHighlight: <boolean> true,
|
||||||
|
markCurrentDay: <boolean> true,
|
||||||
|
disableUntil: <IMyDate> {year: 0, month: 0, day: 0},
|
||||||
|
disableSince: <IMyDate> {year: 0, month: 0, day: 0},
|
||||||
|
disableDays: <Array<IMyDate>> [],
|
||||||
|
enableDays: <Array<IMyDate>> [],
|
||||||
|
disableDateRange: <IMyDateRange> {begin: <IMyDate> {year: 0, month: 0, day: 0}, end: <IMyDate> {year: 0, month: 0, day: 0}},
|
||||||
|
disableWeekends: <boolean> false,
|
||||||
|
showWeekNumbers: <boolean> false,
|
||||||
|
height: <string> "34px",
|
||||||
|
width: <string> "100%",
|
||||||
|
selectionTxtFontSize: <string> "18px",
|
||||||
|
inline: <boolean> false,
|
||||||
|
showClearDateBtn: <boolean> true,
|
||||||
|
alignSelectorRight: <boolean> false,
|
||||||
|
openSelectorTopOfInput: <boolean> false,
|
||||||
|
indicateInvalidDate: <boolean> true,
|
||||||
|
editableDateField: <boolean> true,
|
||||||
|
editableMonthAndYear: <boolean> true,
|
||||||
|
disableHeaderButtons: <boolean> true,
|
||||||
|
minYear: <number> this.MIN_YEAR,
|
||||||
|
maxYear: <number> this.MAX_YEAR,
|
||||||
|
componentDisabled: <boolean> false,
|
||||||
|
inputValueRequired: <boolean> false,
|
||||||
|
showSelectorArrow: <boolean> true,
|
||||||
|
showInputField: <boolean> true,
|
||||||
|
openSelectorOnInputClick: <boolean> false,
|
||||||
|
inputAutoFill: <boolean> true,
|
||||||
|
ariaLabelInputField: <string> "Date input field",
|
||||||
|
ariaLabelClearDate: <string> "Clear Date",
|
||||||
|
ariaLabelOpenCalendar: <string> "Open Calendar",
|
||||||
|
ariaLabelPrevMonth: <string> "Previous Month",
|
||||||
|
ariaLabelNextMonth: <string> "Next Month",
|
||||||
|
ariaLabelPrevYear: <string> "Previous Year",
|
||||||
|
ariaLabelNextYear: <string> "Next Year"
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor(public elem: ElementRef, private renderer: Renderer, private cdr: ChangeDetectorRef, private localeService: LocaleService, private utilService: UtilService) {
|
||||||
|
this.setLocaleOptions();
|
||||||
|
renderer.listenGlobal("document", "click", (event: any) => {
|
||||||
|
if (this.showSelector && event.target && this.elem.nativeElement !== event.target && !this.elem.nativeElement.contains(event.target)) {
|
||||||
|
this.showSelector = false;
|
||||||
|
this.calendarToggle.emit(4);
|
||||||
|
}
|
||||||
|
if (this.opts.editableMonthAndYear && event.target && this.elem.nativeElement.contains(event.target)) {
|
||||||
|
this.resetMonthYearEdit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setLocaleOptions(): void {
|
||||||
|
let opts: IMyOptions = this.localeService.getLocaleOptions(this.locale);
|
||||||
|
Object.keys(opts).forEach((k) => {
|
||||||
|
(<IMyOptions>this.opts)[k] = opts[k];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setOptions(): void {
|
||||||
|
if (this.options !== undefined) {
|
||||||
|
Object.keys(this.options).forEach((k) => {
|
||||||
|
(<IMyOptions>this.opts)[k] = this.options[k];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (this.opts.minYear < this.MIN_YEAR) {
|
||||||
|
this.opts.minYear = this.MIN_YEAR;
|
||||||
|
}
|
||||||
|
if (this.opts.maxYear > this.MAX_YEAR) {
|
||||||
|
this.opts.maxYear = this.MAX_YEAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
let separator: string = this.utilService.getDateFormatSeparator(this.opts.dateFormat);
|
||||||
|
this.autoFillOpts = {separator: separator, formatParts: this.opts.dateFormat.split(separator), enabled: this.opts.inputAutoFill};
|
||||||
|
}
|
||||||
|
|
||||||
|
getComponentWidth(): string {
|
||||||
|
if (this.opts.showInputField) {
|
||||||
|
return this.opts.width;
|
||||||
|
}
|
||||||
|
else if (this.selectionDayTxt.length > 0 && this.opts.showClearDateBtn) {
|
||||||
|
return "60px";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "30px";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getSelectorTopPosition(): string {
|
||||||
|
if (this.opts.openSelectorTopOfInput) {
|
||||||
|
return this.elem.nativeElement.children[0].offsetHeight + "px";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resetMonthYearEdit(): void {
|
||||||
|
this.editMonth = false;
|
||||||
|
this.editYear = false;
|
||||||
|
this.invalidMonth = false;
|
||||||
|
this.invalidYear = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
editMonthClicked(event: any): void {
|
||||||
|
event.stopPropagation();
|
||||||
|
if (this.opts.editableMonthAndYear) {
|
||||||
|
this.editMonth = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
editYearClicked(event: any): void {
|
||||||
|
event.stopPropagation();
|
||||||
|
if (this.opts.editableMonthAndYear) {
|
||||||
|
this.editYear = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
userDateInput(event: any): void {
|
||||||
|
this.invalidDate = false;
|
||||||
|
if (event.target.value.length === 0) {
|
||||||
|
this.clearDate();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let date: IMyDate = this.utilService.isDateValid(event.target.value, this.opts.dateFormat, this.opts.minYear, this.opts.maxYear, this.opts.disableUntil, this.opts.disableSince, this.opts.disableWeekends, this.opts.disableDays, this.opts.disableDateRange, this.opts.monthLabels, this.opts.enableDays);
|
||||||
|
if (date.day !== 0 && date.month !== 0 && date.year !== 0) {
|
||||||
|
this.selectDate(date);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.invalidDate = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.invalidDate) {
|
||||||
|
this.inputFieldChanged.emit({value: event.target.value, dateFormat: this.opts.dateFormat, valid: !(event.target.value.length === 0 || this.invalidDate)});
|
||||||
|
this.onChangeCb("");
|
||||||
|
this.onTouchedCb();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onFocusInput(event: any): void {
|
||||||
|
this.inputFocusBlur.emit({reason: 1, value: event.target.value});
|
||||||
|
}
|
||||||
|
|
||||||
|
lostFocusInput(event: any): void {
|
||||||
|
this.selectionDayTxt = event.target.value;
|
||||||
|
this.onTouchedCb();
|
||||||
|
this.inputFocusBlur.emit({reason: 2, value: event.target.value});
|
||||||
|
}
|
||||||
|
|
||||||
|
userMonthInput(event: any): void {
|
||||||
|
if (event.keyCode === 13 || event.keyCode === 37 || event.keyCode === 39) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.invalidMonth = false;
|
||||||
|
|
||||||
|
let m: number = this.utilService.isMonthLabelValid(event.target.value, this.opts.monthLabels);
|
||||||
|
if (m !== -1) {
|
||||||
|
this.editMonth = false;
|
||||||
|
if (m !== this.visibleMonth.monthNbr) {
|
||||||
|
this.visibleMonth = {monthTxt: this.monthText(m), monthNbr: m, year: this.visibleMonth.year};
|
||||||
|
this.generateCalendar(m, this.visibleMonth.year, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.invalidMonth = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
userYearInput(event: any): void {
|
||||||
|
if (event.keyCode === 13 || event.keyCode === 37 || event.keyCode === 39) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.invalidYear = false;
|
||||||
|
|
||||||
|
let y: number = this.utilService.isYearLabelValid(Number(event.target.value), this.opts.minYear, this.opts.maxYear);
|
||||||
|
if (y !== -1) {
|
||||||
|
this.editYear = false;
|
||||||
|
if (y !== this.visibleMonth.year) {
|
||||||
|
this.visibleMonth = {monthTxt: this.visibleMonth.monthTxt, monthNbr: this.visibleMonth.monthNbr, year: y};
|
||||||
|
this.generateCalendar(this.visibleMonth.monthNbr, y, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.invalidYear = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isTodayDisabled(): void {
|
||||||
|
this.disableTodayBtn = this.utilService.isDisabledDay(this.getToday(), this.opts.disableUntil, this.opts.disableSince, this.opts.disableWeekends, this.opts.disableDays, this.opts.disableDateRange, this.opts.enableDays);
|
||||||
|
}
|
||||||
|
|
||||||
|
parseOptions(): void {
|
||||||
|
if (this.locale) {
|
||||||
|
this.setLocaleOptions();
|
||||||
|
}
|
||||||
|
this.setOptions();
|
||||||
|
this.isTodayDisabled();
|
||||||
|
this.dayIdx = this.weekDayOpts.indexOf(this.opts.firstDayOfWeek);
|
||||||
|
if (this.dayIdx !== -1) {
|
||||||
|
let idx: number = this.dayIdx;
|
||||||
|
for (let i = 0; i < this.weekDayOpts.length; i++) {
|
||||||
|
this.weekDays.push(this.opts.dayLabels[this.weekDayOpts[idx]]);
|
||||||
|
idx = this.weekDayOpts[idx] === "sa" ? 0 : idx + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
writeValue(value: Object): void {
|
||||||
|
if (value && value["date"]) {
|
||||||
|
this.updateDateValue(this.parseSelectedDate(value["date"]), false);
|
||||||
|
}
|
||||||
|
else if (value === "") {
|
||||||
|
this.updateDateValue({year: 0, month: 0, day: 0}, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
registerOnChange(fn: any): void {
|
||||||
|
this.onChangeCb = fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
registerOnTouched(fn: any): void {
|
||||||
|
this.onTouchedCb = fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
|
if (changes.hasOwnProperty("selector") && changes["selector"].currentValue > 0) {
|
||||||
|
this.openBtnClicked();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changes.hasOwnProperty("placeholder")) {
|
||||||
|
this.placeholder = changes["placeholder"].currentValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changes.hasOwnProperty("locale")) {
|
||||||
|
this.locale = changes["locale"].currentValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changes.hasOwnProperty("options")) {
|
||||||
|
this.options = changes["options"].currentValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.weekDays.length = 0;
|
||||||
|
this.parseOptions();
|
||||||
|
|
||||||
|
if (changes.hasOwnProperty("defaultMonth")) {
|
||||||
|
let dm: string = changes["defaultMonth"].currentValue;
|
||||||
|
if (dm !== null && dm !== undefined && dm !== "") {
|
||||||
|
this.selectedMonth = this.parseSelectedMonth(dm);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.selectedMonth = {monthTxt: "", monthNbr: 0, year: 0};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changes.hasOwnProperty("selDate")) {
|
||||||
|
let sd: any = changes["selDate"];
|
||||||
|
if (sd.currentValue !== null && sd.currentValue !== undefined && sd.currentValue !== "" && Object.keys(sd.currentValue).length !== 0) {
|
||||||
|
this.selectedDate = this.parseSelectedDate(sd.currentValue);
|
||||||
|
setTimeout(() => {
|
||||||
|
this.onChangeCb(this.getDateModel(this.selectedDate));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Do not clear on init
|
||||||
|
if (!sd.isFirstChange()) {
|
||||||
|
this.clearDate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.opts.inline) {
|
||||||
|
this.setVisibleMonth();
|
||||||
|
}
|
||||||
|
else if (this.showSelector) {
|
||||||
|
this.generateCalendar(this.visibleMonth.monthNbr, this.visibleMonth.year, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
removeBtnClicked(): void {
|
||||||
|
// Remove date button clicked
|
||||||
|
this.clearDate();
|
||||||
|
if (this.showSelector) {
|
||||||
|
this.calendarToggle.emit(3);
|
||||||
|
}
|
||||||
|
this.showSelector = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
openBtnClicked(): void {
|
||||||
|
// Open selector button clicked
|
||||||
|
this.showSelector = !this.showSelector;
|
||||||
|
if (this.showSelector) {
|
||||||
|
this.setVisibleMonth();
|
||||||
|
this.calendarToggle.emit(1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.calendarToggle.emit(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setVisibleMonth(): void {
|
||||||
|
// Sets visible month of calendar
|
||||||
|
let y: number = 0, m: number = 0;
|
||||||
|
if (!this.utilService.isInitializedDate(this.selectedDate)) {
|
||||||
|
if (this.selectedMonth.year === 0 && this.selectedMonth.monthNbr === 0) {
|
||||||
|
let today: IMyDate = this.getToday();
|
||||||
|
y = today.year;
|
||||||
|
m = today.month;
|
||||||
|
} else {
|
||||||
|
y = this.selectedMonth.year;
|
||||||
|
m = this.selectedMonth.monthNbr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
y = this.selectedDate.year;
|
||||||
|
m = this.selectedDate.month;
|
||||||
|
}
|
||||||
|
this.visibleMonth = {monthTxt: this.opts.monthLabels[m], monthNbr: m, year: y};
|
||||||
|
|
||||||
|
// Create current month
|
||||||
|
this.generateCalendar(m, y, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
prevMonth(): void {
|
||||||
|
// Previous month from calendar
|
||||||
|
let d: Date = this.getDate(this.visibleMonth.year, this.visibleMonth.monthNbr, 1);
|
||||||
|
d.setMonth(d.getMonth() - 1);
|
||||||
|
|
||||||
|
let y: number = d.getFullYear();
|
||||||
|
let m: number = d.getMonth() + 1;
|
||||||
|
|
||||||
|
this.visibleMonth = {monthTxt: this.monthText(m), monthNbr: m, year: y};
|
||||||
|
this.generateCalendar(m, y, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
nextMonth(): void {
|
||||||
|
// Next month from calendar
|
||||||
|
let d: Date = this.getDate(this.visibleMonth.year, this.visibleMonth.monthNbr, 1);
|
||||||
|
d.setMonth(d.getMonth() + 1);
|
||||||
|
|
||||||
|
let y: number = d.getFullYear();
|
||||||
|
let m: number = d.getMonth() + 1;
|
||||||
|
|
||||||
|
this.visibleMonth = {monthTxt: this.monthText(m), monthNbr: m, year: y};
|
||||||
|
this.generateCalendar(m, y, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
prevYear(): void {
|
||||||
|
// Previous year from calendar
|
||||||
|
this.visibleMonth.year--;
|
||||||
|
this.generateCalendar(this.visibleMonth.monthNbr, this.visibleMonth.year, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
nextYear(): void {
|
||||||
|
// Next year from calendar
|
||||||
|
this.visibleMonth.year++;
|
||||||
|
this.generateCalendar(this.visibleMonth.monthNbr, this.visibleMonth.year, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
todayClicked(): void {
|
||||||
|
// Today button clicked
|
||||||
|
let today: IMyDate = this.getToday();
|
||||||
|
this.selectDate(today);
|
||||||
|
if (this.opts.inline && today.year !== this.visibleMonth.year || today.month !== this.visibleMonth.monthNbr) {
|
||||||
|
this.visibleMonth = {monthTxt: this.opts.monthLabels[today.month], monthNbr: today.month, year: today.year};
|
||||||
|
this.generateCalendar(today.month, today.year, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cellClicked(cell: any): void {
|
||||||
|
// Cell clicked on the calendar
|
||||||
|
if (cell.cmo === this.PREV_MONTH) {
|
||||||
|
// Previous month day
|
||||||
|
this.prevMonth();
|
||||||
|
}
|
||||||
|
else if (cell.cmo === this.CURR_MONTH) {
|
||||||
|
// Current month day - if date is already selected clear it
|
||||||
|
if (cell.dateObj.year === this.selectedDate.year && cell.dateObj.month === this.selectedDate.month && cell.dateObj.day === this.selectedDate.day) {
|
||||||
|
this.clearDate();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.selectDate(cell.dateObj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cell.cmo === this.NEXT_MONTH) {
|
||||||
|
// Next month day
|
||||||
|
this.nextMonth();
|
||||||
|
}
|
||||||
|
this.resetMonthYearEdit();
|
||||||
|
}
|
||||||
|
|
||||||
|
cellKeyDown(event: any, cell: any) {
|
||||||
|
// Cell keyboard handling
|
||||||
|
if ((event.keyCode === 13 || event.keyCode === 32) && !cell.disabled) {
|
||||||
|
event.preventDefault();
|
||||||
|
this.cellClicked(cell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clearDate(): void {
|
||||||
|
// Clears the date and notifies parent using callbacks and value accessor
|
||||||
|
let date: IMyDate = {year: 0, month: 0, day: 0};
|
||||||
|
this.dateChanged.emit({date: date, jsdate: null, formatted: "", epoc: 0});
|
||||||
|
this.onChangeCb("");
|
||||||
|
this.onTouchedCb();
|
||||||
|
this.updateDateValue(date, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
selectDate(date: IMyDate): void {
|
||||||
|
// Date selected, notifies parent using callbacks and value accessor
|
||||||
|
let dateModel: IMyDateModel = this.getDateModel(date);
|
||||||
|
this.dateChanged.emit(dateModel);
|
||||||
|
this.onChangeCb(dateModel);
|
||||||
|
this.onTouchedCb();
|
||||||
|
this.updateDateValue(date, false);
|
||||||
|
if (this.showSelector) {
|
||||||
|
this.calendarToggle.emit(2);
|
||||||
|
}
|
||||||
|
this.showSelector = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateDateValue(date: IMyDate, clear: boolean): void {
|
||||||
|
// Updates date values
|
||||||
|
this.selectedDate = date;
|
||||||
|
this.selectionDayTxt = clear ? "" : this.formatDate(date);
|
||||||
|
this.inputFieldChanged.emit({value: this.selectionDayTxt, dateFormat: this.opts.dateFormat, valid: !clear});
|
||||||
|
this.invalidDate = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
getDateModel(date: IMyDate): IMyDateModel {
|
||||||
|
// Creates a date model object from the given parameter
|
||||||
|
return {date: date, jsdate: this.getDate(date.year, date.month, date.day), formatted: this.formatDate(date), epoc: Math.round(this.getTimeInMilliseconds(date) / 1000.0)};
|
||||||
|
}
|
||||||
|
|
||||||
|
preZero(val: string): string {
|
||||||
|
// Prepend zero if smaller than 10
|
||||||
|
return parseInt(val) < 10 ? "0" + val : val;
|
||||||
|
}
|
||||||
|
|
||||||
|
formatDate(val: any): string {
|
||||||
|
// Returns formatted date string, if mmm is part of dateFormat returns month as a string
|
||||||
|
let formatted: string = this.opts.dateFormat.replace("yyyy", val.year).replace("dd", this.preZero(val.day));
|
||||||
|
return this.opts.dateFormat.indexOf("mmm") !== -1 ? formatted.replace("mmm", this.monthText(val.month)) : formatted.replace("mm", this.preZero(val.month));
|
||||||
|
}
|
||||||
|
|
||||||
|
monthText(m: number): string {
|
||||||
|
// Returns month as a text
|
||||||
|
return this.opts.monthLabels[m];
|
||||||
|
}
|
||||||
|
|
||||||
|
monthStartIdx(y: number, m: number): number {
|
||||||
|
// Month start index
|
||||||
|
let d = new Date();
|
||||||
|
d.setDate(1);
|
||||||
|
d.setMonth(m - 1);
|
||||||
|
d.setFullYear(y);
|
||||||
|
let idx = d.getDay() + this.sundayIdx();
|
||||||
|
return idx >= 7 ? idx - 7 : idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
daysInMonth(m: number, y: number): number {
|
||||||
|
// Return number of days of current month
|
||||||
|
return new Date(y, m, 0).getDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
daysInPrevMonth(m: number, y: number): number {
|
||||||
|
// Return number of days of the previous month
|
||||||
|
let d: Date = this.getDate(y, m, 1);
|
||||||
|
d.setMonth(d.getMonth() - 1);
|
||||||
|
return this.daysInMonth(d.getMonth() + 1, d.getFullYear());
|
||||||
|
}
|
||||||
|
|
||||||
|
isCurrDay(d: number, m: number, y: number, cmo: number, today: IMyDate): boolean {
|
||||||
|
// Check is a given date the today
|
||||||
|
return d === today.day && m === today.month && y === today.year && cmo === this.CURR_MONTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
getToday(): IMyDate {
|
||||||
|
let date: Date = new Date();
|
||||||
|
return {year: date.getFullYear(), month: date.getMonth() + 1, day: date.getDate()};
|
||||||
|
}
|
||||||
|
|
||||||
|
getTimeInMilliseconds(date: IMyDate): number {
|
||||||
|
return this.getDate(date.year, date.month, date.day).getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
getDayNumber(date: IMyDate): number {
|
||||||
|
// Get day number: su=0, mo=1, tu=2, we=3 ...
|
||||||
|
let d: Date = this.getDate(date.year, date.month, date.day);
|
||||||
|
return d.getDay();
|
||||||
|
}
|
||||||
|
|
||||||
|
getWeekday(date: IMyDate): string {
|
||||||
|
// Get weekday: su, mo, tu, we ...
|
||||||
|
return this.weekDayOpts[this.getDayNumber(date)];
|
||||||
|
}
|
||||||
|
|
||||||
|
getDate(year: number, month: number, day: number): Date {
|
||||||
|
// Creates a date object from given year, month and day
|
||||||
|
return new Date(year, month - 1, day, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
sundayIdx(): number {
|
||||||
|
// Index of Sunday day
|
||||||
|
return this.dayIdx > 0 ? 7 - this.dayIdx : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
generateCalendar(m: number, y: number, notifyChange: boolean): void {
|
||||||
|
this.dates.length = 0;
|
||||||
|
let today: IMyDate = this.getToday();
|
||||||
|
let monthStart: number = this.monthStartIdx(y, m);
|
||||||
|
let dInThisM: number = this.daysInMonth(m, y);
|
||||||
|
let dInPrevM: number = this.daysInPrevMonth(m, y);
|
||||||
|
|
||||||
|
let dayNbr: number = 1;
|
||||||
|
let cmo: number = this.PREV_MONTH;
|
||||||
|
for (let i = 1; i < 7; i++) {
|
||||||
|
let week: Array<IMyCalendarDay> = [];
|
||||||
|
if (i === 1) {
|
||||||
|
// First week
|
||||||
|
let pm = dInPrevM - monthStart + 1;
|
||||||
|
// Previous month
|
||||||
|
for (let j = pm; j <= dInPrevM; j++) {
|
||||||
|
let date: IMyDate = {year: y, month: m - 1, day: j};
|
||||||
|
week.push({dateObj: date, cmo: cmo, currDay: this.isCurrDay(j, m, y, cmo, today), dayNbr: this.getDayNumber(date), disabled: this.utilService.isDisabledDay(date, this.opts.disableUntil, this.opts.disableSince, this.opts.disableWeekends, this.opts.disableDays, this.opts.disableDateRange, this.opts.enableDays)});
|
||||||
|
}
|
||||||
|
|
||||||
|
cmo = this.CURR_MONTH;
|
||||||
|
// Current month
|
||||||
|
let daysLeft: number = 7 - week.length;
|
||||||
|
for (let j = 0; j < daysLeft; j++) {
|
||||||
|
let date: IMyDate = {year: y, month: m, day: dayNbr};
|
||||||
|
week.push({dateObj: date, cmo: cmo, currDay: this.isCurrDay(dayNbr, m, y, cmo, today), dayNbr: this.getDayNumber(date), disabled: this.utilService.isDisabledDay(date, this.opts.disableUntil, this.opts.disableSince, this.opts.disableWeekends, this.opts.disableDays, this.opts.disableDateRange, this.opts.enableDays)});
|
||||||
|
dayNbr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Rest of the weeks
|
||||||
|
for (let j = 1; j < 8; j++) {
|
||||||
|
if (dayNbr > dInThisM) {
|
||||||
|
// Next month
|
||||||
|
dayNbr = 1;
|
||||||
|
cmo = this.NEXT_MONTH;
|
||||||
|
}
|
||||||
|
let date: IMyDate = {year: y, month: cmo === this.CURR_MONTH ? m : m + 1, day: dayNbr};
|
||||||
|
week.push({dateObj: date, cmo: cmo, currDay: this.isCurrDay(dayNbr, m, y, cmo, today), dayNbr: this.getDayNumber(date), disabled: this.utilService.isDisabledDay(date, this.opts.disableUntil, this.opts.disableSince, this.opts.disableWeekends, this.opts.disableDays, this.opts.disableDateRange, this.opts.enableDays)});
|
||||||
|
dayNbr++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let weekNbr: number = this.opts.showWeekNumbers && this.opts.firstDayOfWeek === "mo" ? this.utilService.getWeekNumber(week[0].dateObj) : 0;
|
||||||
|
this.dates.push({week: week, weekNbr: weekNbr});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setHeaderBtnDisabledState(m, y);
|
||||||
|
|
||||||
|
if (notifyChange) {
|
||||||
|
// Notify parent
|
||||||
|
this.calendarViewChanged.emit({year: y, month: m, first: {number: 1, weekday: this.getWeekday({year: y, month: m, day: 1})}, last: {number: dInThisM, weekday: this.getWeekday({year: y, month: m, day: dInThisM})}});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parseSelectedDate(selDate: any): IMyDate {
|
||||||
|
// Parse selDate value - it can be string or IMyDate object
|
||||||
|
let date: IMyDate = {day: 0, month: 0, year: 0};
|
||||||
|
if (typeof selDate === "string") {
|
||||||
|
let sd: string = <string>selDate;
|
||||||
|
date.day = this.utilService.parseDatePartNumber(this.opts.dateFormat, sd, "dd");
|
||||||
|
|
||||||
|
date.month = this.opts.dateFormat.indexOf("mmm") !== -1
|
||||||
|
? this.utilService.parseDatePartMonthName(this.opts.dateFormat, sd, "mmm", this.opts.monthLabels)
|
||||||
|
: this.utilService.parseDatePartNumber(this.opts.dateFormat, sd, "mm");
|
||||||
|
|
||||||
|
date.year = this.utilService.parseDatePartNumber(this.opts.dateFormat, sd, "yyyy");
|
||||||
|
}
|
||||||
|
else if (typeof selDate === "object") {
|
||||||
|
date = selDate;
|
||||||
|
}
|
||||||
|
this.selectionDayTxt = this.formatDate(date);
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
parseSelectedMonth(ms: string): IMyMonth {
|
||||||
|
return this.utilService.parseDefaultMonth(ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
setHeaderBtnDisabledState(m: number, y: number): void {
|
||||||
|
let dpm: boolean = false;
|
||||||
|
let dpy: boolean = false;
|
||||||
|
let dnm: boolean = false;
|
||||||
|
let dny: boolean = false;
|
||||||
|
if (this.opts.disableHeaderButtons) {
|
||||||
|
dpm = this.utilService.isMonthDisabledByDisableUntil({year: m === 1 ? y - 1 : y, month: m === 1 ? 12 : m - 1, day: this.daysInMonth(m === 1 ? 12 : m - 1, m === 1 ? y - 1 : y)}, this.opts.disableUntil);
|
||||||
|
dpy = this.utilService.isMonthDisabledByDisableUntil({year: y - 1, month: m, day: this.daysInMonth(m, y - 1)}, this.opts.disableUntil);
|
||||||
|
dnm = this.utilService.isMonthDisabledByDisableSince({year: m === 12 ? y + 1 : y, month: m === 12 ? 1 : m + 1, day: 1}, this.opts.disableSince);
|
||||||
|
dny = this.utilService.isMonthDisabledByDisableSince({year: y + 1, month: m, day: 1}, this.opts.disableSince);
|
||||||
|
}
|
||||||
|
this.prevMonthDisabled = m === 1 && y === this.opts.minYear || dpm;
|
||||||
|
this.prevYearDisabled = y - 1 < this.opts.minYear || dpy;
|
||||||
|
this.nextMonthDisabled = m === 12 && y === this.opts.maxYear || dnm;
|
||||||
|
this.nextYearDisabled = y + 1 > this.opts.maxYear || dny;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { CommonModule } from "@angular/common";
|
||||||
|
import { FormsModule } from "@angular/forms";
|
||||||
|
import { NgModule } from "@angular/core";
|
||||||
|
import { MyDatePicker } from "./my-date-picker.component";
|
||||||
|
import { FocusDirective } from "./directives/my-date-picker.focus.directive";
|
||||||
|
import { InputAutoFillDirective } from "./directives/my-date-picker.input.auto.fill.directive";
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
imports: [CommonModule, FormsModule],
|
||||||
|
declarations: [MyDatePicker, FocusDirective, InputAutoFillDirective],
|
||||||
|
exports: [MyDatePicker, FocusDirective, InputAutoFillDirective]
|
||||||
|
})
|
||||||
|
export class MyDatePickerModule {
|
||||||
|
}
|
|
@ -0,0 +1,232 @@
|
||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
import { IMyLocales, IMyOptions } from "../interfaces/index";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class LocaleService {
|
||||||
|
private locales: IMyLocales = {
|
||||||
|
"en": {
|
||||||
|
dayLabels: {su: "Sun", mo: "Mon", tu: "Tue", we: "Wed", th: "Thu", fr: "Fri", sa: "Sat"},
|
||||||
|
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "May", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Dec" },
|
||||||
|
dateFormat: "yyyy-mm-dd",
|
||||||
|
todayBtnTxt: "Today",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true,
|
||||||
|
},
|
||||||
|
"he": {
|
||||||
|
dayLabels: {su: "רא", mo: "שנ", tu: "של", we: "רב", th: "חמ", fr: "שי", sa: "שב"},
|
||||||
|
monthLabels: { 1: "ינו", 2: "פבר", 3: "מרץ", 4: "אפר", 5: "מאי", 6: "יונ", 7: "יול", 8: "אוג", 9: "ספט", 10: "אוק", 11: "נוב", 12: "דצמ" },
|
||||||
|
dateFormat: "dd/mm/yyyy",
|
||||||
|
todayBtnTxt: "היום",
|
||||||
|
firstDayOfWeek: "su",
|
||||||
|
sunHighlight: false
|
||||||
|
},
|
||||||
|
"ja": {
|
||||||
|
dayLabels: {su: "日", mo: "月", tu: "火", we: "水", th: "木", fr: "金", sa: "土"},
|
||||||
|
monthLabels: {1: "1月", 2: "2月", 3: "3月", 4: "4月", 5: "5月", 6: "6月", 7: "7月", 8: "8月", 9: "9月", 10: "10月", 11: "11月", 12: "12月"},
|
||||||
|
dateFormat: "yyyy.mm.dd",
|
||||||
|
todayBtnTxt: "今日",
|
||||||
|
sunHighlight: false
|
||||||
|
},
|
||||||
|
"fr": {
|
||||||
|
dayLabels: {su: "Dim", mo: "Lun", tu: "Mar", we: "Mer", th: "Jeu", fr: "Ven", sa: "Sam"},
|
||||||
|
monthLabels: {1: "Jan", 2: "Fév", 3: "Mar", 4: "Avr", 5: "Mai", 6: "Juin", 7: "Juil", 8: "Aoû", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Déc"},
|
||||||
|
dateFormat: "dd/mm/yyyy",
|
||||||
|
todayBtnTxt: "Aujourd'hui",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true,
|
||||||
|
},
|
||||||
|
"fi": {
|
||||||
|
dayLabels: {su: "Su", mo: "Ma", tu: "Ti", we: "Ke", th: "To", fr: "Pe", sa: "La"},
|
||||||
|
monthLabels: {1: "Tam", 2: "Hel", 3: "Maa", 4: "Huh", 5: "Tou", 6: "Kes", 7: "Hei", 8: "Elo", 9: "Syy", 10: "Lok", 11: "Mar", 12: "Jou"},
|
||||||
|
dateFormat: "dd.mm.yyyy",
|
||||||
|
todayBtnTxt: "Tänään",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true,
|
||||||
|
},
|
||||||
|
"es": {
|
||||||
|
dayLabels: {su: "Do", mo: "Lu", tu: "Ma", we: "Mi", th: "Ju", fr: "Vi", sa: "Sa"},
|
||||||
|
monthLabels: {1: "Ene", 2: "Feb", 3: "Mar", 4: "Abr", 5: "May", 6: "Jun", 7: "Jul", 8: "Ago", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Dic"},
|
||||||
|
dateFormat: "dd.mm.yyyy",
|
||||||
|
todayBtnTxt: "Hoy",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true,
|
||||||
|
},
|
||||||
|
"hu": {
|
||||||
|
dayLabels: {su: "Vas", mo: "Hét", tu: "Kedd", we: "Sze", th: "Csü", fr: "Pén", sa: "Szo"},
|
||||||
|
monthLabels: { 1: "Jan", 2: "Feb", 3: "Már", 4: "Ápr", 5: "Máj", 6: "Jún", 7: "Júl", 8: "Aug", 9: "Szep", 10: "Okt", 11: "Nov", 12: "Dec" },
|
||||||
|
dateFormat: "yyyy-mm-dd",
|
||||||
|
todayBtnTxt: "Ma",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true
|
||||||
|
},
|
||||||
|
"sv": {
|
||||||
|
dayLabels: {su: "Sön", mo: "Mån", tu: "Tis", we: "Ons", th: "Tor", fr: "Fre", sa: "Lör"},
|
||||||
|
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Maj", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Dec" },
|
||||||
|
dateFormat: "yyyy-mm-dd",
|
||||||
|
todayBtnTxt: "Idag",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: false
|
||||||
|
},
|
||||||
|
"nl": {
|
||||||
|
dayLabels: {su: "Zon", mo: "Maa", tu: "Din", we: "Woe", th: "Don", fr: "Vri", sa: "Zat"},
|
||||||
|
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Mei", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Dec" },
|
||||||
|
dateFormat: "dd-mm-yyyy",
|
||||||
|
todayBtnTxt: "Vandaag",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: false
|
||||||
|
},
|
||||||
|
"ru": {
|
||||||
|
dayLabels: {su: "Вс", mo: "Пн", tu: "Вт", we: "Ср", th: "Чт", fr: "Пт", sa: "Сб"},
|
||||||
|
monthLabels: { 1: "Янв", 2: "Фев", 3: "Март", 4: "Апр", 5: "Май", 6: "Июнь", 7: "Июль", 8: "Авг", 9: "Сент", 10: "Окт", 11: "Ноя", 12: "Дек" },
|
||||||
|
dateFormat: "dd.mm.yyyy",
|
||||||
|
todayBtnTxt: "Сегодня",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true
|
||||||
|
},
|
||||||
|
"uk": {
|
||||||
|
dayLabels: {su: "Нд", mo: "Пн", tu: "Вт", we: "Ср", th: "Чт", fr: "Пт", sa: "Сб"},
|
||||||
|
monthLabels: { 1: "Січ", 2: "Лют", 3: "Бер", 4: "Кві", 5: "Тра", 6: "Чер", 7: "Лип", 8: "Сер", 9: "Вер", 10: "Жов", 11: "Лис", 12: "Гру" },
|
||||||
|
dateFormat: "dd.mm.yyyy",
|
||||||
|
todayBtnTxt: "Сьогодні",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true
|
||||||
|
},
|
||||||
|
"no": {
|
||||||
|
dayLabels: {su: "Søn", mo: "Man", tu: "Tir", we: "Ons", th: "Tor", fr: "Fre", sa: "Lør"},
|
||||||
|
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Mai", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Des" },
|
||||||
|
dateFormat: "dd.mm.yyyy",
|
||||||
|
todayBtnTxt: "I dag",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: false
|
||||||
|
},
|
||||||
|
"tr": {
|
||||||
|
dayLabels: {su: "Paz", mo: "Pzt", tu: "Sal", we: "Çar", th: "Per", fr: "Cum", sa: "Cmt"},
|
||||||
|
monthLabels: { 1: "Oca", 2: "Şub", 3: "Mar", 4: "Nis", 5: "May", 6: "Haz", 7: "Tem", 8: "Ağu", 9: "Eyl", 10: "Eki", 11: "Kas", 12: "Ara" },
|
||||||
|
dateFormat: "dd.mm.yyyy",
|
||||||
|
todayBtnTxt: "Bugün",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: false
|
||||||
|
},
|
||||||
|
"pt-br": {
|
||||||
|
dayLabels: {su: "Dom", mo: "Seg", tu: "Ter", we: "Qua", th: "Qui", fr: "Sex", sa: "Sab"},
|
||||||
|
monthLabels: { 1: "Jan", 2: "Fev", 3: "Mar", 4: "Abr", 5: "Mai", 6: "Jun", 7: "Jul", 8: "Ago", 9: "Set", 10: "Out", 11: "Nov", 12: "Dez" },
|
||||||
|
dateFormat: "dd/mm/yyyy",
|
||||||
|
todayBtnTxt: "Hoje",
|
||||||
|
firstDayOfWeek: "su",
|
||||||
|
sunHighlight: true
|
||||||
|
},
|
||||||
|
"de": {
|
||||||
|
dayLabels: {su: "So", mo: "Mo", tu: "Di", we: "Mi", th: "Do", fr: "Fr", sa: "Sa"},
|
||||||
|
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mär", 4: "Apr", 5: "Mai", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Dez" },
|
||||||
|
dateFormat: "dd.mm.yyyy",
|
||||||
|
todayBtnTxt: "Heute",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true
|
||||||
|
},
|
||||||
|
"it": {
|
||||||
|
dayLabels: { su: "Dom", mo: "Lun", tu: "Mar", we: "Mer", th: "Gio", fr: "Ven", sa: "Sab" },
|
||||||
|
monthLabels: { 1: "Gen", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Mag", 6: "Giu", 7: "Lug", 8: "Ago", 9: "Set", 10: "Ott", 11: "Nov", 12: "Dic" },
|
||||||
|
dateFormat: "dd/mm/yyyy",
|
||||||
|
todayBtnTxt: "Oggi",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true
|
||||||
|
},
|
||||||
|
"it-ch": {
|
||||||
|
dayLabels: { su: "Dom", mo: "Lun", tu: "Mar", we: "Mer", th: "Gio", fr: "Ven", sa: "Sab" },
|
||||||
|
monthLabels: { 1: "Gen", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Mag", 6: "Giu", 7: "Lug", 8: "Ago", 9: "Set", 10: "Ott", 11: "Nov", 12: "Dic" },
|
||||||
|
dateFormat: "dd.mm.yyyy",
|
||||||
|
todayBtnTxt: "Oggi",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true
|
||||||
|
},
|
||||||
|
"pl": {
|
||||||
|
dayLabels: { su: "Nie", mo: "Pon", tu: "Wto", we: "Śro", th: "Czw", fr: "Pią", sa: "Sob" },
|
||||||
|
monthLabels: { 1: "Sty", 2: "Lut", 3: "Mar", 4: "Kwi", 5: "Maj", 6: "Cze", 7: "Lip", 8: "Sie", 9: "Wrz", 10: "Paź", 11: "Lis", 12: "Gru" },
|
||||||
|
dateFormat: "yyyy-mm-dd",
|
||||||
|
todayBtnTxt: "Dzisiaj",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true,
|
||||||
|
},
|
||||||
|
"my": {
|
||||||
|
dayLabels: {su: "တနင်္ဂနွေ", mo: "တနင်္လာ", tu: "အင်္ဂါ", we: "ဗုဒ္ဓဟူး", th: "ကြသပတေး", fr: "သောကြာ", sa: "စနေ"},
|
||||||
|
monthLabels: { 1: "ဇန်နဝါရီ", 2: "ဖေဖော်ဝါရီ", 3: "မတ်", 4: "ဧပြီ", 5: "မေ", 6: "ဇွန်", 7: "ဇူလိုင်", 8: "ဩဂုတ်", 9: "စက်တင်ဘာ", 10: "အောက်တိုဘာ", 11: "နိုဝင်ဘာ", 12: "ဒီဇင်ဘာ" },
|
||||||
|
dateFormat: "yyyy-mm-dd",
|
||||||
|
todayBtnTxt: "ယနေ့",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true,
|
||||||
|
},
|
||||||
|
"sk": {
|
||||||
|
dayLabels: { su: "Ne", mo: "Po", tu: "Ut", we: "St", th: "Št", fr: "Pi", sa: "So" },
|
||||||
|
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Máj", 6: "Jún", 7: "Júl", 8: "Aug", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Dec" },
|
||||||
|
dateFormat: "dd.mm.yyyy",
|
||||||
|
todayBtnTxt: "Dnes",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true,
|
||||||
|
},
|
||||||
|
"sl": {
|
||||||
|
dayLabels: { su: "Ned", mo: "Pon", tu: "Tor", we: "Sre", th: "Čet", fr: "Pet", sa: "Sob" },
|
||||||
|
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Maj", 6: "Jun", 7: "Jul", 8: "Avg", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Dec" },
|
||||||
|
dateFormat: "dd. mm. yyyy",
|
||||||
|
todayBtnTxt: "Danes",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true,
|
||||||
|
},
|
||||||
|
"zh-cn": {
|
||||||
|
dayLabels: {su: "日", mo: "一", tu: "二", we: "三", th: "四", fr: "五", sa: "六"},
|
||||||
|
monthLabels: { 1: "1月", 2: "2月", 3: "3月", 4: "4月", 5: "5月", 6: "6月", 7: "7月", 8: "8月", 9: "9月", 10: "10月", 11: "11月", 12: "12月" },
|
||||||
|
dateFormat: "yyyy-mm-dd",
|
||||||
|
todayBtnTxt: "今天",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true,
|
||||||
|
},
|
||||||
|
"ro": {
|
||||||
|
dayLabels: {su: "du", mo: "lu", tu: "ma", we: "mi", th: "jo", fr: "vi", sa: "sa"},
|
||||||
|
monthLabels: { 1: "ian", 2: "feb", 3: "mart", 4: "apr", 5: "mai", 6: "iun", 7: "iul", 8: "aug", 9: "sept", 10: "oct", 11: "nov", 12: "dec" },
|
||||||
|
dateFormat: "dd.mm.yyyy",
|
||||||
|
todayBtnTxt: "Astăzi",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true,
|
||||||
|
},
|
||||||
|
"ca": {
|
||||||
|
dayLabels: {su: "dg", mo: "dl", tu: "dt", we: "dc", th: "dj", fr: "dv", sa: "ds"},
|
||||||
|
monthLabels: {1: "Gen", 2: "Febr", 3: "Març", 4: "Abr", 5: "Maig", 6: "Juny", 7: "Jul", 8: "Ag", 9: "Set", 10: "Oct", 11: "Nov", 12: "Des"},
|
||||||
|
dateFormat: "dd.mm.yyyy",
|
||||||
|
todayBtnTxt: "Avui",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true,
|
||||||
|
},
|
||||||
|
"id": {
|
||||||
|
dayLabels: {su: "Min", mo: "Sen", tu: "Sel", we: "Rab", th: "Kam", fr: "Jum", sa: "Sab"},
|
||||||
|
monthLabels: {1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "Mei", 6: "Jun", 7: "Jul", 8: "Ags", 9: "Sep", 10: "Okt", 11: "Nov", 12: "Des"},
|
||||||
|
dateFormat: "dd-mm-yyyy",
|
||||||
|
todayBtnTxt: "Hari ini",
|
||||||
|
firstDayOfWeek: "su",
|
||||||
|
sunHighlight: true
|
||||||
|
},
|
||||||
|
"en-au": {
|
||||||
|
dayLabels: {su: "Sun", mo: "Mon", tu: "Tue", we: "Wed", th: "Thu", fr: "Fri", sa: "Sat"},
|
||||||
|
monthLabels: { 1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr", 5: "May", 6: "Jun", 7: "Jul", 8: "Aug", 9: "Sep", 10: "Oct", 11: "Nov", 12: "Dec" },
|
||||||
|
dateFormat: "dd/mm/yyyy",
|
||||||
|
todayBtnTxt: "Today",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true
|
||||||
|
},
|
||||||
|
"am-et": {
|
||||||
|
dayLabels: {su: "እሑድ", mo: "ሰኞ", tu: "ማክሰኞ", we: "ረቡዕ", th: "ሐሙስ", fr: "ዓርብ", sa: "ቅዳሜ"},
|
||||||
|
monthLabels: { 1: "ጃንዩ", 2: "ፌብሩ", 3: "ማርች", 4: "ኤፕረ", 5: "ሜይ", 6: "ጁን", 7: "ጁላይ", 8: "ኦገስ", 9: "ሴፕቴ", 10: "ኦክተ", 11: "ኖቬም", 12: "ዲሴም" },
|
||||||
|
dateFormat: "yyyy-mm-dd",
|
||||||
|
todayBtnTxt: "ዛሬ",
|
||||||
|
firstDayOfWeek: "mo",
|
||||||
|
sunHighlight: true
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
getLocaleOptions(locale: string): IMyOptions {
|
||||||
|
if (locale && this.locales.hasOwnProperty(locale)) {
|
||||||
|
// User given locale
|
||||||
|
return this.locales[locale];
|
||||||
|
}
|
||||||
|
// Default: en
|
||||||
|
return this.locales["en"];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,169 @@
|
||||||
|
import { Injectable } from "@angular/core";
|
||||||
|
import { IMyDate } from "../interfaces/my-date.interface";
|
||||||
|
import { IMyDateRange } from "../interfaces/my-date-range.interface";
|
||||||
|
import { IMyMonth } from "../interfaces/my-month.interface";
|
||||||
|
import { IMyMonthLabels } from "../interfaces/my-month-labels.interface";
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class UtilService {
|
||||||
|
isDateValid(dateStr: string, dateFormat: string, minYear: number, maxYear: number, disableUntil: IMyDate, disableSince: IMyDate, disableWeekends: boolean, disableDays: Array<IMyDate>, disableDateRange: IMyDateRange, monthLabels: IMyMonthLabels, enableDays: Array<IMyDate>): IMyDate {
|
||||||
|
let returnDate: IMyDate = {day: 0, month: 0, year: 0};
|
||||||
|
let daysInMonth: Array<number> = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||||
|
let isMonthStr: boolean = this.getDatePartIndex(dateFormat, "mmm") !== -1;
|
||||||
|
|
||||||
|
if (dateStr.length !== dateFormat.length) {
|
||||||
|
return returnDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
let separator: string = this.getDateFormatSeparator(dateFormat);
|
||||||
|
|
||||||
|
let parts: Array<string> = dateStr.split(separator);
|
||||||
|
if (parts.length !== 3) {
|
||||||
|
return returnDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
let day: number = this.parseDatePartNumber(dateFormat, dateStr, "dd");
|
||||||
|
let month: number = isMonthStr ? this.parseDatePartMonthName(dateFormat, dateStr, "mmm", monthLabels) : this.parseDatePartNumber(dateFormat, dateStr, "mm");
|
||||||
|
let year: number = this.parseDatePartNumber(dateFormat, dateStr, "yyyy");
|
||||||
|
|
||||||
|
if (day !== -1 && month !== -1 && year !== -1) {
|
||||||
|
if (year < minYear || year > maxYear || month < 1 || month > 12) {
|
||||||
|
return returnDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
let date: IMyDate = {year: year, month: month, day: day};
|
||||||
|
|
||||||
|
if (this.isDisabledDay(date, disableUntil, disableSince, disableWeekends, disableDays, disableDateRange, enableDays)) {
|
||||||
|
return returnDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (year % 400 === 0 || (year % 100 !== 0 && year % 4 === 0)) {
|
||||||
|
daysInMonth[1] = 29;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (day < 1 || day > daysInMonth[month - 1]) {
|
||||||
|
return returnDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Valid date
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
return returnDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
getDateFormatSeparator(dateFormat: string): string {
|
||||||
|
return dateFormat.replace(/[dmy]/g, "")[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
isMonthLabelValid(monthLabel: string, monthLabels: IMyMonthLabels): number {
|
||||||
|
for (let key = 1; key <= 12; key++) {
|
||||||
|
if (monthLabel.toLowerCase() === monthLabels[key].toLowerCase()) {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
isYearLabelValid(yearLabel: number, minYear: number, maxYear: number): number {
|
||||||
|
if (yearLabel >= minYear && yearLabel <= maxYear) {
|
||||||
|
return yearLabel;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
parseDatePartNumber(dateFormat: string, dateString: string, datePart: string): number {
|
||||||
|
let pos: number = this.getDatePartIndex(dateFormat, datePart);
|
||||||
|
if (pos !== -1) {
|
||||||
|
let value: string = dateString.substring(pos, pos + datePart.length);
|
||||||
|
if (!/^\d+$/.test(value)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return parseInt(value);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
parseDatePartMonthName(dateFormat: string, dateString: string, datePart: string, monthLabels: IMyMonthLabels): number {
|
||||||
|
let pos: number = this.getDatePartIndex(dateFormat, datePart);
|
||||||
|
if (pos !== -1) {
|
||||||
|
return this.isMonthLabelValid(dateString.substring(pos, pos + datePart.length), monthLabels);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
getDatePartIndex(dateFormat: string, datePart: string): number {
|
||||||
|
return dateFormat.indexOf(datePart);
|
||||||
|
}
|
||||||
|
|
||||||
|
parseDefaultMonth(monthString: string): IMyMonth {
|
||||||
|
let month: IMyMonth = {monthTxt: "", monthNbr: 0, year: 0};
|
||||||
|
if (monthString !== "") {
|
||||||
|
let split = monthString.split(monthString.match(/[^0-9]/)[0]);
|
||||||
|
month.monthNbr = split[0].length === 2 ? parseInt(split[0]) : parseInt(split[1]);
|
||||||
|
month.year = split[0].length === 2 ? parseInt(split[1]) : parseInt(split[0]);
|
||||||
|
}
|
||||||
|
return month;
|
||||||
|
}
|
||||||
|
|
||||||
|
isDisabledDay(date: IMyDate, disableUntil: IMyDate, disableSince: IMyDate, disableWeekends: boolean, disableDays: Array<IMyDate>, disableDateRange: IMyDateRange, enableDays: Array<IMyDate>): boolean {
|
||||||
|
for (let obj of enableDays) {
|
||||||
|
if (obj.year === date.year && obj.month === date.month && obj.day === date.day) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let dateMs: number = this.getTimeInMilliseconds(date);
|
||||||
|
if (this.isInitializedDate(disableUntil) && dateMs <= this.getTimeInMilliseconds(disableUntil)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isInitializedDate(disableSince) && dateMs >= this.getTimeInMilliseconds(disableSince)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disableWeekends) {
|
||||||
|
let dayNbr = this.getDayNumber(date);
|
||||||
|
if (dayNbr === 0 || dayNbr === 6) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let obj of disableDays) {
|
||||||
|
if (obj.year === date.year && obj.month === date.month && obj.day === date.day) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isInitializedDate(disableDateRange.begin) && this.isInitializedDate(disableDateRange.end) && dateMs >= this.getTimeInMilliseconds(disableDateRange.begin) && dateMs <= this.getTimeInMilliseconds(disableDateRange.end)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
getWeekNumber(date: IMyDate): number {
|
||||||
|
let d: Date = new Date(date.year, date.month - 1, date.day, 0, 0, 0, 0);
|
||||||
|
d.setDate(d.getDate() + (d.getDay() === 0 ? -3 : 4 - d.getDay()));
|
||||||
|
return Math.round(((d.getTime() - new Date(d.getFullYear(), 0, 4).getTime()) / 86400000) / 7) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
isMonthDisabledByDisableUntil(date: IMyDate, disableUntil: IMyDate): boolean {
|
||||||
|
return this.isInitializedDate(disableUntil) && this.getTimeInMilliseconds(date) <= this.getTimeInMilliseconds(disableUntil);
|
||||||
|
}
|
||||||
|
|
||||||
|
isMonthDisabledByDisableSince(date: IMyDate, disableSince: IMyDate): boolean {
|
||||||
|
return this.isInitializedDate(disableSince) && this.getTimeInMilliseconds(date) >= this.getTimeInMilliseconds(disableSince);
|
||||||
|
}
|
||||||
|
|
||||||
|
isInitializedDate(date: IMyDate): boolean {
|
||||||
|
return date.year !== 0 && date.month !== 0 && date.day !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
getTimeInMilliseconds(date: IMyDate): number {
|
||||||
|
return new Date(date.year, date.month - 1, date.day, 0, 0, 0, 0).getTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
getDayNumber(date: IMyDate): number {
|
||||||
|
let d: Date = new Date(date.year, date.month - 1, date.day, 0, 0, 0, 0);
|
||||||
|
return d.getDay();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,102 +1,102 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu]]></loc>
|
<loc><![CDATA[demo.openaire.eu]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/participate/deposit-publications-data]]></loc>
|
<loc><![CDATA[demo.openaire.eu/participate/deposit-publications-data]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/participate/claim]]></loc>
|
<loc><![CDATA[demo.openaire.eu/participate/claim]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/find]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/find]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/find/publications]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/find/publications]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/find/datasets]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/find/datasets]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/find/projects]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/find/projects]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/find/people]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/find/people]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/find/organizations]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/find/organizations]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/find/dataproviders]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/find/dataproviders]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/advanced/publications]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/advanced/publications]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/advanced/datasets]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/advanced/datasets]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/advanced/projects]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/advanced/projects]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/advanced/people]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/advanced/people]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/advanced/organizations]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/advanced/organizations]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/advanced/dataproviders]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/advanced/dataproviders]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/data-providers]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/data-providers]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc><![CDATA[https://demo.openaire.eu/search/entity-registries]]></loc>
|
<loc><![CDATA[demo.openaire.eu/search/entity-registries]]></loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://demo.openaire.eu/participate/deposit-publications</loc>
|
<loc>demo.openaire.eu/participate/deposit-publications</loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
<url>
|
<url>
|
||||||
<loc>https://demo.openaire.eu/participate/deposit-datasets</loc>
|
<loc>demo.openaire.eu/participate/deposit-datasets</loc>
|
||||||
<changefreq>weekly</changefreq>
|
<changefreq>weekly</changefreq>
|
||||||
<priority>0.5</priority>
|
<priority>0.5</priority>
|
||||||
</url>
|
</url>
|
||||||
|
|
Loading…
Reference in New Issue