-
Notifications
You must be signed in to change notification settings - Fork 2
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 #913 from bcgov/feat/calculated-intensity-performance
Feat/calculated intensity performance
- Loading branch information
Showing
28 changed files
with
498 additions
and
24 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 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
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
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,43 @@ | ||
import { WidgetProps } from "@rjsf/core"; | ||
import NumberFormat from "react-number-format"; | ||
|
||
const ReadOnlyCalculatedValueWidget: React.FC<WidgetProps> = ({ | ||
id, | ||
formContext, | ||
label, | ||
uiSchema, | ||
}) => { | ||
// If we are using this widget to show numbers as money or percent, we can set `isMoney` or `isPercent` to true in the uiSchema. | ||
const isMoney = uiSchema?.isMoney; | ||
const isPercent = uiSchema?.isPercent; | ||
|
||
return ( | ||
<dd> | ||
{formContext.calculatedValue ? ( | ||
<NumberFormat | ||
fixedDecimalScale={isMoney || isPercent} | ||
prefix={isMoney ? "$" : ""} | ||
suffix={isPercent ? "%" : ""} | ||
id={id} | ||
decimalScale={isMoney || isPercent ? 2 : 10} //Hardcoded for now, we can change it if we need to | ||
value={formContext.calculatedValue} | ||
displayType="text" | ||
aria-label={label} | ||
/> | ||
) : ( | ||
<NumberFormat | ||
fixedDecimalScale={isMoney || isPercent} | ||
prefix={isMoney ? "$" : ""} | ||
suffix={isPercent ? "%" : ""} | ||
id={id} | ||
decimalScale={isMoney || isPercent ? 2 : 10} | ||
value={0} | ||
displayType="text" | ||
aria-label={label} | ||
/> | ||
)} | ||
</dd> | ||
); | ||
}; | ||
|
||
export default ReadOnlyCalculatedValueWidget; |
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
Oops, something went wrong.