mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
Merge remote-tracking branch 'origin/FloatingAction'
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)}>
|
||||||
|
<ButtonGroup>
|
||||||
|
{/* ----------- Save and New ----------- */}
|
||||||
<Button
|
<Button
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
type="submit"
|
type="submit"
|
||||||
onClick={(event) => {
|
onClick={handleSubmitBtnClick}
|
||||||
saveInvoke(onSubmitClick, event);
|
text={customerId ? <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}
|
||||||
>
|
>
|
||||||
{customerId ? <T id={'edit'} /> : <T id={'save'} />}
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
disabled={isSubmitting}
|
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
className={'ml1'}
|
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||||
name={'save_and_new'}
|
/>
|
||||||
type="submit"
|
</Popover>
|
||||||
onClick={(event) => {
|
{/* ----------- Clear & Reset----------- */}
|
||||||
saveInvoke(onSubmitAndNewClick, event);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<T id={'save_new'} />
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className={'ml1'}
|
className={'ml1'}
|
||||||
onClick={(event) => {
|
disabled={isSubmitting}
|
||||||
saveInvoke(onCancelClick, event);
|
onClick={handleClearBtnClick}
|
||||||
}}
|
text={customerId ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||||
>
|
/>
|
||||||
<T id={'close'} />
|
{/* ----------- Cancel ----------- */}
|
||||||
</Button>
|
<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(
|
||||||
|
(event) => {
|
||||||
history.goBack();
|
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,10 +1,20 @@
|
|||||||
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 { useFormikContext } from 'formik';
|
import { useFormikContext } from 'formik';
|
||||||
import { FormattedMessage as T } from 'react-intl';
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
import { CLASSES } from 'common/classes';
|
import { CLASSES } from 'common/classes';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { saveInvoke } from 'utils';
|
import { saveInvoke } from 'utils';
|
||||||
|
import { Icon } from 'components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expense form floating actions.
|
* Expense form floating actions.
|
||||||
@@ -14,56 +24,142 @@ export default function ExpenseFloatingFooter({
|
|||||||
onSubmitClick,
|
onSubmitClick,
|
||||||
onCancelClick,
|
onCancelClick,
|
||||||
onDraftClick,
|
onDraftClick,
|
||||||
|
onClearClick,
|
||||||
onSubmitAndNewClick,
|
onSubmitAndNewClick,
|
||||||
|
onSubmitForm,
|
||||||
|
onResetForm,
|
||||||
expense,
|
expense,
|
||||||
}) {
|
}) {
|
||||||
const handleSubmitBtnClick = (event) => {
|
const handleSubmitPublishAndNewBtnClick = (event) => {
|
||||||
saveInvoke(onSubmitClick, event);
|
onSubmitForm();
|
||||||
|
saveInvoke(onSubmitClick, event, {
|
||||||
|
redirect: false,
|
||||||
|
publish: true,
|
||||||
|
resetForm: true,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancelBtnClick = (event) => {
|
const handleSubmitPublishContinueEditingBtnClick = (event) => {
|
||||||
saveInvoke(onCancelClick, event);
|
onSubmitForm();
|
||||||
|
saveInvoke(onSubmitClick, event, {
|
||||||
|
redirect: false,
|
||||||
|
publish: true,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmitAndDraftBtnClick = (event) => {
|
const handleSubmitDraftAndNewBtnClick = (event) => {
|
||||||
saveInvoke(onDraftClick, event);
|
onSubmitForm();
|
||||||
|
saveInvoke(onSubmitClick, event, {
|
||||||
|
redirect: false,
|
||||||
|
publish: false,
|
||||||
|
resetForm: true,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmitAndNewBtnClick = (event) => {
|
const handleSubmitDraftContinueEditingBtnClick = (event) => {
|
||||||
saveInvoke(onSubmitAndNewClick, event);
|
onSubmitForm();
|
||||||
|
saveInvoke(onSubmitClick, event, {
|
||||||
|
redirect: false,
|
||||||
|
publish: true,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||||
|
<ButtonGroup>
|
||||||
|
{/* ----------- Save And Publish ----------- */}
|
||||||
<Button
|
<Button
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
type="submit"
|
type="submit"
|
||||||
onClick={handleSubmitBtnClick}
|
onClick={(event) => {
|
||||||
|
saveInvoke(onSubmitClick, event, {
|
||||||
|
redirect: true,
|
||||||
|
publish: true,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
text={
|
||||||
|
expense && expense.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>
|
||||||
|
}
|
||||||
|
minimal={true}
|
||||||
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
|
position={Position.BOTTOM_LEFT}
|
||||||
>
|
>
|
||||||
{expense && expense.id ? <T id={'edit'} /> : <T id={'save'} />}
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className={'ml1'}
|
intent={Intent.PRIMARY}
|
||||||
|
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||||
|
/>
|
||||||
|
</Popover>
|
||||||
|
|
||||||
|
{/* ----------- Save As Draft ----------- */}
|
||||||
|
<Button
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
onClick={handleSubmitAndNewBtnClick}
|
className={'ml1'}
|
||||||
type="submit"
|
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>
|
||||||
|
}
|
||||||
|
minimal={true}
|
||||||
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
|
position={Position.BOTTOM_LEFT}
|
||||||
>
|
>
|
||||||
<T id={'save_new'} />
|
<Button rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />} />
|
||||||
</Button>
|
</Popover>
|
||||||
|
{/* ----------- Clear ----------- */}
|
||||||
<Button
|
<Button
|
||||||
className={'ml1'}
|
className={'ml1'}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
onClick={handleSubmitAndDraftBtnClick}
|
onClick={(event) => {
|
||||||
>
|
onResetForm();
|
||||||
<T id={'save_as_draft'} />
|
saveInvoke(onClearClick, event);
|
||||||
</Button>
|
}}
|
||||||
|
text={expense && expense.id ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||||
<Button className={'ml1'} onClick={handleCancelBtnClick}>
|
/>
|
||||||
<T id={'close'} />
|
{/* ----------- Cancel ----------- */}
|
||||||
</Button>
|
<Button
|
||||||
|
className={'ml1'}
|
||||||
|
onClick={(event) => {
|
||||||
|
saveInvoke(onCancelClick, event);
|
||||||
|
}}
|
||||||
|
text={<T id={'cancel'} />}
|
||||||
|
/>
|
||||||
|
</ButtonGroup>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ function ExpenseForm({
|
|||||||
onFormSubmit,
|
onFormSubmit,
|
||||||
onCancelForm,
|
onCancelForm,
|
||||||
}) {
|
}) {
|
||||||
const [payload, setPayload] = useState({});
|
const [submitPayload, setSubmitPayload] = useState({});
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
const isNewMode = !expenseId;
|
const isNewMode = !expenseId;
|
||||||
@@ -199,6 +199,8 @@ function ExpenseForm({
|
|||||||
setFieldValue,
|
setFieldValue,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
getFieldProps,
|
getFieldProps,
|
||||||
|
submitForm,
|
||||||
|
resetForm,
|
||||||
} = useFormik({
|
} = useFormik({
|
||||||
enableReinitialize: true,
|
enableReinitialize: true,
|
||||||
validationSchema,
|
validationSchema,
|
||||||
@@ -228,7 +230,7 @@ function ExpenseForm({
|
|||||||
|
|
||||||
const form = {
|
const form = {
|
||||||
...values,
|
...values,
|
||||||
publish: payload.publish,
|
publish: submitPayload.publish,
|
||||||
categories,
|
categories,
|
||||||
};
|
};
|
||||||
const saveExpense = (mdeiaIds) =>
|
const saveExpense = (mdeiaIds) =>
|
||||||
@@ -246,7 +248,7 @@ function ExpenseForm({
|
|||||||
intent: Intent.SUCCESS,
|
intent: Intent.SUCCESS,
|
||||||
});
|
});
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
saveInvokeSubmit({ action: 'update', ...payload });
|
saveInvokeSubmit({ action: 'update', ...submitPayload });
|
||||||
clearSavedMediaIds([]);
|
clearSavedMediaIds([]);
|
||||||
resetForm();
|
resetForm();
|
||||||
})
|
})
|
||||||
@@ -265,8 +267,11 @@ function ExpenseForm({
|
|||||||
intent: Intent.SUCCESS,
|
intent: Intent.SUCCESS,
|
||||||
});
|
});
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
|
|
||||||
|
if (submitPayload.resetForm) {
|
||||||
resetForm();
|
resetForm();
|
||||||
saveInvokeSubmit({ action: 'new', ...payload });
|
}
|
||||||
|
saveInvokeSubmit({ action: 'new', ...submitPayload });
|
||||||
clearSavedMediaIds();
|
clearSavedMediaIds();
|
||||||
})
|
})
|
||||||
.catch((errors) => {
|
.catch((errors) => {
|
||||||
@@ -288,20 +293,17 @@ function ExpenseForm({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleSubmitClick = useCallback(() => {
|
const handleSubmitClick = useCallback(
|
||||||
setPayload({ publish: true, redirect: true });
|
(event, payload) => {
|
||||||
}, [setPayload]);
|
setSubmitPayload({ ...payload });
|
||||||
|
},
|
||||||
|
[setSubmitPayload],
|
||||||
|
);
|
||||||
|
|
||||||
const handleCancelClick = useCallback(() => {
|
const handleCancelClick = useCallback(() => {
|
||||||
history.goBack();
|
history.goBack();
|
||||||
}, []);
|
}, [history]);
|
||||||
|
|
||||||
const handleSubmitAndNewClick = useCallback(() => {
|
|
||||||
setPayload({ publish: true, redirect: false });
|
|
||||||
});
|
|
||||||
const handleSubmitAndDraftClick = useCallback(() => {
|
|
||||||
setPayload({ publish: false, redirect: false });
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleDeleteFile = useCallback(
|
const handleDeleteFile = useCallback(
|
||||||
(_deletedFiles) => {
|
(_deletedFiles) => {
|
||||||
@@ -370,8 +372,8 @@ function ExpenseForm({
|
|||||||
isSubmitting={isSubmitting}
|
isSubmitting={isSubmitting}
|
||||||
onSubmitClick={handleSubmitClick}
|
onSubmitClick={handleSubmitClick}
|
||||||
onCancelClick={handleCancelClick}
|
onCancelClick={handleCancelClick}
|
||||||
onDraftClick={handleSubmitAndDraftClick}
|
onSubmitForm={submitForm}
|
||||||
onSubmitAndNewClick={handleSubmitAndNewClick}
|
onResetForm={resetForm}
|
||||||
expense={expense}
|
expense={expense}
|
||||||
/>
|
/>
|
||||||
</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)}>
|
||||||
|
<ButtonGroup>
|
||||||
|
{/* ----------- Save and New ----------- */}
|
||||||
<Button
|
<Button
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
type="submit"
|
type="submit"
|
||||||
onClick={handleSubmitBtnClick}
|
onClick={handleSubmitBtnClick}
|
||||||
>
|
text={estimateId ? <T id={'edit'} /> : <T id={'save'} />}
|
||||||
{(estimateId) ? <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'}
|
|
||||||
type="submit"
|
|
||||||
onClick={handleSubmitAndNewClick}
|
onClick={handleSubmitAndNewClick}
|
||||||
|
/>
|
||||||
|
</Menu>
|
||||||
|
}
|
||||||
|
minimal={true}
|
||||||
|
interactionKind={PopoverInteractionKind.CLICK}
|
||||||
|
position={Position.BOTTOM_LEFT}
|
||||||
>
|
>
|
||||||
<T id={'save_new'} />
|
<Button
|
||||||
</Button>
|
intent={Intent.PRIMARY}
|
||||||
|
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||||
|
/>
|
||||||
|
</Popover>
|
||||||
|
{/* ----------- Clear & Reset----------- */}
|
||||||
<Button
|
<Button
|
||||||
className={'ml1'}
|
className={'ml1'}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
onClick={handleClearBtnClick}
|
onClick={handleClearBtnClick}
|
||||||
>
|
text={estimateId ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||||
<T id={'clear'} />
|
/>
|
||||||
</Button>
|
{/* ----------- Cancel ----------- */}
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className={'ml1'}
|
className={'ml1'}
|
||||||
type="submit"
|
|
||||||
onClick={handleCancelBtnClick}
|
onClick={handleCancelBtnClick}
|
||||||
>
|
text={<T id={'cancel'} />}
|
||||||
<T id={'close'} />
|
/>
|
||||||
</Button>
|
</ButtonGroup>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,8 +228,8 @@ const EstimateForm = ({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const handleSubmitClick = useCallback(
|
const handleSubmitClick = useCallback(
|
||||||
(event) => {
|
(event, payload) => {
|
||||||
setSubmitPayload({ redirect: true });
|
setSubmitPayload({ ...payload });
|
||||||
},
|
},
|
||||||
[setSubmitPayload],
|
[setSubmitPayload],
|
||||||
);
|
);
|
||||||
@@ -259,11 +259,12 @@ const EstimateForm = ({
|
|||||||
<EditableItemsEntriesTable filterSellableItems={true} />
|
<EditableItemsEntriesTable filterSellableItems={true} />
|
||||||
<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);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,9 +1,20 @@
|
|||||||
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 { Icon } from 'components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Payment receive floating actions bar.
|
* Payment receive floating actions bar.
|
||||||
@@ -13,53 +24,74 @@ export default function PaymentReceiveFormFloatingActions({
|
|||||||
onSubmitClick,
|
onSubmitClick,
|
||||||
onCancelClick,
|
onCancelClick,
|
||||||
onClearClick,
|
onClearClick,
|
||||||
|
onSubmitForm,
|
||||||
paymentReceiveId,
|
paymentReceiveId,
|
||||||
}) {
|
}) {
|
||||||
const handleSubmitClick = (event) => {
|
const handleSubmitBtnClick = (event) => {
|
||||||
onSubmitClick && onSubmitClick(event);
|
saveInvoke(onSubmitClick, event, {
|
||||||
|
redirect: true,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClearBtnClick = (event) => {
|
const handleClearBtnClick = (event) => {
|
||||||
onClearClick && onClearClick(event);
|
onClearClick && onClearClick(event);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCloseBtnClick = (event) => {
|
const handleCancelBtnClick = (event) => {
|
||||||
onCancelClick && onCancelClick(event);
|
onCancelClick && onCancelClick(event);
|
||||||
|
saveInvoke(onCancelClick, event);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmitAndNewClick = (event) => {
|
||||||
|
onSubmitForm();
|
||||||
|
saveInvoke(onSubmitClick, event, {
|
||||||
|
redirect: false,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||||
|
<ButtonGroup>
|
||||||
|
{/* ----------- Save and New ----------- */}
|
||||||
<Button
|
<Button
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
type="submit"
|
type="submit"
|
||||||
onClick={handleSubmitClick}
|
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}
|
||||||
>
|
>
|
||||||
{paymentReceiveId ? <T id={'edit'} /> : <T id={'save_send'} />}
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
disabled={isSubmitting}
|
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
className={'ml1'}
|
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||||
name={'save'}
|
/>
|
||||||
type="submit"
|
</Popover>
|
||||||
onClick={handleSubmitClick}
|
{/* ----------- Clear & Reset----------- */}
|
||||||
>
|
|
||||||
<T id={'save'} />
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className={'ml1'}
|
className={'ml1'}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
onClick={handleClearBtnClick}
|
onClick={handleClearBtnClick}
|
||||||
>
|
text={paymentReceiveId ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||||
<T id={'clear'} />
|
/>
|
||||||
</Button>
|
{/* ----------- Cancel ----------- */}
|
||||||
|
<Button
|
||||||
<Button className={'ml1'} type="submit" onClick={handleCloseBtnClick}>
|
className={'ml1'}
|
||||||
<T id={'close'} />
|
onClick={handleCancelBtnClick}
|
||||||
</Button>
|
text={<T id={'cancel'} />}
|
||||||
|
/>
|
||||||
|
</ButtonGroup>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ function PaymentReceiveForm({
|
|||||||
const [clearLinesAlert, setClearLinesAlert] = useState(false);
|
const [clearLinesAlert, setClearLinesAlert] = useState(false);
|
||||||
const [fullAmount, setFullAmount] = useState(null);
|
const [fullAmount, setFullAmount] = useState(null);
|
||||||
const [clearFormAlert, setClearFormAlert] = useState(false);
|
const [clearFormAlert, setClearFormAlert] = useState(false);
|
||||||
|
const [submitPayload, setSubmitPayload] = useState({});
|
||||||
|
|
||||||
const { formatMessage } = useIntl();
|
const { formatMessage } = useIntl();
|
||||||
const [localPaymentEntries, setLocalPaymentEntries] = useState(
|
const [localPaymentEntries, setLocalPaymentEntries] = useState(
|
||||||
@@ -190,7 +191,10 @@ function PaymentReceiveForm({
|
|||||||
});
|
});
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
resetForm();
|
resetForm();
|
||||||
|
|
||||||
|
if (submitPayload.redirect) {
|
||||||
history.push('/payment-receives');
|
history.push('/payment-receives');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// Handle request response errors.
|
// Handle request response errors.
|
||||||
const onError = (errors) => {
|
const onError = (errors) => {
|
||||||
@@ -224,6 +228,7 @@ function PaymentReceiveForm({
|
|||||||
isSubmitting,
|
isSubmitting,
|
||||||
touched,
|
touched,
|
||||||
resetForm,
|
resetForm,
|
||||||
|
submitForm,
|
||||||
} = useFormik({
|
} = useFormik({
|
||||||
enableReinitialize: true,
|
enableReinitialize: true,
|
||||||
validationSchema,
|
validationSchema,
|
||||||
@@ -351,6 +356,17 @@ function PaymentReceiveForm({
|
|||||||
[changePageSubtitle],
|
[changePageSubtitle],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleSubmitClick = useCallback(
|
||||||
|
(event, payload) => {
|
||||||
|
setSubmitPayload({ ...payload });
|
||||||
|
},
|
||||||
|
[setSubmitPayload],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleCancelClick = useCallback(() => {
|
||||||
|
history.goBack();
|
||||||
|
}, [history]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
@@ -429,6 +445,9 @@ function PaymentReceiveForm({
|
|||||||
isSubmitting={isSubmitting}
|
isSubmitting={isSubmitting}
|
||||||
paymentReceiveId={paymentReceiveId}
|
paymentReceiveId={paymentReceiveId}
|
||||||
onClearClick={handleClearBtnClick}
|
onClearClick={handleClearBtnClick}
|
||||||
|
onSubmitClick={handleSubmitClick}
|
||||||
|
onCancelClick={handleCancelClick}
|
||||||
|
onSubmitForm={submitForm}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ const defaultInitialValues = {
|
|||||||
/**
|
/**
|
||||||
* Receipt form.
|
* Receipt form.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function ReceiptForm({
|
function ReceiptForm({
|
||||||
//#withMedia
|
//#withMedia
|
||||||
requestSubmitMedia,
|
requestSubmitMedia,
|
||||||
@@ -231,17 +230,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) => {
|
||||||
};
|
|
||||||
|
|
||||||
const handleCancelClick = (event) => {
|
|
||||||
history.goBack();
|
history.goBack();
|
||||||
};
|
},
|
||||||
|
[history],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.PAGE_FORM_RECEIPT, CLASSES.PAGE_FORM)}>
|
<div className={classNames(CLASSES.PAGE_FORM_RECEIPT, CLASSES.PAGE_FORM)}>
|
||||||
@@ -252,6 +253,7 @@ function ReceiptForm({
|
|||||||
initialValues={initialValues}
|
initialValues={initialValues}
|
||||||
onSubmit={handleFormSubmit}
|
onSubmit={handleFormSubmit}
|
||||||
>
|
>
|
||||||
|
{({ isSubmitting }) => (
|
||||||
<Form>
|
<Form>
|
||||||
<ReceiptFromHeader
|
<ReceiptFromHeader
|
||||||
onReceiptNumberChanged={handleReceiptNumberChanged}
|
onReceiptNumberChanged={handleReceiptNumberChanged}
|
||||||
@@ -260,12 +262,13 @@ function ReceiptForm({
|
|||||||
<EditableItemsEntriesTable filterSellableItems={true} />
|
<EditableItemsEntriesTable filterSellableItems={true} />
|
||||||
<ReceiptFormFooter />
|
<ReceiptFormFooter />
|
||||||
<ReceiptFormFloatingActions
|
<ReceiptFormFloatingActions
|
||||||
|
isSubmitting={isSubmitting}
|
||||||
receiptId={receiptId}
|
receiptId={receiptId}
|
||||||
onSubmitClick={handleSubmitClick}
|
onSubmitClick={handleSubmitClick}
|
||||||
onSubmitAndNewClick={handleSubmitAndNewClick}
|
onCancelClick={handleCancelClick}
|
||||||
onCancelForm={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)}>
|
||||||
|
<ButtonGroup>
|
||||||
|
{/* ----------- Save and New ----------- */}
|
||||||
<Button
|
<Button
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
type="submit"
|
type="submit"
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
saveInvoke(onSubmitClick, 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}
|
||||||
>
|
>
|
||||||
{receiptId ? <T id={'edit'} /> : <T id={'save'} />}
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
disabled={isSubmitting}
|
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
className={'ml1'}
|
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||||
name={'save'}
|
/>
|
||||||
type="submit"
|
</Popover>
|
||||||
onClick={(event) => {
|
{/* ----------- Clear & Reset----------- */}
|
||||||
saveInvoke(onSubmitAndNewClick, event);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<T id={'save_new'} />
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
className={'ml1'}
|
className={'ml1'}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
onClick={(event) => {
|
onClick={handleClearBtnClick}
|
||||||
resetForm();
|
text={receiptId ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||||
saveInvoke(onClearClick, event);
|
/>
|
||||||
}}
|
{/* ----------- Cancel ----------- */}
|
||||||
>
|
<Button
|
||||||
<T id={'clear'} />
|
className={'ml1'}
|
||||||
</Button>
|
onClick={handleCancelBtnClick}
|
||||||
|
text={<T id={'cancel'} />}
|
||||||
<Button className={'ml1'} onClick={(event) => {
|
/>
|
||||||
saveInvoke(onCancelClick, event);
|
</ButtonGroup>
|
||||||
}}>
|
|
||||||
<T id={'close'} />
|
|
||||||
</Button>
|
|
||||||
</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)}>
|
||||||
|
<ButtonGroup>
|
||||||
|
{/* ----------- Save and New ----------- */}
|
||||||
<Button
|
<Button
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
type="submit"
|
type="submit"
|
||||||
onClick={(event) => {
|
onClick={handleSubmitBtnClick}
|
||||||
saveInvoke(onSubmitClick, event);
|
text={vendor ? <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}
|
||||||
>
|
>
|
||||||
{vendor ? <T id={'edit'} /> : <T id={'save'} />}
|
|
||||||
</Button>
|
|
||||||
<Button
|
<Button
|
||||||
disabled={isSubmitting}
|
|
||||||
intent={Intent.PRIMARY}
|
intent={Intent.PRIMARY}
|
||||||
className={'ml1'}
|
rightIcon={<Icon icon="arrow-drop-up-16" iconSize={20} />}
|
||||||
name={'save_and_new'}
|
/>
|
||||||
type="submit"
|
</Popover>
|
||||||
onClick={(event) => {
|
{/* ----------- Clear & Reset----------- */}
|
||||||
saveInvoke(onSubmitAndNewClick, event);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<T id={'save_new'} />
|
|
||||||
</Button>
|
|
||||||
<Button
|
<Button
|
||||||
className={'ml1'}
|
className={'ml1'}
|
||||||
onClick={(event) => {
|
disabled={isSubmitting}
|
||||||
saveInvoke(onCancelClick, event);
|
onClick={handleClearBtnClick}
|
||||||
}}
|
text={vendor ? <T id={'reset'} /> : <T id={'clear'} />}
|
||||||
>
|
/>
|
||||||
<T id={'close'} />
|
{/* ----------- Cancel ----------- */}
|
||||||
</Button>
|
<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>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -844,12 +844,11 @@ export default {
|
|||||||
you_cannot_make_payment_with_zero_total_amount: 'You cannot record payment transaction with zero total amount',
|
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_sure_to_publish_this_manual_journal:
|
||||||
'Are you sure you want to publish this manual journal?',
|
'Are you sure you want to publish this manual journal?',
|
||||||
save_publish:'Save and Publish',
|
save_publish: 'Save and Publish',
|
||||||
publish_and_new: 'Publish and new',
|
publish_and_new: 'Publish and new',
|
||||||
publish_continue_editing:'Publish (continue editing)',
|
publish_continue_editing: 'Publish (continue editing)',
|
||||||
save_and_new:'Save and new',
|
save_and_new: 'Save and new',
|
||||||
save_continue_editing:'Save (continue editing)',
|
save_continue_editing: 'Save (continue editing)',
|
||||||
reset:'Reset ',
|
reset: 'Reset ',
|
||||||
|
save_and_send: 'Save and Send',
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user