@@ -8,6 +8,8 @@ import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/rou
8
8
import { SearcherService } from '@umbraco-cms/backoffice/external/backend-api' ;
9
9
import { UmbLitElement , umbFocus } from '@umbraco-cms/backoffice/lit-element' ;
10
10
import { tryExecute } from '@umbraco-cms/backoffice/resources' ;
11
+ import { UmbPaginationManager } from '@umbraco-cms/backoffice/utils' ;
12
+ import type { UUIPaginationEvent } from '@umbraco-cms/backoffice/external/uui' ;
11
13
12
14
interface ExposedSearchResultField {
13
15
name : string ;
@@ -34,6 +36,17 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
34
36
@state ( )
35
37
private _workspacePath = 'aa' ;
36
38
39
+ @state ( )
40
+ _totalPages = 1 ;
41
+
42
+ @state ( )
43
+ _currentPage = 1 ;
44
+
45
+ @state ( )
46
+ _totalNumberOfResults = 0 ;
47
+
48
+ #paginationManager = new UmbPaginationManager ( ) ;
49
+
37
50
private _onKeyPress ( e : KeyboardEvent ) {
38
51
if ( e . key == 'Enter' ) {
39
52
this . _onSearch ( ) ;
@@ -44,6 +57,12 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
44
57
45
58
constructor ( ) {
46
59
super ( ) ;
60
+
61
+ this . #paginationManager. setPageSize ( 100 ) ;
62
+
63
+ this . observe ( this . #paginationManager. currentPage , ( number ) => ( this . _currentPage = number ) ) ;
64
+ this . observe ( this . #paginationManager. totalPages , ( number ) => ( this . _totalPages = number ) ) ;
65
+
47
66
new UmbModalRouteRegistrationController ( this , UMB_WORKSPACE_MODAL )
48
67
. addAdditionalPath ( ':entityType' )
49
68
. onSetup ( ( routingInfo ) => {
@@ -64,13 +83,15 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
64
83
path : { searcherName : this . searcherName } ,
65
84
query : {
66
85
term : this . _searchInput . value ,
67
- take : 100 ,
68
- skip : 0 ,
86
+ take : this . #paginationManager . getPageSize ( ) ,
87
+ skip : this . #paginationManager . getSkip ( ) ,
69
88
} ,
70
89
} ) ,
71
90
) ;
72
91
73
92
this . _searchResults = data ?. items ?? [ ] ;
93
+ this . #paginationManager. setTotalItems ( data . total ) ;
94
+ this . _totalNumberOfResults = data . total ;
74
95
this . _updateFieldFilter ( ) ;
75
96
this . _searchLoading = false ;
76
97
}
@@ -158,13 +179,29 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
158
179
}
159
180
}
160
181
182
+ #onPageChange( event : UUIPaginationEvent ) {
183
+ this . #paginationManager. setCurrentPageNumber ( event . target ?. current ) ;
184
+ this . _onSearch ( ) ;
185
+ }
186
+
161
187
private renderSearchResults ( ) {
162
188
if ( this . _searchLoading ) return html `<uui- loader> </ uui- loader> ` ;
163
189
if ( ! this . _searchResults ) return nothing ;
164
190
if ( ! this . _searchResults . length ) {
165
191
return html `<p> ${ this . localize . term ( 'examineManagement_noResults' ) } </ p> ` ;
166
192
}
167
- return html `<div class= "table-container" >
193
+ return html `
194
+ <div>
195
+ ${ this . localize . term (
196
+ 'examineManagement_searchResultsFound' ,
197
+ this . #paginationManager. getDisplayStart ( ) ,
198
+ this . #paginationManager. getDisplayEnd ( ) ,
199
+ this . _totalNumberOfResults ,
200
+ this . _currentPage ,
201
+ this . _totalPages ,
202
+ ) }
203
+ </ div>
204
+ <div class= "table-container" >
168
205
<uui- scroll- container>
169
206
<uui- table class= "search" >
170
207
<uui- table-head>
@@ -212,7 +249,16 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
212
249
</ uui- tag>
213
250
</ uui- icon- regis try- essential>
214
251
</ butto n>
215
- </ div> ` ;
252
+ </ div>
253
+ <uui- pagination
254
+ .total = ${ this . _totalPages }
255
+ .current = ${ this . _currentPage }
256
+ firstlabel= ${ this . localize . term ( 'general_first' ) }
257
+ previouslabel= ${ this . localize . term ( 'general_previous' ) }
258
+ nextlabel= ${ this . localize . term ( 'general_next' ) }
259
+ lastlabel= ${ this . localize . term ( 'general_last' ) }
260
+ @change = ${ this . #onPageChange} > </ uui- pagination>
261
+ ` ;
216
262
}
217
263
218
264
renderHeadCells ( ) {
0 commit comments