From 489ef3df0d3034c7fa0e4a3f1c9dbb8ebf8809e1 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Tue, 22 Sep 2020 10:10:43 -0700 Subject: [PATCH] Replaced appropriate number fields with calculator field. BOD-398 --- .../contract-form/contract-form.component.jsx | 10 +-- .../courtesy-car-form.component.jsx | 4 +- ...form-input-number-calculator.component.jsx | 39 ++++++------ .../job-scoreboard-add-button.component.jsx | 7 ++- .../jobs-create-jobs-info.component.jsx | 61 ++++++++++--------- .../jobs-detail-general.component.jsx | 7 ++- .../scoreboard-entry-edit.component.jsx | 12 ++-- .../shop-info/shop-info.component.jsx | 13 ++-- .../tech-job-clock-out-button.component.jsx | 56 ++++++++--------- .../time-ticket-modal.component.jsx | 7 ++- .../vendors-form/vendors-form.component.jsx | 9 +-- 11 files changed, 116 insertions(+), 109 deletions(-) diff --git a/client/src/components/contract-form/contract-form.component.jsx b/client/src/components/contract-form/contract-form.component.jsx index cf5ad03f5..bfc4c55b5 100644 --- a/client/src/components/contract-form/contract-form.component.jsx +++ b/client/src/components/contract-form/contract-form.component.jsx @@ -6,6 +6,8 @@ import FormDatePicker from "../form-date-picker/form-date-picker.component"; import FormFieldsChanged from "../form-fields-changed-alert/form-fields-changed-alert.component"; import InputPhone from "../form-items-formatted/phone-form-item.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; +import InputNumberCalculator from "../form-input-number-calculator/form-input-number-calculator.component"; + export default function ContractFormComponent({ form, create = false }) { const { t } = useTranslation(); return ( @@ -298,16 +300,16 @@ export default function ContractFormComponent({ form, create = false }) { - + - + - + - + diff --git a/client/src/components/courtesy-car-form/courtesy-car-form.component.jsx b/client/src/components/courtesy-car-form/courtesy-car-form.component.jsx index 4c8438bbb..9028503c8 100644 --- a/client/src/components/courtesy-car-form/courtesy-car-form.component.jsx +++ b/client/src/components/courtesy-car-form/courtesy-car-form.component.jsx @@ -7,6 +7,8 @@ import FormDatePicker from "../form-date-picker/form-date-picker.component"; import FormFieldsChanged from "../form-fields-changed-alert/form-fields-changed-alert.component"; import CurrencyInput from "../form-items-formatted/currency-form-item.component"; import LayoutFormRow from "../layout-form-row/layout-form-row.component"; +import InputNumberCalculator from "../form-input-number-calculator/form-input-number-calculator.component"; + export default function CourtesyCarCreateFormComponent({ form, saveLoading }) { const { t } = useTranslation(); return ( @@ -172,7 +174,7 @@ export default function CourtesyCarCreateFormComponent({ form, saveLoading }) { }, ]} > - + { const [value, setValue] = useState(formValue); const [total, setTotal] = useState(0); const [history, setHistory] = useState([]); - const handleChange = (e) => { - const key = e.target.value; - switch (key) { - case "/": - case "*": - case "+": - case "-": - return; - default: - setValue(key); - return; - } - }; + const ref = useRef(null); const handleKeyDown = (e) => { + console.log("e :>> ", e.currentTarget.value); const { key } = e; - let action; switch (key) { case "/": @@ -38,11 +26,13 @@ const FormInputNUmberCalculator = ( action = "="; break; default: + setValue(e.currentTarget.value); return; } - const val = parseFloat(value); setValue(null); + ref.current.blur(); + ref.current.focus(); if (!isNaN(val)) { setHistory([...history, val, action]); } @@ -82,7 +72,12 @@ const FormInputNUmberCalculator = ( } }, 0); setTotal(subTotal); - if (history[history.length - 1] === "=") setValue(subTotal); + if (history[history.length - 1] === "=") { + setValue(subTotal); + ref.current.blur(); + ref.current.focus(); + setHistory([]); + } } }, [history]); @@ -101,13 +96,13 @@ const FormInputNUmberCalculator = ( return (
0}> - setHistory([])} + {...restProps} />
diff --git a/client/src/components/job-scoreboard-add-button/job-scoreboard-add-button.component.jsx b/client/src/components/job-scoreboard-add-button/job-scoreboard-add-button.component.jsx index c01cba278..781f716e0 100644 --- a/client/src/components/job-scoreboard-add-button/job-scoreboard-add-button.component.jsx +++ b/client/src/components/job-scoreboard-add-button/job-scoreboard-add-button.component.jsx @@ -1,11 +1,12 @@ import { useMutation } from "@apollo/react-hooks"; -import { Button, Card, Form, InputNumber, notification, Popover } from "antd"; +import { Button, Card, Form, notification, Popover } from "antd"; import moment from "moment"; import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { logImEXEvent } from "../../firebase/firebase.utils"; import { INSERT_SCOREBOARD_ENTRY } from "../../graphql/scoreboard.queries"; import FormDatePicker from "../form-date-picker/form-date-picker.component"; +import InputNumberCalculator from "../form-input-number-calculator/form-input-number-calculator.component"; export default function ScoreboardAddButton({ job, ...otherBtnProps }) { const { t } = useTranslation(); @@ -68,7 +69,7 @@ export default function ScoreboardAddButton({ job, ...otherBtnProps }) { }, ]} > - +
- + - + ); return ( - + diff --git a/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx b/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx index 2d698a33d..96e228405 100644 --- a/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx +++ b/client/src/components/time-ticket-modal/time-ticket-modal.component.jsx @@ -1,8 +1,9 @@ -import { Form, Input, InputNumber, Select } from "antd"; +import { Form, Input, Select } from "antd"; import React from "react"; import { useTranslation } from "react-i18next"; import EmployeeSearchSelect from "../employee-search-select/employee-search-select.component"; import FormDatePicker from "../form-date-picker/form-date-picker.component"; +import InputNumberCalculator from "../form-input-number-calculator/form-input-number-calculator.component"; import JobSearchSelect from "../job-search-select/job-search-select.component"; import LaborAllocationsTable from "../labor-allocations-table/labor-allocations-table.component"; @@ -77,7 +78,7 @@ export default function TimeTicketModalComponent({ }, ]} > - + - + - + @@ -111,7 +112,7 @@ export default function VendorsFormComponent({ - +