reform 1.2.3 → 1.2.4
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 +4 -4
- data/CHANGES.md +14 -0
- data/README.md +2 -2
- data/database.sqlite3 +0 -0
- data/lib/reform/contract.rb +7 -0
- data/lib/reform/version.rb +1 -1
- data/test/readonly_test.rb +14 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9de1e1d5688d37d56c180a7b0c622a5319bd7347
|
4
|
+
data.tar.gz: b68d927a7b7a2dc8beb287ce8692c4527866a731
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56c84d82a9e5981796d199a045d6e014e7f3dc1d69051e997b07c5b213c905a7f92c21d20b618907212f0a3544711b142f3fbd2d790bcc498ecfcaa5d290244c
|
7
|
+
data.tar.gz: cce2349a4ff6c075a23bb28d9f536997f3f49c869b4f08469cedb2978e9d0784b858b0c0649b4ab770e8d12d340224c2472860668c05fd2eba97ca23e459ef13
|
data/CHANGES.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## 1.2.4
|
2
|
+
|
3
|
+
* Added `Form#readonly?` to find out whether a field is set to writeable. This is helpful for simple_form to display a disabled input field.
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
property :title, writeable: false
|
7
|
+
```
|
8
|
+
|
9
|
+
In the view, you can then use something along the following code.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
f.input :title, readonly: @form.readonly?(:title)
|
13
|
+
```
|
14
|
+
|
1
15
|
## 1.2.3
|
2
16
|
|
3
17
|
* Make `ModelReflections` work with simple_form 3.1.0. (#176). It also provides `defined_enums` and `::reflect_on_association` now.
|
data/README.md
CHANGED
@@ -310,7 +310,7 @@ When rendering this form you could use the form's accessors manually.
|
|
310
310
|
Or use something like `#fields_for` in a Rails environment.
|
311
311
|
|
312
312
|
```haml
|
313
|
-
= form_for @form |f|
|
313
|
+
= form_for @form do |f|
|
314
314
|
= f.text_field :title
|
315
315
|
= f.text_field :length
|
316
316
|
|
@@ -378,7 +378,7 @@ Reform will expose the collection using the `#songs` method.
|
|
378
378
|
However, `#fields_for` works just fine, again.
|
379
379
|
|
380
380
|
```haml
|
381
|
-
= form_for @form |f|
|
381
|
+
= form_for @form do |f|
|
382
382
|
= f.text_field :title
|
383
383
|
|
384
384
|
= f.fields_for :songs do |s|
|
data/database.sqlite3
CHANGED
Binary file
|
data/lib/reform/contract.rb
CHANGED
@@ -191,6 +191,13 @@ module Reform
|
|
191
191
|
|
192
192
|
alias_method :aliased_model, :model
|
193
193
|
|
194
|
+
module Readonly
|
195
|
+
def readonly?(name)
|
196
|
+
self.class.representer_class.representable_attrs.get(name)[:writeable] == false
|
197
|
+
end
|
198
|
+
end
|
199
|
+
include Readonly
|
200
|
+
|
194
201
|
# TODO: remove me in 2.0.
|
195
202
|
module Reform20Switch
|
196
203
|
def self.included(base)
|
data/lib/reform/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class ReadonlyTest < MiniTest::Spec
|
4
|
+
class SongForm < Reform::Form
|
5
|
+
property :artist
|
6
|
+
property :title, writeable: false
|
7
|
+
# TODO: what to do with virtual values?
|
8
|
+
end
|
9
|
+
|
10
|
+
let (:form) { SongForm.new(OpenStruct.new) }
|
11
|
+
|
12
|
+
it { form.readonly?(:artist).must_equal false }
|
13
|
+
it { form.readonly?(:title).must_equal true }
|
14
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reform
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-12-
|
12
|
+
date: 2014-12-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: representable
|
@@ -276,6 +276,7 @@ files:
|
|
276
276
|
- test/rails/integration_test.rb
|
277
277
|
- test/read_only_test.rb
|
278
278
|
- test/readable_test.rb
|
279
|
+
- test/readonly_test.rb
|
279
280
|
- test/reform_test.rb
|
280
281
|
- test/representer_test.rb
|
281
282
|
- test/save_test.rb
|
@@ -363,6 +364,7 @@ test_files:
|
|
363
364
|
- test/rails/integration_test.rb
|
364
365
|
- test/read_only_test.rb
|
365
366
|
- test/readable_test.rb
|
367
|
+
- test/readonly_test.rb
|
366
368
|
- test/reform_test.rb
|
367
369
|
- test/representer_test.rb
|
368
370
|
- test/save_test.rb
|