Skip to content

Commit

Permalink
fix: DHIS2-10715 working lists default sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
JoakimSM committed Mar 17, 2021
1 parent 7f41dcb commit e8280c3
Showing 1 changed file with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import log from 'loglevel';
import i18n from '@dhis2/d2-i18n';
import { errorCreator } from 'capture-core-utils';
import { dataElementTypes } from '../../../../../../../metaData';
import { getTeiListData } from './getTeiListData';
import {
initListViewSuccess,
Expand All @@ -11,21 +10,6 @@ import {
} from '../../../../WorkingListsCommon';
import type { Input } from './initTeiWorkingListsView.types';

const getSortDirection = columnType =>
([dataElementTypes.TEXT, dataElementTypes.LONG_TEXT].includes(columnType) ? 'asc' : 'desc');

const getSortConfig = (columnsMetaForDataFetching) => {
let column = columnsMetaForDataFetching.find(col => col.visible);
if (!column) {
column = columnsMetaForDataFetching[0];
}

return {
sortById: column.id,
sortByDirection: getSortDirection(column.type),
};
};

const getClientFilters = (criteria = {}) => {
// Build logic later when we actually have some non static templates
const { programStatus } = criteria;
Expand All @@ -48,7 +32,8 @@ export const initTeiWorkingListsView = ({
querySingleResource,
absoluteApiPath,
}: Input) => {
const { sortById, sortByDirection } = getSortConfig([...columnsMetaForDataFetching.values()]);
const sortById = 'regDate';
const sortByDirection = 'desc';
const pageSize = 15;
const page = 1;
const filters = getClientFilters(selectedTemplate.criteria);
Expand Down

0 comments on commit e8280c3

Please sign in to comment.