Skip to content

Commit

Permalink
fix: paging error is now a devmode warning (#942)
Browse files Browse the repository at this point in the history
* made warnings depend on mode

* added precision
  • Loading branch information
MattL75 committed Jun 18, 2019
1 parent a9f1ea3 commit 41e01f1
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions library/src/lib/pagination/pagination.service.ts
@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core';
import { Injectable, isDevMode } from '@angular/core';
import { Pagination } from './pagination.model';

const DISPLAY_NUM_PAGES = 3;
Expand Down Expand Up @@ -83,13 +83,13 @@ export class PaginationService {
* @param pagination An object of type *Pagination*.
*/
public validate(pagination: Pagination) {
if (!pagination.totalItems) {
console.error(`No pages provided in the Pagination object; we cannot provide paging`);
if (!pagination.totalItems && isDevMode()) {
console.warn(`No pages provided in the Pagination object. This warning only appears in development mode.`);
}
if (!pagination.itemsPerPage) {
pagination.itemsPerPage = this.DEFAULT_ITEMS_PER_PAGE;
} else if (pagination.itemsPerPage < 0) {
console.error(`itemsPerPage must be greater than zero`);
} else if (pagination.itemsPerPage < 0 && isDevMode()) {
console.warn(`itemsPerPage must be greater than zero. This warning only appears in development mode.`);
}
if (!pagination.currentPage) {
pagination.currentPage = 1;
Expand Down

0 comments on commit 41e01f1

Please sign in to comment.