FilteredPage.ts 803 Bytes
Newer Older
Matija Obreza's avatar
Matija Obreza committed
1
import Page, { IPageRequest, SortDirection } from 'model/Page';
Matija Obreza's avatar
Subsets    
Matija Obreza committed
2
3
4
5
6

/*
* Defined in OpenAPI as '#/definitions/Page<T>'
*/
class FilteredPage<T> extends Page<T> {
Matija Obreza's avatar
Matija Obreza committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  public filterCode?: string;
  public filter?: any;

  public static reSort(paged: FilteredPage<any>, property?: string, direction?: SortDirection): FilteredPage<any> {
    const resorted: FilteredPage<any> =  {
      filterCode: paged ? paged.filterCode : undefined,
      number: undefined, // because loadMore defaults to 0
      size: undefined,
      sort: [ {
        property: property ? property : undefined,
        direction: direction ? direction : undefined,
      } ],
    };

    console.log(`reSort for prop=${property} dir=${direction}`, resorted);
    return resorted;
  }
Matija Obreza's avatar
Subsets    
Matija Obreza committed
24
25
26
}

export { FilteredPage as default, IPageRequest };