Skip to content

Commit 68b3722

Browse files
committed
add explicit drag button
1 parent da317bb commit 68b3722

File tree

5 files changed

+34
-9
lines changed

5 files changed

+34
-9
lines changed

compose/neurosynth-frontend/src/components/HotTables/HotTables.module.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,14 @@
4444
color: gray !important;
4545
text-align: center !important;
4646
}
47+
48+
.drag-handle {
49+
cursor: grab;
50+
user-select: none;
51+
font-size: 16px;
52+
line-height: 1;
53+
display: flex;
54+
align-items: center;
55+
justify-content: center;
56+
padding: 2px 4px;
57+
}

compose/neurosynth-frontend/src/pages/Annotations/components/EditAnnotationsHotTable.helpers.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,18 @@ export const annotationNotesToHotData = (
119119
};
120120
};
121121

122-
export const createColumnHeader = (colKey: string, colType: EPropertyType, allowRemoveColumn: boolean) => {
122+
export const createColumnHeader = (
123+
colKey: string,
124+
colType: EPropertyType,
125+
allowRemoveColumn: boolean,
126+
showDragHandle = false
127+
) => {
128+
const dragHandle = showDragHandle
129+
? `<div data-drag-handle="true" class="${styles['drag-handle']}" title="Drag to reorder">&#8942;</div>`
130+
: '<div style="width: 12px;"></div>';
131+
123132
const allowRemove = allowRemoveColumn
124-
? `<div style="width: 50px; display: flex; align-items: center; justify-content: center">
133+
? `<div data-remove-col="true" style="width: 50px; display: flex; align-items: center; justify-content: center">
125134
${renderToString(
126135
<Cancel
127136
sx={{
@@ -133,10 +142,11 @@ export const createColumnHeader = (colKey: string, colType: EPropertyType, allow
133142
/>
134143
)}
135144
</div>`
136-
: '<div></div>';
145+
: '<div style="width: 50px;"></div>';
137146

138147
return (
139-
`<div title="${colKey}" style="display: flex; align-items: center; justify-content: center;">` +
148+
`<div data-col-key="${colKey}" title="${colKey}" style="display: flex; align-items: center; justify-content: center; gap: 6px;">` +
149+
dragHandle +
140150
`<div class="${styles[colType]} ${styles.truncate}" style="width: 100px">${colKey}</div>` +
141151
allowRemove +
142152
`</div>`

compose/neurosynth-frontend/src/pages/Annotations/components/EditAnnotationsHotTable.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,12 @@ const AnnotationsHotTable: React.FC<{ annotationId?: string }> = React.memo((pro
134134

135135
const handleCellMouseUp = (event: MouseEvent, coords: CellCoords, TD: HTMLTableCellElement): void => {
136136
const target = event.target as HTMLButtonElement;
137-
if (coords.row < 0 && (target.tagName === 'svg' || target.tagName === 'path')) {
138-
handleRemoveHotColumn(TD.innerText);
137+
if (coords.row < 0) {
138+
const removeTarget = (target as HTMLElement).closest('[data-remove-col="true"]');
139+
if (removeTarget) {
140+
const colKey = (target as HTMLElement).closest('[data-col-key]')?.getAttribute('data-col-key');
141+
if (colKey) handleRemoveHotColumn(colKey);
142+
}
139143
}
140144
};
141145

compose/neurosynth-frontend/src/pages/Annotations/hooks/useEditAnnotationsHotTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ const useEditAnnotationsHotTable = (annotationId?: string, disableEdit?: boolean
7777
...['Study', 'Analysis'],
7878
...annotationsHotState.noteKeys.map((col) => {
7979
const allowRemoveColumn = col.key !== 'included';
80-
return createColumnHeader(col.key, col.type, allowRemoveColumn);
80+
return createColumnHeader(col.key, col.type, allowRemoveColumn, !disableEdit);
8181
}),
8282
];
83-
}, [annotationsHotState.noteKeys]);
83+
}, [annotationsHotState.noteKeys, disableEdit]);
8484

8585
const colWidths = useMemo(() => {
8686
return createColWidths(annotationsHotState.noteKeys, 300, 150, 150);

compose/neurosynth-frontend/src/pages/Study/hooks/useEditStudyAnnotationsHotTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const useEditStudyAnnotationsHotTable = (readonly?: boolean) => {
5858
colHeaders: [
5959
'Analysis Name',
6060
'Analysis Description',
61-
...(noteKeys ?? []).map((x) => createColumnHeader(x.key, x.type, true)),
61+
...(noteKeys ?? []).map((x) => createColumnHeader(x.key, x.type, true, false)),
6262
],
6363
colWidths: createColWidths(noteKeys || [], 150, 150, 150),
6464
};

0 commit comments

Comments
 (0)