-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Counter Editor: move components to own files (#4138)
- Loading branch information
1 parent
75a5546
commit 75883a1
Showing
4 changed files
with
248 additions
and
236 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
107 changes: 107 additions & 0 deletions
107
client/app/visualizations/counter/Editor/FormatSettings.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import React from 'react'; | ||
import * as Grid from 'antd/lib/grid'; | ||
import Input from 'antd/lib/input'; | ||
import InputNumber from 'antd/lib/input-number'; | ||
import Switch from 'antd/lib/switch'; | ||
import { EditorPropTypes } from '@/visualizations'; | ||
|
||
import { isValueNumber } from '../utils'; | ||
|
||
export default function FormatSettings({ options, data, onOptionsChange }) { | ||
const inputsEnabled = isValueNumber(data.rows, options); | ||
return ( | ||
<React.Fragment> | ||
<Grid.Row type="flex" align="middle" className="m-b-10"> | ||
<Grid.Col span={12}> | ||
<label htmlFor="counter-formatting-decimal-place">Formatting Decimal Place</label> | ||
</Grid.Col> | ||
<Grid.Col span={12}> | ||
<InputNumber | ||
id="counter-formatting-decimal-place" | ||
className="w-100" | ||
data-test="Counter.Formatting.DecimalPlace" | ||
defaultValue={options.stringDecimal} | ||
disabled={!inputsEnabled} | ||
onChange={stringDecimal => onOptionsChange({ stringDecimal })} | ||
/> | ||
</Grid.Col> | ||
</Grid.Row> | ||
|
||
<Grid.Row type="flex" align="middle" className="m-b-10"> | ||
<Grid.Col span={12}> | ||
<label htmlFor="counter-formatting-decimal-character">Formatting Decimal Character</label> | ||
</Grid.Col> | ||
<Grid.Col span={12}> | ||
<Input | ||
id="counter-formatting-decimal-character" | ||
className="w-100" | ||
data-test="Counter.Formatting.DecimalCharacter" | ||
defaultValue={options.stringDecChar} | ||
disabled={!inputsEnabled} | ||
onChange={e => onOptionsChange({ stringDecChar: e.target.value })} | ||
/> | ||
</Grid.Col> | ||
</Grid.Row> | ||
|
||
<Grid.Row type="flex" align="middle" className="m-b-10"> | ||
<Grid.Col span={12}> | ||
<label htmlFor="counter-formatting-thousands-separator">Formatting Thousands Separator</label> | ||
</Grid.Col> | ||
<Grid.Col span={12}> | ||
<Input | ||
id="counter-formatting-thousands-separator" | ||
className="w-100" | ||
data-test="Counter.Formatting.ThousandsSeparator" | ||
defaultValue={options.stringThouSep} | ||
disabled={!inputsEnabled} | ||
onChange={e => onOptionsChange({ stringThouSep: e.target.value })} | ||
/> | ||
</Grid.Col> | ||
</Grid.Row> | ||
|
||
<Grid.Row type="flex" align="middle" className="m-b-10"> | ||
<Grid.Col span={12}> | ||
<label htmlFor="counter-formatting-string-prefix">Formatting String Prefix</label> | ||
</Grid.Col> | ||
<Grid.Col span={12}> | ||
<Input | ||
id="counter-formatting-string-prefix" | ||
className="w-100" | ||
data-test="Counter.Formatting.StringPrefix" | ||
defaultValue={options.stringPrefix} | ||
disabled={!inputsEnabled} | ||
onChange={e => onOptionsChange({ stringPrefix: e.target.value })} | ||
/> | ||
</Grid.Col> | ||
</Grid.Row> | ||
|
||
<Grid.Row type="flex" align="middle" className="m-b-10"> | ||
<Grid.Col span={12}> | ||
<label htmlFor="counter-formatting-string-suffix">Formatting String Suffix</label> | ||
</Grid.Col> | ||
<Grid.Col span={12}> | ||
<Input | ||
id="counter-formatting-string-suffix" | ||
className="w-100" | ||
data-test="Counter.Formatting.StringSuffix" | ||
defaultValue={options.stringSuffix} | ||
disabled={!inputsEnabled} | ||
onChange={e => onOptionsChange({ stringSuffix: e.target.value })} | ||
/> | ||
</Grid.Col> | ||
</Grid.Row> | ||
|
||
<label className="d-flex align-items-center" htmlFor="counter-format-target-value"> | ||
<Switch | ||
id="counter-format-target-value" | ||
data-test="Counter.Formatting.FormatTargetValue" | ||
defaultChecked={options.formatTargetValue} | ||
onChange={formatTargetValue => onOptionsChange({ formatTargetValue })} | ||
/> | ||
<span className="m-l-10">Format Target Value</span> | ||
</label> | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
FormatSettings.propTypes = EditorPropTypes; |
Oops, something went wrong.