forked from jquense/react-big-calendar
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Rearrangement Algorithm Implementation (jquense#1473)
* Rearrangement Algorithm Implementation * day layout algorithm as strategy pattern * day layout algorithm css customizable & move Event class into overlap algorithm * restore yarn.lock
- Loading branch information
Showing
12 changed files
with
667 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React from 'react' | ||
import { Calendar, Views } from 'react-big-calendar' | ||
import events from '../events' | ||
import ExampleControlSlot from '../ExampleControlSlot' | ||
import _ from 'lodash' | ||
|
||
const propTypes = {} | ||
|
||
class CreateEventWithNoOverlap extends React.Component { | ||
constructor(...args) { | ||
super(...args) | ||
|
||
this.state = { | ||
events: _.cloneDeep(events), | ||
dayLayoutAlgorithm: 'no-overlap', | ||
} | ||
} | ||
|
||
handleSelect = ({ start, end }) => { | ||
const title = window.prompt('New Event name') | ||
if (title) | ||
this.setState({ | ||
events: [ | ||
...this.state.events, | ||
{ | ||
start, | ||
end, | ||
title, | ||
}, | ||
], | ||
}) | ||
} | ||
|
||
render() { | ||
const { localizer } = this.props | ||
return ( | ||
<> | ||
<ExampleControlSlot.Entry waitForOutlet> | ||
<strong> | ||
Click an event to see more info, or drag the mouse over the calendar | ||
to select a date/time range. | ||
<br /> | ||
The events are being arranged by `no-overlap` algorithm. | ||
</strong> | ||
</ExampleControlSlot.Entry> | ||
<Calendar | ||
selectable | ||
localizer={localizer} | ||
events={this.state.events} | ||
defaultView={Views.WEEK} | ||
scrollToTime={new Date(1970, 1, 1, 6)} | ||
defaultDate={new Date(2015, 3, 12)} | ||
onSelectEvent={event => alert(event.title)} | ||
onSelectSlot={this.handleSelect} | ||
dayLayoutAlgorithm={this.state.dayLayoutAlgorithm} | ||
/> | ||
</> | ||
) | ||
} | ||
} | ||
|
||
CreateEventWithNoOverlap.propTypes = propTypes | ||
|
||
export default CreateEventWithNoOverlap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.