Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gregschmit/recurring_select
A gem for adding selectors for setting recurring events.
https://github.com/gregschmit/recurring_select
Last synced: about 2 months ago
JSON representation
A gem for adding selectors for setting recurring events.
- Host: GitHub
- URL: https://github.com/gregschmit/recurring_select
- Owner: gregschmit
- License: mit
- Created: 2011-11-25T22:36:06.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2024-01-27T03:24:05.000Z (8 months ago)
- Last Synced: 2024-06-18T15:31:51.109Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 650 KB
- Stars: 325
- Watchers: 67
- Forks: 236
- Open Issues: 43
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: MIT-LICENSE
Awesome Lists containing this project
README
# Recurring Select
[![Build Status](https://travis-ci.org/gregschmit/recurring_select.svg?branch=master)](https://travis-ci.org/GetJobber/recurring_select) [![Code Climate](https://codeclimate.com/github/gregschmit/recurring_select.png)](https://codeclimate.com/github/gregschmit/recurring_select)
This gem adds selectors and helpers for working with recurring schedules in a Rails app. It uses [ice_cube](https://github.com/seejohnrun/ice_cube) recurring scheduling gem.
Created by the [Jobber](http://getjobber.com) team for Jobber, the leading business management tool for field service companies.
Check out the [live demo](http://recurring-select-demo.herokuapp.com/) (code in [spec/dummy](https://github.com/GetJobber/recurring_select/tree/master/spec/dummy) folder).
## Usage
Basic selector:
Add the gem to your Gemfile:
```ruby
gem 'recurring_select'
```### Require Assets
#### Desktop Interface:
- application.js: `//= require recurring_select`
- application.css: `//= require recurring_select`#### jQuery Mobile Interface:
- application.js: `//= require jquery`
- application.js: `//= require jquery-mobile-rs`
- application.css: `//= require jquery-mobile-rs`### Form Helper
In the form view call the helper:
```erb
<%= f.select_recurring :recurring_rule_column %>
```#### Options
```ruby
f.select_recurring :current_existing_rule, [
IceCube::Rule.weekly.day(:monday, :wednesday, :friday),
IceCube::Rule.monthly.day_of_month(-1)
]
```Use :allow_blank for a "not recurring" option:
```ruby
f.select_recurring :current_existing_rule, nil, :allow_blank => true
```### Additional Helpers
Recurring Select also comes with helpers for parsing 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.```ruby
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 if you're receiving strings, fixed
numbers, strings vs symbols, etc.```ruby
RecurringSelect.dirty_hash_to_rule(params)
```### I18n
Recurring Select is I18n aware
You can create a locale file like this:
```yaml
en:
recurring_select:
not_recurring: "- not recurring -"
change_schedule: "Change schedule..."
set_schedule: "Set schedule..."
new_custom_schedule: "New custom schedule..."
custom_schedule: "Custom schedule..."
or: or
```You have to translate JavaScript texts too by including the locale file in your assets manifest. Only French and English are supported for the moment.
```
//= require recurring_select/en
//= require recurring_select/fr
```For other languages include a JavaScript file like this:
```js
RecurringSelectDialog.config.texts = {
locale_iso_code: "fr"
repeat: "Repeat"
frequency: "Frequency"
daily: "Daily"
weekly: "Weekly"
monthly: "Monthly"
yearly: "Yearly"
every: "Every"
days: "day(s)"
weeks_on: "week(s) on"
months: "month(s)"
years: "year(s)"
first_day_of_week: 1
day_of_month: "Day of month"
day_of_week: "Day of week"
cancel: "Cancel"
ok: "OK"
days_first_letter: ["S", "M", "T", "W", "T", "F", "S"]
order: ["1st", "2nd", "3rd", "4th", "5th", "Last"]
}
```Options include:
```js
RecurringSelectDialog.config.options = {
monthly: {
show_week: [true, true, true, true, false, false] //display week 1, 2 .... Last
}
}
```## Testing and Development
Start the dummy server for clicking around the interface:
```console
rails s
```Tests can be ran against different versions of Rails like so:
```
BUNDLE_GEMFILE=spec/gemfiles/rails-7 bundle install
BUNDLE_GEMFILE=spec/gemfiles/rails-7 bundle exec rspec spec
```Feel free to open issues or send pull requests.
## Licensing
This project rocks and uses the MIT license.