@@ -8,6 +8,8 @@ import { UmbModalRouteRegistrationController } from '@umbraco-cms/backoffice/rou
88import { SearcherService } from '@umbraco-cms/backoffice/external/backend-api' ;
99import { UmbLitElement , umbFocus } from '@umbraco-cms/backoffice/lit-element' ;
1010import { tryExecute } from '@umbraco-cms/backoffice/resources' ;
11+ import { UmbPaginationManager } from '@umbraco-cms/backoffice/utils' ;
12+ import type { UUIPaginationEvent } from '@umbraco-cms/backoffice/external/uui' ;
1113
1214interface ExposedSearchResultField {
1315 name : string ;
@@ -34,6 +36,17 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
3436 @state ( )
3537 private _workspacePath = 'aa' ;
3638
39+ @state ( )
40+ _totalPages = 1 ;
41+
42+ @state ( )
43+ _currentPage = 1 ;
44+
45+ @state ( )
46+ _totalNumberOfResults = 0 ;
47+
48+ #paginationManager = new UmbPaginationManager ( ) ;
49+
3750 private _onKeyPress ( e : KeyboardEvent ) {
3851 if ( e . key == 'Enter' ) {
3952 this . _onSearch ( ) ;
@@ -44,6 +57,12 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
4457
4558 constructor ( ) {
4659 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+
4766 new UmbModalRouteRegistrationController ( this , UMB_WORKSPACE_MODAL )
4867 . addAdditionalPath ( ':entityType' )
4968 . onSetup ( ( routingInfo ) => {
@@ -64,13 +83,15 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
6483 path : { searcherName : this . searcherName } ,
6584 query : {
6685 term : this . _searchInput . value ,
67- take : 100 ,
68- skip : 0 ,
86+ take : this . #paginationManager . getPageSize ( ) ,
87+ skip : this . #paginationManager . getSkip ( ) ,
6988 } ,
7089 } ) ,
7190 ) ;
7291
7392 this . _searchResults = data ?. items ?? [ ] ;
93+ this . #paginationManager. setTotalItems ( data . total ) ;
94+ this . _totalNumberOfResults = data . total ;
7495 this . _updateFieldFilter ( ) ;
7596 this . _searchLoading = false ;
7697 }
@@ -158,13 +179,29 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
158179 }
159180 }
160181
182+ #onPageChange( event : UUIPaginationEvent ) {
183+ this . #paginationManager. setCurrentPageNumber ( event . target ?. current ) ;
184+ this . _onSearch ( ) ;
185+ }
186+
161187 private renderSearchResults ( ) {
162188 if ( this . _searchLoading ) return html `<uui- loader> </ uui- loader> ` ;
163189 if ( ! this . _searchResults ) return nothing ;
164190 if ( ! this . _searchResults . length ) {
165191 return html `<p> ${ this . localize . term ( 'examineManagement_noResults' ) } </ p> ` ;
166192 }
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" >
168205 <uui- scroll- container>
169206 <uui- table class= "search" >
170207 <uui- table-head>
@@ -212,7 +249,16 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement {
212249 </ uui- tag>
213250 </ uui- icon- regis try- essential>
214251 </ 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+ ` ;
216262 }
217263
218264 renderHeadCells ( ) {
0 commit comments