mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
fix: FastField re-rendering.
fix: Allocate landed cost dialog.
This commit is contained in:
@@ -48,7 +48,7 @@ function BillForm({
|
||||
currency_code: baseCurrency,
|
||||
}),
|
||||
}),
|
||||
[bill],
|
||||
[bill, baseCurrency],
|
||||
);
|
||||
|
||||
// Transform response error to fields.
|
||||
|
||||
@@ -7,6 +7,7 @@ import classNames from 'classnames';
|
||||
|
||||
import { CLASSES } from 'common/classes';
|
||||
import { ContactSelecetList, FieldRequiredHint, Icon } from 'components';
|
||||
import { vendorsFieldShouldUpdate } from './utils';
|
||||
|
||||
import { useBillFormContext } from './BillFormProvider';
|
||||
import withDialogActions from 'containers/Dialog/withDialogActions';
|
||||
@@ -28,7 +29,11 @@ function BillFormHeader() {
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_HEADER_FIELDS)}>
|
||||
{/* ------- Vendor name ------ */}
|
||||
<FastField name={'vendor_id'}>
|
||||
<FastField
|
||||
name={'vendor_id'}
|
||||
vendors={vendors}
|
||||
shouldUpdate={vendorsFieldShouldUpdate}
|
||||
>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
<FormGroup
|
||||
label={<T id={'vendor_name'} />}
|
||||
|
||||
@@ -4,13 +4,23 @@ import { FastField } from 'formik';
|
||||
import { CLASSES } from 'common/classes';
|
||||
import { useBillFormContext } from './BillFormProvider';
|
||||
import ItemsEntriesTable from 'containers/Entries/ItemsEntriesTable';
|
||||
import {
|
||||
entriesFieldShouldUpdate
|
||||
} from './utils';
|
||||
|
||||
/**
|
||||
* Bill form body.
|
||||
*/
|
||||
export default function BillFormBody({ defaultBill }) {
|
||||
const { items } = useBillFormContext();
|
||||
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_BODY)}>
|
||||
<FastField name={'entries'}>
|
||||
<FastField
|
||||
name={'entries'}
|
||||
items={items}
|
||||
shouldUpdate={entriesFieldShouldUpdate}
|
||||
>
|
||||
{({
|
||||
form: { values, setFieldValue },
|
||||
field: { value },
|
||||
@@ -25,6 +35,7 @@ export default function BillFormBody({ defaultBill }) {
|
||||
errors={error}
|
||||
linesNumber={4}
|
||||
currencyCode={values.currency_code}
|
||||
landedCost={true}
|
||||
/>
|
||||
)}
|
||||
</FastField>
|
||||
|
||||
@@ -2,7 +2,11 @@ import moment from 'moment';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
import { AppToaster } from 'components';
|
||||
import { transformToForm, repeatValue } from 'utils';
|
||||
import {
|
||||
defaultFastFieldShouldUpdate,
|
||||
transformToForm,
|
||||
repeatValue,
|
||||
} from 'utils';
|
||||
|
||||
export const MIN_LINES_NUMBER = 4;
|
||||
|
||||
@@ -13,6 +17,7 @@ export const defaultBillEntry = {
|
||||
discount: '',
|
||||
quantity: '',
|
||||
description: '',
|
||||
landed_cost: false,
|
||||
};
|
||||
|
||||
export const defaultBill = {
|
||||
@@ -62,3 +67,23 @@ export const handleDeleteErrors = (errors) => {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Detarmines vendors fast field should update
|
||||
*/
|
||||
export const vendorsFieldShouldUpdate = (newProps, oldProps) => {
|
||||
return (
|
||||
newProps.vendors !== oldProps.vendors ||
|
||||
defaultFastFieldShouldUpdate(newProps, oldProps)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Detarmines entries fast field should update.
|
||||
*/
|
||||
export const entriesFieldShouldUpdate = (newProps, oldProps) => {
|
||||
return (
|
||||
newProps.items !== oldProps.items ||
|
||||
defaultFastFieldShouldUpdate(newProps, oldProps)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -59,7 +59,7 @@ export function ActionsMenu({
|
||||
/>
|
||||
</If>
|
||||
<MenuItem
|
||||
// icon={<Icon icon="quick-payment-16" iconSize={16} />}
|
||||
icon={<Icon icon="receipt-24" iconSize={16} />}
|
||||
text={intl.get('allocate_landed_coast')}
|
||||
onClick={safeCallback(onAllocateLandedCost, original)}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user