Skip to content

Commit bb96834

Browse files
committed
sort cancer types alphabetically
1 parent 2af6f16 commit bb96834

File tree

12 files changed

+51
-28
lines changed

12 files changed

+51
-28
lines changed

src/main/webapp/app/components/tabs/CurationHistoryTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const CurationHistoryTab = observer(({ historyData, getUsers, users, historyTabS
7373

7474
useEffect(() => {
7575
async function fetchAllDrugs() {
76-
const drugs = await getDrugs({ page: 0, size: GET_ALL_DRUGS_PAGE_SIZE, sort: 'id,asc' });
76+
const drugs = await getDrugs({ page: 0, size: GET_ALL_DRUGS_PAGE_SIZE, sort: ['id,asc'] });
7777
setDrugList(drugs['data']);
7878
}
7979

src/main/webapp/app/components/tabs/ReviewHistoryTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function ReviewHistoryTab({ firebaseDb, drugList, getDrugs }: StoreProps) {
2424
}, []);
2525

2626
useEffect(() => {
27-
getDrugs({ page: 0, size: GET_ALL_DRUGS_PAGE_SIZE, sort: 'id,asc' });
27+
getDrugs({ page: 0, size: GET_ALL_DRUGS_PAGE_SIZE, sort: ['id,asc'] });
2828
}, []);
2929

3030
function handleDownload() {

src/main/webapp/app/pages/curation/CurationPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const CurationPage = (props: ICurationPageProps) => {
5656

5757
useEffect(() => {
5858
props.searchGeneEntities({ query: hugoSymbolParam, exact: true });
59-
props.getDrugs({ page: 0, size: GET_ALL_DRUGS_PAGE_SIZE, sort: 'id,asc' });
59+
props.getDrugs({ page: 0, size: GET_ALL_DRUGS_PAGE_SIZE, sort: ['id,asc'] });
6060
return () => {
6161
props.setOpenMutationCollapsibleIndex(null);
6262
};

src/main/webapp/app/pages/curation/list/TherapiesList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const TherapiesList = ({
6060
treatmentIndex,
6161
treatment,
6262
};
63-
})
63+
}),
6464
);
6565
}, []);
6666

@@ -113,7 +113,7 @@ const TherapiesList = ({
113113
onConfirm={async (newTreatment, newDrugs) => {
114114
try {
115115
await Promise.all(newDrugs.map(drug => createDrug(drug)));
116-
await getDrugs({ page: 0, size: GET_ALL_DRUGS_PAGE_SIZE, sort: 'id,asc' });
116+
await getDrugs({ page: 0, size: GET_ALL_DRUGS_PAGE_SIZE, sort: ['id,asc'] });
117117
await addTreatment(`${tisPath}/${tisLength - 1}/treatments`, newTreatment);
118118
} catch (error) {
119119
notifyError(error);

src/main/webapp/app/shared/select/CancerTypeSelect.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,14 @@ const CancerTypeSelect: React.FunctionComponent<ICancerTypeSelectProps> = props
7272
let result = undefined;
7373
let options = [];
7474
if (searchWord) {
75-
result = await props.searchCancerTypes({ query: searchWord, page: page - 1, size: ITEMS_PER_PAGE, sort: DEFAULT_SORT_PARAMETER });
75+
result = await props.searchCancerTypes({
76+
query: searchWord,
77+
page: page - 1,
78+
size: ITEMS_PER_PAGE,
79+
sort: ['subtype,ASC', 'mainType,ASC'],
80+
});
7681
} else {
77-
result = await props.getCancerTypes({ page: page - 1, size: ITEMS_PER_PAGE, sort: 'id,ASC' });
82+
result = await props.getCancerTypes({ page: page - 1, size: ITEMS_PER_PAGE, sort: ['subtype,ASC', 'mainType,ASC'] });
7883
}
7984

8085
options = getAllCancerTypesOptions(result.data);

src/main/webapp/app/shared/select/DrugSelect.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const DrugSelect: React.FunctionComponent<IDrugSelectProps> = props => {
4949
}
5050

5151
async function fetchAllDrugs() {
52-
const drugs: IDrug[] = (await getDrugs({ page: 0, size: GET_ALL_DRUGS_PAGE_SIZE, sort: sortParameter }))?.['data'];
52+
const drugs: IDrug[] = (await getDrugs({ page: 0, size: GET_ALL_DRUGS_PAGE_SIZE, sort: [sortParameter] }))?.['data'];
5353
setDrugOptions(getDrugSelectOptionsFromDrugs(drugs));
5454
}
5555

src/main/webapp/app/shared/select/GeneSelect.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ const GeneSelect = (props: IGeneSelectProps) => {
3030
let result = undefined;
3131
let options: GeneSelectOption[] = [];
3232
if (searchWord) {
33-
result = await searchGenes({ query: searchWord, page: page - 1, size: ITEMS_PER_PAGE, sort: sortParamter });
33+
result = await searchGenes({ query: searchWord, page: page - 1, size: ITEMS_PER_PAGE, sort: [sortParamter] });
3434
} else {
35-
result = await getGenes({ page: page - 1, size: ITEMS_PER_PAGE, sort: sortParamter });
35+
result = await getGenes({ page: page - 1, size: ITEMS_PER_PAGE, sort: [sortParamter] });
3636
}
3737

3838
options = result?.data?.map((entity: IGene) => ({

src/main/webapp/app/shared/table/OncoKBAsyncTable.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import ReactTable, { TableProps } from 'react-table';
33
import { Col, Input, Row } from 'reactstrap';
44
import { ASC, DESC, ITEMS_PER_PAGE } from 'app/shared/util/pagination.constants';
55
import { debouncedSearchWithPagination } from '../util/pagination-crud-store';
6+
import { IQueryParams, ISearchParams } from '../util/jhipster-types';
67

78
/* eslint-disable @typescript-eslint/ban-types */
89
export interface IOncoKBAsyncTableProps<T> extends Partial<TableProps<T>> {
910
initialPaginationState: PaginationState<T>;
10-
searchEntities: ({ query, page, size, sort }) => void;
11-
getEntities: ({ page, size, sort }) => void;
11+
searchEntities: ({ query, page, size, sort }: ISearchParams) => void;
12+
getEntities: ({ page, size, sort }: IQueryParams) => void;
1213
totalItems: number;
1314
loading?: boolean;
1415
fixedHeight?: boolean;
@@ -28,17 +29,19 @@ export const OncoKBAsyncTable = <T extends object>(props: IOncoKBAsyncTableProps
2829
useEffect(() => {
2930
if (searchKeyword) {
3031
debouncedSearchWithPagination(
31-
searchKeyword,
32-
paginationState.activePage - 1,
33-
props.pageSize,
34-
`${paginationState.sort as string},${paginationState.order}`,
35-
props.searchEntities
32+
{
33+
query: searchKeyword,
34+
page: paginationState.activePage - 1,
35+
size: props.pageSize,
36+
sort: [`${paginationState.sort as string},${paginationState.order}`],
37+
},
38+
props.searchEntities,
3639
);
3740
} else {
3841
props.getEntities({
3942
page: paginationState.activePage - 1,
4043
size: pageSize,
41-
sort: `${paginationState.sort as string},${paginationState.order}`,
44+
sort: [`${paginationState.sort as string},${paginationState.order}`],
4245
});
4346
}
4447
}, [paginationState.activePage, paginationState.order, paginationState.sort, pageSize, searchKeyword]);

src/main/webapp/app/shared/util/infinite-scroll-crud-store.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ import { IRootStore } from 'app/stores';
33
import BaseCrudStore from './base-crud-store';
44
import { action, observable, makeObservable } from 'mobx';
55
import { loadMoreDataWhenScrolled, parseHeaderForLinks } from 'react-jhipster';
6+
import { parseSort } from './utils';
67

78
export class InfiniteScrollCrudStore<T> extends BaseCrudStore<T> {
89
public links: { [key: string]: number } = { last: 0 };
910

10-
constructor(protected rootStore: IRootStore, protected apiUrl: string, protected settings = { clearOnUnobserved: false }) {
11+
constructor(
12+
protected rootStore: IRootStore,
13+
protected apiUrl: string,
14+
protected settings = { clearOnUnobserved: false },
15+
) {
1116
super(rootStore, apiUrl, settings);
1217

1318
makeObservable(this, {
@@ -26,7 +31,7 @@ export class InfiniteScrollCrudStore<T> extends BaseCrudStore<T> {
2631
}
2732

2833
*getAll({ page, size, sort }) {
29-
this.lastUrl = `${this.apiUrl}${sort ? `?page=${page}&size=${size}&sort=${sort}` : ''}`;
34+
this.lastUrl = `${this.apiUrl}${sort ? `?page=${page}&size=${size}${parseSort(sort)}` : ''}`;
3035
return yield* this.getAllFromLastUrl();
3136
}
3237

src/main/webapp/app/shared/util/jhipster-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface IQueryParams {
99
query?: string;
1010
page?: number;
1111
size?: number;
12-
sort?: string;
12+
sort?: string[];
1313
}
1414

1515
export interface ISearchParams extends IQueryParams {

0 commit comments

Comments
 (0)