generated from EyeSeeTea/dhis2-app-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from EyeSeeTea/feat/checkboxes-on-select
Feat: checkboxes on select
- Loading branch information
Showing
12 changed files
with
325 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/webapp/components/selectmulti-checkboxes/SelectMultiCheckboxes.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import Select from "@material-ui/core/Select"; | ||
import Checkbox from "@material-ui/core/Checkbox"; | ||
import MenuItem from "@material-ui/core/MenuItem"; | ||
import ListItemText from "@material-ui/core/ListItemText"; | ||
import InputLabel from "@material-ui/core/InputLabel"; | ||
import FormControl from "@material-ui/core/FormControl"; | ||
import styled from "styled-components"; | ||
import { memo } from "react"; | ||
|
||
type Option = { | ||
text: string; | ||
value: string; | ||
}; | ||
|
||
type Props = { | ||
label: string; | ||
options: Option[]; | ||
value: string[]; | ||
onChange: (values: string[]) => void; | ||
}; | ||
|
||
export const SelectMultiCheckboxes: React.FC<Props> = memo( | ||
({ onChange, options, value, label }) => { | ||
const onChangeSelector = (event: React.ChangeEvent<{ value: unknown }>) => { | ||
onChange(event.target.value as string[]); | ||
}; | ||
return ( | ||
<StyledFormControl> | ||
<InputLabel id="mutiple-checkbox-label">{label}</InputLabel> | ||
<Select | ||
labelId="mutiple-checkbox-label" | ||
id="mutiple-checkbox" | ||
multiple | ||
value={value} | ||
onChange={onChangeSelector} | ||
renderValue={selected => (selected as string[]).join(", ")} | ||
> | ||
{options.map(option => ( | ||
<MenuItem key={option.text} value={option.text}> | ||
<Checkbox checked={value.indexOf(option.text) > -1} /> | ||
<ListItemText primary={option.text} /> | ||
</MenuItem> | ||
))} | ||
</Select> | ||
</StyledFormControl> | ||
); | ||
} | ||
); | ||
|
||
const StyledFormControl = styled(FormControl)` | ||
min-width: 7.5rem; | ||
max-width: 18.75rem; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 0 additions & 56 deletions
56
src/webapp/pages/analysis/steps/3-disaggregates/hooks/useDisaggregatesStep.tsx
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.