mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,58 +1,171 @@
|
||||
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 { useFormikContext } from 'formik';
|
||||
import { FormattedMessage as T } from 'react-intl';
|
||||
import { CLASSES } from 'common/classes';
|
||||
import classNames from 'classnames';
|
||||
import { saveInvoke } from 'utils';
|
||||
import { Icon } from 'components';
|
||||
|
||||
export default function InvoiceFloatingActions({
|
||||
isSubmitting,
|
||||
onSubmitClick,
|
||||
onSubmitAndNewClick,
|
||||
onCancelClick,
|
||||
onClearClick,
|
||||
invoice,
|
||||
}) {
|
||||
const { resetForm } = useFormikContext();
|
||||
const { resetForm, submitForm } = useFormikContext();
|
||||
|
||||
const handleSubmitPublishAndNewBtnClick = useCallback(
|
||||
(event) => {
|
||||
submitForm();
|
||||
saveInvoke(onSubmitClick, event, {
|
||||
redirect: false,
|
||||
publish: true,
|
||||
resetForm: true,
|
||||
});
|
||||
},
|
||||
[submitForm],
|
||||
);
|
||||
|
||||
const handleSubmitPublishContinueEditingBtnClick = useCallback(
|
||||
(event) => {
|
||||
submitForm();
|
||||
saveInvoke(onSubmitClick, event, {
|
||||
redirect: false,
|
||||
publish: true,
|
||||
});
|
||||
},
|
||||
[submitForm],
|
||||
);
|
||||
|
||||
const handleSubmitDraftAndNewBtnClick = useCallback(
|
||||
(event) => {
|
||||
submitForm();
|
||||
saveInvoke(onSubmitClick, event, {
|
||||
redirect: false,
|
||||
publish: false,
|
||||
resetForm: true,
|
||||
});
|
||||
},
|
||||
[submitForm],
|
||||
);
|
||||
|
||||
const handleSubmitDraftContinueEditingBtnClick = useCallback(
|
||||
(event) => {
|
||||
submitForm();
|
||||
saveInvoke(onSubmitClick, event, {
|
||||
redirect: false,
|
||||
publish: true,
|
||||
});
|
||||
},
|
||||
[submitForm],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
type="submit"
|
||||
onClick={(event) => {
|
||||
saveInvoke(onSubmitClick, event);
|
||||
}}
|
||||
>
|
||||
{invoice && invoice.id ? <T id={'edit'} /> : <T id={'save'} />}
|
||||
</Button>
|
||||
<ButtonGroup>
|
||||
{/* ----------- Save And Publish ----------- */}
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
type="submit"
|
||||
onClick={(event) => {
|
||||
saveInvoke(onSubmitClick, event, {
|
||||
redirect: true,
|
||||
publish: true,
|
||||
});
|
||||
}}
|
||||
text={
|
||||
invoice && invoice.id ? (
|
||||
<T id={'edit'} />
|
||||
) : (
|
||||
<T id={'save_publish'} />
|
||||
)
|
||||
}
|
||||
/>
|
||||
<Popover
|
||||
content={
|
||||
<Menu>
|
||||
<MenuItem
|
||||
text={<T id={'publish_and_new'} />}
|
||||
onClick={handleSubmitPublishAndNewBtnClick}
|
||||
/>
|
||||
<MenuItem
|
||||
text={<T id={'publish_continue_editing'} />}
|
||||
onClick={handleSubmitPublishContinueEditingBtnClick}
|
||||
/>
|
||||
</Menu>
|
||||
}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
<Button
|
||||
intent={Intent.PRIMARY}
|
||||
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||
/>
|
||||
</Popover>
|
||||
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
intent={Intent.PRIMARY}
|
||||
className={'ml1'}
|
||||
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'} type="submit" onClick={(event) => {
|
||||
saveInvoke(onCancelClick, event);
|
||||
}}>
|
||||
<T id={'close'} />
|
||||
</Button>
|
||||
{/* ----------- Save As Draft ----------- */}
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
className={'ml1'}
|
||||
type="submit"
|
||||
onClick={(event) => {
|
||||
saveInvoke(onSubmitClick, event, {
|
||||
redirect: true,
|
||||
publish: false,
|
||||
});
|
||||
}}
|
||||
text={<T id={'save_as_draft'} />}
|
||||
/>
|
||||
<Popover
|
||||
content={
|
||||
<Menu>
|
||||
<MenuItem
|
||||
text={<T id={'save_and_new'} />}
|
||||
onClick={handleSubmitDraftAndNewBtnClick}
|
||||
/>
|
||||
<MenuItem
|
||||
text={<T id={'save_continue_editing'} />}
|
||||
onClick={handleSubmitDraftContinueEditingBtnClick}
|
||||
/>
|
||||
</Menu>
|
||||
}
|
||||
interactionKind={PopoverInteractionKind.CLICK}
|
||||
position={Position.BOTTOM_LEFT}
|
||||
>
|
||||
<Button rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />} />
|
||||
</Popover>
|
||||
{/* ----------- Clear ----------- */}
|
||||
<Button
|
||||
className={'ml1'}
|
||||
disabled={isSubmitting}
|
||||
onClick={(event) => {
|
||||
resetForm();
|
||||
saveInvoke(onClearClick, event);
|
||||
}}
|
||||
text={invoice && invoice.id ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||
/>
|
||||
{/* ----------- Cancel ----------- */}
|
||||
<Button
|
||||
className={'ml1'}
|
||||
type="submit"
|
||||
onClick={(event) => {
|
||||
saveInvoke(onCancelClick, event);
|
||||
}}
|
||||
text={<T id={'cancel'} />}
|
||||
/>
|
||||
</ButtonGroup>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -191,7 +191,11 @@ function InvoiceForm({
|
||||
if (submitPayload.redirect) {
|
||||
history.push('/invoices');
|
||||
}
|
||||
if (submitPayload.resetForm) {
|
||||
resetForm();
|
||||
}
|
||||
};
|
||||
|
||||
// Handle the request error.
|
||||
const onError = (errors) => {
|
||||
if (errors) {
|
||||
@@ -207,21 +211,17 @@ function InvoiceForm({
|
||||
}
|
||||
};
|
||||
|
||||
const handleCancelClick = useCallback(
|
||||
(payload) => {
|
||||
history.goBack();
|
||||
const handleCancelClick = useCallback(() => {
|
||||
history.goBack();
|
||||
}, [history]);
|
||||
|
||||
const handleSubmitClick = useCallback(
|
||||
(event, payload) => {
|
||||
setSubmitPayload({ ...payload });
|
||||
},
|
||||
[history],
|
||||
[setSubmitPayload],
|
||||
);
|
||||
|
||||
const handleSubmitClick = useCallback(() => {
|
||||
setSubmitPayload({ redirect: true });
|
||||
}, [setSubmitPayload]);
|
||||
|
||||
const handleSubmitAndNewClick = useCallback(() => {
|
||||
setSubmitPayload({ redirect: false });
|
||||
}, [setSubmitPayload]);
|
||||
|
||||
const handleInvoiceNumberChanged = useCallback(
|
||||
(invoiceNumber) => {
|
||||
changePageSubtitle(
|
||||
@@ -256,7 +256,6 @@ function InvoiceForm({
|
||||
invoice={invoice}
|
||||
onCancelClick={handleCancelClick}
|
||||
onSubmitClick={handleSubmitClick}
|
||||
onSubmitAndNewClick={handleSubmitAndNewClick}
|
||||
/>
|
||||
</Form>
|
||||
)}
|
||||
|
||||
@@ -844,4 +844,12 @@ export default {
|
||||
you_cannot_make_payment_with_zero_total_amount: 'You cannot record payment transaction with zero total amount',
|
||||
are_sure_to_publish_this_manual_journal:
|
||||
'Are you sure you want to publish this manual journal?',
|
||||
save_publish:'Save and Publish',
|
||||
publish_and_new: 'Publish and new',
|
||||
publish_continue_editing:'Publish (continue editing)',
|
||||
save_and_new:'Save and new',
|
||||
save_continue_editing:'Save (continue editing)',
|
||||
reset:'Reset ',
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -42,15 +42,11 @@ export default {
|
||||
viewBox: '0 0 448 512',
|
||||
},
|
||||
'arrow-back-24': {
|
||||
path: [
|
||||
'M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z',
|
||||
],
|
||||
path: ['M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z'],
|
||||
viewBox: '0 0 24, 24',
|
||||
},
|
||||
'arrow-forward-24': {
|
||||
path: [
|
||||
'M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z',
|
||||
],
|
||||
path: ['M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8-8-8z'],
|
||||
viewBox: '0 0 24 24',
|
||||
},
|
||||
'ellipsis-h': {
|
||||
@@ -194,20 +190,20 @@ export default {
|
||||
viewBox: '0 0 384 512',
|
||||
},
|
||||
'search-24': {
|
||||
path: ['M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'],
|
||||
path: [
|
||||
'M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z',
|
||||
],
|
||||
viewBox: '0 0 24 24',
|
||||
},
|
||||
'plus-24': {
|
||||
path: [
|
||||
'M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z'
|
||||
],
|
||||
path: ['M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z'],
|
||||
viewBox: '0 0 24 24',
|
||||
},
|
||||
'notification-24': {
|
||||
path: [
|
||||
'M12 22c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2zm6-6v-5c0-3.07-1.63-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.64 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2zm-2 1H8v-6c0-2.48 1.51-4.5 4-4.5s4 2.02 4 4.5v6z',
|
||||
],
|
||||
viewBox: '0 0 24 24'
|
||||
viewBox: '0 0 24 24',
|
||||
},
|
||||
'help-24': {
|
||||
path: [
|
||||
@@ -216,7 +212,6 @@ export default {
|
||||
viewBox: '0 0 24 24',
|
||||
},
|
||||
|
||||
|
||||
// 16
|
||||
'file-import-16': {
|
||||
path: [
|
||||
@@ -298,5 +293,9 @@ export default {
|
||||
'M16 9h-2.55V6h-2.9v3H8l4 4zm3-6H4.99C3.88 3 3 3.9 3 5v14c0 1.1.88 2 1.99 2H19c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5v-3h3.56c.69 1.19 1.97 2 3.45 2s2.75-.81 3.45-2H19v3zm0-5h-4.99c0 1.1-.9 2-2 2s-2-.9-2-2H5l-.01-9H19v9z',
|
||||
],
|
||||
viewBox: '0 0 24 24'
|
||||
}
|
||||
},
|
||||
'arrow-drop-up-16': {
|
||||
path: ['M7 14l5-5 5 5z'],
|
||||
viewBox: '0 0 24 24',
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user