-
-
Notifications
You must be signed in to change notification settings - Fork 79
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 #642 from WildMeOrg/511_continuation_of_encounter_…
…search Continuation of Encounter Search (using OpenSearch)
- Loading branch information
Showing
107 changed files
with
3,957 additions
and
1,760 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
import { createContext } from "react"; | ||
|
||
const FilterContext = createContext(true); | ||
export default FilterContext; | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import Select from 'react-select'; | ||
import { useEffect, useState } from 'react'; | ||
import { useRef } from 'react'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import { FormGroup, FormLabel } from 'react-bootstrap'; | ||
import Description from './Form/Description' | ||
|
||
const colourStyles = { | ||
option: (styles) => ({ | ||
...styles, | ||
color: 'black', | ||
}), | ||
control: (styles) => ({ ...styles, backgroundColor: 'white' }), | ||
singleValue: (styles) => ({ ...styles, color: 'black' }), | ||
menuPortal: base => ({ ...base, zIndex: 9999 }), | ||
control: base => ({ ...base, zIndex: 1 }), | ||
}; | ||
|
||
export default function AndSelector({ | ||
noLabel, | ||
noDesc, | ||
label, | ||
isMulti, | ||
options, | ||
onChange, | ||
field, | ||
filterKey, | ||
term, }) { | ||
|
||
const [selectedOptions, setSelectedOptions] = useState([]); | ||
const selectedOptionsRef = useRef(selectedOptions); | ||
|
||
useEffect(() => { | ||
|
||
onChange(null, field); | ||
return () => { | ||
options.forEach(option => { | ||
onChange(null, `${field}.${option.value}`); | ||
}); | ||
}; | ||
}, []); | ||
|
||
const handleChange = (selected) => { | ||
|
||
const addedOptions = selected.filter(option => !selectedOptions.includes(option)); | ||
const removedOptions = selectedOptions.filter(option => !selected.includes(option)); | ||
|
||
setSelectedOptions(selected || []); | ||
selectedOptionsRef.current = selected || []; | ||
|
||
if (addedOptions.length > 0) { | ||
addedOptions.forEach(option => { | ||
onChange({ | ||
filterId: `${field}.${option.value}`, | ||
clause: "filter", | ||
filterKey: filterKey, | ||
query: { | ||
"term": { | ||
[field]: option.value | ||
} | ||
} | ||
}); | ||
}) | ||
} | ||
|
||
if (removedOptions.length > 0) { | ||
removedOptions.forEach(option => { | ||
onChange(null, `${field}.${option.value}`); | ||
}); | ||
} | ||
} | ||
|
||
return ( | ||
<FormGroup className="mt-2"> | ||
{noLabel ? null : <FormLabel><FormattedMessage id={label} defaultMessage={label} /></FormLabel>} | ||
{noDesc ? null : <Description> | ||
<FormattedMessage id={`${label}_DESC`} /> | ||
</Description>} | ||
|
||
<Select | ||
isMulti={isMulti} | ||
options={options} | ||
className="basic-multi-select" | ||
classNamePrefix="select" | ||
styles={colourStyles} | ||
menuPlacement="auto" | ||
menuPortalTarget={document.body} | ||
value={selectedOptions} | ||
onChange={handleChange} | ||
/> | ||
</FormGroup> | ||
); | ||
} |
Oops, something went wrong.