excid3 / simple_calendar

A wonderfully simple calendar gem for Rails
http://excid3.github.io/simple_calendar
MIT License
1.56k stars 267 forks source link

Multi-day events / end_time #147

Closed krsyoung closed 8 years ago

krsyoung commented 8 years ago

Hey, loving the gem! My use case has events that can span multiple days (i.e. would have a start_time and an end_time). Any objections to this type of functionality or previous experience in it being overly complicated?

Happy to take a stab at it if you are open to the idea.

excid3 commented 8 years ago

Hey @krsyoung!

No objections, been wanting to do this for a while now and gave it an attempt a couple times before but didn't come up with a clean solution that I liked. I think that having a clean solution to handle ones without end_times the same way as ones with end_times, is going to be the trick.

I figure you can just insert it on each day and if it's start, end, or middle, we can probably add some CSS classes that you can use for styling it to look like it spans those extra days (like a negative margin so that it appears to cross over all of them).

I don't think I have any code from my spikes before because I didn't like them and just kind of put it off. Would love to collaborate on a PR for this!

krsyoung commented 8 years ago

👍 sounds good @excid3! I'll go a round with it today and see what happens.

Agree with your thoughts regarding handling just a start_time equally as nicely as with an end_time.

excid3 commented 8 years ago

Awesome! Hit me up if you run into any questions.

Thinking on it for the last few minutes, I presume that for end_time we could default it to the start_time if an end_time isn't provided. That would make it so you could always assume there was an end_time in the loops.

The big change will probably be modifying the hash that it generates for each day's worth of sorted events.

krsyoung commented 8 years ago

So, I've succeeded in adding the most hideous code to the entire project (sorry!). Basically I took the approach of just explicitly adding the event to the corresponding hash entry for each day that it is relevant for.

Everything else works as before but I need to triple check the edge cases. Interested on thoughts of the general approach and if we're close enough I'll go with a PR and we can polish it off.

excid3 commented 8 years ago

Closed via #148