diff --git a/.ruby-version b/.ruby-version index 00355e29..15a27998 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.7 +3.3.0 diff --git a/Gemfile b/Gemfile index f9e1be74..3fb61507 100644 --- a/Gemfile +++ b/Gemfile @@ -6,5 +6,6 @@ gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby gem 'jquery-rails' -gem 'rails', '~> 4.0.12' -gem 'sass-rails', '~> 4.0.5' +gem 'rails', '~> 6.1.6' +gem 'sass', '~> 3.7' +# gem 'pry' diff --git a/Gemfile.lock b/Gemfile.lock index 0add2dbb..9d828ea6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,135 +1,248 @@ PATH remote: . specs: - recurring_select (2.1.0) + recurring_select (7.0.0) coffee-rails (>= 3.1) ice_cube (>= 0.11) jquery-rails (>= 3.0) - rails (>= 3.2) - sass-rails (>= 4.0) + rails (~> 6.1.6) + sass (~> 3.7) GEM remote: https://rubygems.org/ specs: - actionmailer (4.0.13) - actionpack (= 4.0.13) + actioncable (6.1.7.10) + actionpack (= 6.1.7.10) + activesupport (= 6.1.7.10) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.1.7.10) + actionpack (= 6.1.7.10) + activejob (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) + mail (>= 2.7.1) + actionmailer (6.1.7.10) + actionpack (= 6.1.7.10) + actionview (= 6.1.7.10) + activejob (= 6.1.7.10) + activesupport (= 6.1.7.10) mail (~> 2.5, >= 2.5.4) - actionpack (4.0.13) - activesupport (= 4.0.13) - builder (~> 3.1.0) - erubis (~> 2.7.0) - rack (~> 1.5.2) - rack-test (~> 0.6.2) - activemodel (4.0.13) - activesupport (= 4.0.13) - builder (~> 3.1.0) - activerecord (4.0.13) - activemodel (= 4.0.13) - activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.13) - arel (~> 4.0.0) - activerecord-deprecated_finders (1.0.4) - activesupport (4.0.13) - i18n (~> 0.6, >= 0.6.9) - minitest (~> 4.2) - multi_json (~> 1.3) - thread_safe (~> 0.1) - tzinfo (~> 0.3.37) - arel (4.0.2) - builder (3.1.4) - coffee-rails (4.2.2) + rails-dom-testing (~> 2.0) + actionpack (6.1.7.10) + actionview (= 6.1.7.10) + activesupport (= 6.1.7.10) + rack (~> 2.0, >= 2.0.9) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.7.10) + actionpack (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) + nokogiri (>= 1.8.5) + actionview (6.1.7.10) + activesupport (= 6.1.7.10) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.7.10) + activesupport (= 6.1.7.10) + globalid (>= 0.3.6) + activemodel (6.1.7.10) + activesupport (= 6.1.7.10) + activerecord (6.1.7.10) + activemodel (= 6.1.7.10) + activesupport (= 6.1.7.10) + activestorage (6.1.7.10) + actionpack (= 6.1.7.10) + activejob (= 6.1.7.10) + activerecord (= 6.1.7.10) + activesupport (= 6.1.7.10) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (6.1.7.10) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + builder (3.3.0) + coffee-rails (5.0.0) coffee-script (>= 2.2.0) - railties (>= 4.0.0) + railties (>= 5.2.0) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) - diff-lcs (1.2.5) - erubis (2.7.0) - execjs (2.7.0) - hike (1.2.3) - i18n (0.7.0) - ice_cube (0.16.2) - jquery-rails (3.1.2) - railties (>= 3.0, < 5.0) + concurrent-ruby (1.3.4) + crass (1.0.6) + date (3.4.0) + diff-lcs (1.5.1) + erubi (1.13.0) + execjs (2.10.0) + ffi (1.17.0-aarch64-linux-gnu) + ffi (1.17.0-aarch64-linux-musl) + ffi (1.17.0-arm-linux-gnu) + ffi (1.17.0-arm-linux-musl) + ffi (1.17.0-arm64-darwin) + ffi (1.17.0-x86-linux-gnu) + ffi (1.17.0-x86-linux-musl) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) + ffi (1.17.0-x86_64-linux-musl) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.6) + concurrent-ruby (~> 1.0) + ice_cube (0.17.0) + jquery-rails (4.6.0) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) thor (>= 0.14, < 2.0) - mail (2.6.3) - mime-types (>= 1.16, < 3) - mime-types (2.6.2) - minitest (4.7.5) - multi_json (1.11.2) - pg (0.17.1) - rack (1.5.5) - rack-test (0.6.3) - rack (>= 1.0) - rails (4.0.13) - actionmailer (= 4.0.13) - actionpack (= 4.0.13) - activerecord (= 4.0.13) - activesupport (= 4.0.13) - bundler (>= 1.3.0, < 2.0) - railties (= 4.0.13) - sprockets-rails (~> 2.0) - railties (4.0.13) - actionpack (= 4.0.13) - activesupport (= 4.0.13) - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rake (10.4.2) - rspec (3.1.0) - rspec-core (~> 3.1.0) - rspec-expectations (~> 3.1.0) - rspec-mocks (~> 3.1.0) - rspec-core (3.1.7) - rspec-support (~> 3.1.0) - rspec-expectations (3.1.2) + loofah (2.23.1) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) + method_source (1.1.0) + mini_mime (1.1.5) + minitest (5.25.1) + net-imap (0.5.1) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol + nio4r (2.7.4) + nokogiri (1.16.7-aarch64-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm-linux) + racc (~> 1.4) + nokogiri (1.16.7-arm64-darwin) + racc (~> 1.4) + nokogiri (1.16.7-x86-linux) + racc (~> 1.4) + nokogiri (1.16.7-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.16.7-x86_64-linux) + racc (~> 1.4) + pg (1.5.9) + racc (1.8.1) + rack (2.2.10) + rack-test (2.1.0) + rack (>= 1.3) + rails (6.1.7.10) + actioncable (= 6.1.7.10) + actionmailbox (= 6.1.7.10) + actionmailer (= 6.1.7.10) + actionpack (= 6.1.7.10) + actiontext (= 6.1.7.10) + actionview (= 6.1.7.10) + activejob (= 6.1.7.10) + activemodel (= 6.1.7.10) + activerecord (= 6.1.7.10) + activestorage (= 6.1.7.10) + activesupport (= 6.1.7.10) + bundler (>= 1.15.0) + railties (= 6.1.7.10) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (6.1.7.10) + actionpack (= 6.1.7.10) + activesupport (= 6.1.7.10) + method_source + rake (>= 12.2) + thor (~> 1.0) + rake (13.2.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.1.0) - rspec-mocks (3.1.3) - rspec-support (~> 3.1.0) - rspec-rails (3.1.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.1.0) - rspec-expectations (~> 3.1.0) - 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) - 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) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-rails (6.1.5) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.1) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sprockets (4.2.1) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.2) + actionpack (>= 6.1) + activesupport (>= 6.1) + sprockets (>= 3.0.0) + thor (1.3.2) + timeout (0.4.2) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.7.1) PLATFORMS - ruby + aarch64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86-linux + x86-linux-gnu + x86-linux-musl + x86_64-darwin + x86_64-linux + x86_64-linux-gnu + x86_64-linux-musl DEPENDENCIES activerecord-jdbcpostgresql-adapter bundler (>= 1.3.5) jquery-rails pg - rails (~> 4.0.12) + rails (~> 6.1.6) rake (>= 0.9.6) recurring_select! rspec (>= 2.14) rspec-rails (>= 2.14) - sass-rails (~> 4.0.5) + sass (~> 3.7) BUNDLED WITH - 1.16.2 + 2.5.23 diff --git a/Gemfile.lock.bak b/Gemfile.lock.bak new file mode 100644 index 00000000..0add2dbb --- /dev/null +++ b/Gemfile.lock.bak @@ -0,0 +1,135 @@ +PATH + remote: . + specs: + recurring_select (2.1.0) + coffee-rails (>= 3.1) + ice_cube (>= 0.11) + jquery-rails (>= 3.0) + rails (>= 3.2) + sass-rails (>= 4.0) + +GEM + remote: https://rubygems.org/ + specs: + actionmailer (4.0.13) + actionpack (= 4.0.13) + mail (~> 2.5, >= 2.5.4) + actionpack (4.0.13) + activesupport (= 4.0.13) + builder (~> 3.1.0) + erubis (~> 2.7.0) + rack (~> 1.5.2) + rack-test (~> 0.6.2) + activemodel (4.0.13) + activesupport (= 4.0.13) + builder (~> 3.1.0) + activerecord (4.0.13) + activemodel (= 4.0.13) + activerecord-deprecated_finders (~> 1.0.2) + activesupport (= 4.0.13) + arel (~> 4.0.0) + activerecord-deprecated_finders (1.0.4) + activesupport (4.0.13) + i18n (~> 0.6, >= 0.6.9) + minitest (~> 4.2) + multi_json (~> 1.3) + thread_safe (~> 0.1) + tzinfo (~> 0.3.37) + arel (4.0.2) + builder (3.1.4) + coffee-rails (4.2.2) + coffee-script (>= 2.2.0) + railties (>= 4.0.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + diff-lcs (1.2.5) + erubis (2.7.0) + execjs (2.7.0) + hike (1.2.3) + i18n (0.7.0) + ice_cube (0.16.2) + jquery-rails (3.1.2) + railties (>= 3.0, < 5.0) + thor (>= 0.14, < 2.0) + mail (2.6.3) + mime-types (>= 1.16, < 3) + mime-types (2.6.2) + minitest (4.7.5) + multi_json (1.11.2) + pg (0.17.1) + rack (1.5.5) + rack-test (0.6.3) + rack (>= 1.0) + rails (4.0.13) + actionmailer (= 4.0.13) + actionpack (= 4.0.13) + activerecord (= 4.0.13) + activesupport (= 4.0.13) + bundler (>= 1.3.0, < 2.0) + railties (= 4.0.13) + sprockets-rails (~> 2.0) + railties (4.0.13) + actionpack (= 4.0.13) + activesupport (= 4.0.13) + rake (>= 0.8.7) + thor (>= 0.18.1, < 2.0) + rake (10.4.2) + rspec (3.1.0) + rspec-core (~> 3.1.0) + rspec-expectations (~> 3.1.0) + rspec-mocks (~> 3.1.0) + rspec-core (3.1.7) + rspec-support (~> 3.1.0) + rspec-expectations (3.1.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.1.0) + rspec-mocks (3.1.3) + rspec-support (~> 3.1.0) + rspec-rails (3.1.0) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.1.0) + rspec-expectations (~> 3.1.0) + 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) + 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) + +PLATFORMS + ruby + +DEPENDENCIES + activerecord-jdbcpostgresql-adapter + bundler (>= 1.3.5) + jquery-rails + pg + rails (~> 4.0.12) + rake (>= 0.9.6) + recurring_select! + rspec (>= 2.14) + rspec-rails (>= 2.14) + sass-rails (~> 4.0.5) + +BUNDLED WITH + 1.16.2 diff --git a/Gemfile.orig.lock b/Gemfile.orig.lock new file mode 100644 index 00000000..1cd67c30 --- /dev/null +++ b/Gemfile.orig.lock @@ -0,0 +1,195 @@ +PATH + remote: . + specs: + recurring_select (2.1.0) + coffee-rails (>= 3.1) + ice_cube (>= 0.11) + jquery-rails (>= 3.0) + rails (>= 3.2) + sass-rails (>= 4.0) + +GEM + remote: https://rubygems.org/ + specs: + actioncable (5.2.3) + actionpack (= 5.2.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.3) + actionpack (= 5.2.3) + actionview (= 5.2.3) + activejob (= 5.2.3) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (5.2.3) + actionview (= 5.2.3) + activesupport (= 5.2.3) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (5.2.3) + activesupport (= 5.2.3) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.3) + activesupport (= 5.2.3) + globalid (>= 0.3.6) + activemodel (5.2.3) + activesupport (= 5.2.3) + activerecord (5.2.3) + activemodel (= 5.2.3) + activesupport (= 5.2.3) + arel (>= 9.0) + activestorage (5.2.3) + actionpack (= 5.2.3) + activerecord (= 5.2.3) + marcel (~> 0.3.1) + activesupport (5.2.3) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) + minitest (~> 5.1) + tzinfo (~> 1.1) + arel (9.0.0) + builder (3.2.3) + coderay (1.1.2) + coffee-rails (5.0.0) + coffee-script (>= 2.2.0) + railties (>= 5.2.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.5) + crass (1.0.5) + diff-lcs (1.3) + erubi (1.9.0) + execjs (2.7.0) + ffi (1.11.1) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.7.0) + concurrent-ruby (~> 1.0) + ice_cube (0.16.3) + jquery-rails (4.3.5) + rails-dom-testing (>= 1, < 3) + railties (>= 4.2.0) + thor (>= 0.14, < 2.0) + loofah (2.3.1) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (0.9.2) + mimemagic (0.3.3) + mini_mime (1.0.2) + mini_portile2 (2.4.0) + minitest (5.13.0) + nio4r (2.5.2) + nokogiri (1.10.5) + mini_portile2 (~> 2.4.0) + pg (1.1.4) + pry (0.12.2) + coderay (~> 1.1.0) + method_source (~> 0.9.0) + rack (2.0.7) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.3) + actioncable (= 5.2.3) + actionmailer (= 5.2.3) + actionpack (= 5.2.3) + actionview (= 5.2.3) + activejob (= 5.2.3) + activemodel (= 5.2.3) + activerecord (= 5.2.3) + activestorage (= 5.2.3) + activesupport (= 5.2.3) + bundler (>= 1.3.0) + railties (= 5.2.3) + sprockets-rails (>= 2.0.0) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (5.2.3) + actionpack (= 5.2.3) + activesupport (= 5.2.3) + method_source + rake (>= 0.8.7) + thor (>= 0.19.0, < 2.0) + rake (13.0.0) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) + rspec (3.9.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-core (3.9.0) + rspec-support (~> 3.9.0) + rspec-expectations (3.9.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-mocks (3.9.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.9.0) + rspec-rails (3.9.0) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.9.0) + rspec-expectations (~> 3.9.0) + rspec-mocks (~> 3.9.0) + rspec-support (~> 3.9.0) + rspec-support (3.9.0) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (5.1.0) + railties (>= 5.2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (>= 1.1, < 3) + sprockets (3.7.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + thor (0.20.3) + thread_safe (0.3.6) + tilt (2.0.10) + tzinfo (1.2.5) + thread_safe (~> 0.1) + websocket-driver (0.7.1) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.4) + +PLATFORMS + ruby + +DEPENDENCIES + activerecord-jdbcpostgresql-adapter + bundler (>= 1.3.5) + jquery-rails + pg + pry + rails (~> 5.2.3) + rake (>= 0.9.6) + recurring_select! + rspec (>= 2.14) + rspec-rails (>= 2.14) + sass-rails (~> 5.1.0) + +BUNDLED WITH + 2.0.2 diff --git a/README.md b/README.md index 8d526d9e..5aac5da9 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ 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) diff --git a/app/assets/javascripts/jquery-mobile-rs.js b/app/assets/javascripts/jquery-mobile-rs.js new file mode 100644 index 00000000..a8218f39 --- /dev/null +++ b/app/assets/javascripts/jquery-mobile-rs.js @@ -0,0 +1,18 @@ +//= require recurring_select + +$(function () { + $(document).on("recurring_select:cancel recurring_select:save", ".recurring_select", function () { + return $(this).selectmenu('refresh'); + }); + + return $(document).on("recurring_select:dialog_opened", ".rs_dialog_holder", function () { + $(this).find("select").attr("data-theme", $('.recurring_select').data("theme")).attr("data-mini", true).selectmenu(); + $(this).find("input[type=text]").textinput(); + + return $(this).on("recurring_select:dialog_positioned", ".rs_dialog", function () { + return $(this).css({ + "top": $(window).scrollTop() + "px" + }); + }); + }); +}); \ No newline at end of file diff --git a/app/assets/javascripts/jquery-mobile-rs.js.coffee b/app/assets/javascripts/jquery-mobile-rs.js.coffee deleted file mode 100644 index 11db15b7..00000000 --- a/app/assets/javascripts/jquery-mobile-rs.js.coffee +++ /dev/null @@ -1,15 +0,0 @@ -//= require recurring_select -//= require_self - -$ -> - $(document).on "recurring_select:cancel recurring_select:save", ".recurring_select", -> - $(this).selectmenu('refresh') - - $(document).on "recurring_select:dialog_opened", ".rs_dialog_holder", -> - $(this).find("select").attr("data-theme", $('.recurring_select').data("theme")).attr("data-mini", true).selectmenu() - $(this).find("input[type=text]").textinput() - - $(this).on "recurring_select:dialog_positioned", ".rs_dialog", -> - $(this).css - "top" : $(window).scrollTop()+"px" - diff --git a/app/assets/javascripts/recurring_select.js b/app/assets/javascripts/recurring_select.js new file mode 100644 index 00000000..ac282e7d --- /dev/null +++ b/app/assets/javascripts/recurring_select.js @@ -0,0 +1,126 @@ +//= require recurring_select_dialog + +const $ = jQuery; +$(function () { + $(document).on("focus", ".recurring_select", function () { + return $(this).recurring_select('set_initial_values'); + }); + + return $(document).on("change", ".recurring_select", function () { + return $(this).recurring_select('changed'); + }); +}); + +var methods = { + set_initial_values() { + this.data('initial-value-hash', this.val()); + return this.data('initial-value-str', $(this.find("option").get()[this.prop("selectedIndex")]).text()); + }, + + changed() { + if (this.val() === "custom") { + return methods.open_custom.apply(this); + } else { + return methods.set_initial_values.apply(this); + } + }, + + open_custom() { + this.data("recurring-select-active", true); + new RecurringSelectDialog(this); + return this.blur(); + }, + + save(new_rule) { + this.find("option[data-custom]").remove(); + const new_json_val = JSON.stringify(new_rule.hash); + + // TODO: check for matching name, and replace that value if found + + if ($.inArray(new_json_val, this.find("option").map(function () { + return $(this).val(); + })) === -1) { + methods.insert_option.apply(this, [new_rule.str, new_json_val]); + } + + this.val(new_json_val); + methods.set_initial_values.apply(this); + return this.trigger("recurring_select:save"); + }, + + current_rule() { + return { + str: this.data("initial-value-str"), + hash: $.parseJSON(this.data("initial-value-hash")) + }; + }, + + cancel() { + this.val(this.data("initial-value-hash")); + this.data("recurring-select-active", false); + return this.trigger("recurring_select:cancel"); + }, + + + insert_option(new_rule_str, new_rule_json) { + let separator = this.find("option:disabled"); + if (separator.length === 0) { + separator = this.find("option"); + } + separator = separator.last(); + + const new_option = $(document.createElement("option")); + new_option.attr("data-custom", true); + + if (new_rule_str.substr(new_rule_str.length - 1) !== "*") { + new_rule_str += "*"; + } + + new_option.text(new_rule_str); + new_option.val(new_rule_json); + return new_option.insertBefore(separator); + }, + + methods() { + return methods; + } +}; + +$.fn.recurring_select = function (method) { + if (method in methods) { + return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } else { + return $.error(`Method ${method} does not exist on jQuery.recurring_select`); + } +}; + +$.fn.recurring_select.options = { + monthly: { + show_week: [true, true, true, true, false, false] + } +}; + +$.fn.recurring_select.texts = { + locale_iso_code: "en", + repeat: "Repeat", + last_day: "Last Day", + 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)", + day_of_month: "Day of month", + day_of_week: "Day of week", + cancel: "Cancel", + ok: "OK", + summary: "Summary", + first_day_of_week: 0, + days_first_letter: ["S", "M", "T", "W", "T", "F", "S"], + order: ["1st", "2nd", "3rd", "4th", "5th", "Last"], + show_week: [true, true, true, true, false, false] +}; \ No newline at end of file diff --git a/app/assets/javascripts/recurring_select.js.coffee b/app/assets/javascripts/recurring_select.js.coffee deleted file mode 100644 index d4932139..00000000 --- a/app/assets/javascripts/recurring_select.js.coffee +++ /dev/null @@ -1,105 +0,0 @@ -//= require recurring_select_dialog -//= require_self - -$ = jQuery -$ -> - $(document).on "focus", ".recurring_select", -> - $(this).recurring_select('set_initial_values') - - $(document).on "change", ".recurring_select", -> - $(this).recurring_select('changed') - -methods = - set_initial_values: -> - @data 'initial-value-hash', @val() - @data 'initial-value-str', $(@find("option").get()[@.prop("selectedIndex")]).text() - - changed: -> - if @val() == "custom" - methods.open_custom.apply(@) - else - methods.set_initial_values.apply(@) - - open_custom: -> - @data "recurring-select-active", true - new RecurringSelectDialog(@) - @blur() - - save: (new_rule) -> - @find("option[data-custom]").remove() - new_json_val = JSON.stringify(new_rule.hash) - - # TODO: check for matching name, and replace that value if found - - if $.inArray(new_json_val, @find("option").map -> $(@).val()) == -1 - methods.insert_option.apply @, [new_rule.str, new_json_val] - - @val new_json_val - methods.set_initial_values.apply @ - @.trigger "recurring_select:save" - - current_rule: -> - str: @data("initial-value-str") - hash: $.parseJSON(@data("initial-value-hash")) - - cancel: -> - @val @data("initial-value-hash") - @data "recurring-select-active", false - @.trigger "recurring_select:cancel" - - - insert_option: (new_rule_str, new_rule_json) -> - separator = @find("option:disabled") - if separator.length == 0 - separator = @find("option") - separator = separator.last() - - new_option = $(document.createElement("option")) - new_option.attr "data-custom", true - - if new_rule_str.substr(new_rule_str.length - 1) != "*" - new_rule_str+="*" - - new_option.text new_rule_str - new_option.val new_rule_json - new_option.insertBefore separator - - methods: -> - methods - -$.fn.recurring_select = (method) -> - if method of methods - return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ) ); - else - $.error( "Method #{method} does not exist on jQuery.recurring_select" ); - -$.fn.recurring_select.options = { - monthly: { - show_week: [true, true, true, true, false, false] - } -} - -$.fn.recurring_select.texts = { - locale_iso_code: "en" - repeat: "Repeat" - last_day: "Last Day" - 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)" - day_of_month: "Day of month" - day_of_week: "Day of week" - cancel: "Cancel" - ok: "OK" - summary: "Summary" - first_day_of_week: 0 - days_first_letter: ["S", "M", "T", "W", "T", "F", "S" ] - order: ["1st", "2nd", "3rd", "4th", "5th", "Last"] - show_week: [true, true, true, true, false, false] -} diff --git a/app/assets/javascripts/recurring_select/fr.js b/app/assets/javascripts/recurring_select/fr.js new file mode 100644 index 00000000..a91844fa --- /dev/null +++ b/app/assets/javascripts/recurring_select/fr.js @@ -0,0 +1,25 @@ +$.fn.recurring_select.texts = { + locale_iso_code: "fr", + repeat: "Récurrence", + last_day: "Dernier jour", + frequency: "Fréquence", + daily: "Tous les jours", + weekly: "Toutes les semaines", + monthly: "Tous les mois", + yearly: "Tous les ans", + every: "Tous les", + days: "jour(s)", + weeks_on: "semaine(s) le", + months: "mois", + years: "année(s)", + cancel: "Annuler", + day_of_month: "Jour du mois", + day_of_week: "Jour de la semaine", + ok: "OK", + cancel: "Annuler", + summary: "Résumé", + first_day_of_week: 1, + 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] +} \ No newline at end of file diff --git a/app/assets/javascripts/recurring_select/fr.js.coffee b/app/assets/javascripts/recurring_select/fr.js.coffee deleted file mode 100644 index 687890cf..00000000 --- a/app/assets/javascripts/recurring_select/fr.js.coffee +++ /dev/null @@ -1,25 +0,0 @@ -$.fn.recurring_select.texts = { - locale_iso_code: "fr" - repeat: "Récurrence" - last_day: "Dernier jour" - frequency: "Fréquence" - daily: "Tous les jours" - weekly: "Toutes les semaines" - monthly: "Tous les mois" - yearly: "Tous les ans" - every: "Tous les" - days: "jour(s)" - weeks_on: "semaine(s) le" - months: "mois" - years: "année(s)" - cancel: "Annuler" - day_of_month: "Jour du mois" - day_of_week: "Jour de la semaine" - ok: "OK" - cancel: "Annuler" - summary: "Résumé" - first_day_of_week: 1 - 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] -} \ No newline at end of file diff --git a/app/assets/stylesheets/jquery-mobile-rs.scss b/app/assets/stylesheets/jquery-mobile-rs.scss index 7211dae5..ed3685d0 100644 --- a/app/assets/stylesheets/jquery-mobile-rs.scss +++ b/app/assets/stylesheets/jquery-mobile-rs.scss @@ -1,47 +1,80 @@ -/* -*= require recurring_select -*= require_self -*/ +@import "recurring_select.scss"; /* Make the jQuery mobile wrapped input elements inline */ div.ui-recurring-select { - display:inline-block; + display: inline-block; } -.frequency-select-wrapper label{ - display:inline; +.frequency-select-wrapper label { + display: inline; } /* Make the jQuery mobile wrapped labels and radios remain inline elements inline */ p.monthly_rule_type label { - display:inline; + display: inline; } -.rs_dialog_holder {padding-left:0px; background-color:#333; background-color:rgba(30,30,30,0.3); font-size:1em; position:absolute; - .rs_dialog { position:absolute; left:10px; right:10px; margin:0px; display:block; z-index:51; +.rs_dialog_holder { + padding-left: 0px; + background-color: #333; + background-color: rgba(30, 30, 30, 0.3); + font-size: 1em; + position: absolute; + + .rs_dialog { + position: absolute; + left: 10px; + right: 10px; + margin: 0px; + display: block; + z-index: 51; .rs_dialog_content { - label.ui-select { display:inline-block;} - div.ui-select {display:inline-block;} + label.ui-select { + display: inline-block; + } + + div.ui-select { + display: inline-block; + } - input.rs_interval {display:inline-block;} + input.rs_interval { + display: inline-block; + } .freq_option_section { - .day_holder {height:36px; - a {padding:10px 12px;} + .day_holder { + height: 36px; + + a { + padding: 10px 12px; + } } - .rs_calendar { width:225px; - * { text-shadow: none; } - a {padding:10px 8px;} - a.end_of_month { width: 111px; } + .rs_calendar { + width: 225px; + + * { + text-shadow: none; + } + + a { + padding: 10px 8px; + } + + a.end_of_month { + width: 111px; + } } } - .rs_summary span { font-size:90%; font-weight:normal; } + .rs_summary span { + font-size: 90%; + font-weight: normal; + } } } -} +} \ No newline at end of file diff --git a/lib/recurring_select.rb b/lib/recurring_select.rb index 5f727ed4..64049a18 100644 --- a/lib/recurring_select.rb +++ b/lib/recurring_select.rb @@ -22,11 +22,9 @@ def self.dirty_hash_to_rule(params) def self.is_valid_rule?(possible_rule) return true if possible_rule.is_a?(IceCube::Rule) return false if possible_rule.blank? - if possible_rule.is_a?(String) begin - JSON.parse(possible_rule) - return true + return JSON.parse(possible_rule).is_a?(Hash) # JSON.parse("null") does not throw an error, it returns nil rescue JSON::ParserError return false end diff --git a/lib/recurring_select/version.rb b/lib/recurring_select/version.rb index 3e6c68a6..70bb317f 100644 --- a/lib/recurring_select/version.rb +++ b/lib/recurring_select/version.rb @@ -1,3 +1,3 @@ module RecurringSelect - VERSION = "2.1.0" + VERSION = "7.0.0" end diff --git a/recurring_select.gemspec b/recurring_select.gemspec index d881ddcd..1897e7fb 100644 --- a/recurring_select.gemspec +++ b/recurring_select.gemspec @@ -7,8 +7,8 @@ require "recurring_select/version" Gem::Specification.new do |s| s.name = "recurring_select" s.version = RecurringSelect::VERSION - s.authors = ["Jobber", "Forrest Zeisler", "Nathan Youngman"] - s.email = ["forrest@getjobber.com"] + s.authors = ["Jobber", "Forrest Zeisler", "Nathan Youngman", "Tyler Merritt"] + s.email = ["tgmerritt@gmail.com"] s.homepage = "http://github.com/getjobber/recurring_select" s.summary = "A select helper which gives you magical powers to generate ice_cube rules." s.description = "This gem provides a useful interface for creating recurring rules for the ice_cube gem." @@ -16,12 +16,17 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.md"] s.test_files = Dir["test/**/*"] - s.add_dependency "rails", ">= 3.2" + # Dependencies + s.add_dependency "rails", "~> 6.1.6" s.add_dependency "jquery-rails", ">= 3.0" s.add_dependency "ice_cube", ">= 0.11" - s.add_dependency "sass-rails", ">= 4.0" + + # Switch from sassc-rails to dart-sass + s.add_dependency "sass", "~> 3.7" + s.add_dependency "coffee-rails", ">= 3.1" + # Development dependencies s.add_development_dependency "bundler", ">= 1.3.5" s.add_development_dependency "rspec-rails", ">= 2.14" s.add_development_dependency "rspec", ">= 2.14" diff --git a/spec/app/helpers/recurring_select_helper_spec.rb b/spec/app/helpers/recurring_select_helper_spec.rb index c43ce34a..bceef930 100644 --- a/spec/app/helpers/recurring_select_helper_spec.rb +++ b/spec/app/helpers/recurring_select_helper_spec.rb @@ -9,7 +9,7 @@ class FromTester describe "#recurring_options_for_select" do it "should use the correct options (basic)" do subject = FromTester.new - subject.should_receive(:options_for_select).with( + expect(subject).to receive(:options_for_select).with( [ ['- not recurring -', 'null'], ['Set schedule...', 'custom'] @@ -20,7 +20,7 @@ class FromTester it "should use the correct options (no defaults but custom rule)" do subject = FromTester.new - subject.should_receive(:options_for_select).with( + expect(subject).to receive(:options_for_select).with( [ ["Weekly", IceCube::Rule.weekly.to_hash.to_json], ['or', {:disabled => true}], @@ -32,7 +32,7 @@ class FromTester it "should use the correct options (defaults with no rule)" do subject = FromTester.new - subject.should_receive(:options_for_select).with( + expect(subject).to receive(:options_for_select).with( [ ["Weekly", IceCube::Rule.weekly.to_hash.to_json], ["Monthly", IceCube::Rule.monthly.to_hash.to_json], @@ -45,7 +45,7 @@ class FromTester it "should use the correct options (non-recurring rule with defaults)" do subject = FromTester.new - subject.should_receive(:options_for_select).with( + expect(subject).to receive(:options_for_select).with( [ ["- not recurring -", 'null'], ["different", 1], diff --git a/spec/dummy/app/assets/config/manifest.js b/spec/dummy/app/assets/config/manifest.js new file mode 100644 index 00000000..e0020d01 --- /dev/null +++ b/spec/dummy/app/assets/config/manifest.js @@ -0,0 +1,2 @@ +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css \ No newline at end of file diff --git a/spec/gemfiles/Gemfile.rails-5.0.x b/spec/gemfiles/Gemfile.rails-5.0.x index b42c6e4b..4a531621 100644 --- a/spec/gemfiles/Gemfile.rails-5.0.x +++ b/spec/gemfiles/Gemfile.rails-5.0.x @@ -4,5 +4,5 @@ gemspec :path => "./../.." gem 'pg', platform: :ruby gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby -gem "rails", "~> 5.2" -gem "sass-rails", "~> 5.0" \ No newline at end of file +gem "rails", "~> 5.0.7.2" +gem "sass-rails", "~> 5.0.7.2" \ No newline at end of file diff --git a/spec/lib/recurring_select_spec.rb b/spec/lib/recurring_select_spec.rb index 3b00fa5f..1db4dbea 100644 --- a/spec/lib/recurring_select_spec.rb +++ b/spec/lib/recurring_select_spec.rb @@ -2,24 +2,24 @@ describe RecurringSelect do it "should be a module" do - RecurringSelect.should be_kind_of Module + expect(RecurringSelect).to be_kind_of Module end describe "#is_valid_rule?" do it "should identify invalid rules" do - RecurringSelect.should_not be_is_valid_rule(nil) - RecurringSelect.should_not be_is_valid_rule("") - RecurringSelect.should_not be_is_valid_rule(false) - RecurringSelect.should_not be_is_valid_rule("null") - RecurringSelect.should_not be_is_valid_rule("0") - RecurringSelect.should_not be_is_valid_rule("custom") - RecurringSelect.should_not be_is_valid_rule([1, 2]) + expect(RecurringSelect.is_valid_rule?(nil)).to be false + expect(RecurringSelect.is_valid_rule?("")).to be false + expect(RecurringSelect.is_valid_rule?(false)).to be false + expect(RecurringSelect.is_valid_rule?("null")).to be false + expect(RecurringSelect.is_valid_rule?("0")).to be false + expect(RecurringSelect.is_valid_rule?("custom")).to be false + expect(RecurringSelect.is_valid_rule?([1, 2])).to be false end it "should identify valid rules" do - RecurringSelect.should be_is_valid_rule(IceCube::Rule.weekly) - RecurringSelect.should be_is_valid_rule(IceCube::Rule.weekly.to_hash) - RecurringSelect.should be_is_valid_rule(IceCube::Rule.weekly.to_hash.to_json) + expect(RecurringSelect.is_valid_rule?(IceCube::Rule.weekly)).to be true + expect(RecurringSelect.is_valid_rule?(IceCube::Rule.weekly.to_hash)).to be true + expect(RecurringSelect.is_valid_rule?(IceCube::Rule.weekly.to_hash.to_json)).to be true end end