IO-3537 Bill Entry Scroll to Top for Errors
Signed-off-by: Allan Carr <allan@imexsystems.ca>
This commit is contained in:
@@ -2,7 +2,7 @@ import { useApolloClient, useMutation } from "@apollo/client/react";
|
|||||||
import { useTreatmentsWithConfig } from "@splitsoftware/splitio-react";
|
import { useTreatmentsWithConfig } from "@splitsoftware/splitio-react";
|
||||||
import { Button, Checkbox, Form, Modal, Space } from "antd";
|
import { Button, Checkbox, Form, Modal, Space } from "antd";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
@@ -53,6 +53,7 @@ function BillEnterModalContainer({ billEnterModal, toggleModalVisible, bodyshop,
|
|||||||
const client = useApolloClient();
|
const client = useApolloClient();
|
||||||
const [generateLabel, setGenerateLabel] = useLocalStorage("enter_bill_generate_label", false);
|
const [generateLabel, setGenerateLabel] = useLocalStorage("enter_bill_generate_label", false);
|
||||||
const notification = useNotification();
|
const notification = useNotification();
|
||||||
|
const formTopRef = useRef(null);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
treatments: { Enhanced_Payroll, Imgproxy }
|
treatments: { Enhanced_Payroll, Imgproxy }
|
||||||
@@ -447,13 +448,21 @@ function BillEnterModalContainer({ billEnterModal, toggleModalVisible, bodyshop,
|
|||||||
autoComplete={"off"}
|
autoComplete={"off"}
|
||||||
layout="vertical"
|
layout="vertical"
|
||||||
form={form}
|
form={form}
|
||||||
onFinishFailed={() => {
|
onFinishFailed={(errorInfo) => {
|
||||||
setEnterAgain(false);
|
setEnterAgain(false);
|
||||||
|
// Scroll to the top of the form to show validation errors
|
||||||
|
if (errorInfo.errorFields && errorInfo.errorFields.length > 0) {
|
||||||
|
setTimeout(() => {
|
||||||
|
formTopRef.current?.scrollIntoView({ behavior: "smooth", block: "start" });
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<RbacWrapper action="bills:enter">
|
<div ref={formTopRef}>
|
||||||
<BillFormContainer form={form} disableInvNumber={billEnterModal.context.disableInvNumber} />
|
<RbacWrapper action="bills:enter">
|
||||||
</RbacWrapper>
|
<BillFormContainer form={form} disableInvNumber={billEnterModal.context.disableInvNumber} />
|
||||||
|
</RbacWrapper>
|
||||||
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -39,11 +39,13 @@ export default function FormsFieldChanged({ form, skipPrompt }) {
|
|||||||
{errors.length > 0 && (
|
{errors.length > 0 && (
|
||||||
<AlertComponent
|
<AlertComponent
|
||||||
type="error"
|
type="error"
|
||||||
title={
|
message={t("general.labels.validationerror")}
|
||||||
|
description={
|
||||||
<div>
|
<div>
|
||||||
<ul>{errors.map((e, idx) => e.errors.map((e2, idx2) => <li key={`${idx}${idx2}`}>{e2}</li>))}</ul>
|
<ul>{errors.map((e, idx) => e.errors.map((e2, idx2) => <li key={`${idx}${idx2}`}>{e2}</li>))}</ul>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
showIcon
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
|
|||||||
@@ -1367,6 +1367,7 @@
|
|||||||
"unknown": "Unknown",
|
"unknown": "Unknown",
|
||||||
"unsavedchanges": "Unsaved changes.",
|
"unsavedchanges": "Unsaved changes.",
|
||||||
"username": "Username",
|
"username": "Username",
|
||||||
|
"validationerror": "Please fix the following errors:",
|
||||||
"view": "View",
|
"view": "View",
|
||||||
"wednesday": "Wednesday",
|
"wednesday": "Wednesday",
|
||||||
"yes": "Yes"
|
"yes": "Yes"
|
||||||
|
|||||||
@@ -1367,6 +1367,7 @@
|
|||||||
"unknown": "Desconocido",
|
"unknown": "Desconocido",
|
||||||
"unsavedchanges": "",
|
"unsavedchanges": "",
|
||||||
"username": "",
|
"username": "",
|
||||||
|
"validationerror": "",
|
||||||
"view": "",
|
"view": "",
|
||||||
"wednesday": "",
|
"wednesday": "",
|
||||||
"yes": ""
|
"yes": ""
|
||||||
|
|||||||
@@ -1367,6 +1367,7 @@
|
|||||||
"unknown": "Inconnu",
|
"unknown": "Inconnu",
|
||||||
"unsavedchanges": "",
|
"unsavedchanges": "",
|
||||||
"username": "",
|
"username": "",
|
||||||
|
"validationerror": "",
|
||||||
"view": "",
|
"view": "",
|
||||||
"wednesday": "",
|
"wednesday": "",
|
||||||
"yes": ""
|
"yes": ""
|
||||||
|
|||||||
Reference in New Issue
Block a user