Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby

gem 'jquery-rails'

gem 'rails', '~> 4.0.12'
gem 'sass-rails', '~> 4.0.5'
gem 'rails', '>= 4.0.12'
gem 'sass-rails', '~> 5.0.6'
38 changes: 20 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
concurrent-ruby (1.0.2)
diff-lcs (1.2.5)
erubis (2.7.0)
execjs (2.6.0)
hike (1.2.3)
i18n (0.7.0)
ice_cube (0.13.0)
jquery-rails (3.1.2)
Expand All @@ -57,7 +57,7 @@ GEM
mime-types (>= 1.16, < 3)
mime-types (2.6.2)
minitest (4.7.5)
multi_json (1.11.2)
multi_json (1.12.1)
pg (0.17.1)
rack (1.5.5)
rack-test (0.6.3)
Expand All @@ -75,7 +75,7 @@ GEM
activesupport (= 4.0.13)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.4.2)
rake (11.2.2)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
Expand All @@ -96,25 +96,24 @@ GEM
rspec-mocks (~> 3.1.0)
rspec-support (~> 3.1.0)
rspec-support (3.1.2)
sass (3.2.19)
sass-rails (4.0.5)
railties (>= 4.0.0, < 5.0)
sass (~> 3.2.2)
sprockets (~> 2.8, < 3.0)
sprockets-rails (~> 2.0)
sprockets (2.12.4)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sass (3.4.22)
sass-rails (5.0.6)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
sprockets (3.7.0)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
tzinfo (0.3.44)
tilt (2.0.5)
tzinfo (0.3.51)

PLATFORMS
ruby
Expand All @@ -124,9 +123,12 @@ DEPENDENCIES
bundler (>= 1.3.5)
jquery-rails
pg
rails (~> 4.0.12)
rails (>= 4.0.12)
rake (>= 0.9.6)
recurring_select!
rspec (>= 2.14)
rspec-rails (>= 2.14)
sass-rails (~> 4.0.5)
sass-rails (~> 5.0.6)

BUNDLED WITH
1.11.2
4 changes: 2 additions & 2 deletions app/assets/javascripts/recurring_select.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ $.fn.recurring_select.texts = {
every: "Every"
days: "day(s)"
weeks_on: "week(s) on"
months: "month(s)"
years: "year(s)"
months_on: "month(s) on"
years_on: "year(s) on"
day_of_month: "Day of month"
day_of_week: "Day of week"
cancel: "Cancel"
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/recurring_select/fr.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ $.fn.recurring_select.texts = {
every: "Tous les"
days: "jour(s)"
weeks_on: "semaine(s) le"
months: "mois"
years: "année(s)"
months_on: "mois le"
years_on: "année(s) le"
cancel: "Annuler"
day_of_month: "Jour du mois"
day_of_week: "Jour de la semaine"
Expand All @@ -22,4 +22,4 @@ $.fn.recurring_select.texts = {
days_first_letter: ["D", "L", "M", "M", "J", "V", "S" ]
order: ["1er", "2ème", "3ème", "4ème", "5ème", "Dernier"]
show_week: [true, true, true, true, false, false]
}
}
74 changes: 72 additions & 2 deletions app/assets/javascripts/recurring_select_dialog.js.coffee.erb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ window.RecurringSelectDialog =
interval_input = section.find('.rs_yearly_interval')
interval_input.val(@current_rule.hash.interval)
interval_input.on "change keyup", @intervalChanged

@current_rule.hash.validations ||= {}
@current_rule.hash.validations.day_of_month ||= []
@current_rule.hash.validations.day_of_week ||= {}
@init_calendar_year(section)
section.show()


Expand Down Expand Up @@ -220,6 +225,17 @@ window.RecurringSelectDialog =
@content.find(".rs_calendar_week").toggle(week_mode)
@content.find(".rs_calendar_day").toggle(!week_mode)

init_calendar_year: (section) =>
yearly_calendar = section.find(".rs_calendar_year")
yearly_calendar.html ""
for num in [1..31]
yearly_calendar.append (day_link = $(document.createElement("a")).text(num))
if $.inArray(num, @current_rule.hash.validations.day_of_month) != -1
day_link.addClass("selected")

section.find("#rs_yearly_months").on "change", @monthSelectedChanged
yearly_calendar.find("a").on "click tap", @dateOfYearChanged

# ========================= Change callbacks ===============================

freqChanged: =>
Expand Down Expand Up @@ -298,6 +314,45 @@ window.RecurringSelectDialog =
@summaryUpdate()
false

monthSelectedChanged: (event) =>
selected_month = @content.find("#rs_yearly_months").val()
days_in_month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

yearly_calendar = @content.find(".rs_calendar_year")
yearly_calendar.html ""
for num in [1..days_in_month[selected_month]]
yearly_calendar.append (day_link = $(document.createElement("a")).text(num))
if $.inArray(num, @current_rule.hash.validations.day_of_month) != -1
day_link.addClass("selected")
yearly_calendar.find("a").on "click tap", @dateOfYearChanged
@selectMonthAndDay()
false

dateOfYearChanged: (event) =>
yearly_calendar = @content.find(".rs_calendar_year")
yearly_calendar.find("a").removeClass("selected")
$(event.currentTarget).toggleClass("selected")
@selectMonthAndDay()
false

selectMonthAndDay: () =>
selected_month = parseInt(@content.find("#rs_yearly_months").val()) + 1
@current_rule.str = null
@current_rule.hash ||= {}
@current_rule.hash.validations = {}
raw_days = @content.find(".yearly_options .rs_calendar_year a.selected").map ->
res = if $(this).text() == $.fn.recurring_select.texts["last_day"] then -1 else parseInt($(this).text())
res
if raw_days.get().length != 0
@current_rule.hash.validations.day_of_month = raw_days.get()
@current_rule.hash.validations.month_of_year = selected_month
else
@current_rule.hash.validations = null
@summaryUpdate()
false



# ========================= Change callbacks ===============================

template: () ->
Expand Down Expand Up @@ -343,7 +398,7 @@ window.RecurringSelectDialog =
<p>
#{$.fn.recurring_select.texts["every"]}
<input type='text' data-wrapper-class='ui-recurring-select' name='rs_monthly_interval' class='rs_monthly_interval rs_interval' value='1' size='2' />
#{$.fn.recurring_select.texts["months"]}:
#{$.fn.recurring_select.texts["months_on"]}:
</p>
<p class='monthly_rule_type'>
<span><label for='monthly_rule_type_day'>#{$.fn.recurring_select.texts["day_of_month"]}</label><input type='radio' class='monthly_rule_type_day' name='monthly_rule_type' id='monthly_rule_type_day' value='true' /></span>
Expand All @@ -356,8 +411,23 @@ window.RecurringSelectDialog =
<p>
#{$.fn.recurring_select.texts["every"]}
<input type='text' data-wrapper-class='ui-recurring-select' name='rs_yearly_interval' class='rs_yearly_interval rs_interval' value='1' size='2' />
#{$.fn.recurring_select.texts["years"]}
#{$.fn.recurring_select.texts["years_on"]}
</p>
<select id='rs_yearly_months'>
<option value='0'>January</option>
<option value='1'>February</option>
<option value='2'>March</option>
<option value='3'>April</option>
<option value='4'>May</option>
<option value='5'>June</option>
<option value='6'>July</option>
<option value='7'>August</option>
<option value='8'>September</option>
<option value='9'>October</option>
<option value='10'>November</option>
<option value='11'>December</option>
</select>
<p class='rs_calendar_year'></p>
</div>
<p class='rs_summary'>
<span></span>
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/recurring_select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ select {
}
}

.rs_calendar_day, .rs_calendar_week {
.rs_calendar_day, .rs_calendar_week, .rs_calendar_year {
width:155px;
a {display:inline-block; text-align:center; width:15px; padding:5px 3px; font-size:12px; border-style:solid; border-color:#ccc; border-width:1px 1px 1px 1px; margin:-1px 0 0 -1px; line-height:10px; background-color:#fff; font-weight:bold;
&.selected {background-color:#89a; color:#fff; @include gradiant(#9ab, #789); @include inset_shadows(0px, 1px, 2px, rgba(0,0,0,0.2)); text-shadow:0 1px 1px #333;}
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/recurring_select_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module RecurringSelectHelper
module FormHelper
if Rails::VERSION::MAJOR == 4
if Rails::VERSION::MAJOR >= 4
def select_recurring(object, method, default_schedules = nil, options = {}, html_options = {})
RecurringSelectTag.new(object, method, self, default_schedules, options, html_options).render
end
Expand Down
4 changes: 4 additions & 0 deletions lib/recurring_select.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ def self.filter_params(params)
params[:validations][:day_of_year] = params[:validations][:day_of_year].collect(&:to_i)
end

if params[:validations][:month_of_year]
params[:validations][:month_of_year] = params[:validations][:month_of_year][0].to_i
end

params
end
end