mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
fix(auth): hide/show password revealer in auth pages.
fix(expense): auto-adding new lines. fix(journal): auto-adding new lines.
This commit is contained in:
@@ -3,12 +3,10 @@ import classNames from 'classnames';
|
||||
import { CLASSES } from 'common/classes';
|
||||
import ExpenseFormEntriesField from './ExpenseFormEntriesField';
|
||||
|
||||
export default function ExpenseFormBody({
|
||||
|
||||
}) {
|
||||
export default function ExpenseFormBody() {
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_BODY)}>
|
||||
<ExpenseFormEntriesField />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { FastField } from 'formik';
|
||||
import React from 'react';
|
||||
import ExpenseFormEntriesTable from './ExpenseFormEntriesTable';
|
||||
import { useExpenseFormContext } from './ExpenseFormPageProvider';
|
||||
import { defaultExpenseEntry } from './utils';
|
||||
|
||||
/**
|
||||
* Expense form entries field.
|
||||
@@ -9,8 +9,6 @@ import { useExpenseFormContext } from './ExpenseFormPageProvider';
|
||||
export default function ExpenseFormEntriesField({
|
||||
linesNumber = 4,
|
||||
}) {
|
||||
const { defaultCategoryEntry } = useExpenseFormContext();
|
||||
|
||||
return (
|
||||
<FastField name={'categories'}>
|
||||
{({ form, field: { value }, meta: { error, touched } }) => (
|
||||
@@ -20,7 +18,7 @@ export default function ExpenseFormEntriesField({
|
||||
onChange={(entries) => {
|
||||
form.setFieldValue('categories', entries);
|
||||
}}
|
||||
defaultEntry={defaultCategoryEntry}
|
||||
defaultEntry={defaultExpenseEntry}
|
||||
linesNumber={linesNumber}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
import React, { useCallback } from 'react';
|
||||
import { Button } from '@blueprintjs/core';
|
||||
import { FormattedMessage as T } from 'react-intl';
|
||||
|
||||
import { DataTableEditable } from 'components';
|
||||
import ExpenseDeleteEntriesAlert from 'containers/Alerts/Expenses/ExpenseDeleteEntriesAlert';
|
||||
import { useExpenseFormContext } from './ExpenseFormPageProvider';
|
||||
import { useExpenseFormTableColumns } from './components';
|
||||
|
||||
import withAlertActions from 'containers/Alert/withAlertActions';
|
||||
|
||||
import { transformUpdatedRows, compose, saveInvoke, repeatValue } from 'utils';
|
||||
import {
|
||||
saveInvoke,
|
||||
compose,
|
||||
updateTableRow,
|
||||
updateMinEntriesLines,
|
||||
updateAutoAddNewLine,
|
||||
updateRemoveLineByIndex,
|
||||
} from 'utils';
|
||||
|
||||
/**
|
||||
* Expenses form entries.
|
||||
*/
|
||||
function ExpenseFormEntriesTable({
|
||||
// #withAlertActions
|
||||
openAlert,
|
||||
|
||||
export default function ExpenseFormEntriesTable({
|
||||
// #ownPorps
|
||||
entries,
|
||||
defaultEntry,
|
||||
@@ -32,29 +30,30 @@ function ExpenseFormEntriesTable({
|
||||
|
||||
// Handles update datatable data.
|
||||
const handleUpdateData = useCallback(
|
||||
(rowIndex, columnIdOrObj, value) => {
|
||||
const newRows = transformUpdatedRows(
|
||||
entries,
|
||||
rowIndex,
|
||||
columnIdOrObj,
|
||||
value,
|
||||
);
|
||||
(rowIndex, columnId, value) => {
|
||||
const newRows = compose(
|
||||
updateAutoAddNewLine(defaultEntry, ['expense_account_id']),
|
||||
updateTableRow(rowIndex, columnId, value),
|
||||
)(entries);
|
||||
|
||||
saveInvoke(onChange, newRows);
|
||||
},
|
||||
[entries, onChange],
|
||||
[entries, defaultEntry, onChange],
|
||||
);
|
||||
|
||||
// Handles click remove datatable row.
|
||||
const handleRemoveRow = useCallback(
|
||||
(rowIndex) => {
|
||||
// Can't continue if there is just one row line or less.
|
||||
if (entries.length <= 1) {
|
||||
return;
|
||||
}
|
||||
const newRows = entries.filter((row, index) => index !== rowIndex);
|
||||
const newRows = compose(
|
||||
// Ensure minimum lines count.
|
||||
updateMinEntriesLines(4, defaultEntry),
|
||||
// Remove the line by the given index.
|
||||
updateRemoveLineByIndex(rowIndex),
|
||||
)(entries);
|
||||
|
||||
saveInvoke(onChange, newRows);
|
||||
},
|
||||
[entries, onChange],
|
||||
[entries, defaultEntry, onChange],
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -72,6 +71,4 @@ function ExpenseFormEntriesTable({
|
||||
footer={true}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default compose(withAlertActions)(ExpenseFormEntriesTable);
|
||||
}
|
||||
Reference in New Issue
Block a user