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

feat: set the same order for all analyses - alphabetically by analysi… #448

Merged
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,8 @@ const DisplayAnalyses: React.FC<{
}> = (props) => {
const [selectedAnalysisIndex, setSelectedAnalysisIndex] = useState(0);

console.log(props.analyses);

const handleSelectAnalysis = (index: number) => {
setSelectedAnalysisIndex(index);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,6 @@ const DisplayAnalysesList: React.FC<{
selected={props.selectedIndex === index}
onSelectAnalysis={(id, i) => props.onSelectAnalysisIndex(i)}
/>
// <ListItem key={analysis.id || index} disablePadding divider>
// <ListItemButton
// onClick={() => props.onSelectAnalysisIndex(index)}
// selected={props.selectedIndex === index}
// >
// <ListItemText
// sx={{ wordBreak: 'break-all' }}
// primary={analysis.name || ''}
// secondary={analysis.description || ''}
// />
// {(analysis.points?.length || 0) === 0 && (
// <Tooltip title="There is a potential issue" placement="top">
// <ListItemIcon>
// <ErrorOutlineIcon color="warning" />
// </ListItemIcon>
// </Tooltip>
// )}
// </ListItemButton>
// </ListItem>
))}
</List>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ const EditStudyAnnotations: React.FC = (props) => {
allowAddColumn={false}
allowRemoveColumns={false}
onChange={handleChange}
size="9rem"
size="9.5rem"
/>
</Box>
<LoadingButton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import HotTable, { HotTableProps } from '@handsontable/react';
import { Box } from '@mui/material';
import { EPropertyType, IMetadataRowModel, getType } from 'components/EditMetadata';
import AddMetadataRow from 'components/EditMetadata/EditMetadataRow/AddMetadataRow';
import styles from 'components/EditAnnotations/AnnotationsHotTable/AnnotationsHotTable.module.css';
import { EPropertyType } from 'components/EditMetadata';
import { CellCoords } from 'handsontable';
import { CellChange, CellValue, ChangeSource } from 'handsontable/common';
import { registerAllModules } from 'handsontable/registry';
import { ColumnSettings } from 'handsontable/settings';
import { useCallback, useEffect, useRef, useState } from 'react';
import styles from 'components/EditAnnotations/AnnotationsHotTable/AnnotationsHotTable.module.css';
import { Cancel } from '@mui/icons-material';
import { DetailedSettings as MergeCellsSettings } from 'handsontable/plugins/mergeCells';
import { AnnotationNoteValue, NoteKeyType } from '../helpers/utils';
import { numericValidator } from 'handsontable/validators';
import { renderToString } from 'react-dom/server';
import { CellCoords } from 'handsontable';
import React from 'react';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { AnnotationNoteValue, NoteKeyType } from '../helpers/utils';

const booleanValidator = (value: CellValue, callback: (isValid: boolean) => void) => {
const isValid =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ export const annotationNotesToHotData = (
.sort((a, b) => {
const firstStudyId = a.study as string;
const secondStudyId = b.study as string;

if (a.study === b.study) {
return (a.analysis_name || '').localeCompare(b.analysis_name || '');
}

return firstStudyId.localeCompare(secondStudyId);
})
.forEach((annotationNote, index) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ const useCreateStudyset = () => {
queryClient.invalidateQueries('studysets');
enqueueSnackbar('Created new studyset successfully', { variant: 'success' });
},
onError: () => {
enqueueSnackbar('There was an error creating the studyset', { variant: 'error' });
},
}
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ const useGetStudyById = (studyId: string) => {
const analyses = res.data.analyses as AnalysisReturn[];

const sortedAnalyses = (analyses || []).sort((a, b) => {
const dateA = Date.parse(a.created_at || '');
const dateB = Date.parse(b.created_at || '');
if (isNaN(dateA) || isNaN(dateB)) return 0;

return dateB - dateA;
return (a.name || '').localeCompare(b.name || '');
// this sorts by creation date: we may want this later
// const dateA = Date.parse(a.created_at || '');
// const dateB = Date.parse(b.created_at || '');
// if (isNaN(dateA) || isNaN(dateB)) return 0;
// return dateB - dateA;
});

res.data.analyses = sortedAnalyses;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import ProjectPage from 'pages/Projects/ProjectPage/ProjectPage';
import ExtractionPage from 'pages/ExtractionPage/ExtractionPage';
import CurationImportPage from 'pages/CurationPage/CurationImportPage';
import AnnotationsPage from 'pages/Annotations/AnnotationsPage/AnnotationsPage';
import StudyAnnotationsPage from 'pages/Annotations/StudyAnnotationsPage/StudyAnnotationsPage';
import ProjectStudyPage from 'pages/Studies/ProjectStudyPage/ProjectStudyPage';

const StudysetPage = React.lazy(() => import('../Studysets/StudysetPage/StudysetPage'));
Expand Down Expand Up @@ -75,11 +74,6 @@ const BaseNavigation: React.FC = (_props) => {
<AnnotationsPage />
</Box>
</Route>
<Route path="/projects/:projectId/extraction/studies/:studyId/annotations" exact>
<Box sx={BaseNavigationStyles.pagesContainer}>
<StudyAnnotationsPage />
</Box>
</Route>
<Route
path={[
'/projects/:projectId/extraction/studies/:studyId/edit',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ export const studyAnalysesToStoreAnalyses = (analyses?: AnalysisReturn[]): IStor
});

return (studyAnalyses || []).sort((a, b) => {
const dateA = Date.parse(a.created_at || '');
const dateB = Date.parse(b.created_at || '');
if (isNaN(dateA) || isNaN(dateB)) return 0;
return (a.name || '').localeCompare(b.name || '');

return dateB - dateA;
// previously sorted by date: may want this again in the future
// const dateA = Date.parse(a.created_at || '');
// const dateB = Date.parse(b.created_at || '');
// if (isNaN(dateA) || isNaN(dateB)) return 0;
// return dateB - dateA;
});
};

Expand Down
Loading