Module: CalendarizeHelper

Defined in:
app/helpers/calendarize_helper.rb

Defined Under Namespace

Modules: Controller, Model Classes: AbstractCalendarBuilder, DailyCalendarBuilder, Scopes, WeeklyCalendarBuilder

Instance Method Summary collapse

Instance Method Details

#calendar_current_paramsObject

Returns the current params for a calendar Used when you want to keep track of the calendar between two requests Can be used with path helpers

Usage: resource_path(calendar_current_params)



64
65
66
# File 'app/helpers/calendarize_helper.rb', line 64

def calendar_current_params
  { calendar: @calendar.clone }
end

#daily_calendar_for(*args, &block) ⇒ Object Also known as: daily_calendar

Creates a daily calendar for events

Usage: daily_calendar day, events, [options] { |c| … }

Params :day, Date, the day to display :events, ?, the events to display. An event must responds to:

- start_time: a TimeWithZone object (from ActiveRecord)
- end_time: a TimeWithZone object (from ActiveRecord)

:block |c|, is yield for every event placed so you can customize it’s content. :c is the calendar, which have:

- @event: the current event that is rendering
- @is_all_day: if the current event is an all-day one

Options :unit, integer, the time unit in minutes between two rows, defaults to 60. Must be > 0. :date_format, symbol, the format of the date to find at I18n.l(‘date.formats.date_format’), defaults to :long :url, the url path to call for some actions (ex: previous day), some params will be appended, defaults to request.path :id, integer, id of the calendar, default to one provided by this helper :day_start, integer, when to start showing events on the calendar, in minutes, defaults to 0 :day_end, integer, when to stop showing events on the calendar, in minutes, defaults to 1440 (24 hours) :verbose, boolean, show all the rows or only those with events, defaults to true



25
26
27
# File 'app/helpers/calendarize_helper.rb', line 25

def daily_calendar_for(*args, &block)
  DailyCalendarBuilder.new(self, *args).compute.render(&block)
end

#weekly_calendar_for(*args, &block) ⇒ Object Also known as: weekly_calendar

Creates a weekly calendar for events

Usage: weekly_calendar day, events, [options] { |c| … }

Params :day, Date, the day to display. Will display the week that contains that day :events, ?, the events to display. An event must responds to:

- start_time: a TimeWithZone object (from ActiveRecord)
- end_time: a TimeWithZone object (from ActiveRecord)

:block |c|, is yield for every event placed so you can customize it’s content. :c is the calendar, which have:

- @event: the current event that is rendering

Options :unit, integer, the time unit in minutes between two rows, defaults to 60. Must be > 0. :date_format, symbol, the format of the date to find at I18n.l(‘date.formats.date_format’), defaults to :long :id, integer, id of the calendar, default to one provided by this helper :week_start, Date::DAYS_INTO_WEEK.keys or string, the day to start the week, defaults to :monday :week_end, Date::DAYS_INTO_WEEK.keys or string, the day to end the week, defaults to :sunday



51
52
53
# File 'app/helpers/calendarize_helper.rb', line 51

def weekly_calendar_for(*args, &block)
  WeeklyCalendarBuilder.new(self, *args).compute.render(&block)
end