mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
Fix: FloatingActions.
This commit is contained in:
@@ -1,52 +1,97 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Intent, Button } from '@blueprintjs/core';
|
import {
|
||||||
|
Intent,
|
||||||
|
Button,
|
||||||
|
ButtonGroup,
|
||||||
|
Popover,
|
||||||
|
PopoverInteractionKind,
|
||||||
|
Position,
|
||||||
|
Menu,
|
||||||
|
MenuItem,
|
||||||
|
} from '@blueprintjs/core';
|
||||||
import { FormattedMessage as T } from 'react-intl';
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
|
import { useFormikContext } from 'formik';
|
||||||
import { saveInvoke } from 'utils';
|
import { saveInvoke } from 'utils';
|
||||||
|
import { Icon } from 'components';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Customer floating actions bar.
|
||||||
|
*/
|
||||||
export default function CustomerFloatingActions({
|
export default function CustomerFloatingActions({
|
||||||
onSubmitClick,
|
onSubmitClick,
|
||||||
onSubmitAndNewClick,
|
|
||||||
onCancelClick,
|
onCancelClick,
|
||||||
|
|
||||||
isSubmitting,
|
isSubmitting,
|
||||||
customerId,
|
customerId,
|
||||||
}) {
|
}) {
|
||||||
|
const { resetForm, submitForm } = useFormikContext();
|
||||||
|
|
||||||
|
const handleSubmitBtnClick = (event) => {
|
||||||
|
saveInvoke(onSubmitClick, event, {
|
||||||
|
noRedirect: false,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCancelBtnClick = (event) => {
|
||||||
|
saveInvoke(onCancelClick, event);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClearBtnClick = (event) => {
|
||||||
|
// saveInvoke(onClearClick, event);
|
||||||
|
resetForm();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmitAndNewClick = (event) => {
|
||||||
|
submitForm();
|
||||||
|
saveInvoke(onSubmitClick, event, {
|
||||||
|
noRedirect: true,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||||
<Button
|
<ButtonGroup>
|
||||||
disabled={isSubmitting}
|
{/* ----------- Save and New ----------- */}
|
||||||
intent={Intent.PRIMARY}
|
<Button
|
||||||
type="submit"
|
disabled={isSubmitting}
|
||||||
onClick={(event) => {
|
intent={Intent.PRIMARY}
|
||||||
saveInvoke(onSubmitClick, event);
|
type="submit"
|
||||||
}}
|
onClick={handleSubmitBtnClick}
|
||||||
>
|
text={customerId ? <T id={'edit'} /> : <T id={'save'} />}
|
||||||
{customerId ? <T id={'edit'} /> : <T id={'save'} />}
|
/>
|
||||||
</Button>
|
<Popover
|
||||||
|
content={
|
||||||
<Button
|
<Menu>
|
||||||
disabled={isSubmitting}
|
<MenuItem
|
||||||
intent={Intent.PRIMARY}
|
text={<T id={'save_and_new'} />}
|
||||||
className={'ml1'}
|
onClick={handleSubmitAndNewClick}
|
||||||
name={'save_and_new'}
|
/>
|
||||||
type="submit"
|
</Menu>
|
||||||
onClick={(event) => {
|
}
|
||||||
saveInvoke(onSubmitAndNewClick, event);
|
minimal={true}
|
||||||
}}
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
>
|
position={Position.BOTTOM_LEFT}
|
||||||
<T id={'save_new'} />
|
>
|
||||||
</Button>
|
<Button
|
||||||
|
intent={Intent.PRIMARY}
|
||||||
<Button
|
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||||
className={'ml1'}
|
/>
|
||||||
onClick={(event) => {
|
</Popover>
|
||||||
saveInvoke(onCancelClick, event);
|
{/* ----------- Clear & Reset----------- */}
|
||||||
}}
|
<Button
|
||||||
>
|
className={'ml1'}
|
||||||
<T id={'close'} />
|
disabled={isSubmitting}
|
||||||
</Button>
|
onClick={handleClearBtnClick}
|
||||||
|
text={customerId ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||||
|
/>
|
||||||
|
{/* ----------- Cancel ----------- */}
|
||||||
|
<Button
|
||||||
|
className={'ml1'}
|
||||||
|
onClick={handleCancelBtnClick}
|
||||||
|
text={<T id={'cancel'} />}
|
||||||
|
/>
|
||||||
|
</ButtonGroup>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -229,13 +229,19 @@ function CustomerForm({
|
|||||||
[setDeletedFiles, deletedFiles],
|
[setDeletedFiles, deletedFiles],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleCancelClick = () => {
|
const handleCancelClick = useCallback(
|
||||||
history.goBack();
|
(event) => {
|
||||||
};
|
history.goBack();
|
||||||
|
},
|
||||||
|
[history],
|
||||||
|
);
|
||||||
|
|
||||||
const handleSubmitAndNewClick = () => {
|
const handleSubmitClick = useCallback(
|
||||||
setSubmitPayload({ noRedirect: true });
|
(event, payload) => {
|
||||||
};
|
setSubmitPayload({ ...payload });
|
||||||
|
},
|
||||||
|
[setSubmitPayload],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM, CLASSES.PAGE_FORM_CUSTOMER)}>
|
<div className={classNames(CLASSES.PAGE_FORM, CLASSES.PAGE_FORM_CUSTOMER)}>
|
||||||
@@ -261,8 +267,8 @@ function CustomerForm({
|
|||||||
<CustomerFloatingActions
|
<CustomerFloatingActions
|
||||||
isSubmitting={isSubmitting}
|
isSubmitting={isSubmitting}
|
||||||
customerId={customer}
|
customerId={customer}
|
||||||
|
onSubmitClick={handleSubmitClick}
|
||||||
onCancelClick={handleCancelClick}
|
onCancelClick={handleCancelClick}
|
||||||
onSubmitAndNewClick={handleSubmitAndNewClick}
|
|
||||||
/>
|
/>
|
||||||
</Form>
|
</Form>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,18 +1,37 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Intent, Button } from '@blueprintjs/core';
|
import {
|
||||||
|
Intent,
|
||||||
|
Button,
|
||||||
|
ButtonGroup,
|
||||||
|
Popover,
|
||||||
|
PopoverInteractionKind,
|
||||||
|
Position,
|
||||||
|
Menu,
|
||||||
|
MenuItem,
|
||||||
|
} from '@blueprintjs/core';
|
||||||
import { FormattedMessage as T } from 'react-intl';
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
|
import { CLASSES } from 'common/classes';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import { useFormikContext } from 'formik';
|
||||||
import { saveInvoke } from 'utils';
|
import { saveInvoke } from 'utils';
|
||||||
|
import { Icon } from 'components';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Estimate floating actions bar.
|
||||||
|
*/
|
||||||
export default function EstimateFloatingActions({
|
export default function EstimateFloatingActions({
|
||||||
isSubmitting,
|
isSubmitting,
|
||||||
onSubmitClick,
|
onSubmitClick,
|
||||||
onCancelClick,
|
onCancelClick,
|
||||||
onClearClick,
|
onClearClick,
|
||||||
onSubmitAndNewClick,
|
|
||||||
estimateId,
|
estimateId,
|
||||||
}) {
|
}) {
|
||||||
|
const { resetForm, submitForm } = useFormikContext();
|
||||||
|
|
||||||
const handleSubmitBtnClick = (event) => {
|
const handleSubmitBtnClick = (event) => {
|
||||||
saveInvoke(onSubmitClick, event);
|
saveInvoke(onSubmitClick, event, {
|
||||||
|
redirect: true,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancelBtnClick = (event) => {
|
const handleCancelBtnClick = (event) => {
|
||||||
@@ -20,49 +39,60 @@ export default function EstimateFloatingActions({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleClearBtnClick = (event) => {
|
const handleClearBtnClick = (event) => {
|
||||||
saveInvoke(onClearClick, event);
|
// saveInvoke(onClearClick, event);
|
||||||
|
resetForm();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmitAndNewClick = (event) => {
|
const handleSubmitAndNewClick = (event) => {
|
||||||
saveInvoke(onSubmitAndNewClick, event);
|
submitForm();
|
||||||
}
|
saveInvoke(onSubmitClick, event, {
|
||||||
|
redirect: false,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={'form__floating-footer'}>
|
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||||
<Button
|
<ButtonGroup>
|
||||||
disabled={isSubmitting}
|
{/* ----------- Save and New ----------- */}
|
||||||
intent={Intent.PRIMARY}
|
<Button
|
||||||
type="submit"
|
disabled={isSubmitting}
|
||||||
onClick={handleSubmitBtnClick}
|
intent={Intent.PRIMARY}
|
||||||
>
|
type="submit"
|
||||||
{(estimateId) ? <T id={'edit'} /> : <T id={'save'} />}
|
onClick={handleSubmitBtnClick}
|
||||||
</Button>
|
text={estimateId ? <T id={'edit'} /> : <T id={'save'} />}
|
||||||
|
/>
|
||||||
<Button
|
<Popover
|
||||||
disabled={isSubmitting}
|
content={
|
||||||
intent={Intent.PRIMARY}
|
<Menu>
|
||||||
className={'ml1'}
|
<MenuItem
|
||||||
type="submit"
|
text={<T id={'save_and_new'} />}
|
||||||
onClick={handleSubmitAndNewClick}
|
onClick={handleSubmitAndNewClick}
|
||||||
>
|
/>
|
||||||
<T id={'save_new'} />
|
</Menu>
|
||||||
</Button>
|
}
|
||||||
|
minimal={true}
|
||||||
<Button
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
className={'ml1'}
|
position={Position.BOTTOM_LEFT}
|
||||||
disabled={isSubmitting}
|
>
|
||||||
onClick={handleClearBtnClick}
|
<Button
|
||||||
>
|
intent={Intent.PRIMARY}
|
||||||
<T id={'clear'} />
|
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||||
</Button>
|
/>
|
||||||
|
</Popover>
|
||||||
<Button
|
{/* ----------- Clear & Reset----------- */}
|
||||||
className={'ml1'}
|
<Button
|
||||||
type="submit"
|
className={'ml1'}
|
||||||
onClick={handleCancelBtnClick}
|
disabled={isSubmitting}
|
||||||
>
|
onClick={handleClearBtnClick}
|
||||||
<T id={'close'} />
|
text={estimateId ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||||
</Button>
|
/>
|
||||||
|
{/* ----------- Cancel ----------- */}
|
||||||
|
<Button
|
||||||
|
className={'ml1'}
|
||||||
|
onClick={handleCancelBtnClick}
|
||||||
|
text={<T id={'cancel'} />}
|
||||||
|
/>
|
||||||
|
</ButtonGroup>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,13 +216,19 @@ const EstimateForm = ({
|
|||||||
[changePageSubtitle],
|
[changePageSubtitle],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleSubmitClick = useCallback((event) => {
|
const handleSubmitClick = useCallback(
|
||||||
setSubmitPayload({ redirect: true });
|
(event, payload) => {
|
||||||
}, [setSubmitPayload]);
|
setSubmitPayload({ ...payload });
|
||||||
|
},
|
||||||
|
[setSubmitPayload],
|
||||||
|
);
|
||||||
|
|
||||||
const handleCancelClick = useCallback((event) => {
|
const handleCancelClick = useCallback(
|
||||||
history.goBack();
|
(event) => {
|
||||||
}, [history]);
|
history.goBack();
|
||||||
|
},
|
||||||
|
[history],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM, CLASSES.PAGE_FORM_ESTIMATE)}>
|
<div className={classNames(CLASSES.PAGE_FORM, CLASSES.PAGE_FORM_ESTIMATE)}>
|
||||||
@@ -238,15 +244,16 @@ const EstimateForm = ({
|
|||||||
<EstimateFormHeader
|
<EstimateFormHeader
|
||||||
onEstimateNumberChanged={handleEstimateNumberChange}
|
onEstimateNumberChanged={handleEstimateNumberChange}
|
||||||
/>
|
/>
|
||||||
<EstimateNumberWatcher estimateNumber={estimateNumber} />
|
<EstimateNumberWatcher estimateNumber={estimateNumber} />
|
||||||
<EditableItemsEntriesTable />
|
<EditableItemsEntriesTable />
|
||||||
<EstimateFormFooter />
|
<EstimateFormFooter />
|
||||||
<EstimateFloatingActions
|
<EstimateFloatingActions
|
||||||
isSubmiting={isSubmitting}
|
isSubmitting={isSubmitting}
|
||||||
estimateId={estimateId}
|
estimateId={estimateId}
|
||||||
onSubmitClick={handleSubmitClick}
|
onSubmitClick={handleSubmitClick}
|
||||||
onCancelClick={handleCancelClick}
|
onCancelClick={handleCancelClick}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</Form>
|
</Form>
|
||||||
)}
|
)}
|
||||||
</Formik>
|
</Formik>
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ import classNames from 'classnames';
|
|||||||
import { saveInvoke } from 'utils';
|
import { saveInvoke } from 'utils';
|
||||||
import { Icon } from 'components';
|
import { Icon } from 'components';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invoice floating actions bar.
|
||||||
|
*/
|
||||||
export default function InvoiceFloatingActions({
|
export default function InvoiceFloatingActions({
|
||||||
isSubmitting,
|
isSubmitting,
|
||||||
onSubmitClick,
|
onSubmitClick,
|
||||||
@@ -106,6 +110,7 @@ export default function InvoiceFloatingActions({
|
|||||||
/>
|
/>
|
||||||
</Menu>
|
</Menu>
|
||||||
}
|
}
|
||||||
|
minimal={true}
|
||||||
interactionKind={PopoverInteractionKind.CLICK}
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
position={Position.BOTTOM_LEFT}
|
position={Position.BOTTOM_LEFT}
|
||||||
>
|
>
|
||||||
@@ -141,6 +146,7 @@ export default function InvoiceFloatingActions({
|
|||||||
/>
|
/>
|
||||||
</Menu>
|
</Menu>
|
||||||
}
|
}
|
||||||
|
minimal={true}
|
||||||
interactionKind={PopoverInteractionKind.CLICK}
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
position={Position.BOTTOM_LEFT}
|
position={Position.BOTTOM_LEFT}
|
||||||
>
|
>
|
||||||
@@ -159,7 +165,6 @@ export default function InvoiceFloatingActions({
|
|||||||
{/* ----------- Cancel ----------- */}
|
{/* ----------- Cancel ----------- */}
|
||||||
<Button
|
<Button
|
||||||
className={'ml1'}
|
className={'ml1'}
|
||||||
type="submit"
|
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
saveInvoke(onCancelClick, event);
|
saveInvoke(onCancelClick, event);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ const defaultInitialValues = {
|
|||||||
/**
|
/**
|
||||||
* Receipt form.
|
* Receipt form.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function ReceiptForm({
|
function ReceiptForm({
|
||||||
//#withMedia
|
//#withMedia
|
||||||
requestSubmitMedia,
|
requestSubmitMedia,
|
||||||
@@ -218,17 +217,19 @@ function ReceiptForm({
|
|||||||
[changePageSubtitle],
|
[changePageSubtitle],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleSubmitClick = (event) => {
|
const handleSubmitClick = useCallback(
|
||||||
setSubmitPayload({ redirect: true });
|
(event, payload) => {
|
||||||
};
|
setSubmitPayload({ ...payload });
|
||||||
|
},
|
||||||
|
[setSubmitPayload],
|
||||||
|
);
|
||||||
|
|
||||||
const handleSubmitAndNewClick = (event) => {
|
const handleCancelClick = useCallback(
|
||||||
setSubmitPayload({ redirect: false });
|
(event) => {
|
||||||
};
|
history.goBack();
|
||||||
|
},
|
||||||
const handleCancelClick = (event) => {
|
[history],
|
||||||
history.goBack();
|
);
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_RECEIPT, CLASSES.PAGE_FORM)}>
|
<div className={classNames(CLASSES.PAGE_FORM_RECEIPT, CLASSES.PAGE_FORM)}>
|
||||||
@@ -239,20 +240,22 @@ function ReceiptForm({
|
|||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
onSubmit={handleFormSubmit}
|
onSubmit={handleFormSubmit}
|
||||||
>
|
>
|
||||||
<Form>
|
{({ isSubmitting }) => (
|
||||||
<ReceiptFromHeader
|
<Form>
|
||||||
onReceiptNumberChanged={handleReceiptNumberChanged}
|
<ReceiptFromHeader
|
||||||
/>
|
onReceiptNumberChanged={handleReceiptNumberChanged}
|
||||||
<ReceiptNumberWatcher receiptNumber={receiptNumber} />
|
/>
|
||||||
<EditableItemsEntriesTable />
|
<ReceiptNumberWatcher receiptNumber={receiptNumber} />
|
||||||
<ReceiptFormFooter />
|
<EditableItemsEntriesTable />
|
||||||
<ReceiptFormFloatingActions
|
<ReceiptFormFooter />
|
||||||
receiptId={receiptId}
|
<ReceiptFormFloatingActions
|
||||||
onSubmitClick={handleSubmitClick}
|
isSubmitting={isSubmitting}
|
||||||
onSubmitAndNewClick={handleSubmitAndNewClick}
|
receiptId={receiptId}
|
||||||
onCancelForm={handleCancelClick}
|
onSubmitClick={handleSubmitClick}
|
||||||
/>
|
onCancelClick={handleCancelClick}
|
||||||
</Form>
|
/>
|
||||||
|
</Form>
|
||||||
|
)}
|
||||||
</Formik>
|
</Formik>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,63 +1,99 @@
|
|||||||
import React from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { Intent, Button } from '@blueprintjs/core';
|
import {
|
||||||
|
Intent,
|
||||||
|
Button,
|
||||||
|
ButtonGroup,
|
||||||
|
Popover,
|
||||||
|
PopoverInteractionKind,
|
||||||
|
Position,
|
||||||
|
Menu,
|
||||||
|
MenuItem,
|
||||||
|
} from '@blueprintjs/core';
|
||||||
import { FormattedMessage as T } from 'react-intl';
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
import { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
import { saveInvoke } from 'utils';
|
import { saveInvoke } from 'utils';
|
||||||
|
import { Icon } from 'components';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receipt floating actions bar.
|
||||||
|
*/
|
||||||
export default function ReceiptFormFloatingActions({
|
export default function ReceiptFormFloatingActions({
|
||||||
isSubmitting,
|
isSubmitting,
|
||||||
receiptId,
|
receiptId,
|
||||||
onSubmitClick,
|
onSubmitClick,
|
||||||
onCancelClick,
|
onCancelClick,
|
||||||
onClearClick,
|
onClearClick,
|
||||||
onSubmitAndNewClick,
|
|
||||||
}) {
|
}) {
|
||||||
const { resetForm } = useFormikContext();
|
const { resetForm, submitForm } = useFormikContext();
|
||||||
|
|
||||||
|
const handleSubmitAndNewClick = useCallback(
|
||||||
|
(event) => {
|
||||||
|
submitForm();
|
||||||
|
saveInvoke(onSubmitClick, event, {
|
||||||
|
redirect: false,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[submitForm],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleCancelBtnClick = (event) => {
|
||||||
|
saveInvoke(onCancelClick, event);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClearBtnClick = (event) => {
|
||||||
|
// saveInvoke(onClearClick, event);
|
||||||
|
resetForm();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||||
<Button
|
<ButtonGroup>
|
||||||
disabled={isSubmitting}
|
{/* ----------- Save and New ----------- */}
|
||||||
intent={Intent.PRIMARY}
|
<Button
|
||||||
type="submit"
|
disabled={isSubmitting}
|
||||||
onClick={(event) => {
|
intent={Intent.PRIMARY}
|
||||||
saveInvoke(onSubmitClick, event);
|
type="submit"
|
||||||
}}
|
onClick={(event) => {
|
||||||
>
|
saveInvoke(onSubmitClick, event, {
|
||||||
{receiptId ? <T id={'edit'} /> : <T id={'save'} />}
|
redirect: true,
|
||||||
</Button>
|
});
|
||||||
|
}}
|
||||||
<Button
|
text={receiptId ? <T id={'edit'} /> : <T id={'save'} />}
|
||||||
disabled={isSubmitting}
|
/>
|
||||||
intent={Intent.PRIMARY}
|
<Popover
|
||||||
className={'ml1'}
|
content={
|
||||||
name={'save'}
|
<Menu>
|
||||||
type="submit"
|
<MenuItem
|
||||||
onClick={(event) => {
|
text={<T id={'save_and_new'} />}
|
||||||
saveInvoke(onSubmitAndNewClick, event);
|
onClick={handleSubmitAndNewClick}
|
||||||
}}
|
/>
|
||||||
>
|
</Menu>
|
||||||
<T id={'save_new'} />
|
}
|
||||||
</Button>
|
minimal={true}
|
||||||
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
<Button
|
position={Position.BOTTOM_LEFT}
|
||||||
className={'ml1'}
|
>
|
||||||
disabled={isSubmitting}
|
<Button
|
||||||
onClick={(event) => {
|
intent={Intent.PRIMARY}
|
||||||
resetForm();
|
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||||
saveInvoke(onClearClick, event);
|
/>
|
||||||
}}
|
</Popover>
|
||||||
>
|
{/* ----------- Clear & Reset----------- */}
|
||||||
<T id={'clear'} />
|
<Button
|
||||||
</Button>
|
className={'ml1'}
|
||||||
|
disabled={isSubmitting}
|
||||||
<Button className={'ml1'} onClick={(event) => {
|
onClick={handleClearBtnClick}
|
||||||
saveInvoke(onCancelClick, event);
|
text={receiptId ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||||
}}>
|
/>
|
||||||
<T id={'close'} />
|
{/* ----------- Cancel ----------- */}
|
||||||
</Button>
|
<Button
|
||||||
|
className={'ml1'}
|
||||||
|
onClick={handleCancelBtnClick}
|
||||||
|
text={<T id={'cancel'} />}
|
||||||
|
/>
|
||||||
|
</ButtonGroup>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,24 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Intent, Button } from '@blueprintjs/core';
|
import {
|
||||||
|
Intent,
|
||||||
|
Button,
|
||||||
|
ButtonGroup,
|
||||||
|
Popover,
|
||||||
|
PopoverInteractionKind,
|
||||||
|
Position,
|
||||||
|
Menu,
|
||||||
|
MenuItem,
|
||||||
|
} from '@blueprintjs/core';
|
||||||
import { FormattedMessage as T } from 'react-intl';
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
|
import { useFormikContext } from 'formik';
|
||||||
import { saveInvoke } from 'utils';
|
import { saveInvoke } from 'utils';
|
||||||
|
import { Icon } from 'components';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vendor floating actions bar.
|
||||||
|
*/
|
||||||
export default function VendorFloatingActions({
|
export default function VendorFloatingActions({
|
||||||
onSubmitClick,
|
onSubmitClick,
|
||||||
onSubmitAndNewClick,
|
onSubmitAndNewClick,
|
||||||
@@ -13,38 +26,73 @@ export default function VendorFloatingActions({
|
|||||||
isSubmitting,
|
isSubmitting,
|
||||||
vendor,
|
vendor,
|
||||||
}) {
|
}) {
|
||||||
|
const { resetForm, submitForm } = useFormikContext();
|
||||||
|
|
||||||
|
const handleSubmitBtnClick = (event) => {
|
||||||
|
saveInvoke(onSubmitClick, event, {
|
||||||
|
noRedirect: false,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleCancelBtnClick = (event) => {
|
||||||
|
saveInvoke(onCancelClick, event);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleClearBtnClick = (event) => {
|
||||||
|
// saveInvoke(onClearClick, event);
|
||||||
|
resetForm();
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmitAndNewClick = (event) => {
|
||||||
|
submitForm();
|
||||||
|
saveInvoke(onSubmitClick, event, {
|
||||||
|
noRedirect: true,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||||
<Button
|
<ButtonGroup>
|
||||||
disabled={isSubmitting}
|
{/* ----------- Save and New ----------- */}
|
||||||
intent={Intent.PRIMARY}
|
<Button
|
||||||
type="submit"
|
disabled={isSubmitting}
|
||||||
onClick={(event) => {
|
intent={Intent.PRIMARY}
|
||||||
saveInvoke(onSubmitClick, event);
|
type="submit"
|
||||||
}}
|
onClick={handleSubmitBtnClick}
|
||||||
>
|
text={vendor ? <T id={'edit'} /> : <T id={'save'} />}
|
||||||
{vendor ? <T id={'edit'} /> : <T id={'save'} />}
|
/>
|
||||||
</Button>
|
<Popover
|
||||||
<Button
|
content={
|
||||||
disabled={isSubmitting}
|
<Menu>
|
||||||
intent={Intent.PRIMARY}
|
<MenuItem
|
||||||
className={'ml1'}
|
text={<T id={'save_and_new'} />}
|
||||||
name={'save_and_new'}
|
onClick={handleSubmitAndNewClick}
|
||||||
type="submit"
|
/>
|
||||||
onClick={(event) => {
|
</Menu>
|
||||||
saveInvoke(onSubmitAndNewClick, event);
|
}
|
||||||
}}
|
minimal={true}
|
||||||
>
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
<T id={'save_new'} />
|
position={Position.BOTTOM_LEFT}
|
||||||
</Button>
|
>
|
||||||
<Button
|
<Button
|
||||||
className={'ml1'}
|
intent={Intent.PRIMARY}
|
||||||
onClick={(event) => {
|
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||||
saveInvoke(onCancelClick, event);
|
/>
|
||||||
}}
|
</Popover>
|
||||||
>
|
{/* ----------- Clear & Reset----------- */}
|
||||||
<T id={'close'} />
|
<Button
|
||||||
</Button>
|
className={'ml1'}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
onClick={handleClearBtnClick}
|
||||||
|
text={vendor ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||||
|
/>
|
||||||
|
{/* ----------- Cancel ----------- */}
|
||||||
|
<Button
|
||||||
|
className={'ml1'}
|
||||||
|
onClick={handleCancelBtnClick}
|
||||||
|
text={<T id={'cancel'} />}
|
||||||
|
/>
|
||||||
|
</ButtonGroup>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,9 +143,12 @@ function VendorForm({
|
|||||||
history.goBack();
|
history.goBack();
|
||||||
}, [history]);
|
}, [history]);
|
||||||
|
|
||||||
const handleSubmitAndNewClick = useCallback(() => {
|
const handleSubmitClick = useCallback(
|
||||||
setSubmitPayload({ noRedirect: true });
|
(event, payload) => {
|
||||||
});
|
setSubmitPayload({ ...payload });
|
||||||
|
},
|
||||||
|
[setSubmitPayload],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM, CLASSES.PAGE_FORM_CUSTOMER)}>
|
<div className={classNames(CLASSES.PAGE_FORM, CLASSES.PAGE_FORM_CUSTOMER)}>
|
||||||
@@ -173,8 +176,8 @@ function VendorForm({
|
|||||||
<VendorFloatingActions
|
<VendorFloatingActions
|
||||||
isSubmitting={isSubmitting}
|
isSubmitting={isSubmitting}
|
||||||
vendor={vendorId}
|
vendor={vendorId}
|
||||||
|
onSubmitClick={handleSubmitClick}
|
||||||
onCancelClick={handleCancelClick}
|
onCancelClick={handleCancelClick}
|
||||||
onSubmitAndNewClick={handleSubmitAndNewClick}
|
|
||||||
/>
|
/>
|
||||||
</Form>
|
</Form>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user