-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: creating new annotation study table with store
- Loading branch information
Showing
29 changed files
with
19,723 additions
and
14,589 deletions.
There are no files selected for viewing
33,891 changes: 19,468 additions & 14,423 deletions
33,891
compose/neurosynth-frontend/package-lock.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
...rontend/src/components/HotTables/EditAnalysisPointsHotTable/EditAnalysisPoints.helpers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import { HotTableProps } from '@handsontable/react'; | ||
import { CellValue } from 'handsontable/common'; | ||
import styles from 'components/HotTables/AnnotationsHotTable/AnnotationsHotTable.module.css'; | ||
import { ColumnSettings } from 'handsontable/settings'; | ||
|
||
const nonEmptyNumericValidator = (value: CellValue, callback: (isValid: boolean) => void) => { | ||
const isNumber = !isNaN(value); | ||
if ( | ||
isNumber && | ||
value !== 'e' && | ||
value !== true && | ||
value !== false && | ||
value !== null && | ||
value !== '' // all these things are considered numbers | ||
) { | ||
callback(true); | ||
} else { | ||
callback(false); | ||
} | ||
}; | ||
|
||
export const hotTableColHeaders = ['X', 'Y', 'Z', 'Value', 'Cluster Size (mm^3)', 'Subpeak?']; | ||
export const hotTableColumnSettings: ColumnSettings[] = [ | ||
{ | ||
validator: nonEmptyNumericValidator, | ||
className: styles.number, | ||
data: 'x', | ||
type: 'numeric', | ||
}, | ||
{ | ||
validator: nonEmptyNumericValidator, | ||
className: styles.number, | ||
data: 'y', | ||
type: 'numeric', | ||
}, | ||
{ | ||
validator: nonEmptyNumericValidator, | ||
className: styles.number, | ||
data: 'z', | ||
type: 'numeric', | ||
}, | ||
{ | ||
className: styles.number, | ||
data: 'value', | ||
type: 'numeric', | ||
}, | ||
{ | ||
className: styles.number, | ||
data: 'cluster_size', | ||
type: 'numeric', | ||
}, | ||
{ | ||
validator: (value: CellValue, callback: (isValid: boolean) => void) => { | ||
callback(value === true || value === false || value === undefined); | ||
}, | ||
className: styles.boolean, | ||
data: 'subpeak', | ||
type: 'checkbox', | ||
}, | ||
]; | ||
|
||
export const EditAnalysisPointsDefaultConfig: HotTableProps = { | ||
outsideClickDeselects: false, | ||
licenseKey: 'non-commercial-and-evaluation', | ||
selectionMode: 'range', | ||
allowRemoveColumn: false, | ||
fillHandle: { | ||
direction: 'vertical', // autofill horizontal doesnt follow cell validations set by columns... | ||
autoInsertRow: false, // when fill handle reaches the bottom of the spreadsheet, prevent more rows from being added | ||
}, | ||
allowInvalid: false, | ||
undo: false, | ||
manualColumnResize: false, | ||
allowInsertColumn: false, | ||
colWidths: [50, 50, 50, 150, 150, 100], | ||
}; | ||
|
||
export const replaceString = (val: string) => { | ||
// replace = ['֊', '‐', '‑', '⁃', '﹣', '-', '‒', '–', '—', '﹘', '−', '-'] | ||
|
||
return val.replaceAll(new RegExp('֊|‐|‑|⁃|﹣|-|‒|–|—|﹘|−|-', 'g'), '-'); | ||
}; | ||
|
||
export const stripTags = (stringWhichMayHaveHTML: any) => { | ||
if (typeof stringWhichMayHaveHTML !== 'string') return ''; | ||
|
||
let doc = new DOMParser().parseFromString(stringWhichMayHaveHTML, 'text/html'); | ||
return doc.body.textContent || ''; | ||
}; | ||
|
||
export const getHotTableInsertionIndices = (selectedCoords: [number, number, number, number][]) => { | ||
if (selectedCoords.length === 0) | ||
return { | ||
insertAboveIndex: 0, | ||
insertBelowIndex: 0, | ||
}; | ||
|
||
let topMostIndex = selectedCoords[0][0]; // target startRow of first selected coord | ||
let bottomMostIndex = selectedCoords[selectedCoords.length - 1][2]; // target endRow of last selected coord | ||
|
||
selectedCoords.forEach(([startRow, startCol, endRow, endCol]) => { | ||
if (startRow < topMostIndex) topMostIndex = startRow; | ||
if (endRow > bottomMostIndex) bottomMostIndex = endRow; | ||
}); | ||
return { | ||
insertAboveIndex: topMostIndex, | ||
insertBelowIndex: bottomMostIndex, | ||
}; | ||
}; |
File renamed without changes.
Oops, something went wrong.