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

#241 add a min width for the origin field #210

Merged
merged 1 commit into from
Jan 26, 2024
Merged
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
1 change: 1 addition & 0 deletions frontend/src/components/Forms/StatementForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const StatementForm = (props: any) => {
disabledReason: "",
fieldName: "origins",
chipsNumber: 5,
minWidth: "50rem",
onSearch: async (
searchValue: string,
formId: string,
Expand Down
47 changes: 30 additions & 17 deletions frontend/src/components/Widgets/CustomEntitiesDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ export default function CustomEntitiesDropdown({
statement,
fieldName = "",
getPreLevelSelectedValues,
areConnectionsExplicit
areConnectionsExplicit,
minWidth = ''
},
}: any) {
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
Expand Down Expand Up @@ -403,20 +404,24 @@ export default function CustomEntitiesDropdown({

<Badge
sx={{ ...styles.badge, flex: 1 }}
badgeContent={!isAllSelectedValuesFromTheAboveLayer ? 0 : selectedOptions?.length}
badgeContent={
!isAllSelectedValuesFromTheAboveLayer ? 0 : selectedOptions?.length
}
>
<Box
aria-describedby={aria}
sx={
open
sx={{
minWidth: minWidth ? minWidth : "auto",
...(open
? { ...styles.root, ...styles.rootOpen }
: selectedOptions.length === 0
? styles.root
: { ...styles.root, ...styles.rootHover }
}
: { ...styles.root, ...styles.rootHover }),
}}
onClick={handleClick}
>
{(!isAllSelectedValuesFromTheAboveLayer || selectedOptions.length === 0) ? (
{!isAllSelectedValuesFromTheAboveLayer ||
selectedOptions.length === 0 ? (
<Typography sx={styles.placeholder}>{placeholder}</Typography>
) : (
<Box gap={1} display="flex" flexWrap="wrap" alignItems="center">
Expand All @@ -439,7 +444,7 @@ export default function CustomEntitiesDropdown({
...styles.chip,
flex: 1,
minWidth: 0,
maxWidth: 'fit-content',
maxWidth: "fit-content",
}}
variant={"outlined"}
onClick={(e) => {
Expand All @@ -457,8 +462,10 @@ export default function CustomEntitiesDropdown({
);
})
: null}
<span style={{marginRight: '.5rem'}}>{selectedOptions.length > chipsNumber &&
`+${selectedOptions.length - chipsNumber}`}</span>
<span style={{ marginRight: ".5rem" }}>
{selectedOptions.length > chipsNumber &&
`+${selectedOptions.length - chipsNumber}`}
</span>
</Box>
)}
{open ? (
Expand Down Expand Up @@ -510,7 +517,7 @@ export default function CustomEntitiesDropdown({
sx={{
...styles.chip,
display: "flex",
textAlign: "left"
textAlign: "left",
}}
variant="outlined"
label={
Expand Down Expand Up @@ -673,9 +680,9 @@ export default function CustomEntitiesDropdown({
"&.selected-unchecked": {
"& .MuiButtonBase-root": {
"&.Mui-checked": {
color: 'red'
}
}
color: "red",
},
},
},

"& .MuiTypography-body1": {
Expand Down Expand Up @@ -743,9 +750,15 @@ export default function CustomEntitiesDropdown({
disableRipple
icon={<UncheckedItemIcon fontSize="small" />}
checkedIcon={
!isAllSelectedValuesFromTheAboveLayer && !hasValueChanged
? <CheckedItemIconBG fontSize="small" style={{color: '#C6D9F6'}} />
: <CheckedItemIcon fontSize="small" />
!isAllSelectedValuesFromTheAboveLayer &&
!hasValueChanged ? (
<CheckedItemIconBG
fontSize="small"
style={{ color: "#C6D9F6" }}
/>
) : (
<CheckedItemIcon fontSize="small" />
)
}
checked={isOptionSelected(option)}
/>
Expand Down