IO-1044 Dynamic fields on time ticket modal

This commit is contained in:
Patrick Fic
2021-05-07 15:14:23 -07:00
parent cc541293eb
commit 49c3a512c0
2 changed files with 33 additions and 24 deletions

View File

@@ -34,6 +34,7 @@ export function TimeTicketModalComponent({
bodyshop, bodyshop,
authLevel, authLevel,
employeeAutoCompleteOptions, employeeAutoCompleteOptions,
isEdit,
}) { }) {
const { t } = useTranslation(); const { t } = useTranslation();
@@ -158,28 +159,33 @@ export function TimeTicketModalComponent({
<Form.Item label={t("timetickets.fields.actualhrs")} name="actualhrs"> <Form.Item label={t("timetickets.fields.actualhrs")} name="actualhrs">
<InputNumber min={0} precision={1} /> <InputNumber min={0} precision={1} />
</Form.Item> </Form.Item>
<Form.Item label={t("timetickets.fields.clockon")} name="clockon"> {isEdit && (
<FormDateTimePicker <>
disabled={ <Form.Item label={t("timetickets.fields.clockon")} name="clockon">
!HasRbacAccess({ <FormDateTimePicker
bodyshop, disabled={
authLevel, !HasRbacAccess({
action: "timetickets:shiftedit", bodyshop,
}) authLevel,
} action: "timetickets:shiftedit",
/> })
</Form.Item> }
<Form.Item label={t("timetickets.fields.clockoff")} name="clockoff"> />
<FormDateTimePicker </Form.Item>
disabled={ <Form.Item label={t("timetickets.fields.clockoff")} name="clockoff">
!HasRbacAccess({ <FormDateTimePicker
bodyshop, disabled={
authLevel, !HasRbacAccess({
action: "timetickets:shiftedit", bodyshop,
}) authLevel,
} action: "timetickets:shiftedit",
/> })
</Form.Item> }
/>
</Form.Item>
</>
)}
<Form.Item label={t("timetickets.fields.memo")} name="memo"> <Form.Item label={t("timetickets.fields.memo")} name="memo">
<MemoInput /> <MemoInput />
</Form.Item> </Form.Item>

View File

@@ -168,12 +168,13 @@ export function TimeTicketModalContainer({
footer={ footer={
<span> <span>
<Button onClick={handleCancel}>{t("general.actions.cancel")}</Button> <Button onClick={handleCancel}>{t("general.actions.cancel")}</Button>
<Button onClick={() => form.submit()}> <Button loading={loading} onClick={() => form.submit()}>
{t("general.actions.save")} {t("general.actions.save")}
</Button> </Button>
{timeTicketModal.context && timeTicketModal.context.id ? null : ( {timeTicketModal.context && timeTicketModal.context.id ? null : (
<Button <Button
type="primary" type="primary"
loading={loading}
onClick={() => { onClick={() => {
setEnterAgain(true); setEnterAgain(true);
}} }}
@@ -214,12 +215,13 @@ export function TimeTicketModalContainer({
<Button onClick={handleCancel}> <Button onClick={handleCancel}>
{t("general.actions.cancel")} {t("general.actions.cancel")}
</Button> </Button>
<Button onClick={() => form.submit()}> <Button loading={loading} onClick={() => form.submit()}>
{t("general.actions.save")} {t("general.actions.save")}
</Button> </Button>
{timeTicketModal.context && timeTicketModal.context.id ? null : ( {timeTicketModal.context && timeTicketModal.context.id ? null : (
<Button <Button
type="primary" type="primary"
loading={loading}
onClick={() => { onClick={() => {
setEnterAgain(true); setEnterAgain(true);
}} }}
@@ -231,6 +233,7 @@ export function TimeTicketModalContainer({
} }
/> />
<TimeTicketModalComponent <TimeTicketModalComponent
isEdit={timeTicketModal.context.id}
form={form} form={form}
employeeAutoCompleteOptions={ employeeAutoCompleteOptions={
EmployeeAutoCompleteData && EmployeeAutoCompleteData.employees EmployeeAutoCompleteData && EmployeeAutoCompleteData.employees