Skip to content

Commit

Permalink
Add a dropdown for selecting the page size on the workbench (#1002)
Browse files Browse the repository at this point in the history
  • Loading branch information
mensinda authored Mar 1, 2024
1 parent 5bde739 commit 466fce0
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
2 changes: 2 additions & 0 deletions webapp/src/main/resources/properties/de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ search.viewMode.REDUCED=Reduziert
search.viewMode.STANDARD=Standard
search.viewMode.COMPACT=Kompakt

search.unitsPerPage=Texte pro Seite: {pageSize}

# Label used in the header loggedInUser dropdown to show user's profile
header.loggedInUser.profile=Mein Profil

Expand Down
2 changes: 2 additions & 0 deletions webapp/src/main/resources/properties/en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ search.viewMode.REDUCED=Reduced
search.viewMode.STANDARD=Standard
search.viewMode.COMPACT=Compact

search.unitsPerPage=Page size: {pageSize}

# Label used in the header loggedInUser dropdown to show user's profile
header.loggedInUser.profile=My Profile

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ let SearchResults = createReactClass({
/** @type {Number} Indicates the current page number of the search results. */
"currentPageNumber": searchParamsStoreState.currentPageNumber,

/** @type {Number} The number of items on each page. */
"pageSize": searchParamsStoreState.pageSize,

/** @type {Number} The index of the currently active textunit. */
"activeTextUnitIndex": 0,

Expand Down Expand Up @@ -353,6 +356,7 @@ let SearchResults = createReactClass({
"searchHadNoResults": resultsStoreState.searchHadNoResults,
"noMoreResults": resultsStoreState.noMoreResults,
"currentPageNumber": paramsStoreState.currentPageNumber,
"pageSize": paramsStoreState.pageSize,
"mustShowToolbar": mustShowToolbar,
"activeTextUnitIndex": this.getActiveTextUnitIndex(),
"isErrorOccurred": resultsStoreState.isErrorOccurred,
Expand Down Expand Up @@ -565,6 +569,22 @@ let SearchResults = createReactClass({
let nextPageButtonDisabled = isSearching || noMoreResults;
let previousPageButtonDisabled = isSearching || isFirstPage;

let pageSizes = [];
for (let i of [10, 25, 50, 100]) {
pageSizes.push(
<MenuItem
key={i}
eventKey={i}
active={i == this.state.pageSize}
onSelect={(s, _) => WorkbenchActions.searchParamsChanged({changedParam: SearchConstants.PAGE_SIZE_CHANGED, pageSize: s})}
>
{i}
</MenuItem>
);
}

const title = <FormattedMessage values={{"pageSize": this.state.pageSize}} id="search.unitsPerPage" />;

if (this.state.mustShowToolbar) {
ui = (
<div>
Expand Down Expand Up @@ -598,6 +618,10 @@ let SearchResults = createReactClass({
</AltContainer>

<TextUnitSelectorCheckBox numberOfSelectedTextUnits={numberOfSelectedTextUnits} disabled={selectorCheckBoxDisabled}/>

<DropdownButton id="text-units-per-page" title={title}>
{pageSizes}
</DropdownButton>
<Button bsSize="small" disabled={previousPageButtonDisabled}
onClick={this.onFetchPreviousPageClicked}><span
className="glyphicon glyphicon-chevron-left"></span></Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ class SearchParamsStore {
this.decrementPageNumber();
break;

case SearchConstants.PAGE_SIZE_CHANGED:

this.changePageSize(paramData.pageSize);
break;

default:
console.error("SearchParamsStore::Unknown param type");
break;
Expand Down Expand Up @@ -367,6 +372,11 @@ class SearchParamsStore {
this.setCurrentPageNumber(this.currentPageNumber + 1);
}

changePageSize(pageSize) {
this.pageSize = pageSize;
this.setCurrentPageNumber(1);
}

setCurrentPageNumber(pageNumber) {
if (pageNumber >= 1) {
this.currentPageNumber = pageNumber;
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/main/resources/public/js/utils/SearchConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ let SearchConstants = keymirror({
"UPDATE_ALL_LOCATION_UPDATE": null,
"UPDATE_ALL_LOCATION_NONE": null,
"NEXT_PAGE_REQUESTED" : null,
"PREVIOUS_PAGE_REQUESTED" : null
"PREVIOUS_PAGE_REQUESTED" : null,
"PAGE_SIZE_CHANGED": null,
});

export default SearchConstants;

0 comments on commit 466fce0

Please sign in to comment.