wonderful_simple_forms 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -10
- data/lib/wonderful_simple_forms/simple_form.rb +12 -4
- data/lib/wonderful_simple_forms/version.rb +1 -1
- data/wonderful_simple_forms-0.1.4.gem +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec8874850c970d67fb10a4b17e51cc58616cfde0
|
4
|
+
data.tar.gz: f1a39bce353becac8a35871516ce657b32981664
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55033114dc065971b6daa48ecefbfcb5401af52bd17c25cb6c9ef52c8366fe440f12f292c62b7f70a60ba538d123850e46803c35f9330c4c09006a98a73a4fe6
|
7
|
+
data.tar.gz: 14489bb7531945a11dbc02260ce171f1ba5d6edf207d1e95617c6af0e31120d5c2bf67ef14e60f6f29cbb0fda0307c0bc57544da2ba00957faec381b84197bd0
|
data/README.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
# WonderfulSimpleForms
|
2
2
|
|
3
|
-
|
3
|
+
Wonderful and simple forms!
|
4
4
|
|
5
|
-
|
5
|
+
Wonderful simple form aims to provide better enhancement for many types in simple_forms.
|
6
|
+
|
7
|
+
You only need to include this gem to get the benefits. Currently we add support to this formats:
|
8
|
+
|
9
|
+
- Enum
|
10
|
+
- Belongs_to
|
6
11
|
|
7
12
|
## Installation
|
8
13
|
|
@@ -22,17 +27,11 @@ Or install it yourself as:
|
|
22
27
|
|
23
28
|
## Usage
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
Just include the gem! (and follow the simple_forms instalattion of course..)
|
32
31
|
|
33
32
|
## Contributing
|
34
33
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
34
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hdf1986/wonderful_simple_forms. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
35
|
|
37
36
|
|
38
37
|
## License
|
@@ -13,7 +13,7 @@ module WonderfulSimpleForms
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def default_input_type_with_belongs_to(*args, &block)
|
16
|
-
att_name = (args.first || @attribute_name).to_s
|
16
|
+
att_name = (args.first || "#{@attribute_name}").to_s
|
17
17
|
options = args.last
|
18
18
|
return :belongs_to if (
|
19
19
|
object.class.reflect_on_all_associations(:belongs_to).any? { |a| a.name == args.first })
|
@@ -34,17 +34,25 @@ module WonderfulSimpleForms
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def enum_list
|
37
|
-
object.class.method(attribute_name.to_s.pluralize.to_sym).call
|
37
|
+
object.class.method(attribute_name.to_s.pluralize.to_sym).call.keys
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
class BelongsToInput < ::SimpleForm::Inputs::CollectionSelectInput
|
42
|
+
attr_reader :original_attribute_name
|
43
|
+
|
44
|
+
def initialize(builder, attribute_name, column, input_type, options = {})
|
45
|
+
@original_attribute_name = attribute_name
|
46
|
+
attribute_name = "#{attribute_name}_id".to_sym
|
47
|
+
super
|
48
|
+
end
|
49
|
+
|
42
50
|
def collection
|
43
51
|
@collection ||= enum_list
|
44
52
|
end
|
45
53
|
|
46
54
|
def enum_list
|
47
|
-
|
55
|
+
original_attribute_name.to_s.classify.constantize.all.map{|instance|[instance.method(:name).call, instance.id]}
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|
@@ -57,4 +65,4 @@ SimpleForm::FormBuilder.class_eval do
|
|
57
65
|
|
58
66
|
alias_method_chain :default_input_type, :enum
|
59
67
|
alias_method_chain :default_input_type, :belongs_to
|
60
|
-
|
68
|
+
endr
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wonderful_simple_forms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hdf1986
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- lib/wonderful_simple_forms.rb
|
73
73
|
- lib/wonderful_simple_forms/simple_form.rb
|
74
74
|
- lib/wonderful_simple_forms/version.rb
|
75
|
+
- wonderful_simple_forms-0.1.4.gem
|
75
76
|
- wonderful_simple_forms.gemspec
|
76
77
|
homepage: https://github.com/hdf1986/wonderful_simple_forms
|
77
78
|
licenses:
|