-
Notifications
You must be signed in to change notification settings - Fork 4
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 #1091 from cityofaustin/9519_edit_recommendations
9519 edit recommendations
- Loading branch information
Showing
9 changed files
with
456 additions
and
86 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
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 was deleted.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
atd-vze/src/views/Crashes/Recommendations/RecommendationSelectValueDropdown.js
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,66 @@ | ||
import React, { useState } from "react"; | ||
import { | ||
Dropdown, | ||
DropdownToggle, | ||
DropdownMenu, | ||
DropdownItem, | ||
} from "reactstrap"; | ||
|
||
const RecommendationSelectValueDropdown = ({ | ||
value, | ||
onOptionClick, | ||
options, | ||
field, | ||
}) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const handleOptionClick = e => { | ||
const { id } = e.target; | ||
|
||
// Mutation expect lookup IDs as integers | ||
const valuesObject = { [field]: parseInt(id) }; | ||
onOptionClick(valuesObject); | ||
}; | ||
|
||
// Add a null option to enable users to clear out the value | ||
const makeOptionsWithNullOption = options => [ | ||
{ id: null, description: "None" }, | ||
...options, | ||
]; | ||
|
||
return ( | ||
<Dropdown | ||
toggle={() => { | ||
setIsOpen(!isOpen); | ||
}} | ||
isOpen={isOpen} | ||
className="mb-3" | ||
> | ||
<DropdownToggle | ||
className="w-100 pt-1 pl-2 d-flex text-left" | ||
style={{ backgroundColor: "transparent", border: "0" }} | ||
> | ||
<div className="flex-grow-1">{value}</div> | ||
<div className="pl-3"> | ||
<i className="fa fa-caret-down fa-lg"></i> | ||
</div> | ||
</DropdownToggle> | ||
<DropdownMenu className="w-100"> | ||
{makeOptionsWithNullOption(options).map(option => { | ||
return ( | ||
<DropdownItem | ||
id={option.id} | ||
key={option.id} | ||
onClick={handleOptionClick} | ||
className="pl-2" | ||
> | ||
{option.description} | ||
</DropdownItem> | ||
); | ||
})} | ||
</DropdownMenu> | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
export default RecommendationSelectValueDropdown; |
Oops, something went wrong.