From f0a8b250d93d2e542f103085f269be8d5dfd7ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marti=CC=81n=20Osimani?= Date: Tue, 17 Oct 2017 17:27:50 -0300 Subject: [PATCH 01/37] Added temp ranges to routine upsert --- package-lock.json | 30 +-- src/presentation/common/button/icon/index.js | 7 +- src/presentation/common/button/index.js | 11 +- src/presentation/common/button/styles.css | 4 +- .../common/text_input/time/index.js | 41 ++++ .../common/text_input/time/styles.css | 3 + .../experiment/details/presenter.js | 4 +- .../experiment/upsert/breadcrumb/index.js | 31 +++ .../experiment/upsert/breadcrumb/presenter.js | 38 ++++ .../experiment/upsert/breadcrumb/styles.css | 40 ++++ .../experiment/upsert/details/index.js | 56 ++++++ .../experiment/upsert/details/presenter.js | 80 ++++++++ .../experiment/upsert/details/style.css | 0 src/presentation/experiment/upsert/index.js | 47 +++-- .../experiment/upsert/parameters/index.js | 68 +++++++ .../experiment/upsert/parameters/presenter.js | 152 ++++++++++++++ .../experiment/upsert/parameters/styles.css | 0 .../experiment/upsert/presenter.js | 188 +++--------------- src/presentation/experiment/upsert/styles.css | 1 - src/redux/routine/action_types.js | 13 ++ src/redux/routine/actions.js | 47 +++-- src/redux/routine/redux/action_status.js | 15 +- .../routine/redux/upsert_action_status.js | 72 +++++++ src/redux/routine/sagas/index.js | 7 +- src/redux/routine/sagas/perform.js | 19 +- src/redux/routine/selector.js | 11 +- 26 files changed, 753 insertions(+), 232 deletions(-) create mode 100644 src/presentation/common/text_input/time/index.js create mode 100644 src/presentation/common/text_input/time/styles.css create mode 100644 src/presentation/experiment/upsert/breadcrumb/index.js create mode 100644 src/presentation/experiment/upsert/breadcrumb/presenter.js create mode 100644 src/presentation/experiment/upsert/breadcrumb/styles.css create mode 100644 src/presentation/experiment/upsert/details/index.js create mode 100644 src/presentation/experiment/upsert/details/presenter.js create mode 100644 src/presentation/experiment/upsert/details/style.css create mode 100644 src/presentation/experiment/upsert/parameters/index.js create mode 100644 src/presentation/experiment/upsert/parameters/presenter.js create mode 100644 src/presentation/experiment/upsert/parameters/styles.css create mode 100644 src/redux/routine/redux/upsert_action_status.js diff --git a/package-lock.json b/package-lock.json index dd7feef..ccc18d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4134,13 +4134,6 @@ } } }, - "string_decoder": { - "version": "1.0.1", - "bundled": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, "string-width": { "version": "1.0.2", "bundled": true, @@ -4150,6 +4143,13 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.1", + "bundled": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, "stringstream": { "version": "0.0.5", "bundled": true, @@ -9530,14 +9530,6 @@ "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=" }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-length": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/string-length/-/string-length-1.0.1.tgz", @@ -9556,6 +9548,14 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "requires": { + "safe-buffer": "5.1.1" + } + }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", diff --git a/src/presentation/common/button/icon/index.js b/src/presentation/common/button/icon/index.js index c3a6b59..7eb15c2 100644 --- a/src/presentation/common/button/icon/index.js +++ b/src/presentation/common/button/icon/index.js @@ -1,11 +1,8 @@ import React from 'react' -import Icon from '../../icon' import { Button } from 'semantic-ui-react' -const IconButton = ({ name, color, onClick }) => ( - +const IconButton = props => ( + } diff --git a/src/presentation/experiment/upsert/breadcrumb/index.js b/src/presentation/experiment/upsert/breadcrumb/index.js new file mode 100644 index 0000000..7476bf2 --- /dev/null +++ b/src/presentation/experiment/upsert/breadcrumb/index.js @@ -0,0 +1,31 @@ +import React from 'react' +import { connect } from 'react-redux' + +import { + upsertSetCurrentSection +} from '../../../../redux/routine/actions' + +import { + selectUpsertActionStatus +} from '../../../../redux/routine/selector' + +import UpsertExperimentBreadcrumbPresenter from './presenter' + +const UpsertExperimentBreadcrumb = ({ currentSection, setCurrentSection }) => { + return ( + + ) +} + +const mapStateToProps = state => ({ + ...selectUpsertActionStatus(state) +}) + +const mapDispatchToProps = dispatch => ({ + setCurrentSection: section => dispatch(upsertSetCurrentSection(section)) +}) + +export default connect(mapStateToProps, mapDispatchToProps)(UpsertExperimentBreadcrumb) diff --git a/src/presentation/experiment/upsert/breadcrumb/presenter.js b/src/presentation/experiment/upsert/breadcrumb/presenter.js new file mode 100644 index 0000000..caa0e84 --- /dev/null +++ b/src/presentation/experiment/upsert/breadcrumb/presenter.js @@ -0,0 +1,38 @@ +import React from 'react' +import { Grid } from 'semantic-ui-react' +import classNames from 'classnames' +import './styles.css' + +import Container from '../../../common/container' + +const SECTIONS = [ + { section: 'details', title: 'Información básica' }, + { section: 'parameters', title: 'Configuar parámetros' } +] + +const UpsertExperimentBreadcrumb = ({ currentSection, setCurrentSection }) => { + const currentSectionIndex = SECTIONS.findIndex(({ section }) => section === currentSection) + return ( +
+ + + { SECTIONS.map(({ section, title }, index) => ( + + currentSectionIndex + })} + onClick={() => setCurrentSection(section)} + > + {title} + + + ))} + + +
+ ) +} + +export default UpsertExperimentBreadcrumb diff --git a/src/presentation/experiment/upsert/breadcrumb/styles.css b/src/presentation/experiment/upsert/breadcrumb/styles.css new file mode 100644 index 0000000..54df43a --- /dev/null +++ b/src/presentation/experiment/upsert/breadcrumb/styles.css @@ -0,0 +1,40 @@ +@value border from '../../../constants/border.css'; +@value primary, accent1, accent2 from '../../../constants/colors.css'; + +.upsertExperimentBreadcrumb { + border-bottom: border; + height: 47px; + background: white; + display: flex; + align-items: center; +} + +.upsertExperimentBreadcrumb .container { + width: 100%; + margin-left: 20px; +} + +.upsertExperimentBreadcrumb .grid { + width: 100%; +} + +.upsertExperimentBreadcrumb a { + color: accent1; + font-size: 16px; + font-weight: 500; +} + +.upsertExperimentBreadcrumb a.dimmed { + color: accent2; +} + +.upsertExperimentBreadcrumb a.active { + color: primary; +} + +.upsertExperimentBreadcrumb h3 { + font-size: 16px; + font-weight: 500; + color: accent1; + padding-top: 8px; +} \ No newline at end of file diff --git a/src/presentation/experiment/upsert/details/index.js b/src/presentation/experiment/upsert/details/index.js new file mode 100644 index 0000000..e10c3ea --- /dev/null +++ b/src/presentation/experiment/upsert/details/index.js @@ -0,0 +1,56 @@ +import React, { Component } from 'react' +import { connect } from 'react-redux' +import moment from 'moment' + +import { + upsertUpdateRoutine +} from '../../../../redux/routine/actions' + +import { + selectUpsertActionStatus, + selectRoutineFetchingStatus +} from '../../../../redux/routine/selector' + +import UpsertExperimentDetailsPresenter from './presenter' + +class UpsertExperimentDetails extends Component { + onUpdateRoutine (routine) { + const hoursDuration = moment.duration(parseInt(routine.hours), 'hours').asSeconds() || 0 + const minutesDuration = moment.duration(parseInt(routine.minutes), 'minutes').asSeconds() || 0 + this.props.updateRoutine({ + ...routine, + estimatedTimeSeconds: hoursDuration + minutesDuration + }) + } + + mapTempRangesToHoursAndSeconds () { + const estimatedTimeSecondsDuration = moment.duration(this.props.routine.estimatedTimeSeconds) + return { + ...this.props.routine, + hours: estimatedTimeSecondsDuration.hours(), + minutes: estimatedTimeSecondsDuration.minutes() + } + } + + render () { + return ( + + ) + } +} + +const mapStateToProps = state => ({ + ...selectUpsertActionStatus(state), + ...selectRoutineFetchingStatus(state) +}) + +const mapDispatchToProps = dispatch => ({ + updateRoutine: routine => dispatch(upsertUpdateRoutine(routine)) +}) + +export default connect(mapStateToProps, mapDispatchToProps)(UpsertExperimentDetails) diff --git a/src/presentation/experiment/upsert/details/presenter.js b/src/presentation/experiment/upsert/details/presenter.js new file mode 100644 index 0000000..090ecd1 --- /dev/null +++ b/src/presentation/experiment/upsert/details/presenter.js @@ -0,0 +1,80 @@ +import React from 'react' +import { Form, Grid } from 'semantic-ui-react' + +import TextInput from '../../../common/text_input' +import TextArea from '../../../common/text_area' + +const UpsertExperimentDetails = ({ routine, error, onUpdateRoutine }) => { + return ( +
+

Información básica

+ +
+ onUpdateRoutine({ ...routine, title })} + /> + + + onUpdateRoutine({ ...routine, strain })} + /> + onUpdateRoutine({ ...routine, medium })} + /> + + onUpdateRoutine({ ...routine, hours })} + /> + onUpdateRoutine({ ...routine, minutes })} + /> + + +