elevation / event_calendar

Show multiple, overlapping events across calendar days and rows. Rails plugin.
http://dev.elevationblog.com/2009/7/23/event-calendar-rails-plugin
MIT License
948 stars 212 forks source link

Show different Event date attributes based on param #74

Open marclipovsky opened 12 years ago

marclipovsky commented 12 years ago

Currently I have two date attributes in the same model (@ticket.starts & @ticket.target). I want to be able to show just the target dates on the calendar and just the start dates without spanning them over multiple days. I'm able to do it for one of them:

has_event_calendar :start_at_field  => 'target', :end_at_field => 'target'

I'd like to have them show up as different colors as well, as shown in the screenshot that linked in the readme.

How would I go about getting this to work?

Thanks!

sufleR commented 12 years ago

You can do whatever you want combining with sql. Remove or comment ":start_at_field => 'target', :end_at_field => 'target'" part and in calendar controller:

@events = Event.events_for_date_range(start_d, end_d)
@events_model_green = Model.select("id, 'some string or column name' as name, target as start_at, target as end_at , 'true'::boolean as all_day, 'green'::text as color ").where(" target >= ? and target <=", start_d, end_d)
@events_model_red = Model.select("id, 'some string or column name' as name, starts as start_at, starts as end_at , 'true'::boolean as all_day, 'red'::text as color ").where("starts >=? and starts <=?",start_d, end_d)
@event_strips = Event.create_event_strips(start_d, end_d, @events + @events_model_green +  @events_model_red)