All files / src/app/core/services custom-paginator-intl.ts

86.36% Statements 19/22
44.44% Branches 4/9
66.66% Functions 2/3
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 302x   2x   2x     2x 17x   17x 17x 17x   17x 17x     3x 2x     1x 1x     1x      
import { Injectable } from '@angular/core';
import { MatPaginatorIntl } from '@angular/material/paginator';
import { Subject } from 'rxjs';
 
import '@angular/localize/init';
 
@Injectable()
export class CustomPaginatorIntl implements MatPaginatorIntl {
  changes = new Subject<void>();
 
  firstPageLabel = $localize`:@@pagination.first_page_label:First page`;
  itemsPerPageLabel = $localize`:@@pagination.items_per_page_label:Items per page`;
  lastPageLabel = $localize`:@@pagination.last_page_label:Last page`;
  
  nextPageLabel = $localize`:@@pagination.next_page_label:Next page`;
  previousPageLabel = $localize`:@@pagination.previous_page_label:Previous page`;
 
  getRangeLabel(page: number, pageSize: number, length: number): string {
    if (length === 0 || pageSize === 0) {
      return $localize`:@@pagination_empty_items:No items found.`;
    }
 
    const startIndex = page * pageSize;
    const endIndex = startIndex < length
      ? Math.min(startIndex + pageSize, length)
      : startIndex + pageSize;
    return $localize`:@@pagination_range_label:Items ${startIndex + 1}-${endIndex} of ${length}`;
  }
}