Skip to content

Instantly share code, notes, and snippets.

@Phazz
Forked from MichaelMartinez/calimple1.md
Last active December 14, 2015 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Phazz/5076696 to your computer and use it in GitHub Desktop.
Save Phazz/5076696 to your computer and use it in GitHub Desktop.

Event_Calendar Implementation

The EventCalendar plugin is only concerned with displaying events. (Or really any model as long as it has name, start_at, and end_at fields.) How they are created is entirely up to you. It does include a generator to get you up and running, but doesn't go as far as creating the event controller and views. For that you could run the following Rails scaffold: script/generate scaffold Event start_at:datetime end_at:datetime

This will give you the controller and views you're looking for.

  • The calendar_controller needs to have the strips instance variable changed to the model you are trying to display @event_strips = Shift.event_strips_for_month(@shown_month)
# Changes the colors
def color
   if self.name == "A Shift"
     self[:color] || '#C10000'
   elsif self.name == "B Shift"
     self[:color] || '#0C0882'
   else
     self[:color] || '#08820A'
   end
 end

Abandoning this for now _ See the Event_Calendar implementation

Add Shift Scaffolding

  1. duty_day:string
  2. shift_day:datetime

Details for table_builder

  • Easy to make work with rails 3.2.3
  • The only hangup so far is an easy fix; <% calendar_for ... and I added <%= calendar_for
  • As of Midnight; the calendar scrolls months
  • TODO:
    1. Add shifts
    2. colorize shifts
    3. integrate ice_cube for recurrence
    4. figure out how to add different model data to this action

ice_cube integration - Below is best bet as of now

  • Create the shifts in app using the form
  • Use the juno tasks model & controller as a template.
  • Once the shifts are created, disable the form and proceed to next step!
  • USE THIS AS MODEL & CONTROLLER!!! Task Model with IceCube -- The Controller
    class Task < ActiveRecord::Base
      include IceCube

    serialize :options, Hash

    validates_presence_of :action
    validates_presence_of :name
    validates_presence_of :options
    validates_presence_of :schedule
    validates_presence_of :state

    # @return [IceCube::Schedule]
    def schedule
      if read_attribute(:schedule)
        Schedule.from_yaml(read_attribute(:schedule))
      else
        nil
      end
    end

    # @param [IceCube::Schedule]
    def schedule=(value)
      write_attribute(:schedule, value.to_yaml)
    end
  end


    # == Schema Information
    # Schema version: 20100707084131
    #
    # Table name: tasks
    #
    #  id             :integer         not null, primary key
    #  state          :string(255)     not null
    #  action         :string(255)     not null
    #  options        :text            not null
    #  schedule       :text            not null
    #  next_occurence :datetime
    #  created_at     :datetime
    #  updated_at     :datetime
    #  name           :string(255)     not null
    #

Ice_cube examples and shit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment