Skip to content

Commit

Permalink
ISSUE #5198 - fix: cannot sort drawings by calibration status
Browse files Browse the repository at this point in the history
  • Loading branch information
Amantini1997 committed Oct 21, 2024
1 parent e87ec9d commit e8903e9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frontend/src/v5/store/drawings/drawings.helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const DRAWING_LIST_COLUMN_WIDTHS = {
width: 155,
hideWhenSmallerThan: Display.Desktop,
},
calibration: {
calibrationStatus: {
width: 155,
hideWhenSmallerThan: Display.Tablet,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// Positive infinity ensures null values are shown at the top
export const dateToNum = (date) => (date ? (date).getTime() : Number.POSITIVE_INFINITY);

import { CALIBRATION_SORT_ORDER } from '@/v5/ui/routes/dashboard/projects/calibration/calibration.helpers';
import { SortingDirection } from '@components/dashboard/dashboardList/dashboardList.types';
import { get, isArray } from 'lodash';

Expand All @@ -37,6 +38,10 @@ export const getSortingFunction = <T>(sortConfig) => {
return +aValue - +bValue;
}

if (aValue in CALIBRATION_SORT_ORDER && bValue in CALIBRATION_SORT_ORDER) {
return CALIBRATION_SORT_ORDER[aValue] - CALIBRATION_SORT_ORDER[bValue];
}

if (typeof aValue === 'string') {
return aValue.localeCompare(bValue);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
import { Matrix3, Vector2 } from 'three';
import { Coord2D, Coord3D, Vector1D, Vector2D, Vector3D } from './calibration.types';
import { isNumber } from 'lodash';
import { CalibrationStatus } from '@/v5/store/drawings/drawings.types';

export const CALIBRATION_SORT_ORDER = {
[CalibrationStatus.EMPTY]: 0,
[CalibrationStatus.UNCALIBRATED]: 1,
[CalibrationStatus.UNCONFIRMED]: 2,
[CalibrationStatus.CALIBRATED]: 3,
};

export const DEFAULT_SETTINGS_CALIBRATION = {
units: 'm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const DrawingsList = ({
<DashboardListHeaderLabel name="revisionsCount" {...DRAWING_LIST_COLUMN_WIDTHS.revisionsCount}>
<FormattedMessage id="drawings.list.header.revisions" defaultMessage="Revisions" />
</DashboardListHeaderLabel>
<DashboardListHeaderLabel name="calibration" {...DRAWING_LIST_COLUMN_WIDTHS.calibration}>
<DashboardListHeaderLabel name="calibrationStatus" {...DRAWING_LIST_COLUMN_WIDTHS.calibrationStatus}>
<FormattedMessage id="drawings.list.header.calibration" defaultMessage="2D/3D Calibration" />
</DashboardListHeaderLabel>
<DashboardListHeaderLabel name="number" {...DRAWING_LIST_COLUMN_WIDTHS.number}>
Expand Down

0 comments on commit e8903e9

Please sign in to comment.