From 75883a1a02afaf4401259f8db78a63b3aab50b9c Mon Sep 17 00:00:00 2001 From: Levko Kravets Date: Fri, 13 Sep 2019 22:35:19 +0300 Subject: [PATCH] Counter Editor: move components to own files (#4138) --- client/app/visualizations/counter/Editor.jsx | 236 ------------------ .../counter/Editor/FormatSettings.jsx | 107 ++++++++ .../counter/Editor/GeneralSettings.jsx | 113 +++++++++ .../visualizations/counter/Editor/index.jsx | 28 +++ 4 files changed, 248 insertions(+), 236 deletions(-) delete mode 100644 client/app/visualizations/counter/Editor.jsx create mode 100644 client/app/visualizations/counter/Editor/FormatSettings.jsx create mode 100644 client/app/visualizations/counter/Editor/GeneralSettings.jsx create mode 100644 client/app/visualizations/counter/Editor/index.jsx diff --git a/client/app/visualizations/counter/Editor.jsx b/client/app/visualizations/counter/Editor.jsx deleted file mode 100644 index 24827bb199..0000000000 --- a/client/app/visualizations/counter/Editor.jsx +++ /dev/null @@ -1,236 +0,0 @@ -import { merge, map } from 'lodash'; -import React from 'react'; -import Tabs from 'antd/lib/tabs'; -import Input from 'antd/lib/input'; -import InputNumber from 'antd/lib/input-number'; -import Select from 'antd/lib/select'; -import Switch from 'antd/lib/switch'; -import * as Grid from 'antd/lib/grid'; -import { EditorPropTypes } from '@/visualizations'; - -import { isValueNumber } from './utils'; - -function GeneralSettings({ options, data, visualizationName, onOptionsChange }) { - return ( - - - - - - - onOptionsChange({ counterLabel: e.target.value })} - /> - - - - - - - - - - - - - - - - - - onOptionsChange({ rowNumber })} - /> - - - - - - - - - - - - - - - - - - onOptionsChange({ targetRowNumber })} - /> - - - - - - ); -} - -GeneralSettings.propTypes = EditorPropTypes; - -function FormatSettings({ options, data, onOptionsChange }) { - const inputsEnabled = isValueNumber(data.rows, options); - return ( - - - - - - - onOptionsChange({ stringDecimal })} - /> - - - - - - - - - onOptionsChange({ stringDecChar: e.target.value })} - /> - - - - - - - - - onOptionsChange({ stringThouSep: e.target.value })} - /> - - - - - - - - - onOptionsChange({ stringPrefix: e.target.value })} - /> - - - - - - - - - onOptionsChange({ stringSuffix: e.target.value })} - /> - - - - - - ); -} - -FormatSettings.propTypes = EditorPropTypes; - -export default function Editor(props) { - const { options, onOptionsChange } = props; - - const optionsChanged = (newOptions) => { - onOptionsChange(merge({}, options, newOptions)); - }; - - return ( - - General}> - - - Format}> - - - - ); -} - -Editor.propTypes = EditorPropTypes; diff --git a/client/app/visualizations/counter/Editor/FormatSettings.jsx b/client/app/visualizations/counter/Editor/FormatSettings.jsx new file mode 100644 index 0000000000..144a1e3566 --- /dev/null +++ b/client/app/visualizations/counter/Editor/FormatSettings.jsx @@ -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 ( + + + + + + + onOptionsChange({ stringDecimal })} + /> + + + + + + + + + onOptionsChange({ stringDecChar: e.target.value })} + /> + + + + + + + + + onOptionsChange({ stringThouSep: e.target.value })} + /> + + + + + + + + + onOptionsChange({ stringPrefix: e.target.value })} + /> + + + + + + + + + onOptionsChange({ stringSuffix: e.target.value })} + /> + + + + + + ); +} + +FormatSettings.propTypes = EditorPropTypes; diff --git a/client/app/visualizations/counter/Editor/GeneralSettings.jsx b/client/app/visualizations/counter/Editor/GeneralSettings.jsx new file mode 100644 index 0000000000..554a588bc9 --- /dev/null +++ b/client/app/visualizations/counter/Editor/GeneralSettings.jsx @@ -0,0 +1,113 @@ +import { map } from 'lodash'; +import React from 'react'; +import * as Grid from 'antd/lib/grid'; +import Select from 'antd/lib/select'; +import Input from 'antd/lib/input'; +import InputNumber from 'antd/lib/input-number'; +import Switch from 'antd/lib/switch'; +import { EditorPropTypes } from '@/visualizations'; + +export default function GeneralSettings({ options, data, visualizationName, onOptionsChange }) { + return ( + + + + + + + onOptionsChange({ counterLabel: e.target.value })} + /> + + + + + + + + + + + + + + + + + + onOptionsChange({ rowNumber })} + /> + + + + + + + + + + + + + + + + + + onOptionsChange({ targetRowNumber })} + /> + + + + + + ); +} + +GeneralSettings.propTypes = EditorPropTypes; diff --git a/client/app/visualizations/counter/Editor/index.jsx b/client/app/visualizations/counter/Editor/index.jsx new file mode 100644 index 0000000000..e897a56672 --- /dev/null +++ b/client/app/visualizations/counter/Editor/index.jsx @@ -0,0 +1,28 @@ +import { merge } from 'lodash'; +import React from 'react'; +import Tabs from 'antd/lib/tabs'; +import { EditorPropTypes } from '@/visualizations'; + +import GeneralSettings from './GeneralSettings'; +import FormatSettings from './FormatSettings'; + +export default function Editor(props) { + const { options, onOptionsChange } = props; + + const optionsChanged = (newOptions) => { + onOptionsChange(merge({}, options, newOptions)); + }; + + return ( + + General}> + + + Format}> + + + + ); +} + +Editor.propTypes = EditorPropTypes;