Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX-2503 Sort log curves in table by active #2504

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from "@tanstack/react-table";
import {
activeId,
booleanSortingFn,
calculateColumnWidth,
componentSortingFn,
expanderId,
Expand All @@ -35,6 +36,7 @@ declare module "@tanstack/react-table" {
interface SortingFns {
[measureSortingFn]: SortingFn<unknown>;
[componentSortingFn]: SortingFn<unknown>;
[booleanSortingFn]: SortingFn<unknown>;
}
}

Expand Down Expand Up @@ -65,7 +67,7 @@ export const useColumnDef = (
header: column.label,
size: width,
meta: { type: column.type },
sortingFn: getSortingFn(column.type),
sortingFn: getSortingFn(column),
enableColumnFilter: column.type !== ContentType.Component,
filterFn: getFilterFn(column),
...addComponentCell(column.type),
Expand Down Expand Up @@ -235,11 +237,13 @@ const getCheckableRowsColumnDef = (
};
};

const getSortingFn = (contentType: ContentType) => {
if (contentType == ContentType.Measure) {
const getSortingFn = (column: ContentTableColumn) => {
if (column.type == ContentType.Measure) {
return measureSortingFn;
} else if (contentType == ContentType.Number) {
} else if (column.type == ContentType.Number) {
return "alphanumeric";
} else if (column.label === activeId) {
return booleanSortingFn;
}
return "text";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
TableContainer
} from "components/ContentViews/table/contentTableStyles";
import {
booleanSortingFn,
calculateHorizontalSpace,
calculateRowHeight,
componentSortingFn,
Expand Down Expand Up @@ -133,6 +134,15 @@ export const ContentTable = React.memo(
const a = rowA.getValue(columnId) == null;
const b = rowB.getValue(columnId) == null;
return a === b ? 0 : a ? -1 : 1;
},
[booleanSortingFn]: (
rowA: Row<any>,
rowB: Row<any>,
columnId: string
) => {
const a = rowA.getValue(columnId);
const b = rowB.getValue(columnId);
return a === b ? 0 : a ? 1 : -1;
}
},
columnResizeMode: "onChange",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const expanderId = "expander";
export const activeId = "active"; //implemented specifically for LogCurveInfoListView, needs rework if other views will also use filtering
export const measureSortingFn = "measure";
export const componentSortingFn = "component";
export const booleanSortingFn = "boolean";

export const constantTableOptions = {
enableColumnResizing: true,
Expand Down