2017-12-19 13:53:46 +01:00
|
|
|
import {Component, Input} from '@angular/core';
|
2020-07-13 16:42:34 +02:00
|
|
|
import {properties} from "../../../../environments/environment";
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'organizationsTab',
|
|
|
|
template: `
|
|
|
|
<div *ngIf=" !organizations || organizations.length == 0" class="uk-alert uk-alert-primary uk-animation-fade" role="alert">
|
|
|
|
No organizations available
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div *ngIf=" organizations && organizations.length > 0">
|
|
|
|
<div *ngIf="organizations.length > pageSize" class="uk-margin-bottom">
|
2018-05-18 14:47:26 +02:00
|
|
|
{{organizations.length | number}} organizations, page {{organizationsPage | number}} of {{totalPages(organizations.length) | number}}
|
2017-12-19 13:53:46 +01:00
|
|
|
<paging-no-load class="uk-float-right" [currentPage]="organizationsPage" [totalResults]="organizations.length" [size]="pageSize" (pageChange)="updateOrganizationsPage($event)"></paging-no-load>
|
|
|
|
</div>
|
|
|
|
|
2018-06-08 13:21:42 +02:00
|
|
|
<div *ngFor="let item of organizations.slice((organizationsPage-1)*pageSize, organizationsPage*pageSize)">
|
|
|
|
<h4 *ngIf=" item != undefined && item['id'] != undefined">
|
2017-12-19 13:53:46 +01:00
|
|
|
<!--a href="{{item['url']}}"-->
|
2020-07-13 16:42:34 +02:00
|
|
|
<a [queryParams]="{organizationId: item.id}" routerLinkActive="router-link-active" [routerLink]="url">
|
2018-06-08 13:21:42 +02:00
|
|
|
<p>{{item['name']}}</p>
|
2017-12-19 13:53:46 +01:00
|
|
|
</a>
|
2018-06-08 13:21:42 +02:00
|
|
|
</h4>
|
|
|
|
<h4 *ngIf="item['id'] == undefined">
|
|
|
|
<p>{{item['name']}}</p>
|
|
|
|
</h4>
|
2017-12-19 13:53:46 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class OrganizationsTabComponent {
|
|
|
|
|
|
|
|
@Input() organizations: {"name": string, "id": string}[];
|
|
|
|
public organizationsPage: number = 1;
|
|
|
|
public pageSize: number = 10;
|
2020-07-13 16:42:34 +02:00
|
|
|
public url = properties.searchLinkToDataProvider.split('?')[0];
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
constructor () {}
|
|
|
|
|
|
|
|
ngOnInit() {}
|
|
|
|
|
|
|
|
ngOnDestroy() {}
|
|
|
|
|
|
|
|
totalPages(totalResults: number): number {
|
|
|
|
let totalPages:any = totalResults/this.pageSize;
|
|
|
|
if(!(Number.isInteger(totalPages))) {
|
|
|
|
totalPages = (parseInt(totalPages, this.pageSize) + 1);
|
|
|
|
}
|
|
|
|
return totalPages;
|
|
|
|
}
|
|
|
|
|
|
|
|
updateOrganizationsPage($event) {
|
|
|
|
this.organizationsPage = $event.value;
|
|
|
|
}
|
|
|
|
}
|