Label.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. export default class Label {
  2. constructor(actualPage, totalPages, recordsCount, totalRecords) {
  3. this.actualPage = actualPage;
  4. this.totalPages = totalPages;
  5. this.recordsCount = recordsCount;
  6. this.totalRecords = totalRecords;
  7. }
  8. render(){
  9. this.paginationLabel = document.createElement('div');
  10. this.paginationLabel.classList.add('col-12');
  11. this.pageLabel = document.createElement('span');
  12. this.pageLabel.innerText = `Page: ${this.actualPage} of ${this.totalPages} | `;
  13. this.recordLabel = document.createElement('span');
  14. this.recordLabel.innerText = `${this.recordsCount} of ${this.totalRecords} records shown`;
  15. this.paginationLabel.appendChild(this.pageLabel);
  16. this.paginationLabel.appendChild(this.recordLabel);
  17. return this.paginationLabel;
  18. }
  19. rerender() {
  20. this.pageLabel.innerText = `Page: ${this.actualPage} of ${this.totalPages} | `;
  21. this.recordLabel.innerText = `${this.recordsCount} of ${this.totalRecords} records shown`;
  22. }
  23. updateLabel(page, perPage, totalPages){
  24. this.actualPage = page;
  25. this.perPage = perPage;
  26. this.rerender();
  27. }
  28. }