Merged in release/2025-12-19 (pull request #2759)
feature/IO-2566-2567-Time-Tickets-Caching - Fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useLazyQuery } from "@apollo/client";
|
||||
import { useTreatmentsWithConfig } from "@splitsoftware/splitio-react";
|
||||
import { Card, Form, Input, InputNumber, Select, Space, Switch } from "antd";
|
||||
import { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -34,7 +35,9 @@ export function TimeTicketModalComponent({
|
||||
authLevel,
|
||||
employeeAutoCompleteOptions,
|
||||
disabled,
|
||||
employeeSelectDisabled
|
||||
employeeSelectDisabled,
|
||||
lineTicketRefreshKey,
|
||||
isOpen
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const {
|
||||
@@ -49,6 +52,18 @@ export function TimeTicketModalComponent({
|
||||
fetchPolicy: "network-only",
|
||||
nextFetchPolicy: "network-only"
|
||||
});
|
||||
|
||||
// Watch the jobid field so we can refetch the bottom section without relying on jobid changes
|
||||
const watchedJobId = Form.useWatch("jobid", form);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isOpen) return;
|
||||
if (!watchedJobId) return;
|
||||
if (!lineTicketRefreshKey) return;
|
||||
|
||||
loadLineTicketData({ variables: { id: watchedJobId } });
|
||||
}, [lineTicketRefreshKey, watchedJobId, isOpen]);
|
||||
|
||||
const CostCenterSelect = ({ emps, value, ...props }) => {
|
||||
return (
|
||||
<Select
|
||||
@@ -307,6 +322,7 @@ export function TimeTicketModalComponent({
|
||||
)}
|
||||
</Form.Item>
|
||||
</LayoutFormRow>
|
||||
|
||||
<Form.Item dependencies={["jobid"]}>
|
||||
{() => {
|
||||
const jobid = form.getFieldValue("jobid");
|
||||
|
||||
@@ -29,6 +29,9 @@ export function TimeTicketModalContainer({ timeTicketModal, toggleModalVisible,
|
||||
const [loading, setLoading] = useState(false);
|
||||
const { t } = useTranslation();
|
||||
const [enterAgain, setEnterAgain] = useState(false);
|
||||
|
||||
const [lineTicketRefreshKey, setLineTicketRefreshKey] = useState(0);
|
||||
|
||||
const [insertTicket] = useMutation(INSERT_NEW_TIME_TICKET);
|
||||
const [updateTicket] = useMutation(UPDATE_TIME_TICKET);
|
||||
const {
|
||||
@@ -85,11 +88,17 @@ export function TimeTicketModalContainer({ timeTicketModal, toggleModalVisible,
|
||||
notification["success"]({
|
||||
message: t("timetickets.successes.created")
|
||||
});
|
||||
if (timeTicketModal.actions.refetch) timeTicketModal.actions.refetch();
|
||||
if (enterAgain) {
|
||||
//Capture the existing information and repopulate it.
|
||||
|
||||
const prev = form.getFieldsValue(["date", "employeeid", "flat_rate"]);
|
||||
// Refresh parent screens (Job Labor tab, etc.)
|
||||
if (timeTicketModal.actions.refetch) timeTicketModal.actions.refetch();
|
||||
|
||||
// Refresh the modal "bottom section" (allocations + embedded ticket list) for the current job
|
||||
setLineTicketRefreshKey((k) => k + 1);
|
||||
|
||||
if (enterAgain) {
|
||||
// Capture existing information and repopulate it.
|
||||
// (Include jobid so Save & New stays on the same RO if it was selected in-form.)
|
||||
const prev = form.getFieldsValue(["jobid", "date", "employeeid", "flat_rate"]);
|
||||
|
||||
form.resetFields();
|
||||
|
||||
@@ -232,6 +241,7 @@ export function TimeTicketModalContainer({ timeTicketModal, toggleModalVisible,
|
||||
</Space>
|
||||
}
|
||||
/>
|
||||
|
||||
<TimeTicketModalComponent
|
||||
isEdit={timeTicketModal.context.id}
|
||||
form={form}
|
||||
@@ -241,6 +251,8 @@ export function TimeTicketModalContainer({ timeTicketModal, toggleModalVisible,
|
||||
timeTicketModal.context?.timeticket?.committed_at ||
|
||||
(timeTicketModal.context?.timeticket?.employeeid && !timeTicketModal.context.id ? true : false)
|
||||
}
|
||||
lineTicketRefreshKey={lineTicketRefreshKey}
|
||||
isOpen={timeTicketModal.open}
|
||||
/>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user