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

ILEX-79 Single term view table issues #73

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from
Open
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
33 changes: 12 additions & 21 deletions src/components/SingleTermView/OverView/CustomizedTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,12 @@ const { gray100, gray50, gray600, gray500, brand600, brand50, brand700, gray700
const tableStyles = {
head: {
display: 'flex',
p: '0.75rem 0 0.5rem',
p: '0.75rem 0.5rem 0.5rem 0.5rem',
borderBottom: `1px solid ${gray100}`,

'& > .MuiBox-root': {
width: '20rem',
px: '0.75rem',
'&:first-of-type': {
width: 'calc(55% - 5.625rem)'
},
'&:last-of-type': {
width: 'calc(45% - 5.625rem)'
},
paddingRight: '0.75rem',
paddingLeft: 0
},
'& .MuiTypography-root': {
color: gray600,
Expand Down Expand Up @@ -96,15 +90,9 @@ const tableStyles = {
},

'& > .MuiBox-root': {
width: '20rem',
gap: '0.5rem',
px: '0.75rem',
'&:first-of-type': {
width: 'calc(55% - 5.625rem)',
},
'&:last-of-type': {
width: 'calc(45% - 5.625rem)'
},
paddingRight: '0.75rem',
paddingLeft: 0
},
},
},
Expand Down Expand Up @@ -160,8 +148,7 @@ const CustomizedTable = ({ data, term, isAddButtonVisible }) => {
const [tableHeader, setTableHeader] = useState([
{ key: 'subject', label: 'Subject', allowSort: false, direction: 'desc' },
{ key: 'predicate', label: 'Predicates', allowSort: false },
{ key: 'object', label: 'Objects', allowSort: true, direction: 'desc' },
{ key: '', label: '' }
{ key: 'object', label: 'Objects', allowSort: true, direction: 'desc' }
]);

const [terms, setTerms] = useState([]);
Expand Down Expand Up @@ -267,12 +254,15 @@ const CustomizedTable = ({ data, term, isAddButtonVisible }) => {
}
}, [objectSearchTerm, fetchTerms]);

const tableWidth = 800;
const columnWidth = `${tableWidth / tableHeader.length}px`;

return (
<>
<Box pb={1.5}>
<Box pb={1.5} width={1} sx={{ maxWidth: `${tableWidth}px` }}>
<Box sx={tableStyles.head}>
{tableHeader.map((head, index) => (
<Box key={index} sx={{ display: 'flex', alignItems: 'center' }}>
<Box key={index} sx={{ display: 'flex', alignItems: 'center', width: columnWidth }}>
<Typography>{head.label}</Typography>
{head.key && head.allowSort && (
<IconButton
Expand All @@ -294,6 +284,7 @@ const CustomizedTable = ({ data, term, isAddButtonVisible }) => {
<TableRow
key={`${row.id}-${index}`}
tableStyles={tableStyles}
columnWidth={columnWidth}
data={row}
index={index}
onDragStart={dragStart}
Expand Down
29 changes: 20 additions & 9 deletions src/components/SingleTermView/OverView/TableRow.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box, IconButton, Tooltip, Typography } from "@mui/material";
import { useState } from "react";
import HelpOutlineOutlinedIcon from '@mui/icons-material/HelpOutlineOutlined';
const TableRow = ({ tableStyles, data, onDragStart, onDragEnter, onDragEnd, index }) => {
const TableRow = ({ tableStyles, data, onDragStart, onDragEnter, onDragEnd, index, columnWidth }) => {
const { id, subject, predicate, object } = data;
const [isHovered, setIsHovered] = useState(false);
return (
Expand All @@ -13,15 +13,26 @@ const TableRow = ({ tableStyles, data, onDragStart, onDragEnter, onDragEnd, inde
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
>
<Box sx={{ paddingLeft: "0 !important" }}>
<Typography>
{subject}
</Typography>
<Box sx={{ paddingLeft: "0 !important", width: columnWidth }}>
<Tooltip title={subject}>
<Typography>
{subject}
</Typography>
</Tooltip>
</Box>
<Box>
<Typography>
{predicate}
</Typography>
<Box sx={{ width: columnWidth }}>
<Tooltip title={predicate}>
<Typography>
{predicate}
</Typography>
</Tooltip>
</Box>
<Box sx={{ width: columnWidth }}>
<Tooltip title={object}>
<Typography>
{object}
</Typography>
</Tooltip>
</Box>
<Box display="flex" justifyContent="flex-end" sx={{ paddingRight: "0 !important" }}>
{
Expand Down