-
Notifications
You must be signed in to change notification settings - Fork 0
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 #130 from RyanNerd/124-change-how-name-button-popo…
…ver-works Revamp the client name and DOB buttons
- Loading branch information
Showing
4 changed files
with
193 additions
and
39 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React from "reactn"; | ||
import {clientFullName} from "../../utility/common"; | ||
import {ResidentRecord} from "../../types/RecordTypes"; | ||
import {Dropdown, DropdownButton} from "react-bootstrap"; | ||
|
||
// @ts-ignore Some props are completely incompatible and even the type `any` doesn't make TS happy | ||
interface IProps { | ||
className?: any | ||
clientRecord: ResidentRecord | ||
development: boolean | ||
onSelect?: (choice: string) => void | ||
disabled?: boolean | ||
[key: string]: any | ||
} | ||
|
||
const ClientButton = (props: IProps) => { | ||
const { | ||
clientRecord, | ||
development = true, | ||
onSelect, | ||
className, | ||
disabled | ||
} = props; | ||
|
||
const handleClick = (choice: string) => { | ||
if (onSelect) { | ||
onSelect(choice); | ||
} | ||
} | ||
|
||
const clientName = ( | ||
<span style={{fontStyle: development ? "italic" : "bold"}}> | ||
{clientFullName(clientRecord)} | ||
</span> | ||
); | ||
|
||
/** | ||
* Work-around so React 17 can be used | ||
* @link https://github.com/react-bootstrap/react-bootstrap/issues/5409#issuecomment-718699584 | ||
*/ | ||
return ( | ||
<DropdownButton | ||
variant="success" | ||
title={clientName} | ||
id="client-dropdown-button" | ||
className={className} | ||
onClick={(e: React.MouseEvent<HTMLElement>) => e.stopPropagation()} | ||
disabled={disabled} | ||
> | ||
<Dropdown.Item | ||
onClick={()=>handleClick('edit')} | ||
> | ||
Edit Client | ||
</Dropdown.Item> | ||
<Dropdown.Item | ||
onClick={()=>handleClick('print')} | ||
> | ||
Print Medbox Labels | ||
</Dropdown.Item> | ||
<Dropdown.Item | ||
onClick={()=>handleClick('hmis')} | ||
> | ||
Copy name to clipboard and launch HMIS | ||
</Dropdown.Item> | ||
<Dropdown.Divider/> | ||
<Dropdown.Item | ||
onClick={()=>handleClick('switch')} | ||
> | ||
Switch to a different client | ||
</Dropdown.Item> | ||
</DropdownButton> | ||
) | ||
} | ||
|
||
export default ClientButton; |
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,65 @@ | ||
import React from "reactn"; | ||
|
||
import {Badge, Dropdown, DropdownButton} from "react-bootstrap"; | ||
|
||
import {clientDOB} from "../../utility/common"; | ||
import {ResidentRecord} from "../../types/RecordTypes"; | ||
|
||
// @ts-ignore Some props are completely incompatible and even the type `any` doesn't make TS happy | ||
interface IProps { | ||
className?: any | ||
clientRecord: ResidentRecord | ||
development: boolean | ||
onSelect?: (choice: string) => void | ||
disabled?: boolean | ||
} | ||
|
||
/** | ||
* ClientDobButton is a dropdown button that displays the date of birth of the given client record | ||
* The dropdown shows the client notes if they have any. | ||
* @param {IProps} props | ||
*/ | ||
const ClientDobButton = (props: IProps) => { | ||
const { | ||
clientRecord, | ||
development = true, | ||
className, | ||
disabled | ||
} = props; | ||
|
||
const clientDobComponent = ( | ||
<span style={{fontStyle: development ? "italic" : "bold"}}> | ||
{clientRecord.Notes && <Badge variant="light">🔔</Badge>}{" "}{clientDOB(clientRecord)} | ||
</span> | ||
); | ||
|
||
/** | ||
* CSS Style override for getting the Dropdown.ItemText to display correctly | ||
* @link https://stackoverflow.com/a/17887494/4323201 | ||
* Work-around so React 17 can be used | ||
* @link https://github.com/react-bootstrap/react-bootstrap/issues/5409#issuecomment-718699584 | ||
*/ | ||
return ( | ||
<DropdownButton | ||
className={className} | ||
disabled={disabled || clientRecord.Notes == null || clientRecord?.Notes?.trim().length === 0} | ||
id="client-dob-dropdown-button" | ||
onClick={(e: React.MouseEvent<HTMLElement>) => e.stopPropagation()} | ||
title={clientDobComponent} | ||
variant="outline-secondary" | ||
> | ||
<Dropdown.Item | ||
style={{whiteSpace: "normal", width: "300px"}} | ||
> | ||
<Dropdown.Header> | ||
<h5>Notes</h5> | ||
</Dropdown.Header> | ||
<Dropdown.ItemText> | ||
{clientRecord.Notes} | ||
</Dropdown.ItemText> | ||
</Dropdown.Item> | ||
</DropdownButton> | ||
) | ||
} | ||
|
||
export default ClientDobButton; |
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