Skip to content

Commit d59aba1

Browse files
committed
OCLOMRS-1044:Bug Fix: Pick Concepts from Source and Dictionaries
1 parent 41bf3d7 commit d59aba1

File tree

1 file changed

+62
-8
lines changed

1 file changed

+62
-8
lines changed

src/apps/concepts/components/ViewConceptsHeader.tsx

+62-8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ import { getContainerIdFromUrl } from "../utils";
1010
import {
1111
Button,
1212
createStyles,
13+
Grid,
14+
IconButton,
15+
Input,
16+
InputAdornment,
1317
makeStyles,
1418
Menu,
1519
MenuItem,
@@ -20,7 +24,7 @@ import {
2024
useAnchor
2125
} from "../../../utils";
2226
import { APISource } from "../../sources";
23-
import { AccountTreeOutlined, FolderOpen } from "@material-ui/icons";
27+
import { AccountTreeOutlined, FolderOpen, Search as SearchIcon } from "@material-ui/icons";
2428
import { APIDictionary } from '../../dictionaries/types';
2529

2630
interface Props {
@@ -59,6 +63,10 @@ const useStyles = makeStyles((theme: Theme) =>
5963
marginRight: "0.2rem",
6064
fill: "#8080809c"
6165
},
66+
searchInput: {
67+
textAlign: "center",
68+
fontSize: "larger"
69+
},
6270
})
6371
);
6472

@@ -70,8 +78,11 @@ const ViewConceptsHeader: React.FC<Props> = ({
7078
children,
7179
sources,
7280
dictionaries
81+
// showOnlyVerified,
82+
// toggleShowVerified
7383
}) => {
7484
const [showSources, setShowSources] = useState(false);
85+
const [search, setSearch] = useState("");
7586
const [preferredSources, setPreferredSources] = useState< { name: string; url: string }[] >();
7687
useEffect(() => {
7788
const defaultSources = Object.entries( PREFERRED_SOURCES_VIEW_ONLY).map(([key, value]) => ({ name: key, url: value }));
@@ -82,6 +93,9 @@ const ViewConceptsHeader: React.FC<Props> = ({
8293
setPreferredSources(allSources);
8394
} else setPreferredSources(defaultSources);
8495
}, [showSources, sources, dictionaries]);
96+
// const handleSearch = (event) => {
97+
// setSearch(event.target.value)
98+
// }
8599

86100
const classes = useStyles();
87101
const isSourceContainer = containerType === SOURCE_CONTAINER;
@@ -91,7 +105,6 @@ const ViewConceptsHeader: React.FC<Props> = ({
91105
handleSwitchSourceClick,
92106
handleSwitchSourceClose
93107
] = useAnchor();
94-
95108
const getTitleBasedOnContainerType = () => {
96109
return isAddToDictionary
97110
? `Import existing concept from ${getContainerIdFromUrl(containerUrl)}`
@@ -124,14 +137,55 @@ const ViewConceptsHeader: React.FC<Props> = ({
124137
keepMounted
125138
open={Boolean(switchSourceAnchor)}
126139
onClose={handleSwitchSourceClose}
127-
>
128-
<Button
129-
variant="contained"
130-
color="primary"
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
131157
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)}
132168
>
133-
{showSources ? "Select a recommended source" : "Select an alternative source"}
134-
</Button>
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"
182+
/>
183+
}
184+
label={
185+
showOnlyVerified ? `Showing verified {"Select a recommended source"} only` : `Show verified {"Select an alternative source"} only`
186+
}
187+
/> */}
188+
</Grid>
135189
{preferredSources?.map(({ name, url }) => (
136190
<MenuItem
137191
// replace because we want to keep the back button useful

0 commit comments

Comments
 (0)