-
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
Resize Month Events and Resize Week/Day Events on Both Ends #578
Conversation
Summary: There were errors in my branch because importing the .default was not pulling in the correct default whereas when I removed it, it seemed to work fine. This might be some kind of change in React 15.6 for how default modules are imported/required.
Summary: For <EventCell /> to know that it can be resized I am passing down the resize prop to that component. This is because, unlike in the previous implementation, I am not passing down what would be the eventWrapper from the dragAndDrop addon. I didn't know how to pass down multiple components based on whether the calendar was resizable. So I went this route. Sorry, not sorry.
Summary: I created <ResizableEventLR /> to handle resizing events in the month view. If <EventCell resizable /> then it will render the resizable component. I added styles so that I could see what is going on. There is a red bg. Sorry, not sorry. There is no functionality at the moment but I started building it out. There is certainly more to be worked on here.
Summary: Updated the resize function to be aware of the end as well as the start time. This is when there are two dnd handlers on an event at once. I renamed the component to be more semantic with its usage. Styles were correspondingly updated.
Summary: I didn't realize the conent should be aligned left.
Summary: Refactored components to look a bit more readable.
Summary: Refactored <ResizableEvent /> and added the ability to resize the top component.
Summary: Refactored the if/else statement into a switch statement.
Summary: I deleted these chanages thinking they were old. My mistake!
Summary: Remove unused code.
Actually, I think I will keep this open |
@arecvlohe @jnmandal any idea if this excellent feature you guys added is going to get merged into the project? |
@svanetten1976 I don't have a good idea. @jquense might know better than me. I don't really know what/how things get vetted and merged. |
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.
💯💯💯 thanks for picking this up @arecvlohe
src/EventCell.js
Outdated
@@ -49,6 +50,10 @@ class EventCell extends React.Component { | |||
if (eventPropGetter) | |||
var { style, className: xClassName } = eventPropGetter(event, start, end, selected); | |||
|
|||
if (this.props.resizable) { |
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 bits should be encapsulated in the addon code, the core library should not require things from /addons (so that they are optional)
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.
ping
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.
I see what you mean here. In our implementation at work I ended up removing this.
src/DayColumn.js
Outdated
, messages | ||
, eventComponent | ||
, eventTimeRangeFormat |
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.
Seems like a rebase error
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.
Actually this is because of a fix I made in #406. eventComponent was being destructured incorrectly in the DayColumn component's renderEvents function (so it was always undefined). We need to be able to specify custom eventComponent for the addOn to work properly.. But its possible this has since been fixed some other way.
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.
Instead of using event component. I updated the addon to pass the ResizeEvent to components: { day: { event }, week: { event } }
as opposed to creating a new prop inside of components. I think this is how the library is intended to be used.
examples/App.js
Outdated
@@ -101,7 +102,7 @@ const Example = React.createClass({ | |||
<strong><i className='fa fa-code'/>{' View example source code'}</strong> | |||
</a> | |||
</div> | |||
<Current className='demo' /> | |||
<Current className='demo' /> |
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.
?
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.
It looks like a space was removed.
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.
can we fix it?
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.
You mean put the space back in?
examples/demos/dnd.js
Outdated
// if we want to update the event while dragging we need to find the event | ||
// by an identifier. here we use the title and the start time, but depending | ||
// on use case you may want have a truly unique id attribute in the event | ||
const nextEvents = events.map(existingEvent => { |
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.
Why doesn't indexOf work here?
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.
@jquense this was due to a quirk in react-dnd, copying my explanation from #406
Since only the original event object is accessible through react-dnd... In the onEventResize callback you will not be able to use Array.prototype.indexOf for finding the event again -- unless you continue to mutate the original event and splice it into the cloned events array... but I'm not sure if we would want to recommend that practice
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.
Ideally in the next iteration of the callback the new event will be there? Why can't we get react dnd to update the thing it's referencing. I don't love this logic is fairly flakey even for an example and likely to lead folks to copying it in their own code with potential issues. Last ditch we should at least add an id to events in the example and use that vs title and date instances
👍 Awesome! But there's quite a lot of noise here. Are all those commits and line changes necessary/relevant to this PR? cc @jquense |
@tobiasandersen Are you saying to rebase or remove things? |
Rebase (or squash merge) :) I saw now that the heavy line changes was due the example bundle, which I guess makes sense! |
I will rebase some changes to remove some fluff from the commit history @tobiasandersen |
@tobiasandersen Doing a rebase is too insane, at least for me, with all the commits that have been merged over the past couple days. But I also think I missed what you were saying. Did you mean I can merge, just choose either the squash merge or rebase merge option? |
Squash and merge would combine all your 47 commits into one. I usually prefer having 1 (or a few maximum) commits per PR. It keeps the history clean, and makes it easier when going back to find when and why things were introduced. However, it also removes the actual history. And I see that you've been a few people working on this – squashing would make it look like you wrote all of it. I'd prefer a squash over the 47 commits if I were to choose from the two. But it's @jquense's project, so I think it's better if he decides what's best :) |
@tobiasandersen I hear you. Let's see what @jquense says... |
@arecvlohe You do whatever makes your life a bit easier to handle the rebase. Generally I think it's worth leaving the branch unsquashed and then squashing via the github butten whe nwe merge so that master ends up with one commit, and the original history is maintained. In this case tho i can imagine that the rebase is super painful without squashing so do what makes it's easier for you. We'll be sure to shout to out everyone who contributed to this PR |
…eature/events-resize
@tobiasandersen @AlexMarvelo @jquense ^^^ |
I wouldn't be surprised if it's due to my latest PR (although I did test the DnD example before merging). I'll have look and get back. |
I will take a look this evening and see what I can find out |
Cool! If it's anything from my last PR, it's probably this extra div that I added: https://github.com/intljusticemission/react-big-calendar/blob/0b2c2347efa8fe4fb77f7931634de9a8ee1362ac/src/DayColumn.js#L132. If you don't find the problem I'll have a check when I wake up tomorrow! |
@tobiasandersen From what I can tell it looks like the event container is the culprit. Unfortunately in |
Sorry about that, should have tested it more than I did. I'm thinking |
I will check that out and see |
It works! I will wait for a successful build to complete first and then move forward with merging into master |
It is done 😄 |
Awesome! Great work! 🎉 |
Hi, after your merge it seems you cannot select events in weekly view anymore when not using drag'n'drop. You added |
Good catch @jadczyk! |
@jadczyk Mind creating a PR to fix this? |
Just did #690 |
Just started using the resize/DnD stuff - thanks @arecvlohe & others - hugely useful! tl;dr: I'm looking for advice on how to best marry DnD with custom components. When creating the underling calendar, it looks like the addon's Would something like this make sense:
becomes instead:
The new HOC would wrap the user's components with one based on the current I'm keen to get folks' other ideas/approaches (or validation of this one). I'm probably misunderstanding the DnD philosophy, but it was a surprise to see thx for any guidance/advice. |
I think that no more additional work should be required to enable DnD except wrapping the calendar with |
Description
This PR adds the ability to resize month events as well as resize week/day events on both ends, top and bottom. I wasn't able to get this to perform correctly on hover which I suppose is ideal. We might find inspiration from #577.
This is a long standing issue so it would be good to see some movement on this.
Also, I think this could be a good first implementation that is refined on going forward.
Screenshots
Month
Week
Issues
#382
PRs
#577, #541, #406