From b010a68f49cf34f2bd3f604dd0e8f5092c27af0a Mon Sep 17 00:00:00 2001 From: dmitrij Date: Mon, 12 Aug 2024 17:38:54 +0300 Subject: [PATCH 1/2] OD-19252 feat: remove validation of oncostRate as money, because it is used to store per cents --- .../oncourse/server/api/service/TutorRoleApiService.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/main/groovy/ish/oncourse/server/api/service/TutorRoleApiService.groovy b/server/src/main/groovy/ish/oncourse/server/api/service/TutorRoleApiService.groovy index 344eb136fd7..f6fccf0c5a4 100644 --- a/server/src/main/groovy/ish/oncourse/server/api/service/TutorRoleApiService.groovy +++ b/server/src/main/groovy/ish/oncourse/server/api/service/TutorRoleApiService.groovy @@ -133,14 +133,14 @@ class TutorRoleApiService extends EntityApiService Date: Thu, 22 Aug 2024 16:59:59 +0200 Subject: [PATCH 2/2] OD-19252 Allow decimal values for oncost rate --- .../sidebar-with-search/SidebarWithSearch.tsx | 2 +- .../swipeable-sidebar/SwipeableSidebar.tsx | 7 ++----- .../components/HamburgerMenu.tsx | 13 ++++--------- .../tutor-roles/components/PayRateItem.tsx | 17 +++++++---------- 4 files changed, 14 insertions(+), 25 deletions(-) diff --git a/client-html/src/js/common/components/layout/sidebar-with-search/SidebarWithSearch.tsx b/client-html/src/js/common/components/layout/sidebar-with-search/SidebarWithSearch.tsx index 60426ea889b..df27c48534f 100644 --- a/client-html/src/js/common/components/layout/sidebar-with-search/SidebarWithSearch.tsx +++ b/client-html/src/js/common/components/layout/sidebar-with-search/SidebarWithSearch.tsx @@ -83,7 +83,7 @@ export const SidebarWithSearch = (props: Props) => { >
- +
{!noSearch && } {Boolean(filters.length) && ( diff --git a/client-html/src/js/common/components/layout/swipeable-sidebar/SwipeableSidebar.tsx b/client-html/src/js/common/components/layout/swipeable-sidebar/SwipeableSidebar.tsx index 2ab542b2363..3575be3c13a 100644 --- a/client-html/src/js/common/components/layout/swipeable-sidebar/SwipeableSidebar.tsx +++ b/client-html/src/js/common/components/layout/swipeable-sidebar/SwipeableSidebar.tsx @@ -7,8 +7,7 @@ */ import { PreferenceEnum, SearchQuery } from "@api/model"; -import { Backdrop, Divider } from "@mui/material"; -import Collapse from "@mui/material/Collapse"; +import { Backdrop, Collapse, Divider } from "@mui/material"; import { darken } from "@mui/material/styles"; import SwipeableDrawer from "@mui/material/SwipeableDrawer"; import Typography from "@mui/material/Typography"; @@ -115,7 +114,6 @@ const styles = (theme: AppTheme) => }); interface Props { - form: string; resetEditView: any; classes: any; opened: boolean; @@ -150,7 +148,6 @@ const sortItems = (a, b) => { const SwipeableSidebar: React.FC = props => { const { - form, dispatch, classes, opened, @@ -427,7 +424,7 @@ const SwipeableSidebar: React.FC = props => { >
- +
void; } const HamburgerMenu = React.memo(props => { - const { opened, toggleSwipeableDrawer } = props; + const { opened, liteBackground, toggleSwipeableDrawer } = props; return (
@@ -36,13 +37,7 @@ const HamburgerMenu = React.memo(props => { {opened ? : } - {/* */} - - +
); }); @@ -55,4 +50,4 @@ const mapStateToDispatch = (dispatch: Dispatch, props: Props) => ({ toggleSwipeableDrawer: () => dispatch(toggleSwipeableDrawer(props.variant)) }); -export default connect(mapStateToProps, mapStateToDispatch)(HamburgerMenu); +export default connect(mapStateToProps, mapStateToDispatch)(HamburgerMenu); diff --git a/client-html/src/js/containers/preferences/containers/tutor-roles/components/PayRateItem.tsx b/client-html/src/js/containers/preferences/containers/tutor-roles/components/PayRateItem.tsx index be6574af724..758d05bdfeb 100644 --- a/client-html/src/js/containers/preferences/containers/tutor-roles/components/PayRateItem.tsx +++ b/client-html/src/js/containers/preferences/containers/tutor-roles/components/PayRateItem.tsx @@ -10,13 +10,8 @@ import { ClassCostRepetitionType } from "@api/model"; import DeleteIcon from "@mui/icons-material/Delete"; import { Card, Grid, IconButton } from "@mui/material"; import Tooltip from "@mui/material/Tooltip"; -import { - formatFieldPercent, - mapSelectItems, - parseFieldPercent, - preventNegativeOrLogEnter, - YYYY_MM_DD_MINUSED -} from "ish-ui"; +import { Decimal } from "decimal.js-light"; +import { decimalMul, mapSelectItems, YYYY_MM_DD_MINUSED } from "ish-ui"; import React from "react"; import FormField from "../../../../../common/components/form/formFields/FormField"; import { valiadateSelectItemAvailable } from "../../../../../common/utils/validation"; @@ -27,8 +22,12 @@ const validateRepetition = val => valiadateSelectItemAvailable(val, repetitionTy const validatePercentage = value => (!value && value !== 0 ? "Field is mandatory" : undefined); +const parseFieldPercent = val => val && val > 0 ? new Decimal(val).div(100).toDecimalPlaces(4).toNumber() : 0; + +const formatFieldPercent = val => decimalMul(val, 100); + const PayRateItem = props => { - const {fields, onDelete} = props; + const { fields, onDelete } = props; return fields.map((item, index) => ( @@ -68,9 +67,7 @@ const PayRateItem = props => { step="0.01" format={formatFieldPercent} parse={parseFieldPercent} - onKeyPress={preventNegativeOrLogEnter} validate={validatePercentage} - debounced={false} />