openaire-library/claims/linking/selected/selectedProjects.component.ts

84 lines
2.8 KiB
TypeScript

import {Component, Input,Output, EventEmitter} from '@angular/core';
import {ClaimProject} from '../../claim-utils/claimEntities.class';
import {RouterHelper} from '../../../utils/routerHelper.class';
@Component({
selector: 'claim-selected-projects',
template: `
<div class="uk-placeholder uk-margin-top" >
<div>
<h5 class=" uk-margin uk-h5 uk-text-primary" *ngIf="projects.length > 0 "> Selected Projects ({{projects.length}}) </h5>
<ul class="uk-list uk-list-divider">
<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-icon-button"><span class="uk-icon">
<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" icon="close" ratio="1"><path fill="none" stroke="#000" stroke-width="1.06" d="M16,16 L4,4"></path><path fill="none" stroke="#000" stroke-width="1.06" d="M16,4 L4,16"></path></svg>
</span></span>
</li>
</ul>
</div>
<div *ngIf="projects.length == 0 " class="uk-text-center">There are no selected projects</div>
</div>
`
})
export class ClaimSelectedProjectsComponent {
ngOnInit() {
var myDate = new Date();
this.todayDate=( myDate.getFullYear()+ "-" +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
}
@Input() projects: ClaimProject[];
@Input() show='home';
@Input() title='Projects';
@Input() linkType:string = "project";
@Input() hideType;
@Input() bulkMode:boolean = false;
@Input() linkToResults:boolean = true;
@Output() projectsChange = new EventEmitter();
@Output() showChange = new EventEmitter();
showsearch:boolean = false;
todayDate = '';
nextDate = '';
public routerHelper:RouterHelper = new RouterHelper();
removeProject(item:any){
var index:number =this.projects.indexOf(item);
if (index > -1) {
this.projects.splice(index, 1);
}
this.projectsChange.emit({
value: this.projects
});
}
showType(type){
if(type != this.show){
this.show = type;
this.showChange.emit({
value: this.show
});
}
}
projectSelected($event) {
// this.showsearch = false;
}
}