From f1a8b6929f5887dea4582f526477f64d5242e1eb Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Wed, 6 Apr 2016 13:52:37 -0700 Subject: [PATCH] fix(scheduler): can remove proposed times --- .../lib/calendar/proposed-time-event.jsx | 14 +++++++++++++- .../lib/calendar/proposed-time-picker.jsx | 2 +- .../lib/proposed-time-calendar-store.es6 | 9 ++++----- .../nylas-calendar/calendar-event-container.jsx | 3 +++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/internal_packages/N1-Scheduler/lib/calendar/proposed-time-event.jsx b/internal_packages/N1-Scheduler/lib/calendar/proposed-time-event.jsx index ff8fc6056..7ab944df9 100644 --- a/internal_packages/N1-Scheduler/lib/calendar/proposed-time-event.jsx +++ b/internal_packages/N1-Scheduler/lib/calendar/proposed-time-event.jsx @@ -8,13 +8,25 @@ import {CALENDAR_ID} from '../scheduler-constants' export default class ProposedTimeEvent extends React.Component { static displayName = "ProposedTimeEvent"; + // Since ProposedTimeEvent is part of an Injected Component set, by + // default it's placed in its own container that's rendered separately. + // + // This makes two separate React trees which cause the react event + // propagations to be separate. See: + // https://github.com/facebook/react/issues/1691 + // + // Unfortunately, this means that `stopPropagation` doesn't work from + // within injected component sets unless the `containerRequired` is set + // to `false` + static containerRequired = false; + static propTypes = { event: React.PropTypes.object, } _onMouseDown(event) { event.stopPropagation(); - SchedulerActions.removeProposedTime(event.target.dataset) + SchedulerActions.removeProposedTime(event.target.dataset); } render() { diff --git a/internal_packages/N1-Scheduler/lib/calendar/proposed-time-picker.jsx b/internal_packages/N1-Scheduler/lib/calendar/proposed-time-picker.jsx index b23eb44f0..a28d07850 100644 --- a/internal_packages/N1-Scheduler/lib/calendar/proposed-time-picker.jsx +++ b/internal_packages/N1-Scheduler/lib/calendar/proposed-time-picker.jsx @@ -86,7 +86,7 @@ export default class ProposedTimePicker extends React.Component { } _onChangeDuration = (event) => { - SchedulerActions.changeDuration(event.target.value.split(",")) + SchedulerActions.changeDuration(event.target.value.split("|")) } _onDone = () => { diff --git a/internal_packages/N1-Scheduler/lib/proposed-time-calendar-store.es6 b/internal_packages/N1-Scheduler/lib/proposed-time-calendar-store.es6 index 718a821d3..87340ba6a 100644 --- a/internal_packages/N1-Scheduler/lib/proposed-time-calendar-store.es6 +++ b/internal_packages/N1-Scheduler/lib/proposed-time-calendar-store.es6 @@ -17,9 +17,7 @@ require('moment-round') */ class ProposedTimeCalendarStore extends NylasStore { DURATIONS = [ - [15, 'minutes', '15 min'], [30, 'minutes', '30 min'], - [50, 'minutes', '50 min'], [1, 'hour', '1 hr'], [1.5, 'hours', '1½ hr'], [2, 'hours', '2 hr'], @@ -30,8 +28,7 @@ class ProposedTimeCalendarStore extends NylasStore { activate() { this._proposedTimes = [] this._pendingSave = false; - // this.triggerLater = _.throttle(this.trigger, 32) - this._duration = this.DURATIONS[3] // 1 hr + this._duration = this.DURATIONS[1] // 1 hr this.unsubscribers = [ SchedulerActions.changeDuration.listen(this._onChangeDuration), SchedulerActions.addProposedTime.listen(this._onAddProposedTime), @@ -88,8 +85,10 @@ class ProposedTimeCalendarStore extends NylasStore { } _onRemoveProposedTime = ({start, end}) => { + const startInt = parseInt(start, 10); + const endInt = parseInt(end, 10); this._proposedTimes = _.filter(this._proposedTimes, (p) => - p.unix() < start || p.unix() > end + p.unix() < startInt || p.unix() > endInt ) this.trigger() } diff --git a/src/components/nylas-calendar/calendar-event-container.jsx b/src/components/nylas-calendar/calendar-event-container.jsx index 1483413fb..aa307e3f6 100644 --- a/src/components/nylas-calendar/calendar-event-container.jsx +++ b/src/components/nylas-calendar/calendar-event-container.jsx @@ -28,6 +28,9 @@ export default class CalendarEventContainer extends React.Component { _onCalendarMouseUp = (event) => { this._DOMCache = {}; + if (!this._mouseIsDown) { + return + } this._mouseIsDown = false; this._runPropsHandler("onCalendarMouseUp", event) }