@@ -141,18 +141,18 @@ export class <%= componentName %> implements OnInit {
141141
142142 sortState = sortStateSignal({});
143143<% _ if (searchEngineAny) { _% >
144- currentSearch = ' ' ;
144+ currentSearch = signal ( ' ' ) ;
145145< % _ } _%>
146146<% _ if (jpaMetamodelFiltering && paginationPagination) { _% >
147147 filters: IFilterOptions = new FilterOptions ();
148148< % _ } _%>
149149
150150<% _ if (paginationPagination) { _% >
151- itemsPerPage = ITEMS_PER_PAGE ;
152- totalItems = 0 ;
153- page = 1 ;
151+ itemsPerPage = signal ( ITEMS_PER_PAGE ) ;
152+ totalItems = signal ( 0 ) ;
153+ page = signal ( 1 ) ;
154154< % _ } else if (paginationInfiniteScroll) { _% >
155- itemsPerPage = ITEMS_PER_PAGE ;
155+ itemsPerPage = signal ( ITEMS_PER_PAGE ) ;
156156 links: WritableSignal< Record< string, undefined | Record< string, string | undefined >>> = signal ({});
157157 hasMorePage = computed (() => !! this .links ().next );
158158 isFirstFetch = computed (() => Object .keys (this .links ()).length === 0 );
@@ -213,9 +213,9 @@ export class <%= componentName %> implements OnInit {
213213<% _ if (searchEngineAny) { _% >
214214 search (query: string): void {
215215 < % _ if (paginationPagination) { _% >
216- this .page = 1 ;
216+ this .page . set ( 1 ) ;
217217 < % _ } _% >
218- this .currentSearch = query;
218+ this .currentSearch . set ( query) ;
219219 < % _ if (notSortableFieldsAfterSearch) { _% >
220220 const { predicate } = this .sortState ();
221221 if (query && predicate && < %= componentName % > .NOT_SORTABLE_FIELDS_AFTER_SEARCH .includes (predicate)) {
@@ -263,27 +263,27 @@ export class <%= componentName %> implements OnInit {
263263 }
264264
265265 navigateToWithComponentValues(event: SortState): void {
266- this.handleNavigation(<% if (paginationPagination) { % > this .page , < % } %> event<% if (jpaMetamodelFiltering && paginationPagination) { % > , this .filters .filterOptions < % } %><% if (searchEngineAny) { % > , this .currentSearch < % } %> );
266+ this.handleNavigation(<% if (paginationPagination) { % > this .page () , < % } %> event<% if (jpaMetamodelFiltering && paginationPagination) { % > , this .filters .filterOptions < % } %><% if (searchEngineAny) { % > , this .currentSearch () < % } %> );
267267 }
268268
269269<% _ if (paginationPagination) { _% >
270270 navigateToPage (page: number): void {
271- this .handleNavigation (page, this .sortState ()< % if (jpaMetamodelFiltering && paginationPagination) { % > , this .filters .filterOptions < % } % >< % if (searchEngineAny) { % > , this .currentSearch < % } % > );
271+ this .handleNavigation (page, this .sortState ()< % if (jpaMetamodelFiltering && paginationPagination) { % > , this .filters .filterOptions < % } % >< % if (searchEngineAny) { % > , this .currentSearch () < % } % > );
272272 }
273273
274274< % _ } _%>
275275 protected fillComponentAttributeFromRoute(params: ParamMap, data: Data): void {
276276<% _ if (paginationPagination) { _% >
277277 const page = params .get (PAGE_HEADER );
278- this .page = + (page ?? 1 );
278+ this .page . set ( + (page ?? 1 ) );
279279< % _ } _% >
280280 this .sortState .set (this .sortService .parseSortParam (params .get (SORT ) ?? data[DEFAULT_SORT_DATA ]));
281281< % _ if (jpaMetamodelFiltering && paginationPagination) { _% >
282282 this .filters .initializeFromParams (params);
283283< % _ } _% >
284284< % _ if (searchEngineAny) { _% >
285285 if (params .has (' search' ) && params .get (' search' ) !== ' ' ) {
286- this .currentSearch = params .get (' search' ) as string;
286+ this .currentSearch . set ( params .get (' search' ) as string) ;
287287 < % _ if (notSortableFieldsAfterSearch) { _% >
288288 const { predicate } = this .sortState ();
289289 if (predicate && < %= componentName % > .NOT_SORTABLE_FIELDS_AFTER_SEARCH .includes (predicate)) {
@@ -338,7 +338,7 @@ export class <%= componentName %> implements OnInit {
338338< % _ if (! paginationNo) { _% >
339339 protected fillComponentAttributesFromResponseHeader (headers: HttpHeaders): void {
340340 < % _ if (paginationPagination) { _% >
341- this .totalItems = Number (headers .get (TOTAL_COUNT_RESPONSE_HEADER ));
341+ this .totalItems . set ( Number (headers .get (TOTAL_COUNT_RESPONSE_HEADER ) ));
342342 < % _ } else if (paginationInfiniteScroll) { _% >
343343 const linkHeader = headers .get (' link' );
344344 if (linkHeader) {
@@ -351,43 +351,29 @@ export class <%= componentName %> implements OnInit {
351351
352352< % _ } _% >
353353 protected queryBackend (): Observable< EntityArrayResponseType> {
354- < % _ if (paginationPagination || searchEngineAny) { _% >
355- const {
356- <%_ if (paginationPagination ) { _ %>
357- page,
358- < % _ } _% >
359- < % _ if (jpaMetamodelFiltering && paginationPagination) { _% >
360- filters,
361- < % _ } _% >
362- < % _ if (searchEngineAny) { _% >
363- currentSearch,
364- < % _ } _% >
365- } = this ;
366- < % _ } _% >
367-
368354 this .isLoading .set (true );
369355< % _ if (paginationPagination) { _% >
370- const pageToLoad: number = page;
356+ const pageToLoad: number = this . page () ;
371357< % _ } _% >
372358 const queryObject <% if ((jpaMetamodelFiltering && paginationPagination ) || searchEngine ) { %>: any <% } %> = {
373359< % _ if (paginationPagination) { _% >
374360 page: pageToLoad - 1 ,
375361< % _ } _% >
376362< % _ if (! paginationNo) { _% >
377- size: this .itemsPerPage ,
363+ size: this .itemsPerPage () ,
378364< % _ } _% >
379365< % _ if (implementsEagerLoadApis || containsBagRelationships) { _% >
380366 eagerload: true ,
381367< % _ } _% >
382368< % _ if (searchEngineAny) { _% >
383- query: currentSearch,
369+ query: this . currentSearch () ,
384370< % _ } _% >
385371< % _ if (! paginationInfiniteScroll) { _% >
386372 sort: this .sortService .buildSortParam (this .sortState ()),
387373< % _ } _% >
388374 };
389375< % _ if (jpaMetamodelFiltering && paginationPagination) { _% >
390- for (const filterOption of filters .filterOptions ) {
376+ for (const filterOption of this . filters .filterOptions ) {
391377 queryObject[filterOption .name ] = filterOption .values ;
392378 }
393379< % _ } _% >
@@ -400,7 +386,7 @@ export class <%= componentName %> implements OnInit {
400386
401387< % _ } _% >
402388< % _ if (searchEngineAny) { _% >
403- if (this .currentSearch && this .currentSearch !== ' ' ) {
389+ if (this .currentSearch () && this .currentSearch () !== ' ' ) {
404390 return this .< %= entityInstance % > Service .search (queryObject)
405391 .pipe (
406392 finalize (() => this .isLoading .set (false ))
@@ -427,7 +413,7 @@ export class <%= componentName %> implements OnInit {
427413< % _ } _% >
428414< % _ if (paginationPagination) { _% >
429415 page,
430- size: this .itemsPerPage ,
416+ size: this .itemsPerPage () ,
431417< % _ } _% >
432418 sort: this .sortService .buildSortParam (sortState),
433419 };
0 commit comments