+
Skip to content

zhdzmn/recurring_select

 
 

Repository files navigation

RecurringSelect

Build Status Code Climate

This is a gem to add a number of selectors and helpers for working with recurring schedules in a rails app. It uses the IceCube recurring scheduling gem.

Created by the Jobber team for Jobber, the leading business management tool for field service companies.

Check out the live demo (code in spec\dummy folder)

Usage

Basic selector:

Load the gem: gem 'recurring_select

Require assets Desktop view application.js //= require recurring_select application.css //= require recurring_select

or jQueryMobile interface application.js //= require jquery-mobile-rs application.css //= require jquery-mobile-rs

In the form view call the helper: <%= f.select_recurring :recurring_rule_column %>

Options

Defaults Values

f.select_recurring :current_existing_rule, [
  IceCube::Rule.weekly.day(:monday, :wednesday, :friday),
  IceCube::Rule.monthly.day_of_month(-1)
]

:allow_blank let's you pick if there is a "not recurring" value

  f.select_recurring :current_existing_rule, :allow_blank => true

Additional Helpers

RecurringSelect also comes with several helpers for parsing up the parameters when they hit your application.

You can send the column into the is_valid_rule? method to check the validity of the input. RecurringSelect.is_valid_rule?(possible_rule)

There is also a dirty_hash_to_rule method for sanitizing the inputs for IceCube. This is sometimes needed based on if you're receiving strings, fixed numbers, strings vs symbols, etc. RecurringSelect.dirty_hash_to_rule(params)

Testing and development

Start the dummy server for clicking around the interface: rails s

Use Guard and RSpec for all tests. I'd love to get jasmine running also, but haven't had time yet.

Tests can be ran against different versions of Rails like so:

RAILS_VERSION=4.0.0.pre SASS_VERSION=4.0.0.rc1 bundle update
RAILS_VERSION=4.0.0.pre SASS_VERSION=4.0.0.rc1 bundle exec rspec spec

Feel free to open issues or send pull requests.

Licensing

This project rocks and uses MIT-LICENSE.

About

A gem for adding selectors for setting recurring events.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 89.7%
  • CoffeeScript 8.3%
  • JavaScript 2.0%
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载