fix(scheduler): can remove proposed times

This commit is contained in:
Evan Morikawa 2016-04-06 13:52:37 -07:00
parent 3fa0ce249f
commit f1a8b6929f
4 changed files with 21 additions and 7 deletions

View file

@ -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() {

View file

@ -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 = () => {

View file

@ -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()
}

View file

@ -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)
}