1. Add EnvProperties in paging components (to get limit).
2. Add limit in pagingFormatterNoLoad.component when input property 'limitPaging' is true (default set to false). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@52104 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
acdb1cc6c7
commit
f9aba210a1
|
@ -1,9 +1,9 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {Router} from '@angular/router';
|
||||
import {Router, ActivatedRoute} from '@angular/router';
|
||||
import {DomSanitizer} from '@angular/platform-browser';
|
||||
//Usage Example <paging [currentPage]="page" [totalResults]="resultsNum" [term]="keyword"> </paging>
|
||||
import {RouterHelper} from './routerHelper.class';
|
||||
|
||||
import {EnvProperties} from './properties/env-properties';
|
||||
@Component({
|
||||
selector: 'paging',
|
||||
template: `
|
||||
|
@ -44,24 +44,31 @@ export class PagingFormatter {
|
|||
@Input() parameterNames:string[];
|
||||
@Input() parameterValues:string[];
|
||||
|
||||
private limit: number;
|
||||
properties:EnvProperties;
|
||||
|
||||
public routerHelper:RouterHelper = new RouterHelper();
|
||||
|
||||
constructor ( private _router: Router, private sanitizer:DomSanitizer) {
|
||||
constructor (private route: ActivatedRoute, private _router: Router, private sanitizer:DomSanitizer) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties = data.envSpecific;
|
||||
}
|
||||
);
|
||||
}
|
||||
getTotalPages(){
|
||||
let total: number = 0;
|
||||
let limit: number = 20;//OpenaireProperties.getPagingLimit();
|
||||
//let limit: number = 20;//OpenaireProperties.getPagingLimit();
|
||||
|
||||
var i:number =parseInt(''+(this.totalResults/this.size));
|
||||
total = (((this.totalResults/this.size) == i )? i :(i+1)) ;
|
||||
|
||||
if((this.currentPage == limit) && (total > limit)) {
|
||||
total = limit;
|
||||
} else if((this.currentPage > limit) && (total > limit)) {
|
||||
if((this.currentPage == this.limit) && (total > this.limit)) {
|
||||
total = this.limit;
|
||||
} else if((this.currentPage > this.limit) && (total > this.limit)) {
|
||||
total = this.currentPage;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {Component, Input, Output, EventEmitter} from '@angular/core';
|
||||
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import{EnvProperties} from './properties/env-properties';
|
||||
|
||||
//Usage Example <paging [currentPage]="page" [totalResults]="resultsNum" [term]="keyword"> </paging>
|
||||
|
||||
|
@ -36,20 +37,42 @@ export class pagingFormatterNoLoad {
|
|||
@Input() public term: string='';
|
||||
@Input() public size: number=10;
|
||||
@Input() public totalResults: number = 10;
|
||||
@Input() public limitPaging: boolean = false;
|
||||
|
||||
// @Input() public params;
|
||||
|
||||
@Output() pageChange = new EventEmitter();
|
||||
|
||||
constructor () {
|
||||
private limit: number;
|
||||
properties:EnvProperties;
|
||||
|
||||
constructor (private route: ActivatedRoute) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
console.info("In paging -- CurrentPage:"+this.currentPage+" "+"total Pages = "+this.getTotalPages() +" Results num:"+this.totalResults);
|
||||
this.route.data
|
||||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties = data.envSpecific;
|
||||
}
|
||||
);
|
||||
}
|
||||
getTotalPages(){
|
||||
let total: number = 0;
|
||||
//let limit: number = 20;//OpenaireProperties.getPagingLimit();
|
||||
|
||||
var i= this.totalResults/this.size;
|
||||
var integerI=parseInt(''+i);
|
||||
return parseInt(''+((i==integerI)?i:i+1));
|
||||
total = parseInt(''+((i==integerI)?i:i+1));
|
||||
|
||||
if(this.limitPaging) {
|
||||
if((this.currentPage == this.limit) && (total > this.limit)) {
|
||||
total = this.limit;
|
||||
} else if((this.currentPage > this.limit) && (total > this.limit)) {
|
||||
total = this.currentPage;
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
onPrev(){
|
||||
this.currentPage=this.currentPage-1;
|
||||
|
|
Loading…
Reference in New Issue