IO-950 Time Ticket editing fix.

This commit is contained in:
Patrick Fic
2021-04-28 08:45:02 -07:00
parent f4ec377da4
commit 2bda63601a
3 changed files with 76 additions and 88 deletions

View File

@@ -37,6 +37,33 @@ export function TimeTicketModalComponent({
}) {
const { t } = useTranslation();
const CostCenterSelect = ({ emps, value, ...props }) => {
return (
<Select
value={value === "timetickets.labels.shift" ? t(value) : value}
{...props}
disabled={value === "timetickets.labels.shift"}
>
{emps &&
emps.rates.map((item) => (
<Select.Option key={item.cost_center}>
{item.cost_center}
</Select.Option>
))}
</Select>
);
};
const MemoInput = ({ value, ...props }) => {
return (
<Input
value={value?.startsWith("timetickets.") ? t(value) : value}
{...props}
disabled={value?.startsWith("timetickets.")}
/>
);
};
return (
<div>
<LayoutFormRow grow noDivider>
@@ -102,14 +129,7 @@ export function TimeTicketModalComponent({
},
]}
>
<Select>
{emps &&
emps.rates.map((item) => (
<Select.Option key={item.cost_center}>
{item.cost_center}
</Select.Option>
))}
</Select>
<CostCenterSelect emps={emps} />
</Form.Item>
);
}}
@@ -117,17 +137,23 @@ export function TimeTicketModalComponent({
</LayoutFormRow>
<LayoutFormRow>
<Form.Item
label={t("timetickets.fields.productivehrs")}
name="productivehrs"
rules={[
{
required: true,
message: t("general.validation.required"),
},
]}
>
<InputNumber min={0} precision={1} />
<Form.Item shouldUpdate>
{() => (
<Form.Item
label={t("timetickets.fields.productivehrs")}
name="productivehrs"
rules={[
{
required:
form.getFieldValue("cost_center") !==
"timetickets.labels.shift",
message: t("general.validation.required"),
},
]}
>
<InputNumber min={0} precision={1} />
</Form.Item>
)}
</Form.Item>
<Form.Item label={t("timetickets.fields.actualhrs")} name="actualhrs">
<InputNumber min={0} precision={1} />
@@ -155,7 +181,7 @@ export function TimeTicketModalComponent({
/>
</Form.Item>
<Form.Item label={t("timetickets.fields.memo")} name="memo">
<Input />
<MemoInput />
</Form.Item>
<Form.Item shouldUpdate>
{() => (

View File

@@ -54,7 +54,7 @@ export function TimeTicketModalContainer({
emps.length === 1
? emps[0].rates.filter(
(r) => r.cost_center === values.cost_center
)[0].rate
)[0]?.rate
: null,
},
},
@@ -205,7 +205,7 @@ export function TimeTicketModalContainer({
timeTicketModal.context.timeticket.jobid ||
null,
date: timeTicketModal.context.timeticket.date
? moment(timeTicketModal.context.date)
? moment(timeTicketModal.context.timeticket.date)
: null,
}
: { jobid: timeTicketModal.context.jobId || null }