Skip to content

Commit

Permalink
[FEAT] add pagination to url for browse by #593 (#604)
Browse files Browse the repository at this point in the history
  • Loading branch information
UcDust authored Sep 19, 2024
1 parent 7158005 commit 38119ff
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ export default class AppBrowseBy extends Mixin(LitElement)
}

this.id = e.location.path[2];
let page = e.location.path[3];
let resultsPerPage = e.location.path[4];

if( this.id ) {
this.currentPage = 1;
this.currentPage = parseInt(page) ? page : 1;
this.resultsPerPage = parseInt(resultsPerPage) ? resultsPerPage : 25;
this.BrowseByModel.browseExperts(this.id, this.currentPage, this.resultsPerPage);
}
}
Expand Down Expand Up @@ -114,7 +118,12 @@ export default class AppBrowseBy extends Mixin(LitElement)
*/
_onPaginationChange(e) {
this.currentPage = e.detail.page;
this.BrowseByModel.browseExperts(this.id, this.currentPage, this.resultsPerPage);

let path = '/browse/expert/' + this.id;
if( this.currentPage > 1 || this.resultsPerPage > 25 ) path += `/${this.currentPage}`;
if( this.resultsPerPage > 25 ) path += `/${this.resultsPerPage}`;
this.AppStateModel.setLocation(path);

window.scrollTo(0, 0);
}

Expand Down

0 comments on commit 38119ff

Please sign in to comment.