-
Notifications
You must be signed in to change notification settings - Fork 8
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
Add set membership columns to the element view table #435
Changes from 4 commits
6b74dd8
d3b4523
996153c
327d4cf
c49f9c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,9 @@ import { Item } from '@visdesignlab/upset2-core'; | |
import { FC, useMemo } from 'react'; | ||
import { useRecoilValue } from 'recoil'; | ||
|
||
import { attributeAtom } from '../../atoms/attributeAtom'; | ||
import { selectedItemsSelector } from '../../atoms/elementsSelectors'; | ||
import { setColumnsSelector } from '../../atoms/dataAtom'; | ||
import { attributeAtom } from '../../atoms/attributeAtom'; | ||
|
||
/** | ||
* Hook to generate rows for the DataGrid | ||
|
@@ -40,10 +41,16 @@ function useColumns(columns: string[]) { | |
* Table to display elements | ||
*/ | ||
export const ElementTable: FC = () => { | ||
const attributeColumns = useRecoilValue(attributeAtom); | ||
const attColumns = useRecoilValue(attributeAtom); | ||
const elements = useRecoilValue(selectedItemsSelector); | ||
const rows = useRows(elements); | ||
const columns = useColumns(['_label', ...attributeColumns]); | ||
const setColumns = useRecoilValue(setColumnsSelector); | ||
let columns = useColumns(['_label', ...([...attColumns, ...setColumns].filter((col) => !col.startsWith('_')))]); | ||
// Sort set columns to the right of other columns & add a boolean type to | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this sort? Looks like it just adds There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "sorting" here is really just the spread operator, putting the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, that comment is outdated; there used to be an explicit sort function but that was removed when I started using spread instead. Comment updated. |
||
columns = columns.map((col) => ({ | ||
...col, | ||
type: setColumns.includes(col.field) ? 'boolean' : 'string', | ||
})); | ||
|
||
return ( | ||
<Box | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer that this is fully spelled out. Makes things more readable (for me who never works in the code)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with jack here