Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
TeaBough committed Oct 2, 2017
1 parent 1ad86b7 commit 15c3b68
Showing 1 changed file with 5 additions and 34 deletions.
39 changes: 5 additions & 34 deletions src/TimeGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export default class TimeGrid extends Component {
allDayAccessor: accessor.isRequired,
startAccessor: accessor.isRequired,
endAccessor: accessor.isRequired,
resourceIdAccessor: accessor.isRequired,

selected: PropTypes.object,
selectable: PropTypes.oneOf([true, false, 'ignoreEvents']),
Expand Down Expand Up @@ -177,9 +178,7 @@ export default class TimeGrid extends Component {

let gutterRef = ref => this._gutters[1] = ref && findDOMNode(ref);

let eventsRendered = resources ?
this.renderEventsWithResource(range, rangeEvents, this.props.now, resources) :
this.renderEvents(range, rangeEvents, this.props.now);
let eventsRendered = this.renderEvents(range, rangeEvents, this.props.now, resources || [{}]);

return (
<div className='rbc-time-view'>
Expand All @@ -202,8 +201,8 @@ export default class TimeGrid extends Component {
</div>
);
}
renderEventsWithResource(range, events, today, resources) {
let { min, max, endAccessor, startAccessor, components } = this.props;
renderEvents(range, events, today, resources) {
let { min, max, endAccessor, startAccessor, resourceIdAccessor, components } = this.props;

return range.map((date, idx) => {
let daysEvents = events.filter(
Expand All @@ -215,7 +214,7 @@ export default class TimeGrid extends Component {
return resources.map((resource, id) => {

let eventsToDisplay = daysEvents.filter(
event => event.resourceId === resource.id
event => get(event, resourceIdAccessor) === resource.id
)

return (
Expand All @@ -238,34 +237,6 @@ export default class TimeGrid extends Component {
})
}

renderEvents(range, events, today, id){
let { min, max, endAccessor, startAccessor, components } = this.props;

return range.map((date, idx) => {
let daysEvents = events.filter(
event => dates.inRange(date,
get(event, startAccessor),
get(event, endAccessor), 'day') && event.resourceId === id
)

return (
<DayColumn
{...this.props }
min={dates.merge(date, min)}
max={dates.merge(date, max)}
eventComponent={components.event}
eventWrapperComponent={components.eventWrapper}
dayWrapperComponent={components.dayWrapper}
className={cn({ 'rbc-now': dates.eq(date, today, 'day') })}
style={segStyle(1, this.slots)}
key={idx}
date={date}
events={daysEvents}
/>
)
})
}

renderHeader(range, events, width, resources) {
let { messages, rtl, selectable, components, now } = this.props;
let { isOverflowing } = this.state || {};
Expand Down

0 comments on commit 15c3b68

Please sign in to comment.