diff --git a/client/src/common/numberFormatsOptions.js b/client/src/common/numberFormatsOptions.js new file mode 100644 index 000000000..d39845288 --- /dev/null +++ b/client/src/common/numberFormatsOptions.js @@ -0,0 +1,18 @@ +export const moneyFormat = [ + { id: 'total', text: 'Total rows' }, + { id: 'always', text: 'Always' }, + { id: 'none', text: 'None' }, +]; + +export const negativeFormat = [ + { id: 'parentheses', text: 'Parentheses ($1000)' }, + { id: 'mines', text: 'Minus -$1000' }, +]; + +export const decimalPlaces = [ + { text: '1 Decimals', label: '$0.1', id: 1 }, + { text: '2 Decimals', label: '$0.01', id: 2 }, + { text: '3 Decimals', label: '$0.001', id: 3 }, + { text: '4 Decimals', label: '$0.0001', id: 4 }, + { text: '5 Decimals', label: '$0.00001', id: 5 }, +]; diff --git a/client/src/components/ListSelect.js b/client/src/components/ListSelect.js index c0aedf686..ebbfb5479 100644 --- a/client/src/components/ListSelect.js +++ b/client/src/components/ListSelect.js @@ -10,6 +10,7 @@ export default function ListSelect({ defaultText, noResultsText = , isLoading = false, + textProp, labelProp, selectedItem, @@ -52,8 +53,9 @@ export default function ListSelect({ const itemRenderer = (item, { handleClick, modifiers, query }) => { return ( ); @@ -77,7 +79,7 @@ export default function ListSelect({ )} > + + + + + ); +} diff --git a/client/src/components/NumberFormats/NumberFormats.schema.js b/client/src/components/NumberFormats/NumberFormats.schema.js new file mode 100644 index 000000000..bd5412c58 --- /dev/null +++ b/client/src/components/NumberFormats/NumberFormats.schema.js @@ -0,0 +1,14 @@ +import * as Yup from 'yup'; +import { DATATYPES_LENGTH } from 'common/dataTypes'; +import { defaultTo } from 'lodash'; + + +const Schema = Yup.object().shape({ + format_money: Yup.string(), + show_zero: Yup.boolean(), + divide_on_1000: Yup.boolean(), + negative_format: Yup.string(), + precision: Yup.string(), +}); + +export const CreateNumberFormateSchema = Schema; diff --git a/client/src/components/NumberFormats/index.js b/client/src/components/NumberFormats/index.js new file mode 100644 index 000000000..7357cc3d8 --- /dev/null +++ b/client/src/components/NumberFormats/index.js @@ -0,0 +1,42 @@ +import React, { useState, useCallback, useMemo } from 'react'; +import { Classes } from '@blueprintjs/core'; +import { Formik } from 'formik'; +import classNames from 'classnames'; +import NumberFormatFields from './NumberFormatFields'; + +import { compose } from 'utils'; + +/** + * Number format form popover content. + */ +function NumberFormats() { + const initialValues = useMemo( + () => ({ + format_money: '', + show_zero: '', + divide_on_1000: '', + negative_format: '', + precision: '', + }), + [], + ); + // Handle cancel button click. + const handleCancelClick = useCallback(() => { + }, []); + + // Handle form submit. + const handleFormSubmit = (values, { setSubmitting }) => { + setSubmitting(true); + const form = { ...values }; + }; + + return ( +
+ + + +
+ ); +} + +export default NumberFormats; diff --git a/client/src/containers/FinancialStatements/BalanceSheet/BalanceSheetActionsBar.js b/client/src/containers/FinancialStatements/BalanceSheet/BalanceSheetActionsBar.js index ad79d6d36..ea21c3849 100644 --- a/client/src/containers/FinancialStatements/BalanceSheet/BalanceSheetActionsBar.js +++ b/client/src/containers/FinancialStatements/BalanceSheet/BalanceSheetActionsBar.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import { NavbarGroup, Button, @@ -13,6 +13,7 @@ import classNames from 'classnames'; import Icon from 'components/Icon'; import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar'; +import NumberFormats from 'components/NumberFormats'; import { compose } from 'utils'; import withBalanceSheetDetail from './withBalanceSheetDetail'; @@ -49,7 +50,13 @@ function BalanceSheetActionsBar({