recurring_select 3.0.0 → 4.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2a0200c05a91d2e53f9893103e3ee5259a0bd0917efaf373e0fff2ced38caa6
4
- data.tar.gz: e950b6d4f120e420885e68c7d69192d3e65c241d9c90d139a44691f676ad41a8
3
+ metadata.gz: 31e198de02d94e75927a32460fe0a56601c1da1f52b9df05d878ea7c2857d637
4
+ data.tar.gz: 351c9d4727459ffb8e5c58eb523a08123ca49b51de8d63fe1e66c13e85d04d87
5
5
  SHA512:
6
- metadata.gz: e2714208952ec80d4cecaf50f579a26ea06b7a1025803ace7486f31c7a307e57e965eb766b28ddfa478195c4557b9f8871a19c6b98125549df4825befc54082b
7
- data.tar.gz: 679630c691151c92b59e98fcf08697f8f2ca5fccb6556e7737f9581aa319ce67ce02ceb9b948c3b86b8d9a8d3b37173b1eb15314e2e2bb5792c71cde4b0b1fc5
6
+ metadata.gz: 9ba0419fbb294618ab4846ed4ce767c057e1574201852b8e61923bcf9889c493cd078db6ab08ea413bb117d92c525c05f39f35d8fe8c1978d8e7104673acda44
7
+ data.tar.gz: '093da6c4eaf8a91da28dce5ce12878670cd3455d2098e5b7ad50c8641dbf69936bd33cc7c0b47386220489ab3350f0ef66b3e30457e3bdbe86cd5722bd65253e'
data/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Recurring Select
2
2
 
3
- [![Build Status](https://travis-ci.org/GetJobber/recurring_select.svg?branch=master)](https://travis-ci.org/GetJobber/recurring_select) [![Code Climate](https://codeclimate.com/github/GetJobber/recurring_select.png)](https://codeclimate.com/github/GetJobber/recurring_select)
3
+ [![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)
4
4
 
5
5
  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.
6
6
 
7
7
  Created by the [Jobber](http://getjobber.com) team for Jobber, the leading business management tool for field service companies.
8
8
 
9
- 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)
9
+ 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).
10
10
 
11
11
 
12
12
  ## Usage
@@ -26,6 +26,7 @@ gem 'recurring_select'
26
26
  - application.css: `//= require recurring_select`
27
27
 
28
28
  #### jQuery Mobile Interface:
29
+ - application.js: `//= require jquery`
29
30
  - application.js: `//= require jquery-mobile-rs`
30
31
  - application.css: `//= require jquery-mobile-rs`
31
32
 
@@ -99,8 +100,8 @@ You have to translate JavaScript texts too by including the locale file in your
99
100
 
100
101
  For other languages include a JavaScript file like this:
101
102
 
102
- ```coffeescript
103
- $.fn.recurring_select.texts = {
103
+ ```js
104
+ RecurringSelectDialog.config.texts = {
104
105
  locale_iso_code: "fr"
105
106
  repeat: "Repeat"
106
107
  frequency: "Frequency"
@@ -125,8 +126,8 @@ $.fn.recurring_select.texts = {
125
126
 
126
127
  Options include:
127
128
 
128
- ```coffeescript
129
- $.fn.recurring_select.options = {
129
+ ```js
130
+ RecurringSelectDialog.config.options = {
130
131
  monthly: {
131
132
  show_week: [true, true, true, true, false, false] //display week 1, 2 .... Last
132
133
  }
@@ -135,31 +136,21 @@ $.fn.recurring_select.options = {
135
136
 
136
137
  ## Testing and Development
137
138
 
138
- The dummy app uses a [Postgres](http://postgresapp.com/) database `recurring_select_development`. To get setup:
139
-
140
- ```console
141
- bundle
142
- rake db:create
143
- ```
144
-
145
139
  Start the dummy server for clicking around the interface:
146
140
 
147
141
  ```console
148
142
  rails s
149
143
  ```
150
144
 
151
- Use [Guard](https://github.com/guard/guard) and RSpec for all tests. I'd
152
- love to get Jasmine running also, but haven't had time yet.
153
-
154
145
  Tests can be ran against different versions of Rails like so:
155
146
 
156
147
  ```
157
- BUNDLE_GEMFILE=spec/gemfiles/Gemfile.rails-4.0.x bundle install
158
- BUNDLE_GEMFILE=spec/gemfiles/Gemfile.rails-4.0.x bundle exec rspec spec
148
+ BUNDLE_GEMFILE=spec/gemfiles/rails-7 bundle install
149
+ BUNDLE_GEMFILE=spec/gemfiles/rails-7 bundle exec rspec spec
159
150
  ```
160
151
 
161
152
  Feel free to open issues or send pull requests.
162
153
 
163
154
  ## Licensing
164
155
 
165
- This project rocks and uses MIT-LICENSE.
156
+ This project rocks and uses the MIT license.
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ Bundler::GemHelper.install_tasks
12
12
  require 'rdoc/task'
13
13
  RDoc::Task.new(:rdoc) do |rdoc|
14
14
  rdoc.rdoc_dir = 'rdoc'
15
- rdoc.title = 'RecurringSelect'
15
+ rdoc.title = 'RecurringSelect'
16
16
  rdoc.options << '--line-numbers'
17
17
  rdoc.rdoc_files.include('README.rdoc')
18
18
  rdoc.rdoc_files.include('lib/**/*.rb')
@@ -0,0 +1,31 @@
1
+ const defaultConfig = {
2
+ options: {
3
+ monthly: {
4
+ show_week: [true, true, true, true, false, false]
5
+ }
6
+ },
7
+ texts: {
8
+ locale_iso_code: "en",
9
+ repeat: "Repeat",
10
+ last_day: "Last Day",
11
+ frequency: "Frequency",
12
+ daily: "Daily",
13
+ weekly: "Weekly",
14
+ monthly: "Monthly",
15
+ yearly: "Yearly",
16
+ every: "Every",
17
+ days: "day(s)",
18
+ weeks_on: "week(s) on",
19
+ months: "month(s)",
20
+ years: "year(s)",
21
+ day_of_month: "Day of month",
22
+ day_of_week: "Day of week",
23
+ cancel: "Cancel",
24
+ ok: "OK",
25
+ summary: "Summary",
26
+ first_day_of_week: 0,
27
+ days_first_letter: ["S", "M", "T", "W", "T", "F", "S" ],
28
+ order: ["1st", "2nd", "3rd", "4th", "5th", "Last"],
29
+ show_week: [true, true, true, true, false, false]
30
+ }
31
+ }
@@ -0,0 +1,20 @@
1
+ //= require recurring_select
2
+ //= require_self
3
+
4
+ const $ = jQuery
5
+
6
+ $(function() {
7
+ $(document).on("recurring_select:cancel recurring_select:save", ".recurring_select", function() {
8
+ $(this).selectmenu('refresh');
9
+ });
10
+
11
+ $(document).on("recurring_select:dialog_opened", ".rs_dialog_holder", function() {
12
+ $(this).find("select").attr("data-theme", $('.recurring_select').data("theme")).attr("data-mini", true).selectmenu();
13
+ $(this).find("input[type=text]").textinput();
14
+
15
+ $(this).on("recurring_select:dialog_positioned", ".rs_dialog", function() {
16
+ $(this).css({
17
+ "top" : $(window).scrollTop()+"px"});
18
+ });
19
+ });
20
+ });
@@ -1,4 +1,4 @@
1
- $.fn.recurring_select.texts = {
1
+ RecurringSelectDialog.config.texts = {
2
2
  locale_iso_code: "fr"
3
3
  repeat: "Récurrence"
4
4
  last_day: "Dernier jour"
@@ -21,4 +21,4 @@ $.fn.recurring_select.texts = {
21
21
  days_first_letter: ["D", "L", "M", "M", "J", "V", "S" ]
22
22
  order: ["1er", "2ème", "3ème", "4ème", "5ème", "Dernier"]
23
23
  show_week: [true, true, true, true, false, false]
24
- }
24
+ }
@@ -0,0 +1,96 @@
1
+ //= require recurring_select_dialog
2
+ //= require_self
3
+
4
+ document.addEventListener("DOMContentLoaded", () => {
5
+ document.addEventListener("focusin", (e) => {
6
+ if (e.target.matches(".recurring_select")) {
7
+ recurring_select.call(e.target, "set_initial_values")
8
+ }
9
+ })
10
+
11
+ document.addEventListener("input", (e) => {
12
+ if (e.target.matches(".recurring_select")) {
13
+ recurring_select.call(e.target, "changed")
14
+ }
15
+ })
16
+ })
17
+
18
+ const methods = {
19
+ set_initial_values() {
20
+ const str = this.querySelectorAll('option')[this.selectedIndex].textContent
21
+ this.setAttribute('data-initial-value-hash', this.value);
22
+ this.setAttribute('data-initial-value-str', str);
23
+ },
24
+
25
+ changed() {
26
+ if (this.value == "custom") {
27
+ methods.open.call(this);
28
+ } else {
29
+ methods.set_initial_values.call(this);
30
+ }
31
+ },
32
+
33
+ open() {
34
+ this.setAttribute("data-recurring-select-active", true);
35
+ new RecurringSelectDialog(this);
36
+ this.blur();
37
+ },
38
+
39
+ save(new_rule) {
40
+ this.querySelectorAll("option[data-custom]").forEach((el) => el.parentNode.removeChild(el) )
41
+ const new_json_val = JSON.stringify(new_rule.hash)
42
+
43
+ // TODO: check for matching name, and replace that value if found
44
+
45
+ const options = Array.from(this.querySelectorAll("option")).map(() => this.value)
46
+ if (!options.includes(new_json_val)) {
47
+ methods.insert_option.apply(this, [new_rule.str, new_json_val])
48
+ }
49
+
50
+ this.value = new_json_val
51
+ methods.set_initial_values.apply(this)
52
+ this.dispatchEvent(new CustomEvent("recurring_select:save"))
53
+ },
54
+
55
+ current_rule() {
56
+ return {
57
+ str: this.getAttribute("data-initial-value-str"),
58
+ hash: JSON.parse(this.getAttribute("data-initial-value-hash"))
59
+ };
60
+ },
61
+
62
+ cancel() {
63
+ this.value = this.getAttribute("data-initial-value-hash")
64
+ this.setAttribute("data-recurring-select-active", false);
65
+ this.dispatchEvent(new CustomEvent("recurring_select:cancel"))
66
+ },
67
+
68
+
69
+ insert_option(new_rule_str, new_rule_json) {
70
+ let separator = this.querySelectorAll("option[disabled]");
71
+ if (separator.length === 0) {
72
+ separator = this.querySelectorAll("option");
73
+ }
74
+ separator = separator[separator.length-1]
75
+
76
+ const new_option = document.createElement("option")
77
+ new_option.setAttribute("data-custom", true);
78
+
79
+ if (new_rule_str.substr(new_rule_str.length - 1) !== "*") {
80
+ new_rule_str+="*";
81
+ }
82
+
83
+ new_option.textContent = new_rule_str
84
+ new_option.value = new_rule_json
85
+ separator.parentNode.insertBefore(new_option, separator)
86
+ }
87
+ };
88
+
89
+ function recurring_select(method) {
90
+ this['recurring_select'] = this['recurring_select'] || recurring_select.bind(this)
91
+ if (method in methods) {
92
+ return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ) );
93
+ } else {
94
+ throw new Error( `Method ${method} does not exist on recurring_select` );
95
+ }
96
+ }