Merge pull request #7054 from opf/feature/29467-Automatic-calculation-of-work–packages-per-pagination-based-on-widget-height
[29467] Automatic calculation of work packages per pagination based on widget height [ci skip]pull/7059/head
commit
87ae3e2ff8
@ -1,4 +1,33 @@ |
||||
import {AbstractWidgetComponent} from "app/modules/grids/widgets/abstract-widget.component"; |
||||
import {OnInit} from "@angular/core"; |
||||
|
||||
export class WidgetWpListComponent extends AbstractWidgetComponent { |
||||
export class WidgetWpListComponent extends AbstractWidgetComponent implements OnInit { |
||||
// An heuristic based on paddings, margins, the widget header height and the pagination height
|
||||
private static widgetSpaceOutsideTable:number = 230; |
||||
private static wpLineHeight:number = 40; |
||||
private static gridAreaHeight:number = 100; |
||||
private static gridAreaSpace:number = 20; |
||||
|
||||
public configuration:any = { |
||||
"actionsColumnEnabled": false, |
||||
"columnMenuEnabled": false, |
||||
"contextMenuEnabled": false |
||||
}; |
||||
|
||||
ngOnInit() { |
||||
this.configuration.forcePerPageOption = this.calculatePerPageOption(); |
||||
} |
||||
|
||||
private calculatePerPageOption() { |
||||
if (this.resource) { |
||||
let numberOfRows = this.resource.height; |
||||
let availableHeight = numberOfRows * WidgetWpListComponent.gridAreaHeight + |
||||
(numberOfRows - 1) * WidgetWpListComponent.gridAreaSpace; |
||||
let perPageOption = Math.floor((availableHeight - WidgetWpListComponent.widgetSpaceOutsideTable) / WidgetWpListComponent.wpLineHeight); |
||||
|
||||
return perPageOption < 1 ? 1 : perPageOption |
||||
} else { |
||||
return false |
||||
} |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue