Commit da745acc authored by Matija Obreza's avatar Matija Obreza Committed by Oleksii Savran

Crop: Added sorting of traits

parent 622026d5
......@@ -9,7 +9,7 @@ import navigateTo from '@gringlobal/client/action/navigation';
import ApiCall from '@gringlobal/client/model/common/ApiCall';
import CropDetails from '@gringlobal/client/model/gringlobal/CropDetails';
import { UserRole } from '@gringlobal/client/model/gringlobal/SysUser';
import { FilteredPage } from '@gringlobal/client/model/page';
import { FilteredPage, SortDirection } from '@gringlobal/client/model/page';
import TaxonomySpecies from '@gringlobal/client/model/gringlobal/TaxonomySpecies';
// Ui
import { Button, Card, CardActions, CardContent, CardHeader } from '@material-ui/core';
......@@ -142,6 +142,11 @@ class CropDetailsPage extends React.Component<ICropDetailsPage> {
loadMoreCropTraitsAction(traitsCall.data);
};
private onCropTraitsSortChange = (sortBy: string, dir: SortDirection) => {
const { traitsCall, loadMoreCropTraitsAction } = this.props;
loadMoreCropTraitsAction(FilteredPage.sort(traitsCall.data, sortBy, dir));
};
public render() {
const { cropCall, t, speciesCall, traitsCall } = this.props;
const { selectedTab } = this.state;
......@@ -236,6 +241,8 @@ class CropDetailsPage extends React.Component<ICropDetailsPage> {
tableConfig={ CropTraitTableConfig }
total={ traitsCall && traitsCall.data && traitsCall.data.content && traitsCall.data.totalElements }
loadMore={ this.loadMoreCropTraits }
sort={ traitsCall && traitsCall.data && traitsCall.data.sort }
onSortChange={ this.onCropTraitsSortChange }
/>
</SlotLayout>
<Authorize roles={ [ UserRole.ADMINISTRATOR ] }>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment