fix: logo style.

fix: page forms style.
feat: auto-fill items entries from item details.
fix: hiding dashboard copyright bar.
This commit is contained in:
a.bouhuolia
2021-02-25 10:51:27 +02:00
parent 5a58e9bafd
commit 9e2c995813
84 changed files with 1019 additions and 682 deletions

View File

@@ -169,6 +169,7 @@ function MakeJournalEntriesForm({
<MakeJournalFormFooter />
<MakeJournalFormFloatingActions />
{/* --------- Dialogs --------- */}
<MakeJournalFormDialogs />
</Form>
</Formik>

View File

@@ -1,12 +1,27 @@
import React from 'react';
import classNames from 'classnames';
import { useFormikContext } from 'formik';
import { CLASSES } from 'common/classes';
import MakeJournalEntriesHeaderFields from "./MakeJournalEntriesHeaderFields";
import { PageFormBigNumber } from 'components';
import { safeSumBy } from 'utils';
export default function MakeJournalEntriesHeader() {
const { values: { entries } } = useFormikContext();
const totalCredit = safeSumBy(entries, 'credit');
const totalDebit = safeSumBy(entries, 'debit');
const total = Math.max(totalCredit, totalDebit);
return (
<div className={classNames(CLASSES.PAGE_FORM_HEADER)}>
<MakeJournalEntriesHeaderFields />
<PageFormBigNumber
label={'Due Amount'}
amount={total}
currencyCode={'USD'}
/>
</div>
)
}

View File

@@ -1,11 +1,11 @@
import React from 'react';
import { useParams } from 'react-router-dom';
import 'style/pages/ManualJournal/MakeJournal.scss';
import MakeJournalEntriesForm from './MakeJournalEntriesForm';
import { MakeJournalProvider } from './MakeJournalProvider';
import 'style/pages/ManualJournal/MakeJournal.scss';
/**
* Make journal entries page.
*/

View File

@@ -9,9 +9,7 @@ import { updateDataReducer } from './utils';
import { useMakeJournalFormContext } from './MakeJournalProvider';
import { useJournalTableEntriesColumns } from './components';
import JournalDeleteEntriesAlert from 'containers/Alerts/ManualJournals/JournalDeleteEntriesAlert';
import { compose } from 'redux';
import { repeatValue } from 'utils';
/**
* Make journal entries table component.
@@ -32,13 +30,7 @@ function MakeJournalEntriesTable({
// Memorized data table columns.
const columns = useJournalTableEntriesColumns();
// Handles click new line.
const onClickNewRow = () => {
const newRows = [...entries, defaultEntry];
saveInvoke(onChange, newRows);
};
// Handles update datatable data.
const handleUpdateData = (rowIndex, columnId, value) => {
const newRows = updateDataReducer(entries, rowIndex, columnId, value);
@@ -50,61 +42,28 @@ function MakeJournalEntriesTable({
const newRows = removeRowsByIndex(entries, rowIndex);
saveInvoke(onChange, newRows);
};
// Handle clear all lines action.
const handleClickClearAllLines = () => {
openAlert('make-journal-delete-all-entries');
};
// Handle clear all lines alaert confirm.
const handleCofirmClearEntriesAlert = () => {
const newRows = repeatValue(defaultEntry, initialLinesNumber);
saveInvoke(onChange, newRows);
};
return (
<>
<DataTableEditable
columns={columns}
data={entries}
sticky={true}
totalRow={true}
payload={{
accounts,
errors: error,
updateData: handleUpdateData,
removeRow: handleRemoveRow,
contacts: customers.map((customer) => ({
...customer,
contact_type: 'customer',
})),
autoFocus: ['account_id', 0],
}}
actions={
<>
<Button
small={true}
className={'button--secondary button--new-line'}
onClick={onClickNewRow}
>
<T id={'new_lines'} />
</Button>
<Button
small={true}
className={'button--secondary button--clear-lines ml1'}
onClick={handleClickClearAllLines}
>
<T id={'clear_all_lines'} />
</Button>
</>
}
/>
<JournalDeleteEntriesAlert
name={'make-journal-delete-all-entries'}
onConfirm={handleCofirmClearEntriesAlert}
/>
</>
<DataTableEditable
columns={columns}
data={entries}
sticky={true}
totalRow={true}
footer={true}
payload={{
accounts,
errors: error,
updateData: handleUpdateData,
removeRow: handleRemoveRow,
contacts: customers.map((customer) => ({
...customer,
contact_type: 'customer',
})),
autoFocus: ['account_id', 0],
}}
/>
);
}

View File

@@ -4,39 +4,41 @@ import classNames from 'classnames';
import { CLASSES } from 'common/classes';
import { FormGroup, TextArea } from '@blueprintjs/core';
import { FormattedMessage as T } from 'react-intl';
import { ErrorMessage, Row, Col } from 'components';
import { Postbox, ErrorMessage, Row, Col } from 'components';
import Dragzone from 'components/Dragzone';
import { inputIntent } from 'utils';
export default function MakeJournalFormFooter() {
return (
<div className={classNames(CLASSES.PAGE_FORM_FOOTER)}>
<Row>
<Col md={8}>
<FastField name={'description'}>
{({ field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'description'} />}
className={'form-group--description'}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name="description" />}
fill={true}
>
<TextArea fill={true} {...field} />
</FormGroup>
)}
</FastField>
</Col>
<Postbox title={'Journal details'} defaultOpen={false}>
<Row>
<Col md={8}>
<FastField name={'description'}>
{({ field, meta: { error, touched } }) => (
<FormGroup
label={<T id={'description'} />}
className={'form-group--description'}
intent={inputIntent({ error, touched })}
helperText={<ErrorMessage name="description" />}
fill={true}
>
<TextArea fill={true} {...field} />
</FormGroup>
)}
</FastField>
</Col>
<Col md={4}>
<Dragzone
initialFiles={[]}
// onDrop={handleDropFiles}
// onDeleteFile={handleDeleteFile}
hint={'Attachments: Maxiumum size: 20MB'}
/>
</Col>
</Row>
<Col md={4}>
<Dragzone
initialFiles={[]}
// onDrop={handleDropFiles}
// onDeleteFile={handleDeleteFile}
hint={'Attachments: Maxiumum size: 20MB'}
/>
</Col>
</Row>
</Postbox>
</div>
);
}