2020-11-11 15:43:13 +01:00
|
|
|
import {Component, Input} from '@angular/core';
|
2018-02-15 11:36:12 +01:00
|
|
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@Component({
|
2021-01-22 15:36:06 +01:00
|
|
|
selector: 'search-paging',
|
|
|
|
template: `
|
|
|
|
<div class="paging-hr searchPaging uk-margin-small-bottom"
|
2020-02-26 16:01:16 +01:00
|
|
|
*ngIf="(results && searchUtils.totalResults > 0) || (!loadPaging && oldTotalResults > 0 && searchUtils.status == errorCodes.LOADING)">
|
2020-02-24 14:33:34 +01:00
|
|
|
<div class="uk-panel uk-margin-small-top uk-grid uk-flex uk-flex-middle">
|
2021-01-22 15:36:06 +01:00
|
|
|
<div class="uk-width-1-1@s uk-width-1-2@m uk-text-uppercase"
|
2020-02-26 16:01:16 +01:00
|
|
|
*ngIf="results && searchUtils.totalResults > 0">
|
2021-01-22 15:36:06 +01:00
|
|
|
<span class="uk-text-bold">{{searchUtils.totalResults|number}}</span>
|
2020-02-24 14:33:34 +01:00
|
|
|
<span class="uk-text-muted uk-text-uppercase"> {{type}}, page </span>
|
2021-01-22 15:36:06 +01:00
|
|
|
<span class="uk-text-bold">{{searchUtils.page | number}}</span>
|
2020-02-24 14:33:34 +01:00
|
|
|
<span class="uk-text-muted uk-text-uppercase"> of </span>
|
2021-01-22 15:36:06 +01:00
|
|
|
<span class="uk-text-bold">{{(totalPages(searchUtils.totalResults)|number)}}</span>
|
2020-02-24 14:33:34 +01:00
|
|
|
</div>
|
2021-01-22 15:36:06 +01:00
|
|
|
<div class="uk-width-1-1@s uk-width-1-2@m"
|
2020-02-26 16:01:16 +01:00
|
|
|
*ngIf="!loadPaging && oldTotalResults > 0 && searchUtils.status == errorCodes.LOADING">
|
2021-01-22 15:36:06 +01:00
|
|
|
<span class="uk-text-bold">{{oldTotalResults|number}}</span>
|
2020-02-24 14:33:34 +01:00
|
|
|
<span class="uk-text-muted uk-text-uppercase"> {{type}}, page </span>
|
2021-01-22 15:36:06 +01:00
|
|
|
<span class="uk-text-bold">{{searchUtils.page | number}}</span>
|
2020-02-24 14:33:34 +01:00
|
|
|
<span class="uk-text-muted uk-text-uppercase"> of </span>
|
2021-01-22 15:36:06 +01:00
|
|
|
<span class="uk-text-bold">{{(totalPages(oldTotalResults)|number)}}</span>
|
2020-02-24 14:33:34 +01:00
|
|
|
</div>
|
|
|
|
<!--div class="uk-width-1-1@s uk-width-1-2@m" *ngIf="results && searchUtils.totalResults > 0">
|
|
|
|
{{searchUtils.totalResults|number}} {{type}}, page {{searchUtils.page | number}} of {{(totalPages(searchUtils.totalResults)|number)}}
|
|
|
|
</div>
|
|
|
|
<div class="uk-width-1-1@s uk-width-1-2@m" *ngIf="!loadPaging && oldTotalResults > 0 && searchUtils.status == errorCodes.LOADING">
|
|
|
|
{{oldTotalResults|number}} {{type}}, page {{searchUtils.page | number}} of {{(totalPages(oldTotalResults)|number)}}
|
|
|
|
</div-->
|
2021-01-22 15:36:06 +01:00
|
|
|
<div class="float-children-right-at-medium margin-small-top-at-small uk-width-expand"
|
|
|
|
*ngIf="results && searchUtils.totalResults > searchUtils.size">
|
|
|
|
<paging [currentPage]="searchUtils.page" [totalResults]="searchUtils.totalResults" [baseUrl]="baseUrl"
|
|
|
|
[size]="searchUtils.size" [parameterNames]="parameterNames" [parameterValues]="parameterValues"
|
|
|
|
[isDisabled]="isDisabled">
|
2020-07-14 15:13:44 +02:00
|
|
|
</paging>
|
2020-02-24 14:33:34 +01:00
|
|
|
</div>
|
2021-01-22 15:36:06 +01:00
|
|
|
<div class="float-children-right-at-medium margin-small-top-at-small uk-width-expand"
|
|
|
|
*ngIf="!loadPaging && oldTotalResults > searchUtils.size && searchUtils.status == errorCodes.LOADING">
|
|
|
|
<paging [currentPage]="searchUtils.page" [totalResults]="oldTotalResults" [baseUrl]="baseUrl"
|
|
|
|
[size]="searchUtils.size" [parameterNames]="parameterNames" [parameterValues]="parameterValues"
|
|
|
|
[isDisabled]="isDisabled">
|
2020-07-14 15:13:44 +02:00
|
|
|
</paging>
|
2020-02-24 14:33:34 +01:00
|
|
|
</div>
|
2017-12-19 13:53:46 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-01-22 15:36:06 +01:00
|
|
|
`
|
2017-12-19 13:53:46 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
export class SearchPagingComponent {
|
2021-01-22 15:36:06 +01:00
|
|
|
@Input() isDisabled: boolean = false;
|
|
|
|
@Input() searchUtils;
|
|
|
|
@Input() results;
|
|
|
|
@Input() baseUrl;
|
|
|
|
@Input() type;
|
|
|
|
@Input() parameterNames: string[];
|
|
|
|
@Input() parameterValues: string[];
|
|
|
|
|
|
|
|
@Input() loadPaging: boolean = true;
|
|
|
|
@Input() oldTotalResults: number = 0;
|
|
|
|
|
|
|
|
public totalResults: number = 0;
|
|
|
|
public errorCodes: ErrorCodes = new ErrorCodes();
|
|
|
|
|
|
|
|
// @Input() totalResults:number = 0;
|
|
|
|
constructor() {
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
// this.totalResults = this.searchUtils.totalResults;
|
|
|
|
// if(!this.loadPaging && this.totalResults == 0) {
|
|
|
|
// this.totalResults = this.oldTotalResults;
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
|
|
|
|
totalPages(totalResults: number): number {
|
|
|
|
let totalPages: any = totalResults / (this.searchUtils.size);
|
|
|
|
if (!(Number.isInteger(totalPages))) {
|
|
|
|
totalPages = (parseInt(totalPages, 10) + 1);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2021-01-22 15:36:06 +01:00
|
|
|
return totalPages;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|