From 6d4b3164a8b7843734fef8e50100ef677c2b2456 Mon Sep 17 00:00:00 2001 From: Ahmed Bouhuolia Date: Thu, 12 Nov 2020 20:44:22 +0200 Subject: [PATCH] feat: optimize sale estimate form performance. feat: optimize sale receipt form performance. feat: optimize sale invoice form performance. feat: optimize bill form performance. --- .vscode/FastField.code-snippets | 21 + .vscode/settings.json | 2 +- client/src/components/AccountsSelectList.js | 2 + client/src/components/App.js | 8 +- client/src/components/ContactSelecetList.js | 1 + client/src/components/index.js | 2 + .../Entries/EditableItemsEntriesTable.js | 83 ++++ .../containers/Entries/ItemsEntriesTable.js | 267 ++++++++++ .../Purchases/Bill/BillFloatingActions.js | 32 +- .../src/containers/Purchases/Bill/BillForm.js | 393 +++++---------- .../Purchases/Bill/BillForm.schema.js | 51 ++ .../Purchases/Bill/BillFormFooter.js | 24 +- .../Purchases/Bill/BillFormHeader.js | 247 +++++----- .../Sales/Estimate/EntriesItemsTable.js | 5 +- .../Sales/Estimate/EstimateFloatingActions.js | 44 +- .../containers/Sales/Estimate/EstimateForm.js | 452 ++++++----------- .../Sales/Estimate/EstimateForm.schema.js | 51 ++ .../Sales/Estimate/EstimateFormFooter.js | 58 +++ .../Sales/Estimate/EstimateFormHeader.js | 272 +++++------ .../Sales/Estimate/EstimateNumberWatcher.js | 46 ++ .../Sales/Invoice/InvoiceFloatingActions.js | 40 +- .../containers/Sales/Invoice/InvoiceForm.js | 455 ++++++------------ .../Sales/Invoice/InvoiceForm.schema.js | 49 ++ .../Sales/Invoice/InvoiceFormFooter.js | 55 +++ .../Sales/Invoice/InvoiceFormHeader.js | 245 +++++----- .../Invoice/InvoiceNumberChangeWatcher.js | 44 ++ .../containers/Sales/Receipt/ReceiptForm.js | 452 ++++++----------- .../Sales/Receipt/ReceiptForm.schema.js | 55 +++ .../Receipt/ReceiptFormFloatingActions.js | 63 +++ .../Sales/Receipt/ReceiptFormFooter.js | 53 ++ .../Sales/Receipt/ReceiptFormHeader.js | 267 +++++----- .../Sales/Receipt/ReceiptNumberWatcher.js | 45 ++ .../Receipt/ReceiptReceiveFloatingActions.js | 52 -- client/src/services/intl.js | 24 + client/src/style/App.scss | 2 +- client/src/utils.js | 4 + 36 files changed, 2088 insertions(+), 1878 deletions(-) create mode 100644 .vscode/FastField.code-snippets create mode 100644 client/src/containers/Entries/EditableItemsEntriesTable.js create mode 100644 client/src/containers/Entries/ItemsEntriesTable.js create mode 100644 client/src/containers/Purchases/Bill/BillForm.schema.js create mode 100644 client/src/containers/Sales/Estimate/EstimateForm.schema.js create mode 100644 client/src/containers/Sales/Estimate/EstimateFormFooter.js create mode 100644 client/src/containers/Sales/Estimate/EstimateNumberWatcher.js create mode 100644 client/src/containers/Sales/Invoice/InvoiceForm.schema.js create mode 100644 client/src/containers/Sales/Invoice/InvoiceFormFooter.js create mode 100644 client/src/containers/Sales/Invoice/InvoiceNumberChangeWatcher.js create mode 100644 client/src/containers/Sales/Receipt/ReceiptForm.schema.js create mode 100644 client/src/containers/Sales/Receipt/ReceiptFormFloatingActions.js create mode 100644 client/src/containers/Sales/Receipt/ReceiptFormFooter.js create mode 100644 client/src/containers/Sales/Receipt/ReceiptNumberWatcher.js delete mode 100644 client/src/containers/Sales/Receipt/ReceiptReceiveFloatingActions.js create mode 100644 client/src/services/intl.js diff --git a/.vscode/FastField.code-snippets b/.vscode/FastField.code-snippets new file mode 100644 index 000000000..1cd9b7fb6 --- /dev/null +++ b/.vscode/FastField.code-snippets @@ -0,0 +1,21 @@ +{ + // Place your Ratteb workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and + // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope + // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is + // used to trigger the snippet and the body will be expanded and inserted. Possible variables are: + // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. + // Placeholders with the same ids are connected. + // Example: + "fastfield": { + "scope": "javascript,typescript", + "prefix": "fastfield", + "body": [ + "", + " {({ form, field: { value }, meta: { error, touched } }) => (", + "", + " )}", + "" + ], + "description": "Fast field component" + } +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 16d3c53ab..ce96ff416 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -26,5 +26,5 @@ "editor.tabSize": 2, "editor.insertSpaces": true, "git.ignoreLimitWarning": true, - "god.tsconfig": "./tsconfig.json", + "god.tsconfig": "./server/tsconfig.json", } \ No newline at end of file diff --git a/client/src/components/AccountsSelectList.js b/client/src/components/AccountsSelectList.js index de1511753..4b1f67593 100644 --- a/client/src/components/AccountsSelectList.js +++ b/client/src/components/AccountsSelectList.js @@ -2,6 +2,7 @@ import React, { useCallback, useState, useEffect, useMemo } from 'react'; import { MenuItem, Button } from '@blueprintjs/core'; import { Select } from '@blueprintjs/select'; import { FormattedMessage as T } from 'react-intl'; +import classNames from 'classnames'; import { isEmpty } from 'lodash'; export default function AccountsSelectList({ @@ -103,6 +104,7 @@ export default function AccountsSelectList({ filterable={true} onItemSelect={onAccountSelect} disabled={disabled} + className={classNames('form-group--select-list')} > + + + + + ); +} + +export default compose( + withItems(({ itemsCurrentPage }) => ({ + itemsCurrentPage, + })), +)(ItemsEntriesTable); diff --git a/client/src/containers/Purchases/Bill/BillFloatingActions.js b/client/src/containers/Purchases/Bill/BillFloatingActions.js index 2373433a4..c71848ea5 100644 --- a/client/src/containers/Purchases/Bill/BillFloatingActions.js +++ b/client/src/containers/Purchases/Bill/BillFloatingActions.js @@ -1,12 +1,15 @@ import React from 'react'; import { Intent, Button } from '@blueprintjs/core'; import { FormattedMessage as T } from 'react-intl'; +import { saveInvoke } from 'utils'; export default function BillFloatingActions({ - formik: { isSubmitting }, + isSubmitting, onSubmitClick, + onSubmitAndNewClick, onCancelClick, - bill, + onClearClick, + billId, }) { return (
@@ -15,11 +18,11 @@ export default function BillFloatingActions({ loading={isSubmitting} intent={Intent.PRIMARY} type="submit" - onClick={() => { - onSubmitClick({ redirect: true }); + onClick={(event) => { + saveInvoke(onSubmitClick, event); }} > - {bill && bill.id ? : } + {billId ? : } -