Skip to content

Commit

Permalink
jquense#563: Add onDoubleClickEvent handler
Browse files Browse the repository at this point in the history
  • Loading branch information
alxmiron committed Sep 29, 2017
1 parent 91c4895 commit 84eff69
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@ class Calendar extends React.Component {
*/
onSelectEvent: PropTypes.func,

/**
* Callback fired when a calendar event is clicked twice.
*
* ```js
* (event: Object, e: SyntheticEvent) => any
* ```
*/
onDoubleClickEvent: PropTypes.func,

/**
* Callback fired when dragging a selection in the Time views.
*
Expand Down Expand Up @@ -645,6 +654,7 @@ class Calendar extends React.Component {
onNavigate={this.handleNavigate}
onDrillDown={this.handleDrillDown}
onSelectEvent={this.handleSelectEvent}
onDoubleClickEvent={this.handleDoubleClickEvent}
onSelectSlot={this.handleSelectSlot}
onShowMore={this._showMore}
/>
Expand Down Expand Up @@ -674,6 +684,10 @@ class Calendar extends React.Component {
notify(this.props.onSelectEvent, args)
};

handleDoubleClickEvent = (...args) => {
notify(this.props.onDoubleClickEvent, args)
}

handleSelectSlot = (slotInfo) => {
notify(this.props.onSelectSlot, slotInfo)
};
Expand Down
6 changes: 6 additions & 0 deletions src/DayColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class DayColumn extends React.Component {
onSelecting: PropTypes.func,
onSelectSlot: PropTypes.func.isRequired,
onSelectEvent: PropTypes.func.isRequired,
onDoubleClickEvent: PropTypes.func.isRequired,

className: PropTypes.string,
dragThroughEvents: PropTypes.bool,
Expand Down Expand Up @@ -208,6 +209,7 @@ class DayColumn extends React.Component {
}}
title={(typeof label === 'string' ? label + ': ' : '') + title }
onClick={(e) => this._select(event, e)}
onDoubleClick={(e) => this._doubleClick(event, e)}
className={cn('rbc-event', className, {
'rbc-selected': _isSelected,
'rbc-event-continues-earlier': continuesPrior,
Expand Down Expand Up @@ -347,6 +349,10 @@ class DayColumn extends React.Component {
_select = (...args) => {
notify(this.props.onSelectEvent, args)
};

_doubleClick = (...args) => {
notify(this.props.onDoubleClickEvent, args)
};
}


Expand Down
5 changes: 4 additions & 1 deletion src/EventCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ let propTypes = {

eventComponent: elementType,
eventWrapperComponent: elementType.isRequired,
onSelect: PropTypes.func
onSelect: PropTypes.func,
onDoubleClick: PropTypes.func
}

class EventCell extends React.Component {
Expand All @@ -33,6 +34,7 @@ class EventCell extends React.Component {
, slotStart
, slotEnd
, onSelect
, onDoubleClick
, eventComponent: Event
, eventWrapperComponent: EventWrapper
, ...props } = this.props;
Expand All @@ -58,6 +60,7 @@ class EventCell extends React.Component {
'rbc-event-continues-after': continuesAfter
})}
onClick={(e) => onSelect(event, e)}
onDoubleClick={(e) => onDoubleClick(event, e)}
>
<div className='rbc-event-content' title={title}>
{ Event
Expand Down
7 changes: 5 additions & 2 deletions src/EventRowMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export default {

eventComponent: elementType,
eventWrapperComponent: elementType.isRequired,
onSelect: PropTypes.func
onSelect: PropTypes.func,
onDoubleClick: PropTypes.func
},

defaultProps: {
Expand All @@ -38,14 +39,16 @@ export default {
, startAccessor, endAccessor, titleAccessor
, allDayAccessor, eventComponent
, eventWrapperComponent
, onSelect } = props;
, onSelect
, onDoubleClick } = props;

return (
<EventCell
event={event}
eventWrapperComponent={eventWrapperComponent}
eventPropGetter={eventPropGetter}
onSelect={onSelect}
onDoubleClick={onDoubleClick}
selected={isSelected(event, selected)}
startAccessor={startAccessor}
endAccessor={endAccessor}
Expand Down
7 changes: 7 additions & 0 deletions src/Month.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ let propTypes = {
onNavigate: PropTypes.func,
onSelectSlot: PropTypes.func,
onSelectEvent: PropTypes.func,
onDoubleClickEvent: PropTypes.func,
onShowMore: PropTypes.func,
onDrillDown: PropTypes.func,
getDrilldownView: PropTypes.func.isRequired,
Expand Down Expand Up @@ -195,6 +196,7 @@ class MonthView extends React.Component {
renderForMeasure={needLimitMeasure}
onShowMore={this.handleShowMore}
onSelect={this.handleSelectEvent}
onDoubleClick={this.handleDoubleClickEvent}
onSelectSlot={this.handleSelectSlot}
eventComponent={components.event}
eventWrapperComponent={components.eventWrapper}
Expand Down Expand Up @@ -306,6 +308,11 @@ class MonthView extends React.Component {
notify(this.props.onSelectEvent, args)
}

handleDoubleClickEvent = (...args) => {
this.clearSelection()
notify(this.props.onDoubleClickEvent, args)
}

handleShowMore = (events, date, cell, slot) => {
const { popup, onDrillDown, onShowMore, getDrilldownView } = this.props
//cancel any pending selections so only the event click goes through.
Expand Down
7 changes: 7 additions & 0 deletions src/TimeGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default class TimeGrid extends Component {
onSelectEnd: PropTypes.func,
onSelectStart: PropTypes.func,
onSelectEvent: PropTypes.func,
onDoubleClickEvent: PropTypes.func,
onDrillDown: PropTypes.func,
getDrilldownView: PropTypes.func.isRequired,

Expand All @@ -81,6 +82,7 @@ export default class TimeGrid extends Component {
super(props)
this.state = { gutterWidth: undefined, isOverflowing: null };
this.handleSelectEvent = this.handleSelectEvent.bind(this)
this.handleDoubleClickEvent = this.handleDoubleClickEvent.bind(this)
this.handleHeaderClick = this.handleHeaderClick.bind(this)
}

Expand Down Expand Up @@ -277,6 +279,7 @@ export default class TimeGrid extends Component {
eventPropGetter={this.props.eventPropGetter}
selected={this.props.selected}
onSelect={this.handleSelectEvent}
onDoubleClick={this.handleDoubleClickEvent}
longPressThreshold={this.props.longPressThreshold}
/>
</div>
Expand Down Expand Up @@ -337,6 +340,10 @@ export default class TimeGrid extends Component {
notify(this.props.onSelectEvent, args)
}

handleDoubleClickEvent(...args) {
notify(this.props.onDoubleClickEvent, args)
}

handleSelectAlldayEvent(...args) {
//cancel any pending selections so only the event click goes through.
this.clearSelection()
Expand Down

0 comments on commit 84eff69

Please sign in to comment.