Skip to content
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,7 +9,6 @@ export const noteKeyObjToArr = (noteKeys?: object | null): NoteKeyType[] => {
.map(([key, descriptor]) => {
if (!descriptor?.type) throw new Error('Invalid note_keys descriptor: missing type');
return {
// rely on new descriptor shape (type + order)
type: descriptor.type,
key,
order: descriptor.order ?? 0,
Expand All @@ -23,25 +22,23 @@ export const noteKeyObjToArr = (noteKeys?: object | null): NoteKeyType[] => {
export const noteKeyArrToObj = (
noteKeyArr: NoteKeyType[]
): { [key: string]: { type: EPropertyType; order: number } } => {
const noteKeyObj = noteKeyArr.reduce((acc, curr, index) => {
acc[curr.key] = {
type: curr.type,
order: curr.order ?? index,
};
return acc;
}, {} as { [key: string]: { type: EPropertyType; order: number } });
const noteKeyObj = noteKeyArr.reduce(
(acc, curr, index) => {
acc[curr.key] = {
type: curr.type,
order: curr.order ?? index,
};
return acc;
},
{} as { [key: string]: { type: EPropertyType; order: number } }
);

return noteKeyObj;
};

export const booleanValidator = (value: CellValue, callback: (isValid: boolean) => void) => {
const isValid =
value === true ||
value === false ||
value === 'true' ||
value === 'false' ||
value === null ||
value === '';
value === true || value === false || value === 'true' || value === 'false' || value === null || value === '';
callback(isValid);
};

Expand All @@ -54,7 +51,7 @@ export const replaceString = (val: string) => {
export const stripTags = (stringWhichMayHaveHTML: any) => {
if (typeof stringWhichMayHaveHTML !== 'string') return '';

let doc = new DOMParser().parseFromString(stringWhichMayHaveHTML, 'text/html');
const doc = new DOMParser().parseFromString(stringWhichMayHaveHTML, 'text/html');
return doc.body.textContent || '';
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,10 @@ const AnnotationsHotTable: React.FC<{ annotationId?: string }> = React.memo((pro
if (noteKeys.find((x) => x.key === trimmedKey)) return false;

setAnnotationsHotState((prev) => {
const updatedNoteKeys = [{ key: trimmedKey, type: getType(row.metadataValue), order: 0 }, ...prev.noteKeys].map(
(noteKey, index) => ({ ...noteKey, order: index })
);
const updatedNoteKeys = [
{ key: trimmedKey, type: getType(row.metadataValue), order: 0 },
...prev.noteKeys,
].map((noteKey, index) => ({ ...noteKey, order: index }));

return {
...prev,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ import {
IAlgorithmSelection,
IAnalysesSelection,
} from 'pages/MetaAnalysis/components/CreateMetaAnalysisSpecificationDialogBase.types';
import {
isMultiGroupAlgorithm,
selectedReferenceDatasetIsDefaultDataset,
} from './SelectAnalysesComponent.helpers';
import { isMultiGroupAlgorithm, selectedReferenceDatasetIsDefaultDataset } from './SelectAnalysesComponent.helpers';
import { DEFAULT_REFERENCE_DATASETS } from './SelectAnalysesComponent.types';
import SelectAnalysesComponentTable from './SelectAnalysesComponentTable';
import SelectAnalysesStringValue from './SelectAnalysesStringValue';
Expand Down Expand Up @@ -50,13 +47,7 @@ const SelectAnalysesComponent: React.FC<{
onSelectValue(initialVal);
selectionOccurred.current = true;
}
}, [
selectedValue.selectionKey,
annotation,
onSelectValue,
selectionOccurred,
algorithm?.estimator,
]);
}, [selectedValue.selectionKey, annotation, onSelectValue, selectionOccurred, algorithm?.estimator]);

const options = useMemo(() => {
return noteKeyObjToArr(annotation?.note_keys)
Expand All @@ -77,17 +68,13 @@ const SelectAnalysesComponent: React.FC<{
const handleSelectColumn = (newVal: IAnalysesSelection | undefined) => {
if (newVal?.selectionKey === selectedValue.selectionKey) return; // we selected the same option that is already selected

const referenceDatasetIsNowInvalid = !selectedReferenceDatasetIsDefaultDataset(
selectedValue.referenceDataset
);
const referenceDatasetIsNowInvalid = !selectedReferenceDatasetIsDefaultDataset(selectedValue.referenceDataset);
if (!newVal) {
onSelectValue({
selectionKey: undefined,
type: undefined,
selectionValue: undefined,
referenceDataset: referenceDatasetIsNowInvalid
? undefined
: selectedValue.referenceDataset,
referenceDataset: referenceDatasetIsNowInvalid ? undefined : selectedValue.referenceDataset,
});
return;
}
Expand All @@ -96,9 +83,7 @@ const SelectAnalysesComponent: React.FC<{
selectionKey: newVal.selectionKey,
type: newVal.type,
selectionValue: newVal.type === EPropertyType.BOOLEAN ? true : undefined,
referenceDataset: referenceDatasetIsNowInvalid
? undefined
: selectedValue.referenceDataset,
referenceDataset: referenceDatasetIsNowInvalid ? undefined : selectedValue.referenceDataset,
};
onSelectValue(update);
};
Expand All @@ -109,9 +94,7 @@ const SelectAnalysesComponent: React.FC<{
sx={CreateMetaAnalysisSpecificationDialogBaseStyles.highlightInput}
label="Inclusion Column"
shouldDisable={false}
isOptionEqualToValue={(option, value) =>
option?.selectionKey === value?.selectionKey
}
isOptionEqualToValue={(option, value) => option?.selectionKey === value?.selectionKey}
value={selectedValue?.selectionKey ? selectedValue : undefined}
size="medium"
inputPropsSx={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const MoveToExtractionDialog: React.FC<IDialog> = (props) => {

const navigate = useNavigate();

const [isLoadingPhase, setIsLoadingPhase] = useState(false);
const [isError, setIsError] = useState(false);
const [loadingStatus, setLoadingStatus] = useState<{
createdStudyset: boolean;
Expand All @@ -55,7 +54,6 @@ const MoveToExtractionDialog: React.FC<IDialog> = (props) => {
});

const handleCloseDialog = () => {
setIsLoadingPhase(false);
setLoadingStatus({
createdAnnotations: false,
createdStudyset: false,
Expand Down
3 changes: 2 additions & 1 deletion compose/neurosynth-frontend/src/stores/AnnotationStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import {
import { setUnloadHandler } from 'helpers/BeforeUnload.helpers';
import { noteKeyArrToObj } from 'components/HotTables/HotTables.utils';

const normalizeNoteKeyOrder = (noteKeys: NoteKeyType[]) => noteKeys.map((noteKey, index) => ({ ...noteKey, order: index }));
const normalizeNoteKeyOrder = (noteKeys: NoteKeyType[]) =>
noteKeys.map((noteKey, index) => ({ ...noteKey, order: index }));

export const useAnnotationStore = create<
{
Expand Down
Loading