Skip to content

Commit f4dc719

Browse files
committed
dispaly all aligned to templates
1 parent 065df61 commit f4dc719

1 file changed

Lines changed: 49 additions & 4 deletions

File tree

applications/virtual-fly-brain/frontend/src/components/TermInfo/GeneralInformation.jsx

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box, Button, Chip, Grid, Typography, Tooltip } from "@mui/material";
1+
import { Box, Button, Chip, Grid, Typography, Tooltip, Stack } from "@mui/material";
22
import React, { useState } from "react";
33
import { useSelector } from 'react-redux';
44
import ReactMarkdown from 'react-markdown';
@@ -272,25 +272,68 @@ const GeneralInformation = ({ data, classes, showMetadataOnly = false }) => {
272272
};
273273

274274
// Render "Aligned To" chip
275-
const renderAlignedTo = () => {
275+
const renderAlignedTo = (data) => {
276+
const images = Object.keys(data?.Images).length !== 0 ? data?.Images : data?.Examples;
277+
const templateIds = Object.keys(images);
278+
279+
if (templateIds.length === 0) {
280+
return null;
281+
}
282+
283+
const AllAlignedTo = () => {
284+
return (
285+
<>
286+
{
287+
templateIds.map((templateId) => {
288+
return (
289+
templateId !== currentTemplateId && <Chip
290+
icon={<LinkIcon />}
291+
label={templateId}
292+
sx={{
293+
cursor: 'pointer',
294+
transition: 'background-color 0.2s ease-in-out',
295+
display: 'flex',
296+
alignItems: 'center',
297+
justifyContent: 'center',
298+
'&:hover': {
299+
backgroundColor: tabActiveColor
300+
}
301+
}}
302+
onClick={() => getInstanceByID(templateId, true, true, true)}
303+
/>
304+
)
305+
})
306+
}
307+
</>
308+
)
309+
}
276310
return currentTemplateId ? (
311+
<>
277312
<Chip
278313
icon={<LinkIcon />}
279314
label={currentTemplateName}
280315
onClick={handleTemplateClick}
281316
sx={{
282317
cursor: 'pointer',
283318
transition: 'background-color 0.2s ease-in-out',
319+
backgroundColor: tabActiveColor,
284320
'&:hover': {
285321
backgroundColor: tabActiveColor
286322
}
287323
}}
288324
/>
325+
<AllAlignedTo />
326+
</>
327+
289328
) : (
290-
<Chip
329+
<>
330+
<Chip
291331
label={currentTemplateName}
292332
sx={{ cursor: 'default' }}
293333
/>
334+
<AllAlignedTo />
335+
</>
336+
294337
);
295338
};
296339

@@ -933,7 +976,9 @@ const GeneralInformation = ({ data, classes, showMetadataOnly = false }) => {
933976
return (
934977
<Box key={key} display='flex' justifyContent='space-between' columnGap={1}>
935978
<Typography sx={classes.heading}>{key}</Typography>
936-
{renderAlignedTo()}
979+
<Stack direction='row' gap={1} alignItems='center' flexWrap='wrap'>
980+
{renderAlignedTo(data?.metadata)}
981+
</Stack>
937982
</Box>
938983
);
939984
}

0 commit comments

Comments
 (0)