Skip to content

Commit

Permalink
OCLOMRS-1044:Bug Fix: Pick Concepts from Source and Dictionaries
Browse files Browse the repository at this point in the history
  • Loading branch information
jwamalwa committed Oct 4, 2021
1 parent 7afdb02 commit ac397b8
Showing 1 changed file with 23 additions and 30 deletions.
53 changes: 23 additions & 30 deletions src/apps/concepts/components/ViewConceptsHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ import { getContainerIdFromUrl } from "../utils";
import {
Button,
createStyles,
IconButton,
Input,
InputAdornment,
makeStyles,
Menu,
MenuItem,
TextField,
Theme
} from "@material-ui/core";
import {
PREFERRED_SOURCES_VIEW_ONLY,
useAnchor
} from "../../../utils";
import { APISource } from "../../sources";
import { AccountTreeOutlined, FolderOpen } from "@material-ui/icons";
import { AccountTreeOutlined, FolderOpen } from "@material-ui/icons";
import { Search as SearchIcon } from "@material-ui/icons";
import { APIDictionary } from '../../dictionaries/types';
import Stack from '@mui/material/Stack'
import { Autocomplete } from "@material-ui/lab";

interface Props {
containerType: string;
Expand Down Expand Up @@ -95,6 +96,7 @@ const ViewConceptsHeader: React.FC<Props> = ({
handleSwitchSourceClose
] = useAnchor();

// const [q, setQ] = useState(initialQ);
const getTitleBasedOnContainerType = () => {
return isAddToDictionary
? `Import existing concept from ${getContainerIdFromUrl(containerUrl)}`
Expand Down Expand Up @@ -128,32 +130,23 @@ const ViewConceptsHeader: React.FC<Props> = ({
open={Boolean(switchSourceAnchor)}
onClose={handleSwitchSourceClose}
>
<Button
variant="text"
onClick={() => setShowSources(!showSources)}
>
{showSources ? "Select a recommended source" : "Select an alternative source"}

<Stack spacing={2} sx={{ width: 300 }}>
<Autocomplete
Choose an alternative source
id="Select-a-recommended-source"
disableClearable
options={dictionaries.map((option: { name: url; }) => option.Sources)}
renderInput={(params) => (
<TextField
{...params}
label="Search input"
InputProps={{
...params.InputProps,
type: 'search',
}}
/>
)}
/>
</Stack>
)
</Button>
<Input
color="secondary"
type="search"
fullWidth
placeholder= {showSources ? "Select a recommended source" : "Select an alternative source"}
data-testid="searchInput"
endAdornment={
<InputAdornment position="end">
<IconButton
onClick={() => setShowSources(!showSources)}
data-testid="searchButton"
>
<SearchIcon />
</IconButton>
</InputAdornment>
}
/>
{preferredSources?.map(({ name, url }) => (
<MenuItem
// replace because we want to keep the back button useful
Expand Down

0 comments on commit ac397b8

Please sign in to comment.