1
|
import {Component, Input} from '@angular/core';
|
2
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
3
|
|
4
|
@Component({
|
5
|
selector: 'search-paging',
|
6
|
template: `
|
7
|
<div class="paging-hr searchPaging uk-margin-small-bottom"
|
8
|
*ngIf="(results && searchUtils.totalResults > 0) || (!loadPaging && oldTotalResults > 0 && searchUtils.status == errorCodes.LOADING)">
|
9
|
<div class="uk-panel uk-margin-small-top uk-grid uk-flex uk-flex-middle">
|
10
|
<div class="uk-width-1-1@s uk-width-1-2@m uk-text-uppercase"
|
11
|
*ngIf="results && searchUtils.totalResults > 0">
|
12
|
<span class="uk-text-bold">{{searchUtils.totalResults|number}}</span>
|
13
|
<span class="uk-text-muted uk-text-uppercase"> {{type}}, page </span>
|
14
|
<span class="uk-text-bold">{{searchUtils.page | number}}</span>
|
15
|
<span class="uk-text-muted uk-text-uppercase"> of </span>
|
16
|
<span class="uk-text-bold">{{(totalPages(searchUtils.totalResults)|number)}}</span>
|
17
|
</div>
|
18
|
<div class="uk-width-1-1@s uk-width-1-2@m"
|
19
|
*ngIf="!loadPaging && oldTotalResults > 0 && searchUtils.status == errorCodes.LOADING">
|
20
|
<span class="uk-text-bold">{{oldTotalResults|number}}</span>
|
21
|
<span class="uk-text-muted uk-text-uppercase"> {{type}}, page </span>
|
22
|
<span class="uk-text-bold">{{searchUtils.page | number}}</span>
|
23
|
<span class="uk-text-muted uk-text-uppercase"> of </span>
|
24
|
<span class="uk-text-bold">{{(totalPages(oldTotalResults)|number)}}</span>
|
25
|
</div>
|
26
|
<!--div class="uk-width-1-1@s uk-width-1-2@m" *ngIf="results && searchUtils.totalResults > 0">
|
27
|
{{searchUtils.totalResults|number}} {{type}}, page {{searchUtils.page | number}} of {{(totalPages(searchUtils.totalResults)|number)}}
|
28
|
</div>
|
29
|
<div class="uk-width-1-1@s uk-width-1-2@m" *ngIf="!loadPaging && oldTotalResults > 0 && searchUtils.status == errorCodes.LOADING">
|
30
|
{{oldTotalResults|number}} {{type}}, page {{searchUtils.page | number}} of {{(totalPages(oldTotalResults)|number)}}
|
31
|
</div-->
|
32
|
<div class="float-children-right-at-medium margin-small-top-at-small uk-width-expand"
|
33
|
*ngIf="results && searchUtils.totalResults > searchUtils.size">
|
34
|
<paging [currentPage]="searchUtils.page" [totalResults]="searchUtils.totalResults" [baseUrl]="baseUrl"
|
35
|
[size]="searchUtils.size" [parameterNames]="parameterNames" [parameterValues]="parameterValues"
|
36
|
[isDisabled]="isDisabled">
|
37
|
</paging>
|
38
|
</div>
|
39
|
<div class="float-children-right-at-medium margin-small-top-at-small uk-width-expand"
|
40
|
*ngIf="!loadPaging && oldTotalResults > searchUtils.size && searchUtils.status == errorCodes.LOADING">
|
41
|
<paging [currentPage]="searchUtils.page" [totalResults]="oldTotalResults" [baseUrl]="baseUrl"
|
42
|
[size]="searchUtils.size" [parameterNames]="parameterNames" [parameterValues]="parameterValues"
|
43
|
[isDisabled]="isDisabled">
|
44
|
</paging>
|
45
|
</div>
|
46
|
</div>
|
47
|
</div>
|
48
|
`
|
49
|
})
|
50
|
|
51
|
export class SearchPagingComponent {
|
52
|
@Input() isDisabled: boolean = false;
|
53
|
@Input() searchUtils;
|
54
|
@Input() results;
|
55
|
@Input() baseUrl;
|
56
|
@Input() type;
|
57
|
@Input() parameterNames: string[];
|
58
|
@Input() parameterValues: string[];
|
59
|
|
60
|
@Input() loadPaging: boolean = true;
|
61
|
@Input() oldTotalResults: number = 0;
|
62
|
|
63
|
public totalResults: number = 0;
|
64
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
65
|
|
66
|
// @Input() totalResults:number = 0;
|
67
|
constructor() {
|
68
|
}
|
69
|
|
70
|
ngOnInit() {
|
71
|
// this.totalResults = this.searchUtils.totalResults;
|
72
|
// if(!this.loadPaging && this.totalResults == 0) {
|
73
|
// this.totalResults = this.oldTotalResults;
|
74
|
// }
|
75
|
}
|
76
|
|
77
|
totalPages(totalResults: number): number {
|
78
|
let totalPages: any = totalResults / (this.searchUtils.size);
|
79
|
if (!(Number.isInteger(totalPages))) {
|
80
|
totalPages = (parseInt(totalPages, 10) + 1);
|
81
|
}
|
82
|
return totalPages;
|
83
|
}
|
84
|
|
85
|
|
86
|
}
|