form-reflex 1.0.1 → 1.0.2

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +88 -79
  3. data/lib/form/reflex/version.rb +1 -1
  4. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a799e9ab14541fc9ed4319b6706b7b540c015cd4c20fbb269340659139107180
4
- data.tar.gz: 8c864e62015c5b29399f69073588e036529c632eed8411f2b9a1b438eb538831
3
+ metadata.gz: 3c516a5bb445f353b3ce0770dafec83837a702557c54ab6bddeae36b07752d35
4
+ data.tar.gz: 523c4553f61ce8b4441eb53105ff3d362cbbcf953e9460f8aa1bdd1d9505069c
5
5
  SHA512:
6
- metadata.gz: 5bc0b823f32bff55448da116ef8381b55f1c47517727e6da0f977496c23d1b10df0e720965bd3ccef44a47102410969cb27aa20e59198417e47d0541b773aae0
7
- data.tar.gz: 94da0a0371716462b506eb18f340f90c926a5ad0f317b04309a79deebffab006d6e2f4ca5d110c1c5613611453c495d8ea07e0db548204df5787e79e9d064227
6
+ metadata.gz: '018f36b9318804533d55cbdb4deec9e74f92d4bfdfded2cdc04f4b22832df40e67be99e48e8a392d83c27030fd710e23a9910e15df0911e4a559bac8bcd482e0'
7
+ data.tar.gz: 3e6fba3ab58c5224f4174dc2dfc4ce357fe2febd2c3b2bc57ba75db88218cb0c1b0331f385165e0078c9a4a32ba829ed12f2e2ada278494fff505d0bc8707d64
data/README.md CHANGED
@@ -1,79 +1,88 @@
1
- # FormReflex
2
- FormReflex is a light extension of [optimism](https://optimism.leastbad.com/), leveraging [stimulus_reflex](https://docs.stimulusreflex.com/).
3
-
4
- FormReflex provides real time form validation on change, using the validations already provided on your model.
5
-
6
- ## Usage
7
-
8
- Please follow the setup instructions for optimism [here](https://optimism.leastbad.com/quick-start)
9
-
10
- Usage for FormReflex is *identical* to the optimism usage, with 2 exceptions:
11
-
12
- 1) You must specify data-reflex="change->FormReflex#handle_change" on your form control
13
-
14
- ```erb
15
- data-reflex="change->FormReflex#handle_change"
16
- ```
17
-
18
- 2) The model you want to validate must be initialized in session[:model]
19
-
20
- For example:
21
-
22
- ```ruby
23
- def new
24
- @post = Post.new
25
- session[:model] = @post unless @stimulus_reflex
26
- end
27
-
28
- private
29
- def set_post
30
- @post = Post.find(params[:id])
31
- session[:model] = @post unless @stimulus_reflex
32
- end
33
- ```
34
-
35
- All in all, pulling in [Optimism's](https://optimism.leastbad.com/) own example, it would look like this:
36
-
37
- ```erb
38
- <%= form_with(model: session[:model]) do |form| %>
39
- <div class="field">
40
- <%= form.label :name %>
41
- <%= form.text_field :name, data: { reflex: "change->FormControl#handle_change" } %>
42
- <%= form.error_for :name %>
43
- </div>
44
-
45
- <div class="field">
46
- <%= form.label :body %>
47
- <%= form.text_area :body, data: { reflex: "change->FormControl#handle_change" } %>
48
- <%= form.error_for :body %>
49
- </div>
50
-
51
- <div class="actions">
52
- <%= form.submit %>
53
- </div>
54
- <% end %>
55
- ```
56
-
57
-
58
- ## Installation
59
- Add this line to your application's Gemfile:
60
-
61
- ```ruby
62
- gem 'form-reflex'
63
- ```
64
-
65
- And then execute:
66
- ```bash
67
- $ bundle
68
- ```
69
-
70
- Or install it yourself as:
71
- ```bash
72
- $ gem install form-reflex
73
- ```
74
-
75
- ## Contributing
76
- Contribution directions go here.
77
-
78
- ## License
79
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
1
+ # FormReflex
2
+ FormReflex is a light extension of [optimism](https://optimism.leastbad.com/), leveraging [stimulus_reflex](https://docs.stimulusreflex.com/).
3
+
4
+ FormReflex provides real time form validation on change, using the validations already provided on your model.
5
+
6
+ ## Usage
7
+
8
+ Please follow the setup instructions for optimism [here](https://optimism.leastbad.com/quick-start)
9
+
10
+ Usage for FormReflex is *identical* to the optimism usage, with 2 exceptions:
11
+
12
+ 1) You must specify data-reflex="change->FormReflex#handle_change" on your form control
13
+
14
+ ```erb
15
+ data-reflex="change->FormReflex#handle_change"
16
+ ```
17
+
18
+ 2) The model you want to validate must be initialized in session[:model]
19
+
20
+ For example:
21
+
22
+ ```ruby
23
+ def new
24
+ @post = Post.new
25
+ session[:model] = @post unless @stimulus_reflex
26
+ end
27
+
28
+ private
29
+ def set_post
30
+ @post = Post.find(params[:id])
31
+ session[:model] = @post unless @stimulus_reflex
32
+ end
33
+ ```
34
+
35
+ All in all, pulling in [Optimism's](https://optimism.leastbad.com/) own example, it would look like this:
36
+
37
+ ```erb
38
+ <%= form_with(model: session[:model]) do |form| %>
39
+ <div class="field">
40
+ <%= form.label :name %>
41
+ <%= form.text_field :name, data: { reflex: "change->FormReflex#handle_change" } %>
42
+ <%= form.error_for :name %>
43
+ </div>
44
+
45
+ <div class="field">
46
+ <%= form.label :body %>
47
+ <%= form.text_area :body, data: { reflex: "change->FormReflex#handle_change" } %>
48
+ <%= form.error_for :body %>
49
+ </div>
50
+
51
+ <div class="actions">
52
+ <%= form.submit %>
53
+ </div>
54
+ <% end %>
55
+ ```
56
+
57
+ You can also add models to an association easily with the `add` method. There's a corresponding `delete` method for removing models from
58
+ an association. Simply add `data-assocation="<name of association>" data-reflex="click->FormReflex#add"`
59
+
60
+ ```
61
+ <button type="button" data-association="post_details" data-reflex="click->FormReflex#add">
62
+ Add Post Detail
63
+ </button>
64
+ ```
65
+
66
+
67
+ ## Installation
68
+ Add this line to your application's Gemfile:
69
+
70
+ ```ruby
71
+ gem 'form-reflex'
72
+ ```
73
+
74
+ And then execute:
75
+ ```bash
76
+ $ bundle
77
+ ```
78
+
79
+ Or install it yourself as:
80
+ ```bash
81
+ $ gem install form-reflex
82
+ ```
83
+
84
+ ## Contributing
85
+ Contribution directions go here.
86
+
87
+ ## License
88
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -1,5 +1,5 @@
1
1
  module Form
2
2
  module Reflex
3
- VERSION = '1.0.1'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,35 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: form-reflex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua LeBlanc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-22 00:00:00.000000000 Z
11
+ date: 2020-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 6.0.3
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
- version: 6.0.3.2
19
+ version: '5.2'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: 6.0.3
30
27
  - - ">="
31
28
  - !ruby/object:Gem::Version
32
- version: 6.0.3.2
29
+ version: '5.2'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: optimism
35
35
  requirement: !ruby/object:Gem::Requirement