-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rearrangement Algorithm Implementation #1473
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
import clsx from 'clsx' | ||
import React from 'react' | ||
|
||
function stringifyPercent(v) { | ||
return typeof v === 'string' ? v : v + '%' | ||
} | ||
|
||
/* eslint-disable react/prop-types */ | ||
function TimeGridEvent(props) { | ||
const { | ||
|
@@ -42,10 +46,10 @@ function TimeGridEvent(props) { | |
onDoubleClick={onDoubleClick} | ||
style={{ | ||
...userProps.style, | ||
top: `${top}%`, | ||
height: `${height}%`, | ||
[rtl ? 'right' : 'left']: `${Math.max(0, xOffset)}%`, | ||
width: `${width}%`, | ||
top: stringifyPercent(top), | ||
[rtl ? 'right' : 'left']: stringifyPercent(xOffset), | ||
width: stringifyPercent(width), | ||
height: stringifyPercent(height), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sometimes the algorithm needs Maybe you think it is no good that I didn't make it all I also tried to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. its fine 👍 |
||
}} | ||
title={ | ||
tooltip | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are for overlapping situation