From 4c028eb14d1ec00adb4a64dea6e6839148460d0e Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Thu, 2 Jun 2016 22:17:54 -0700 Subject: [PATCH 1/6] Escape on metric value field should work --- .../distributions/editor/TextForm/TextInput.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/distributions/editor/TextForm/TextInput.js b/src/components/distributions/editor/TextForm/TextInput.js index 2d16b95e8..abea62e15 100644 --- a/src/components/distributions/editor/TextForm/TextInput.js +++ b/src/components/distributions/editor/TextForm/TextInput.js @@ -44,11 +44,15 @@ class TextInputEditor extends Component { if (e.shiftKey) { return false } else { - this.props.handleReturn() + this.props.handleEscape() return true } } + handleEscape() { + this.props.handleEscape() + } + render() { const {editorState} = this.state; return ( @@ -60,6 +64,7 @@ class TextInputEditor extends Component { > Date: Fri, 3 Jun 2016 00:03:34 -0700 Subject: [PATCH 2/6] Mouse must move to create multiple selection --- src/components/lib/FlowGrid/FlowGrid.jsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/lib/FlowGrid/FlowGrid.jsx b/src/components/lib/FlowGrid/FlowGrid.jsx index 67b0ee34b..1d397c793 100644 --- a/src/components/lib/FlowGrid/FlowGrid.jsx +++ b/src/components/lib/FlowGrid/FlowGrid.jsx @@ -15,6 +15,9 @@ import './FlowGrid.css' let upto = (n) => Array.apply(null, {length: n}).map(Number.call, Number) +//It would be better to have this as state, but we don't want this to cause renders. +let lastMousePosition = [0, 0] + @DragDropContext(HTML5Backend) export default class FlowGrid extends Component{ displayName: 'FlowGrid' @@ -71,14 +74,22 @@ export default class FlowGrid extends Component{ _handleEmptyCellMouseDown(e, location) { if (e.button === 0 && !(e.target && e.target.type === 'textarea')) { this.setState({leftDown: true}) + lastMousePosition = _.pick(e, 'pageX', 'pageY') e.preventDefault() } } - _handleCellMouseEnter(location) { + _mouseMoved(e){ + const sameLocation = (e.pageX === lastMousePosition.pageX) && (e.pageY === lastMousePosition.pageY) + return !sameLocation + } + + _handleCellMouseEnter(location, e) { if (this.state.leftDown) { - this.setState({hover: {row: -1, column: -1}}) - this._handleEndRangeSelect(location) + if (this._mouseMoved(e)) { + this.setState({hover: {row: -1, column: -1}}) + this._handleEndRangeSelect(location) + } } else { this.setState({hover: location}) } From 189a9e5112d5bcb510514cd9cbee03530bb1e5dd Mon Sep 17 00:00:00 2001 From: Matthew McDermott Date: Fri, 3 Jun 2016 11:09:16 -0700 Subject: [PATCH 3/6] Data simulates now. --- src/components/distributions/editor/DataForm/DataForm.js | 4 ++-- src/components/distributions/editor/TextForm/TextForm.js | 2 +- src/components/distributions/editor/index.js | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/distributions/editor/DataForm/DataForm.js b/src/components/distributions/editor/DataForm/DataForm.js index 7e7d58868..5aa28b0d4 100644 --- a/src/components/distributions/editor/DataForm/DataForm.js +++ b/src/components/distributions/editor/DataForm/DataForm.js @@ -3,8 +3,8 @@ import React, {Component} from 'react' import {SmallDataViewer, LargeDataViewer} from './DataViewer' export default class DataForm extends Component{ - _handleDelete() { this.props.onSave({guesstimateType: null, data: null, input: null}) } - _handleSave(data) { this.props.onSave({guesstimateType: 'DATA', data, input: null}) } + _handleDelete() { this.props.onSave({guesstimateType: null, data: null, input: null}, true) } + _handleSave(data) { this.props.onSave({guesstimateType: 'DATA', data, input: null}, true) } render() { const {size, data, onOpen} = this.props diff --git a/src/components/distributions/editor/TextForm/TextForm.js b/src/components/distributions/editor/TextForm/TextForm.js index ed75bc1b6..c6c52fa79 100644 --- a/src/components/distributions/editor/TextForm/TextForm.js +++ b/src/components/distributions/editor/TextForm/TextForm.js @@ -50,7 +50,7 @@ export default class TextForm extends Component{ this.props.onChangeClickMode(newMode) } - _saveData(data) { this.props.onSave({guesstimateType: 'DATA', data, input: null}) } + _saveData(data) { this.props.onSave({guesstimateType: 'DATA', data, input: null}, true) } _shouldDisplayType() { const type = this._guesstimateType() diff --git a/src/components/distributions/editor/index.js b/src/components/distributions/editor/index.js index af117f96b..453dc7f2d 100644 --- a/src/components/distributions/editor/index.js +++ b/src/components/distributions/editor/index.js @@ -29,11 +29,11 @@ export default class Guesstimate extends Component{ _handleChange(params, runSimulations=true, registerGraphChange=false) { this.props.dispatch(changeGuesstimate(this.props.metricId, {...this.props.guesstimate, ...params}, runSimulations, registerGraphChange)) } - _handleSave(params) { - if (!_.isEmpty(params)) {this._handleChange(params, false, true)} + _handleSave(params, runSimulations=false) { + if (!_.isEmpty(params)) {this._handleChange(params, runSimulations, true)} } _changeMetricClickMode(newMode) { this.props.dispatch(changeMetricClickMode(newMode)) } - _addDefaultData() { this._handleSave({guesstimateType: 'DATA', data:[1,2,3], input: null}) } + _addDefaultData() { this._handleSave({guesstimateType: 'DATA', data:[1,2,3], input: null}, true) } render () { const {size, guesstimate, onOpen, errors} = this.props From dcb5a4e4d5c70dbcdee539574dec3fe5bfcdba60 Mon Sep 17 00:00:00 2001 From: Matthew McDermott Date: Fri, 3 Jun 2016 11:25:12 -0700 Subject: [PATCH 4/6] Use _.map to avoid an SI infinte recursion error in dev. --- src/components/distributions/editor/DataForm/DataViewer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/distributions/editor/DataForm/DataViewer.js b/src/components/distributions/editor/DataForm/DataViewer.js index 9237ffaaa..dfb5966c3 100644 --- a/src/components/distributions/editor/DataForm/DataViewer.js +++ b/src/components/distributions/editor/DataForm/DataViewer.js @@ -119,7 +119,7 @@ class Editor extends Component{ const Viewer = ({data}) => (
    - {data.map((element, index) => { + {_.map(data, (element, index) => { return (
  • From cfeeb155e581a16efd97cb025de1671e1774e0a8 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Fri, 3 Jun 2016 11:42:36 -0700 Subject: [PATCH 5/6] Minor change in response to PR --- src/components/lib/FlowGrid/FlowGrid.jsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/lib/FlowGrid/FlowGrid.jsx b/src/components/lib/FlowGrid/FlowGrid.jsx index 1d397c793..259f447b3 100644 --- a/src/components/lib/FlowGrid/FlowGrid.jsx +++ b/src/components/lib/FlowGrid/FlowGrid.jsx @@ -85,11 +85,9 @@ export default class FlowGrid extends Component{ } _handleCellMouseEnter(location, e) { - if (this.state.leftDown) { - if (this._mouseMoved(e)) { - this.setState({hover: {row: -1, column: -1}}) - this._handleEndRangeSelect(location) - } + if (this.state.leftDown && this._mouseMoved(e)) { + this.setState({hover: {row: -1, column: -1}}) + this._handleEndRangeSelect(location) } else { this.setState({hover: location}) } From 9ad9976f4621578a5bcf83c5f1bc3ec28e7600ee Mon Sep 17 00:00:00 2001 From: Matthew McDermott Date: Fri, 3 Jun 2016 11:49:43 -0700 Subject: [PATCH 6/6] Metric modals should only render when they are open, not otherwise. --- src/components/metrics/card/index.js | 13 ++-- src/components/metrics/modal/index.js | 94 +++++++++++++-------------- 2 files changed, 51 insertions(+), 56 deletions(-) diff --git a/src/components/metrics/card/index.js b/src/components/metrics/card/index.js index 79051e8e2..97e3a7ba2 100644 --- a/src/components/metrics/card/index.js +++ b/src/components/metrics/card/index.js @@ -218,12 +218,13 @@ export default class MetricCard extends Component { tabIndex='0' >
    - + {this.state.modalIsOpen && + + } - {isOpen && -
    -
    -
    - -
    -
    -
    -

    {metric.name}

    +
    +
    +
    +
    -
    - -
    -
    -
    -
    - {showSimulation && - - } +
    +

    {metric.name}

    -
    - +
    + +
    +
    +
    +
    +
    + {showSimulation && + + } +
    +
    + +
    -
    -
    -
    -
    - +
    +
    +
    + +
    -
    -
    -
    - {guesstimate && - - } +
    +
    + {guesstimate && + + } +
    -
    - } ) }