diff --git a/client/src/containers/Sales/Invoice/InvoiceFloatingActions.js b/client/src/containers/Sales/Invoice/InvoiceFloatingActions.js index 4f9c7a4fd..f52c278ca 100644 --- a/client/src/containers/Sales/Invoice/InvoiceFloatingActions.js +++ b/client/src/containers/Sales/Invoice/InvoiceFloatingActions.js @@ -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 (
- + + {/* ----------- Save And Publish ----------- */} + - - - - + {/* ----------- Save As Draft ----------- */} +
); } diff --git a/client/src/containers/Sales/Invoice/InvoiceForm.js b/client/src/containers/Sales/Invoice/InvoiceForm.js index d07fd7c0f..fc20481b3 100644 --- a/client/src/containers/Sales/Invoice/InvoiceForm.js +++ b/client/src/containers/Sales/Invoice/InvoiceForm.js @@ -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} /> )} diff --git a/client/src/lang/en/index.js b/client/src/lang/en/index.js index a41420c42..0bbc2740f 100644 --- a/client/src/lang/en/index.js +++ b/client/src/lang/en/index.js @@ -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 ', + + }; diff --git a/client/src/static/json/icons.js b/client/src/static/json/icons.js index cdf481df8..19e2ca018 100644 --- a/client/src/static/json/icons.js +++ b/client/src/static/json/icons.js @@ -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', + }, };