File tree Expand file tree Collapse file tree 7 files changed +32
-43
lines changed Expand file tree Collapse file tree 7 files changed +32
-43
lines changed Original file line number Diff line number Diff line change @@ -6,9 +6,9 @@ describe('buildPagination()', () => {
6
6
query : { } ,
7
7
} ;
8
8
expect ( buildPagination ( mockRequest ) ) . toEqual ( {
9
- limit : 10 ,
10
- offset : 0 ,
11
- order : 'ASC' ,
9
+ limit : undefined ,
10
+ offset : undefined ,
11
+ order : undefined ,
12
12
sortField : undefined ,
13
13
} ) ;
14
14
} ) ;
@@ -19,9 +19,9 @@ describe('buildPagination()', () => {
19
19
} ,
20
20
} ;
21
21
expect ( buildPagination ( mockRequest ) ) . toEqual ( {
22
- limit : 10 ,
23
- offset : 0 ,
24
- order : 'ASC' ,
22
+ limit : undefined ,
23
+ offset : undefined ,
24
+ order : undefined ,
25
25
sortField : 'lastUpdated' ,
26
26
} ) ;
27
27
} ) ;
@@ -49,9 +49,9 @@ describe('buildPagination()', () => {
49
49
} ,
50
50
} ;
51
51
expect ( buildPagination ( mockRequest ) ) . toEqual ( {
52
- limit : 10 ,
53
- offset : 0 ,
54
- order : 'ASC' ,
52
+ limit : undefined ,
53
+ offset : undefined ,
54
+ order : undefined ,
55
55
sortField : undefined ,
56
56
} ) ;
57
57
} ) ;
Original file line number Diff line number Diff line change @@ -119,8 +119,8 @@ describe('getWorkflowOverview', () => {
119
119
mapToWorkflowOverviewDTO ( item ) ,
120
120
) ,
121
121
paginationInfo : {
122
- page : 0 ,
123
- pageSize : 10 ,
122
+ page : undefined ,
123
+ pageSize : undefined ,
124
124
totalCount : mockOverviewsV1 . items . length ,
125
125
} ,
126
126
} ) ;
Original file line number Diff line number Diff line change 1
1
export const WORKFLOW_DATA_KEY = 'workflowdata' ;
2
2
3
3
export const INTERNAL_SERVER_ERROR_MESSAGE = 'internal server error' ;
4
- export const DEFAULT_PAGE_NUMBER = 0 ;
5
- export const DEFAULT_PAGE_SIZE = 10 ;
6
- export const DEFAULT_SORT_FIELD = undefined ;
7
- export const DEFAULT_SORT_ORDER = 'ASC' ;
8
4
export const FETCH_PROCESS_INSTANCES_SORT_FIELD = 'start' ;
Original file line number Diff line number Diff line change 1
1
import { Request } from 'express-serve-static-core' ;
2
2
3
- import {
4
- DEFAULT_PAGE_NUMBER ,
5
- DEFAULT_PAGE_SIZE ,
6
- DEFAULT_SORT_FIELD ,
7
- DEFAULT_SORT_ORDER ,
8
- } from '../service/constants' ;
9
-
10
3
export interface Pagination {
11
4
offset ?: number ;
12
5
limit ?: number ;
@@ -15,18 +8,23 @@ export interface Pagination {
15
8
}
16
9
17
10
export function buildPagination ( req : Request ) : Pagination {
18
- return {
19
- offset : isNaN ( req . query . page as any )
20
- ? DEFAULT_PAGE_NUMBER
21
- : Number ( req . query . page ) ,
22
- limit : isNaN ( req . query . pageSize as any )
23
- ? DEFAULT_PAGE_SIZE
24
- : Number ( req . query . pageSize ) ,
25
- sortField : req . query . orderBy
26
- ? String ( req . query . orderBy )
27
- : DEFAULT_SORT_FIELD ,
28
- order : req . query . orderDirection
29
- ? String ( req . query . orderDirection )
30
- : DEFAULT_SORT_ORDER ,
31
- } ;
11
+ const pagination : Pagination = { } ;
12
+
13
+ if ( ! isNaN ( Number ( req . query . page ) ) ) {
14
+ pagination . offset = Number ( req . query . page ) ;
15
+ }
16
+
17
+ if ( ! isNaN ( Number ( req . query . pageSize ) ) ) {
18
+ pagination . limit = Number ( req . query . pageSize ) ;
19
+ }
20
+
21
+ if ( req . query . orderBy ) {
22
+ pagination . sortField = String ( req . query . orderBy ) ;
23
+ }
24
+
25
+ if ( req . query . orderDirection ) {
26
+ pagination . order = String ( req . query . orderDirection ) ;
27
+ }
28
+
29
+ return pagination ;
32
30
}
Original file line number Diff line number Diff line change 1
- a6f1ec3718385945b49150694189881ac506b364
1
+ af8bd8d631e1bde0b2776e64aae8adbc2bc332ce
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -330,21 +330,16 @@ components:
330
330
properties :
331
331
pageSize :
332
332
type : number
333
- minimum : 10
334
333
page :
335
334
type : number
336
- default : 0
337
335
totalCount :
338
336
type : number
339
- minimum : 0
340
337
orderDirection :
341
338
enum :
342
339
- ASC
343
340
- DESC
344
- default : ASC
345
341
orderBy :
346
342
type : string
347
- minimum : 0
348
343
additionalProperties : false
349
344
WorkflowFormatDTO :
350
345
type : string
You can’t perform that action at this time.
0 commit comments