From 8aa174e70c01631ae4e00a6d208966fcd77cf972 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Fri, 10 Jul 2020 10:21:46 +0200 Subject: Add implementation of portfolio and scenario UI structure --- .../NewPortfolioModalComponent.js | 99 ++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js (limited to 'frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js') diff --git a/frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js b/frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js new file mode 100644 index 00000000..ace2d751 --- /dev/null +++ b/frontend/src/components/modals/custom-components/NewPortfolioModalComponent.js @@ -0,0 +1,99 @@ +import PropTypes from 'prop-types' +import React from 'react' +import Modal from '../Modal' +import { AVAILABLE_METRICS } from '../../../util/available-metrics' + +class NewPortfolioModalComponent extends React.Component { + static propTypes = { + show: PropTypes.bool.isRequired, + callback: PropTypes.func.isRequired, + } + + constructor(props) { + super(props) + this.metricCheckboxes = {} + } + + componentDidMount() { + this.reset() + } + + reset() { + this.textInput.value = '' + AVAILABLE_METRICS.forEach(metric => { + this.metricCheckboxes[metric].checked = true + }) + this.repeatsInput.value = 1 + } + + onSubmit() { + this.props.callback( + this.textInput.value, + { + enabledMetrics: AVAILABLE_METRICS.filter(metric => this.metricCheckboxes[metric].checked), + repeatsPerScenario: parseInt(this.repeatsInput.value), + }, + ) + this.reset() + } + + onCancel() { + this.props.callback(undefined) + this.reset() + } + + render() { + return ( + +
{ + e.preventDefault() + this.onSubmit() + }} + > +
+ + (this.textInput = textInput)} + /> +
+

Targets

+
Metrics
+
+ {AVAILABLE_METRICS.map(metric => ( +
+ +
+ ))} +
+
+ + (this.repeatsInput = repeatsInput)} + /> +
+
+
+ ) + } +} + +export default NewPortfolioModalComponent -- cgit v1.2.3