mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
Merge remote-tracking branch 'origin/FloatingAction'
This commit is contained in:
@@ -1,18 +1,37 @@
|
||||
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 { CLASSES } from 'common/classes';
|
||||
import classNames from 'classnames';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { saveInvoke } from 'utils';
|
||||
import { Icon } from 'components';
|
||||
|
||||
/**
|
||||
* Estimate floating actions bar.
|
||||
*/
|
||||
export default function EstimateFloatingActions({
|
||||
isSubmitting,
|
||||
onSubmitClick,
|
||||
onCancelClick,
|
||||
onClearClick,
|
||||
onSubmitAndNewClick,
|
||||
estimateId,
|
||||
}) {
|
||||
const { resetForm, submitForm } = useFormikContext();
|
||||
|
||||
const handleSubmitBtnClick = (event) => {
|
||||
saveInvoke(onSubmitClick, event);
|
||||
saveInvoke(onSubmitClick, event, {
|
||||
redirect: true,
|
||||
});
|
||||
};
|
||||
|
||||
const handleCancelBtnClick = (event) => {
|
||||
@@ -20,49 +39,60 @@ export default function EstimateFloatingActions({
|
||||
};
|
||||
|
||||
const handleClearBtnClick = (event) => {
|
||||
saveInvoke(onClearClick, event);
|
||||
// saveInvoke(onClearClick, event);
|
||||
resetForm();
|
||||
};
|
||||
|
||||
const handleSubmitAndNewClick = (event) => {
|
||||
saveInvoke(onSubmitAndNewClick, event);
|
||||
}
|
||||
submitForm();
|
||||
saveInvoke(onSubmitClick, event, {
|
||||
redirect: false,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={'form__floating-footer'}>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
type="submit"
|
||||
onClick={handleSubmitBtnClick}
|
||||
>
|
||||
{(estimateId) ? <T id={'edit'} /> : <T id={'save'} />}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
className={'ml1'}
|
||||
type="submit"
|
||||
onClick={handleSubmitAndNewClick}
|
||||
>
|
||||
<T id={'save_new'} />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
className={'ml1'}
|
||||
disabled={isSubmitting}
|
||||
onClick={handleClearBtnClick}
|
||||
>
|
||||
<T id={'clear'} />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
className={'ml1'}
|
||||
type="submit"
|
||||
onClick={handleCancelBtnClick}
|
||||
>
|
||||
<T id={'close'} />
|
||||
</Button>
|
||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||
<ButtonGroup>
|
||||
{/* ----------- Save and New ----------- */}
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
type="submit"
|
||||
onClick={handleSubmitBtnClick}
|
||||
text={estimateId ? <T id={'edit'} /> : <T id={'save'} />}
|
||||
/>
|
||||
<Popover
|
||||
content={
|
||||
<Menu>
|
||||
<MenuItem
|
||||
text={<T id={'save_and_new'} />}
|
||||
onClick={handleSubmitAndNewClick}
|
||||
/>
|
||||
</Menu>
|
||||
}
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
<Button
|
||||
intent={Intent.PRIMARY}
|
||||
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||
/>
|
||||
</Popover>
|
||||
{/* ----------- Clear & Reset----------- */}
|
||||
<Button
|
||||
className={'ml1'}
|
||||
disabled={isSubmitting}
|
||||
onClick={handleClearBtnClick}
|
||||
text={estimateId ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||
/>
|
||||
{/* ----------- Cancel ----------- */}
|
||||
<Button
|
||||
className={'ml1'}
|
||||
onClick={handleCancelBtnClick}
|
||||
text={<T id={'cancel'} />}
|
||||
/>
|
||||
</ButtonGroup>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -228,8 +228,8 @@ const EstimateForm = ({
|
||||
);
|
||||
|
||||
const handleSubmitClick = useCallback(
|
||||
(event) => {
|
||||
setSubmitPayload({ redirect: true });
|
||||
(event, payload) => {
|
||||
setSubmitPayload({ ...payload });
|
||||
},
|
||||
[setSubmitPayload],
|
||||
);
|
||||
@@ -259,11 +259,12 @@ const EstimateForm = ({
|
||||
<EditableItemsEntriesTable filterSellableItems={true} />
|
||||
<EstimateFormFooter />
|
||||
<EstimateFloatingActions
|
||||
isSubmiting={isSubmitting}
|
||||
isSubmitting={isSubmitting}
|
||||
estimateId={estimateId}
|
||||
onSubmitClick={handleSubmitClick}
|
||||
onCancelClick={handleCancelClick}
|
||||
/>
|
||||
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
|
||||
@@ -16,6 +16,10 @@ import classNames from 'classnames';
|
||||
import { saveInvoke } from 'utils';
|
||||
import { Icon } from 'components';
|
||||
|
||||
|
||||
/**
|
||||
* Invoice floating actions bar.
|
||||
*/
|
||||
export default function InvoiceFloatingActions({
|
||||
isSubmitting,
|
||||
onSubmitClick,
|
||||
@@ -106,6 +110,7 @@ export default function InvoiceFloatingActions({
|
||||
/>
|
||||
</Menu>
|
||||
}
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
@@ -141,6 +146,7 @@ export default function InvoiceFloatingActions({
|
||||
/>
|
||||
</Menu>
|
||||
}
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
@@ -159,7 +165,6 @@ export default function InvoiceFloatingActions({
|
||||
{/* ----------- Cancel ----------- */}
|
||||
<Button
|
||||
className={'ml1'}
|
||||
type="submit"
|
||||
onClick={(event) => {
|
||||
saveInvoke(onCancelClick, event);
|
||||
}}
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
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 classNames from 'classnames';
|
||||
|
||||
import { CLASSES } from 'common/classes';
|
||||
import { useFormikContext } from 'formik';
|
||||
import { saveInvoke } from 'utils';
|
||||
import { Icon } from 'components';
|
||||
|
||||
/**
|
||||
* Payment receive floating actions bar.
|
||||
@@ -13,53 +24,74 @@ export default function PaymentReceiveFormFloatingActions({
|
||||
onSubmitClick,
|
||||
onCancelClick,
|
||||
onClearClick,
|
||||
onSubmitForm,
|
||||
paymentReceiveId,
|
||||
}) {
|
||||
const handleSubmitClick = (event) => {
|
||||
onSubmitClick && onSubmitClick(event);
|
||||
const handleSubmitBtnClick = (event) => {
|
||||
saveInvoke(onSubmitClick, event, {
|
||||
redirect: true,
|
||||
});
|
||||
};
|
||||
|
||||
const handleClearBtnClick = (event) => {
|
||||
onClearClick && onClearClick(event);
|
||||
};
|
||||
|
||||
const handleCloseBtnClick = (event) => {
|
||||
const handleCancelBtnClick = (event) => {
|
||||
onCancelClick && onCancelClick(event);
|
||||
saveInvoke(onCancelClick, event);
|
||||
};
|
||||
|
||||
const handleSubmitAndNewClick = (event) => {
|
||||
onSubmitForm();
|
||||
saveInvoke(onSubmitClick, event, {
|
||||
redirect: false,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
type="submit"
|
||||
onClick={handleSubmitClick}
|
||||
>
|
||||
{paymentReceiveId ? <T id={'edit'} /> : <T id={'save_send'} />}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
className={'ml1'}
|
||||
name={'save'}
|
||||
type="submit"
|
||||
onClick={handleSubmitClick}
|
||||
>
|
||||
<T id={'save'} />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
className={'ml1'}
|
||||
disabled={isSubmitting}
|
||||
onClick={handleClearBtnClick}
|
||||
>
|
||||
<T id={'clear'} />
|
||||
</Button>
|
||||
|
||||
<Button className={'ml1'} type="submit" onClick={handleCloseBtnClick}>
|
||||
<T id={'close'} />
|
||||
</Button>
|
||||
<ButtonGroup>
|
||||
{/* ----------- Save and New ----------- */}
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
type="submit"
|
||||
onClick={handleSubmitBtnClick}
|
||||
text={paymentReceiveId ? <T id={'edit'} /> : <T id={'save_and_send'} />}
|
||||
/>
|
||||
<Popover
|
||||
content={
|
||||
<Menu>
|
||||
<MenuItem
|
||||
text={<T id={'save_and_new'} />}
|
||||
onClick={handleSubmitAndNewClick}
|
||||
/>
|
||||
</Menu>
|
||||
}
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
<Button
|
||||
intent={Intent.PRIMARY}
|
||||
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||
/>
|
||||
</Popover>
|
||||
{/* ----------- Clear & Reset----------- */}
|
||||
<Button
|
||||
className={'ml1'}
|
||||
disabled={isSubmitting}
|
||||
onClick={handleClearBtnClick}
|
||||
text={paymentReceiveId ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||
/>
|
||||
{/* ----------- Cancel ----------- */}
|
||||
<Button
|
||||
className={'ml1'}
|
||||
onClick={handleCancelBtnClick}
|
||||
text={<T id={'cancel'} />}
|
||||
/>
|
||||
</ButtonGroup>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ function PaymentReceiveForm({
|
||||
const [clearLinesAlert, setClearLinesAlert] = useState(false);
|
||||
const [fullAmount, setFullAmount] = useState(null);
|
||||
const [clearFormAlert, setClearFormAlert] = useState(false);
|
||||
const [submitPayload, setSubmitPayload] = useState({});
|
||||
|
||||
const { formatMessage } = useIntl();
|
||||
const [localPaymentEntries, setLocalPaymentEntries] = useState(
|
||||
@@ -190,7 +191,10 @@ function PaymentReceiveForm({
|
||||
});
|
||||
setSubmitting(false);
|
||||
resetForm();
|
||||
history.push('/payment-receives');
|
||||
|
||||
if (submitPayload.redirect) {
|
||||
history.push('/payment-receives');
|
||||
}
|
||||
};
|
||||
// Handle request response errors.
|
||||
const onError = (errors) => {
|
||||
@@ -224,6 +228,7 @@ function PaymentReceiveForm({
|
||||
isSubmitting,
|
||||
touched,
|
||||
resetForm,
|
||||
submitForm,
|
||||
} = useFormik({
|
||||
enableReinitialize: true,
|
||||
validationSchema,
|
||||
@@ -351,6 +356,17 @@ function PaymentReceiveForm({
|
||||
[changePageSubtitle],
|
||||
);
|
||||
|
||||
const handleSubmitClick = useCallback(
|
||||
(event, payload) => {
|
||||
setSubmitPayload({ ...payload });
|
||||
},
|
||||
[setSubmitPayload],
|
||||
);
|
||||
|
||||
const handleCancelClick = useCallback(() => {
|
||||
history.goBack();
|
||||
}, [history]);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames(
|
||||
@@ -429,6 +445,9 @@ function PaymentReceiveForm({
|
||||
isSubmitting={isSubmitting}
|
||||
paymentReceiveId={paymentReceiveId}
|
||||
onClearClick={handleClearBtnClick}
|
||||
onSubmitClick={handleSubmitClick}
|
||||
onCancelClick={handleCancelClick}
|
||||
onSubmitForm={submitForm}
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -64,7 +64,6 @@ const defaultInitialValues = {
|
||||
/**
|
||||
* Receipt form.
|
||||
*/
|
||||
|
||||
function ReceiptForm({
|
||||
//#withMedia
|
||||
requestSubmitMedia,
|
||||
@@ -231,17 +230,19 @@ function ReceiptForm({
|
||||
[changePageSubtitle],
|
||||
);
|
||||
|
||||
const handleSubmitClick = (event) => {
|
||||
setSubmitPayload({ redirect: true });
|
||||
};
|
||||
const handleSubmitClick = useCallback(
|
||||
(event, payload) => {
|
||||
setSubmitPayload({ ...payload });
|
||||
},
|
||||
[setSubmitPayload],
|
||||
);
|
||||
|
||||
const handleSubmitAndNewClick = (event) => {
|
||||
setSubmitPayload({ redirect: false });
|
||||
};
|
||||
|
||||
const handleCancelClick = (event) => {
|
||||
history.goBack();
|
||||
};
|
||||
const handleCancelClick = useCallback(
|
||||
(event) => {
|
||||
history.goBack();
|
||||
},
|
||||
[history],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_RECEIPT, CLASSES.PAGE_FORM)}>
|
||||
@@ -252,20 +253,22 @@ function ReceiptForm({
|
||||
initialValues={initialValues}
|
||||
onSubmit={handleFormSubmit}
|
||||
>
|
||||
<Form>
|
||||
<ReceiptFromHeader
|
||||
onReceiptNumberChanged={handleReceiptNumberChanged}
|
||||
/>
|
||||
<ReceiptNumberWatcher receiptNumber={receiptNumber} />
|
||||
<EditableItemsEntriesTable filterSellableItems={true} />
|
||||
<ReceiptFormFooter />
|
||||
<ReceiptFormFloatingActions
|
||||
receiptId={receiptId}
|
||||
onSubmitClick={handleSubmitClick}
|
||||
onSubmitAndNewClick={handleSubmitAndNewClick}
|
||||
onCancelForm={handleCancelClick}
|
||||
/>
|
||||
</Form>
|
||||
{({ isSubmitting }) => (
|
||||
<Form>
|
||||
<ReceiptFromHeader
|
||||
onReceiptNumberChanged={handleReceiptNumberChanged}
|
||||
/>
|
||||
<ReceiptNumberWatcher receiptNumber={receiptNumber} />
|
||||
<EditableItemsEntriesTable filterSellableItems={true} />
|
||||
<ReceiptFormFooter />
|
||||
<ReceiptFormFloatingActions
|
||||
isSubmitting={isSubmitting}
|
||||
receiptId={receiptId}
|
||||
onSubmitClick={handleSubmitClick}
|
||||
onCancelClick={handleCancelClick}
|
||||
/>
|
||||
</Form>
|
||||
)}
|
||||
</Formik>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,63 +1,99 @@
|
||||
import React from 'react';
|
||||
import { Intent, Button } from '@blueprintjs/core';
|
||||
import React, { useCallback } from 'react';
|
||||
import {
|
||||
Intent,
|
||||
Button,
|
||||
ButtonGroup,
|
||||
Popover,
|
||||
PopoverInteractionKind,
|
||||
Position,
|
||||
Menu,
|
||||
MenuItem,
|
||||
} from '@blueprintjs/core';
|
||||
import { FormattedMessage as T } from 'react-intl';
|
||||
import { useFormikContext } from 'formik';
|
||||
import classNames from 'classnames';
|
||||
import { CLASSES } from 'common/classes';
|
||||
import { saveInvoke } from 'utils';
|
||||
import { Icon } from 'components';
|
||||
|
||||
/**
|
||||
* Receipt floating actions bar.
|
||||
*/
|
||||
export default function ReceiptFormFloatingActions({
|
||||
isSubmitting,
|
||||
receiptId,
|
||||
onSubmitClick,
|
||||
onCancelClick,
|
||||
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 (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
type="submit"
|
||||
onClick={(event) => {
|
||||
saveInvoke(onSubmitClick, event);
|
||||
}}
|
||||
>
|
||||
{receiptId ? <T id={'edit'} /> : <T id={'save'} />}
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
className={'ml1'}
|
||||
name={'save'}
|
||||
type="submit"
|
||||
onClick={(event) => {
|
||||
saveInvoke(onSubmitAndNewClick, event);
|
||||
}}
|
||||
>
|
||||
<T id={'save_new'} />
|
||||
</Button>
|
||||
|
||||
<Button
|
||||
className={'ml1'}
|
||||
disabled={isSubmitting}
|
||||
onClick={(event) => {
|
||||
resetForm();
|
||||
saveInvoke(onClearClick, event);
|
||||
}}
|
||||
>
|
||||
<T id={'clear'} />
|
||||
</Button>
|
||||
|
||||
<Button className={'ml1'} onClick={(event) => {
|
||||
saveInvoke(onCancelClick, event);
|
||||
}}>
|
||||
<T id={'close'} />
|
||||
</Button>
|
||||
<ButtonGroup>
|
||||
{/* ----------- Save and New ----------- */}
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
type="submit"
|
||||
onClick={(event) => {
|
||||
saveInvoke(onSubmitClick, event, {
|
||||
redirect: true,
|
||||
});
|
||||
}}
|
||||
text={receiptId ? <T id={'edit'} /> : <T id={'save'} />}
|
||||
/>
|
||||
<Popover
|
||||
content={
|
||||
<Menu>
|
||||
<MenuItem
|
||||
text={<T id={'save_and_new'} />}
|
||||
onClick={handleSubmitAndNewClick}
|
||||
/>
|
||||
</Menu>
|
||||
}
|
||||
minimal={true}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
<Button
|
||||
intent={Intent.PRIMARY}
|
||||
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||
/>
|
||||
</Popover>
|
||||
{/* ----------- Clear & Reset----------- */}
|
||||
<Button
|
||||
className={'ml1'}
|
||||
disabled={isSubmitting}
|
||||
onClick={handleClearBtnClick}
|
||||
text={receiptId ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||
/>
|
||||
{/* ----------- Cancel ----------- */}
|
||||
<Button
|
||||
className={'ml1'}
|
||||
onClick={handleCancelBtnClick}
|
||||
text={<T id={'cancel'} />}
|
||||
/>
|
||||
</ButtonGroup>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user