From 583d0386fa73908d423600e53902ba4a6a1ac759 Mon Sep 17 00:00:00 2001 From: Sahil Dhankhar Date: Mon, 31 Oct 2016 18:16:28 +0530 Subject: [PATCH 01/25] Update recurring_select_helper.rb --- app/helpers/recurring_select_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/helpers/recurring_select_helper.rb b/app/helpers/recurring_select_helper.rb index b4fc7e70..5b5ad70f 100644 --- a/app/helpers/recurring_select_helper.rb +++ b/app/helpers/recurring_select_helper.rb @@ -2,13 +2,13 @@ module RecurringSelectHelper module FormHelper - if Rails::VERSION::MAJOR == 4 + if Rails::VERSION::MAJOR == 3 def select_recurring(object, method, default_schedules = nil, options = {}, html_options = {}) - RecurringSelectTag.new(object, method, self, default_schedules, options, html_options).render + InstanceTag.new(object, method, self, options.delete(:object)).to_recurring_select_tag(default_schedules, options, html_options) end - elsif Rails::VERSION::MAJOR == 3 + else def select_recurring(object, method, default_schedules = nil, options = {}, html_options = {}) - InstanceTag.new(object, method, self, options.delete(:object)).to_recurring_select_tag(default_schedules, options, html_options) + RecurringSelectTag.new(object, method, self, default_schedules, options, html_options).render end end end From 08d08c0cd0fd792f4251d31dc90c1f449b83d712 Mon Sep 17 00:00:00 2001 From: Sahil Dhankhar Date: Mon, 31 Oct 2016 18:27:40 +0530 Subject: [PATCH 02/25] Rails 5 Fix refactor --- app/helpers/recurring_select_helper.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helpers/recurring_select_helper.rb b/app/helpers/recurring_select_helper.rb index 5b5ad70f..51d0533a 100644 --- a/app/helpers/recurring_select_helper.rb +++ b/app/helpers/recurring_select_helper.rb @@ -2,17 +2,17 @@ module RecurringSelectHelper module FormHelper - if Rails::VERSION::MAJOR == 3 + if Rails::VERSION::MAJOR == 4 || Rails::VERSION::MAJOR == 5 def select_recurring(object, method, default_schedules = nil, options = {}, html_options = {}) - InstanceTag.new(object, method, self, options.delete(:object)).to_recurring_select_tag(default_schedules, options, html_options) + RecurringSelectTag.new(object, method, self, default_schedules, options, html_options).render end - else + elsif Rails::VERSION::MAJOR == 3 def select_recurring(object, method, default_schedules = nil, options = {}, html_options = {}) - RecurringSelectTag.new(object, method, self, default_schedules, options, html_options).render + InstanceTag.new(object, method, self, options.delete(:object)).to_recurring_select_tag(default_schedules, options, html_options) end end end - + module FormBuilder def select_recurring(method, default_schedules = nil, options = {}, html_options = {}) if !@template.respond_to?(:select_recurring) From 2c16c4dc846c473cdfce17c187970768368c31d5 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 09:38:53 -0400 Subject: [PATCH 03/25] read 'until' and 'count' from model. add initial UI to select until/count values --- .../javascripts/recurring_select.js.coffee | 5 +++++ .../recurring_select_dialog.js.coffee.erb | 15 +++++++++++++++ lib/recurring_select.rb | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/app/assets/javascripts/recurring_select.js.coffee b/app/assets/javascripts/recurring_select.js.coffee index d4932139..63f376a1 100644 --- a/app/assets/javascripts/recurring_select.js.coffee +++ b/app/assets/javascripts/recurring_select.js.coffee @@ -95,6 +95,11 @@ $.fn.recurring_select.texts = { years: "year(s)" day_of_month: "Day of month" day_of_week: "Day of week" + ends: "Ends" + never: "Never" + after: "After" + occurrences: "occurrences" + on: "On" cancel: "Cancel" ok: "OK" summary: "Summary" diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index baeccd6a..3824da4d 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -359,6 +359,21 @@ window.RecurringSelectDialog = #{$.fn.recurring_select.texts["years"]}

+
+ + + + +

diff --git a/lib/recurring_select.rb b/lib/recurring_select.rb index 5f727ed4..688f7743 100644 --- a/lib/recurring_select.rb +++ b/lib/recurring_select.rb @@ -45,6 +45,7 @@ def self.filter_params(params) params[:interval] = params[:interval].to_i if params[:interval] params[:week_start] = params[:week_start].to_i if params[:week_start] + params[:count] = params[:count].to_i if params[:count] params[:validations] ||= {} params[:validations].symbolize_keys! @@ -78,6 +79,22 @@ def self.filter_params(params) params[:validations][:day_of_year] = params[:validations][:day_of_year].collect(&:to_i) end + begin + # IceCube::TimeUtil will serialize a TimeWithZone into a hash, such as: + # {time: Thu, 04 Sep 2014 06:59:59 +0000, zone: "Pacific Time (US & Canada)"} + # So don't try to DateTime.parse the hash. IceCube::TimeUtil will deserialize this for us. + if (until_param = params[:until]) + if until_param.is_a?(String) + # Set to 23:59:59 (in current TZ) to encompass all events on until day + params[:until] = Time.zone.parse(until_param).change(hour: 23, min: 59, sec: 59) + elsif until_param.is_a?(Hash) # ex: {time: Thu, 28 Aug 2014 06:59:590000, zone: "Pacific Time (US & Canada)"} + params[:until] = until_param[:time].in_time_zone(until_param[:zone]) + end + end + rescue ArgumentError + # Invalid date given, attempt to assign :until will fail silently + end + params end end From 49a8c7a139c3a4b0f90afd0646cb3be617a22ffa Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 09:52:56 -0400 Subject: [PATCH 04/25] work on the formatting of the end options --- .../recurring_select_dialog.js.coffee.erb | 35 +++++++++++-------- app/assets/stylesheets/recurring_select.scss | 4 +++ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index 3824da4d..90d548c6 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -359,20 +359,27 @@ window.RecurringSelectDialog = #{$.fn.recurring_select.texts["years"]}

-
- - - - +
+ + + + +
+ + +
+
+ +

diff --git a/app/assets/stylesheets/recurring_select.scss b/app/assets/stylesheets/recurring_select.scss index 4d5bd72f..7fd32f86 100644 --- a/app/assets/stylesheets/recurring_select.scss +++ b/app/assets/stylesheets/recurring_select.scss @@ -76,6 +76,10 @@ select { } } + .rs_termination_section { + .rs_count {width:30px; text-align:center; display: inline-block;} + } + .rs_summary { padding:0px; margin-top:15px; border-top:1px solid #ccc; span {font-weight:bold; border-top:1px solid #fff; display:block; padding:10px 0 5px 0;} From a985749d3e5370719876ab64a4abd41285172565 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 10:07:13 -0400 Subject: [PATCH 05/25] css for "ends" section --- .../javascripts/recurring_select_dialog.js.coffee.erb | 2 +- app/assets/stylesheets/recurring_select.scss | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index 90d548c6..039194e2 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -363,7 +363,7 @@ window.RecurringSelectDialog =
- +
diff --git a/app/assets/stylesheets/recurring_select.scss b/app/assets/stylesheets/recurring_select.scss index 7fd32f86..64883180 100644 --- a/app/assets/stylesheets/recurring_select.scss +++ b/app/assets/stylesheets/recurring_select.scss @@ -77,6 +77,14 @@ select { } .rs_termination_section { + table { + margin: 0; + padding-top: 5px; + td { + padding: 0 + } + } + .rs_termination_label {margin-right:10px;} .rs_count {width:30px; text-align:center; display: inline-block;} } From a27aaf7c242f9ec6a19234a7a9ff26cf7befab31 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 10:32:11 -0400 Subject: [PATCH 06/25] init and change events for never/count options --- .../recurring_select_dialog.js.coffee.erb | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index 039194e2..1edb1e72 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -20,6 +20,7 @@ window.RecurringSelectDialog = @positionDialogVert(true) @mainEventInit() @freqInit() + @terminationInit() @summaryInit() @outer_holder.trigger "recurring_select:dialog_opened" @freq_select.focus() @@ -141,6 +142,18 @@ window.RecurringSelectDialog = interval_input.on "change keyup", @intervalChanged section.show() + terminationInit: -> + if @current_rule.hash? + if @current_rule.hash.count? + @count_option = @outer_holder.find "input[name='rs_termination'][value='count']" + @count_option.prop('checked', 'checked') + @occurrence_count = @outer_holder.find '#rs_occurrence_count' + @occurrence_count.prop('value', @current_rule.hash.count) + else + @never_option = @outer_holder.find "input[name='rs_termination'][value='never']" + @never_option.prop('checked', 'checked') + @all_termination_options = @outer_holder.find ".rs_termination_section input[type='radio']" + @all_termination_options.on "change", @terminationChanged summaryInit: -> @summary = @outer_holder.find(".rs_summary") @@ -227,8 +240,6 @@ window.RecurringSelectDialog = @current_rule.hash ||= {} @current_rule.hash.interval = 1 - @current_rule.hash.until = null - @current_rule.hash.count = null @current_rule.hash.validations = null @content.find(".freq_option_section").hide(); @content.find("input[type=radio], input[type=checkbox]").prop("checked", false) @@ -298,6 +309,21 @@ window.RecurringSelectDialog = @summaryUpdate() false + terminationChanged: (event) => + @current_rule.str = null + @current_rule.hash ||= {} + switch event.target.value + when 'count' + @current_rule.hash.count = parseInt($('#rs_occurrence_count').val()) + if @current_rule.hash.count < 1 || isNaN(@current_rule.hash.count) + @current_rule.hash.count = 1 + @current_rule.has.until = null + when 'until' + else + @current_rule.hash.until = null + @current_rule.hash.count = null + @summaryUpdate() + # ========================= Change callbacks =============================== template: () -> @@ -366,11 +392,14 @@ window.RecurringSelectDialog =
-
+

From 426bb53e7da5235f166cb95bc4967dec6cb9d67a Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 10:59:06 -0400 Subject: [PATCH 09/25] bug fix --- .../javascripts/recurring_select_dialog.js.coffee.erb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index efcc83a5..dd5256a4 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -145,13 +145,12 @@ window.RecurringSelectDialog = terminationInit: -> if @current_rule.hash? && @current_rule.hash.count? @count_option = @outer_holder.find "input[name='rs_termination'][value='count']" - @count_option.prop('checked', 'checked') + @count_option.prop('checked', true) @occurrence_count = @outer_holder.find '#rs_occurrence_count' @occurrence_count.val(@current_rule.hash.count) else @never_option = @outer_holder.find "input[name='rs_termination'][value='never']" - @never_option.prop('checked', 'checked') - console.log(@never_option) + @never_option.prop('checked', true) @all_termination_options = @outer_holder.find ".rs_termination_section input[type='radio'], #rs_occurrence_count, #rs_until_date" @all_termination_options.on "change", @terminationChanged @@ -315,7 +314,7 @@ window.RecurringSelectDialog = return @current_rule.str = null @current_rule.hash ||= {} - switch @selected_termination_type.value + switch @selected_termination_type.val() when 'count' @current_rule.hash.count = parseInt($('#rs_occurrence_count').val()) if @current_rule.hash.count < 1 || isNaN(@current_rule.hash.count) From b6041d358517e0733fe5054dd7c83087bdf62233 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 11:04:58 -0400 Subject: [PATCH 10/25] don't unset "ends" radio on freq change --- app/assets/javascripts/recurring_select_dialog.js.coffee.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index dd5256a4..b4e7c636 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -241,7 +241,7 @@ window.RecurringSelectDialog = @current_rule.hash.interval = 1 @current_rule.hash.validations = null @content.find(".freq_option_section").hide(); - @content.find("input[type=radio], input[type=checkbox]").prop("checked", false) + @content.find(".freq_option_section input[type=radio], input[type=checkbox]").prop("checked", false) switch @freq_select.val() when "Weekly" @current_rule.hash.rule_type = "IceCube::WeeklyRule" From 2ca21419b04d5db77d80a20dd4641c8a470acaf1 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 11:30:33 -0400 Subject: [PATCH 11/25] don't remove termination options from summary when changing freq --- app/assets/javascripts/recurring_select_dialog.js.coffee.erb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index b4e7c636..1da9be26 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -245,19 +245,15 @@ window.RecurringSelectDialog = switch @freq_select.val() when "Weekly" @current_rule.hash.rule_type = "IceCube::WeeklyRule" - @current_rule.str = $.fn.recurring_select.texts["weekly"] @initWeeklyOptions() when "Monthly" @current_rule.hash.rule_type = "IceCube::MonthlyRule" - @current_rule.str = $.fn.recurring_select.texts["monthly"] @initMonthlyOptions() when "Yearly" @current_rule.hash.rule_type = "IceCube::YearlyRule" - @current_rule.str = $.fn.recurring_select.texts["yearly"] @initYearlyOptions() else @current_rule.hash.rule_type = "IceCube::DailyRule" - @current_rule.str = $.fn.recurring_select.texts["daily"] @initDailyOptions() @summaryUpdate() @positionDialogVert() From 78c10031cd7ff37abc4e93a1cc124a54375141de Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 11:34:08 -0400 Subject: [PATCH 12/25] unset str on freq change to force api call for summary --- app/assets/javascripts/recurring_select_dialog.js.coffee.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index 1da9be26..7034c6e8 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -237,6 +237,7 @@ window.RecurringSelectDialog = freqChanged: => @current_rule.hash = null unless $.isPlainObject(@current_rule.hash) # for custom values + @current_rule.str = null @current_rule.hash ||= {} @current_rule.hash.interval = 1 @current_rule.hash.validations = null From 132a6350b7579d0946ea8e4e5836b3dfad1e1c93 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 11:39:02 -0400 Subject: [PATCH 13/25] add datepicker --- .../javascripts/recurring_select_dialog.js.coffee.erb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index 7034c6e8..595e14da 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -143,14 +143,21 @@ window.RecurringSelectDialog = section.show() terminationInit: -> + @until_date = @outer_holder.find '#rs_until_date' + @until_date.datepicker() if @current_rule.hash? && @current_rule.hash.count? @count_option = @outer_holder.find "input[name='rs_termination'][value='count']" @count_option.prop('checked', true) @occurrence_count = @outer_holder.find '#rs_occurrence_count' @occurrence_count.val(@current_rule.hash.count) + else if @current_rule.hash? && @current_rule.hash.until? + @until_option = @outer_holder.find "input[name='rs_termination'][value='until']" + @until_option.prop('checked', true) + @until_date.val(@current_rule.hash.until) else @never_option = @outer_holder.find "input[name='rs_termination'][value='never']" @never_option.prop('checked', true) + @all_termination_options = @outer_holder.find ".rs_termination_section input[type='radio'], #rs_occurrence_count, #rs_until_date" @all_termination_options.on "change", @terminationChanged @@ -318,6 +325,8 @@ window.RecurringSelectDialog = @current_rule.hash.count = 1 @current_rule.hash.until = null when 'until' + @current_rule.hash.until = $('#rs_until_date').val() + @current_rule.hash.count = null else @current_rule.hash.until = null @current_rule.hash.count = null From 64a722e4ae676168a9fac22ece8ebfe479836909 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 11:51:21 -0400 Subject: [PATCH 14/25] use ruby-friendly date format --- app/assets/javascripts/recurring_select_dialog.js.coffee.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index 595e14da..f9315535 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -144,7 +144,7 @@ window.RecurringSelectDialog = terminationInit: -> @until_date = @outer_holder.find '#rs_until_date' - @until_date.datepicker() + @until_date.datepicker({ dateFormat: 'yyyy-mm-dd'}) if @current_rule.hash? && @current_rule.hash.count? @count_option = @outer_holder.find "input[name='rs_termination'][value='count']" @count_option.prop('checked', true) From 74004ca7b04e6ff7f46eddb5b06f73b1eef316ef Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 12:04:52 -0400 Subject: [PATCH 15/25] parse date from {:time, :zone} hash --- .../javascripts/recurring_select_dialog.js.coffee.erb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index f9315535..821ac673 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -144,7 +144,7 @@ window.RecurringSelectDialog = terminationInit: -> @until_date = @outer_holder.find '#rs_until_date' - @until_date.datepicker({ dateFormat: 'yyyy-mm-dd'}) + @until_date.datepicker({ dateFormat: 'yy-mm-dd'}) if @current_rule.hash? && @current_rule.hash.count? @count_option = @outer_holder.find "input[name='rs_termination'][value='count']" @count_option.prop('checked', true) @@ -153,7 +153,11 @@ window.RecurringSelectDialog = else if @current_rule.hash? && @current_rule.hash.until? @until_option = @outer_holder.find "input[name='rs_termination'][value='until']" @until_option.prop('checked', true) - @until_date.val(@current_rule.hash.until) + if @current_rule.hash.until.time? + @until_val = Date.parse(@current_rule.hash.until.time) + else + @until_val = Date.parse(@current_rule.hash.until) + @until_date.val(@until_val.getFullYear() + '-' + (@until_val.getMonth() + 1) + '-' + @until_val.getDate()) else @never_option = @outer_holder.find "input[name='rs_termination'][value='never']" @never_option.prop('checked', true) From 1816962fa6cf0e46a0df40097b32036413c54921 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 12:18:47 -0400 Subject: [PATCH 16/25] new Date() instead of Date.parse() --- app/assets/javascripts/recurring_select_dialog.js.coffee.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index 821ac673..82ff1bbd 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -154,9 +154,9 @@ window.RecurringSelectDialog = @until_option = @outer_holder.find "input[name='rs_termination'][value='until']" @until_option.prop('checked', true) if @current_rule.hash.until.time? - @until_val = Date.parse(@current_rule.hash.until.time) + @until_val = new Date(@current_rule.hash.until.time) else - @until_val = Date.parse(@current_rule.hash.until) + @until_val = new Date(@current_rule.hash.until) @until_date.val(@until_val.getFullYear() + '-' + (@until_val.getMonth() + 1) + '-' + @until_val.getDate()) else @never_option = @outer_holder.find "input[name='rs_termination'][value='never']" From bedcdbab0218b0b46b137b2be2a477be14422bbe Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 12:49:48 -0400 Subject: [PATCH 17/25] potential bug fixes --- app/assets/javascripts/recurring_select_dialog.js.coffee.erb | 3 ++- lib/recurring_select.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index 82ff1bbd..d214c0ef 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -156,7 +156,8 @@ window.RecurringSelectDialog = if @current_rule.hash.until.time? @until_val = new Date(@current_rule.hash.until.time) else - @until_val = new Date(@current_rule.hash.until) + # adding 00:00 because new Date() for ISO 8601 formats differs in that date-only strings (e.g. "1970-01-01") are treated as UTC, not local. + @until_val = new Date(@current_rule.hash.until + ' 00:00') @until_date.val(@until_val.getFullYear() + '-' + (@until_val.getMonth() + 1) + '-' + @until_val.getDate()) else @never_option = @outer_holder.find "input[name='rs_termination'][value='never']" diff --git a/lib/recurring_select.rb b/lib/recurring_select.rb index 688f7743..17ca2b8a 100644 --- a/lib/recurring_select.rb +++ b/lib/recurring_select.rb @@ -88,6 +88,7 @@ def self.filter_params(params) # Set to 23:59:59 (in current TZ) to encompass all events on until day params[:until] = Time.zone.parse(until_param).change(hour: 23, min: 59, sec: 59) elsif until_param.is_a?(Hash) # ex: {time: Thu, 28 Aug 2014 06:59:590000, zone: "Pacific Time (US & Canada)"} + until_param = until_param.symbolize_keys params[:until] = until_param[:time].in_time_zone(until_param[:zone]) end end From c5b0c25f16a5e916987448c32f6f3f263825e982 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 12:54:08 -0400 Subject: [PATCH 18/25] refactor date parsing --- .../javascripts/recurring_select_dialog.js.coffee.erb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index d214c0ef..821be7bf 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -153,12 +153,14 @@ window.RecurringSelectDialog = else if @current_rule.hash? && @current_rule.hash.until? @until_option = @outer_holder.find "input[name='rs_termination'][value='until']" @until_option.prop('checked', true) + # IceCube::TimeUtil will serialize a TimeWithZone into a hash, such as: + # {time: Thu, 04 Sep 2014 06:59:59 +0000, zone: "Pacific Time (US & Canada)"} + # If we're initializing from an unsaved rule, until will be a string if @current_rule.hash.until.time? @until_val = new Date(@current_rule.hash.until.time) + @until_date.val(@until_val.getFullYear() + '-' + (@until_val.getMonth() + 1) + '-' + @until_val.getDate()) else - # adding 00:00 because new Date() for ISO 8601 formats differs in that date-only strings (e.g. "1970-01-01") are treated as UTC, not local. - @until_val = new Date(@current_rule.hash.until + ' 00:00') - @until_date.val(@until_val.getFullYear() + '-' + (@until_val.getMonth() + 1) + '-' + @until_val.getDate()) + @until_date.val(@current_rule.hash.until) else @never_option = @outer_holder.find "input[name='rs_termination'][value='never']" @never_option.prop('checked', true) From fa04ba590fa7c0f083b485426ecaea59f1bfbd12 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 13:50:46 -0400 Subject: [PATCH 19/25] style the datepicker input --- app/assets/javascripts/recurring_select_dialog.js.coffee.erb | 2 +- app/assets/stylesheets/recurring_select.scss | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index 821be7bf..1b0b9cb3 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -420,7 +420,7 @@ window.RecurringSelectDialog = diff --git a/app/assets/stylesheets/recurring_select.scss b/app/assets/stylesheets/recurring_select.scss index 64883180..9537078b 100644 --- a/app/assets/stylesheets/recurring_select.scss +++ b/app/assets/stylesheets/recurring_select.scss @@ -88,6 +88,10 @@ select { .rs_count {width:30px; text-align:center; display: inline-block;} } + .rs_datepicker { + width: 80px; + text-align: center; + } .rs_summary { padding:0px; margin-top:15px; border-top:1px solid #ccc; span {font-weight:bold; border-top:1px solid #fff; display:block; padding:10px 0 5px 0;} From d6469c1abc030929eb2a9e39dbf25e1775d39f70 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 14:20:55 -0400 Subject: [PATCH 20/25] require jquery-ui-rails for "ends on" date picker --- app/assets/javascripts/recurring_select.js.coffee | 1 + app/assets/stylesheets/recurring_select.scss | 4 ++++ recurring_select.gemspec | 1 + 3 files changed, 6 insertions(+) diff --git a/app/assets/javascripts/recurring_select.js.coffee b/app/assets/javascripts/recurring_select.js.coffee index 63f376a1..17a22b03 100644 --- a/app/assets/javascripts/recurring_select.js.coffee +++ b/app/assets/javascripts/recurring_select.js.coffee @@ -1,3 +1,4 @@ +//= require jquery-ui //= require recurring_select_dialog //= require_self diff --git a/app/assets/stylesheets/recurring_select.scss b/app/assets/stylesheets/recurring_select.scss index 9537078b..a7b09cff 100644 --- a/app/assets/stylesheets/recurring_select.scss +++ b/app/assets/stylesheets/recurring_select.scss @@ -1,3 +1,7 @@ +/* +*= require jquery-ui +*/ + @import "utilities.scss"; /* -------- resets ---------------*/ diff --git a/recurring_select.gemspec b/recurring_select.gemspec index d881ddcd..64b3a1d2 100644 --- a/recurring_select.gemspec +++ b/recurring_select.gemspec @@ -18,6 +18,7 @@ Gem::Specification.new do |s| s.add_dependency "rails", ">= 3.2" s.add_dependency "jquery-rails", ">= 3.0" + s.add_dependency "jquery-ui-rails", ">= 5.0" s.add_dependency "ice_cube", ">= 0.11" s.add_dependency "sass-rails", ">= 4.0" s.add_dependency "coffee-rails", ">= 3.1" From 080bd56fe5274393b49b95041679c0ff6faf2cf9 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 14:59:04 -0400 Subject: [PATCH 21/25] working dummy app with jQuery UI date picker --- Gemfile | 1 + Gemfile.lock | 14 +++++++++----- app/assets/javascripts/recurring_select.js.coffee | 2 +- app/assets/stylesheets/recurring_select.scss | 8 ++++---- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index f9e1be74..5d956cf1 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,7 @@ gem 'pg', platform: :ruby gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby gem 'jquery-rails' +gem 'jquery-ui-rails' gem 'rails', '~> 4.0.12' gem 'sass-rails', '~> 4.0.5' diff --git a/Gemfile.lock b/Gemfile.lock index 70357775..12e49609 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,6 +5,7 @@ PATH coffee-rails (>= 3.1) ice_cube (>= 0.11) jquery-rails (>= 3.0) + jquery-ui-rails (>= 5.0) rails (>= 3.2) sass-rails (>= 4.0) @@ -37,22 +38,24 @@ GEM tzinfo (~> 0.3.37) arel (4.0.2) builder (3.1.4) - coffee-rails (4.1.0) + coffee-rails (4.2.2) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) + railties (>= 4.0.0) coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.9.1.1) + coffee-script-source (1.12.2) diff-lcs (1.2.5) erubis (2.7.0) - execjs (2.6.0) + execjs (2.7.0) hike (1.2.3) i18n (0.7.0) - ice_cube (0.13.0) + ice_cube (0.16.2) jquery-rails (3.1.2) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) + jquery-ui-rails (6.0.1) + railties (>= 3.2.16) mail (2.6.3) mime-types (>= 1.16, < 3) mime-types (2.6.2) @@ -123,6 +126,7 @@ DEPENDENCIES activerecord-jdbcpostgresql-adapter bundler (>= 1.3.5) jquery-rails + jquery-ui-rails pg rails (~> 4.0.12) rake (>= 0.9.6) diff --git a/app/assets/javascripts/recurring_select.js.coffee b/app/assets/javascripts/recurring_select.js.coffee index 17a22b03..7d671c85 100644 --- a/app/assets/javascripts/recurring_select.js.coffee +++ b/app/assets/javascripts/recurring_select.js.coffee @@ -1,4 +1,4 @@ -//= require jquery-ui +//= require jquery-ui/widgets/datepicker //= require recurring_select_dialog //= require_self diff --git a/app/assets/stylesheets/recurring_select.scss b/app/assets/stylesheets/recurring_select.scss index a7b09cff..265a970b 100644 --- a/app/assets/stylesheets/recurring_select.scss +++ b/app/assets/stylesheets/recurring_select.scss @@ -1,7 +1,6 @@ /* -*= require jquery-ui -*/ - + *= require jquery-ui/datepicker + */ @import "utilities.scss"; /* -------- resets ---------------*/ @@ -85,7 +84,8 @@ select { margin: 0; padding-top: 5px; td { - padding: 0 + padding: 0; + vertical-align: top; } } .rs_termination_label {margin-right:10px;} From 1e7150ff3a858661056d0e41bf910eec07d64b55 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 15:04:32 -0400 Subject: [PATCH 22/25] update min jquery-ui-rails version --- recurring_select.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recurring_select.gemspec b/recurring_select.gemspec index 64b3a1d2..49c620de 100644 --- a/recurring_select.gemspec +++ b/recurring_select.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |s| s.add_dependency "rails", ">= 3.2" s.add_dependency "jquery-rails", ">= 3.0" - s.add_dependency "jquery-ui-rails", ">= 5.0" + s.add_dependency "jquery-ui-rails", ">= 6.0" s.add_dependency "ice_cube", ">= 0.11" s.add_dependency "sass-rails", ">= 4.0" s.add_dependency "coffee-rails", ">= 3.1" From ed2c2cc97259f81ba59ce5bfc21e1ad8d48489e0 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 15:05:03 -0400 Subject: [PATCH 23/25] set min date --- app/assets/javascripts/recurring_select_dialog.js.coffee.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index 1b0b9cb3..98d2120b 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -144,7 +144,7 @@ window.RecurringSelectDialog = terminationInit: -> @until_date = @outer_holder.find '#rs_until_date' - @until_date.datepicker({ dateFormat: 'yy-mm-dd'}) + @until_date.datepicker({ dateFormat: 'yy-mm-dd', minDate: Date.now }) if @current_rule.hash? && @current_rule.hash.count? @count_option = @outer_holder.find "input[name='rs_termination'][value='count']" @count_option.prop('checked', true) From 56560c06bc67ad0b79d6b2a1bfcb9fc28fa49cee Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 1 Aug 2017 15:08:51 -0400 Subject: [PATCH 24/25] down to jquery-ui-rails 5.0 for active admin support --- Gemfile | 2 +- Gemfile.lock | 6 +++--- app/assets/javascripts/recurring_select.js.coffee | 2 +- .../javascripts/recurring_select_dialog.js.coffee.erb | 2 +- recurring_select.gemspec | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile b/Gemfile index 5d956cf1..eb28a003 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ gem 'pg', platform: :ruby gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby gem 'jquery-rails' -gem 'jquery-ui-rails' +gem 'jquery-ui-rails', '~> 5.0' gem 'rails', '~> 4.0.12' gem 'sass-rails', '~> 4.0.5' diff --git a/Gemfile.lock b/Gemfile.lock index 12e49609..227fbce0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,7 +5,7 @@ PATH coffee-rails (>= 3.1) ice_cube (>= 0.11) jquery-rails (>= 3.0) - jquery-ui-rails (>= 5.0) + jquery-ui-rails (~> 5.0) rails (>= 3.2) sass-rails (>= 4.0) @@ -54,7 +54,7 @@ GEM jquery-rails (3.1.2) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (6.0.1) + jquery-ui-rails (5.0.5) railties (>= 3.2.16) mail (2.6.3) mime-types (>= 1.16, < 3) @@ -126,7 +126,7 @@ DEPENDENCIES activerecord-jdbcpostgresql-adapter bundler (>= 1.3.5) jquery-rails - jquery-ui-rails + jquery-ui-rails (~> 5.0) pg rails (~> 4.0.12) rake (>= 0.9.6) diff --git a/app/assets/javascripts/recurring_select.js.coffee b/app/assets/javascripts/recurring_select.js.coffee index 7d671c85..23664f61 100644 --- a/app/assets/javascripts/recurring_select.js.coffee +++ b/app/assets/javascripts/recurring_select.js.coffee @@ -1,4 +1,4 @@ -//= require jquery-ui/widgets/datepicker +//= require jquery-ui/datepicker //= require recurring_select_dialog //= require_self diff --git a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb index 98d2120b..03243aa0 100644 --- a/app/assets/javascripts/recurring_select_dialog.js.coffee.erb +++ b/app/assets/javascripts/recurring_select_dialog.js.coffee.erb @@ -144,7 +144,7 @@ window.RecurringSelectDialog = terminationInit: -> @until_date = @outer_holder.find '#rs_until_date' - @until_date.datepicker({ dateFormat: 'yy-mm-dd', minDate: Date.now }) + @until_date.datepicker({ dateFormat: 'yy-mm-dd', minDate: 0 }) if @current_rule.hash? && @current_rule.hash.count? @count_option = @outer_holder.find "input[name='rs_termination'][value='count']" @count_option.prop('checked', true) diff --git a/recurring_select.gemspec b/recurring_select.gemspec index 49c620de..f87cc59f 100644 --- a/recurring_select.gemspec +++ b/recurring_select.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |s| s.add_dependency "rails", ">= 3.2" s.add_dependency "jquery-rails", ">= 3.0" - s.add_dependency "jquery-ui-rails", ">= 6.0" + s.add_dependency "jquery-ui-rails", "~> 5.0" s.add_dependency "ice_cube", ">= 0.11" s.add_dependency "sass-rails", ">= 4.0" s.add_dependency "coffee-rails", ">= 3.1" From 322845fa203439d3728ed140f5bb3339f4800a69 Mon Sep 17 00:00:00 2001 From: Rob Florence Date: Tue, 8 Aug 2017 09:26:30 -0400 Subject: [PATCH 25/25] update to jquery-ui-rails 6 --- Gemfile | 2 +- Gemfile.lock | 18 +++++++++--------- .../javascripts/recurring_select.js.coffee | 2 +- recurring_select.gemspec | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Gemfile b/Gemfile index eb28a003..95492857 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ gem 'pg', platform: :ruby gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby gem 'jquery-rails' -gem 'jquery-ui-rails', '~> 5.0' +gem 'jquery-ui-rails', '>= 6.0' gem 'rails', '~> 4.0.12' gem 'sass-rails', '~> 4.0.5' diff --git a/Gemfile.lock b/Gemfile.lock index 227fbce0..125d5ebf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,7 +5,7 @@ PATH coffee-rails (>= 3.1) ice_cube (>= 0.11) jquery-rails (>= 3.0) - jquery-ui-rails (~> 5.0) + jquery-ui-rails (>= 6.0) rails (>= 3.2) sass-rails (>= 4.0) @@ -49,18 +49,18 @@ GEM erubis (2.7.0) execjs (2.7.0) hike (1.2.3) - i18n (0.7.0) + i18n (0.8.6) ice_cube (0.16.2) jquery-rails (3.1.2) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) - jquery-ui-rails (5.0.5) + jquery-ui-rails (6.0.1) railties (>= 3.2.16) mail (2.6.3) 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) @@ -78,7 +78,7 @@ GEM activesupport (= 4.0.13) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.4.2) + rake (12.0.0) rspec (3.1.0) rspec-core (~> 3.1.0) rspec-expectations (~> 3.1.0) @@ -114,10 +114,10 @@ GEM actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) - thor (0.19.1) - thread_safe (0.3.5) + thor (0.19.4) + thread_safe (0.3.6) tilt (1.4.1) - tzinfo (0.3.44) + tzinfo (0.3.53) PLATFORMS ruby @@ -126,7 +126,7 @@ DEPENDENCIES activerecord-jdbcpostgresql-adapter bundler (>= 1.3.5) jquery-rails - jquery-ui-rails (~> 5.0) + jquery-ui-rails (>= 6.0) pg rails (~> 4.0.12) rake (>= 0.9.6) diff --git a/app/assets/javascripts/recurring_select.js.coffee b/app/assets/javascripts/recurring_select.js.coffee index 23664f61..7d671c85 100644 --- a/app/assets/javascripts/recurring_select.js.coffee +++ b/app/assets/javascripts/recurring_select.js.coffee @@ -1,4 +1,4 @@ -//= require jquery-ui/datepicker +//= require jquery-ui/widgets/datepicker //= require recurring_select_dialog //= require_self diff --git a/recurring_select.gemspec b/recurring_select.gemspec index f87cc59f..49c620de 100644 --- a/recurring_select.gemspec +++ b/recurring_select.gemspec @@ -18,7 +18,7 @@ Gem::Specification.new do |s| s.add_dependency "rails", ">= 3.2" s.add_dependency "jquery-rails", ">= 3.0" - s.add_dependency "jquery-ui-rails", "~> 5.0" + s.add_dependency "jquery-ui-rails", ">= 6.0" s.add_dependency "ice_cube", ">= 0.11" s.add_dependency "sass-rails", ">= 4.0" s.add_dependency "coffee-rails", ">= 3.1"