Skip to content

Commit a3aa7d6

Browse files
committed
OCLOMRS-1044:Bug Fix: Pick Concepts from Source and Dictionaries
1 parent 2840ebc commit a3aa7d6

File tree

1 file changed

+63
-17
lines changed

1 file changed

+63
-17
lines changed

src/apps/concepts/components/ViewConceptsHeader.tsx

+63-17
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@ import { getContainerIdFromUrl } from "../utils";
1010
import {
1111
Button,
1212
createStyles,
13+
Grid,
14+
IconButton,
15+
Input,
16+
InputAdornment,
1317
makeStyles,
1418
Menu,
1519
MenuItem,
16-
TextField,
1720
Theme
1821
} from "@material-ui/core";
1922
import {
2023
PREFERRED_SOURCES_VIEW_ONLY,
2124
useAnchor
2225
} from "../../../utils";
2326
import { APISource } from "../../sources";
24-
import { AccountTreeOutlined, FolderOpen } from "@material-ui/icons";
27+
import { AccountTreeOutlined, FolderOpen, Search as SearchIcon } from "@material-ui/icons";
2528
import { APIDictionary } from '../../dictionaries/types';
2629

2730
interface Props {
@@ -60,6 +63,10 @@ const useStyles = makeStyles((theme: Theme) =>
6063
marginRight: "0.2rem",
6164
fill: "#8080809c"
6265
},
66+
searchInput: {
67+
textAlign: "center",
68+
fontSize: "larger"
69+
},
6370
})
6471
);
6572

@@ -71,8 +78,11 @@ const ViewConceptsHeader: React.FC<Props> = ({
7178
children,
7279
sources,
7380
dictionaries
81+
// showOnlyVerified,
82+
// toggleShowVerified
7483
}) => {
7584
const [showSources, setShowSources] = useState(false);
85+
const [search, setSearch] = useState("");
7686
const [preferredSources, setPreferredSources] = useState< { name: string; url: string }[] >();
7787
useEffect(() => {
7888
const defaultSources = Object.entries( PREFERRED_SOURCES_VIEW_ONLY).map(([key, value]) => ({ name: key, url: value }));
@@ -83,6 +93,9 @@ const ViewConceptsHeader: React.FC<Props> = ({
8393
setPreferredSources(allSources);
8494
} else setPreferredSources(defaultSources);
8595
}, [showSources, sources, dictionaries]);
96+
// const handleSearch = (event) => {
97+
// setSearch(event.target.value)
98+
// }
8699

87100
const classes = useStyles();
88101
const isSourceContainer = containerType === SOURCE_CONTAINER;
@@ -92,7 +105,6 @@ const ViewConceptsHeader: React.FC<Props> = ({
92105
handleSwitchSourceClick,
93106
handleSwitchSourceClose
94107
] = useAnchor();
95-
96108
const getTitleBasedOnContainerType = () => {
97109
return isAddToDictionary
98110
? `Import existing concept from ${getContainerIdFromUrl(containerUrl)}`
@@ -125,21 +137,55 @@ const ViewConceptsHeader: React.FC<Props> = ({
125137
keepMounted
126138
open={Boolean(switchSourceAnchor)}
127139
onClose={handleSwitchSourceClose}
128-
>
129-
<TextField
130-
multiline
131-
className={classes.textField}
132-
InputProps={{
133-
className: classes.underline
134-
}}
135-
inputProps={{
136-
className: classes.input
137-
}}
138-
value={
139-
showSources ? "Choose a source/dictionary" : "Select a different source/dictionary"
140-
}
141-
onClick={() => setShowSources(!showSources)}
140+
>
141+
<Grid
142+
container
143+
// eslint-disable-next-line react/jsx-no-comment-textnodes
144+
direction="column">
145+
{showSources?
146+
<Input
147+
color="primary"
148+
type="search"
149+
fullWidth
150+
placeholder= {"Select an alternative source"}
151+
value={search}
152+
onChange = {event => setSearch(event.target.value)}
153+
data-testid="switch-source"
154+
endAdornment={
155+
<InputAdornment position="end">
156+
<IconButton
157+
onClick={() => setShowSources(!showSources)}
158+
data-testid="searchButton"
159+
>
160+
<SearchIcon />
161+
</IconButton>
162+
</InputAdornment>
163+
}
164+
/> :
165+
<Button
166+
variant="text"
167+
onClick={() => setShowSources(!showSources)}
168+
>
169+
Select a recommended source
170+
{/* {showSources ? "Select a recommended source" : "Select an alternative source"} */}
171+
</Button>
172+
}
173+
174+
{/* <FormControlLabel
175+
control={
176+
<Switch
177+
checkedIcon={<VerifiedSource />}
178+
checked={showOnlyVerified}
179+
onChange={toggleShowVerified}
180+
color="primary"
181+
name="displayVerified"
142182
/>
183+
}
184+
label={
185+
showOnlyVerified ? `Showing verified {"Select a recommended source"} only` : `Show verified {"Select an alternative source"} only`
186+
}
187+
/> */}
188+
</Grid>
143189
{preferredSources?.map(({ name, url }) => (
144190
<MenuItem
145191
// replace because we want to keep the back button useful

0 commit comments

Comments
 (0)