eac_rails_utils 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 326ed69f1c2d044f1d4e78a7ffe7457e7a254c13
|
4
|
+
data.tar.gz: d4cddf12d6717ad1fa54adde43c69290c73091ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e8dbe272f8c609051fccad0a936b83e99f41e80db9b46fe963a932e3f80ba7b883a2718cb25b981d9b488642ee62ec770c7ce89d36bc8e1030217a314575001
|
7
|
+
data.tar.gz: 470884c138fba21d17943de842ce79f43338bfac743e6b021f956c58aa42d23c26dc478a0e3ee6dbb4ad4165d7b675d52baf50e2a08f4b72265279a69403a916
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Eac
|
3
|
+
module CommonFormHelper
|
4
|
+
class FormBuilder
|
5
|
+
module SelectField
|
6
|
+
def select_field(field_name, options = {})
|
7
|
+
options = options.dup
|
8
|
+
field(field_name, options) do
|
9
|
+
form.select(field_name, select_options(field_name, options))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def select_options(field_name, options)
|
16
|
+
options[:options] || listable_select_options(field_name) || raise('No options found')
|
17
|
+
end
|
18
|
+
|
19
|
+
def listable_select_options(field_name)
|
20
|
+
return nil unless model_instance.class.respond_to?(:lists)
|
21
|
+
return nil unless model_instance.class.lists.respond_to?(field_name)
|
22
|
+
model_instance.class.lists.send(field_name).options
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/eac_rails_utils.rb
CHANGED
@@ -17,6 +17,7 @@ module EacRailsUtils
|
|
17
17
|
require 'eac/common_form_helper/form_builder/fields_for'
|
18
18
|
require 'eac/common_form_helper/form_builder/radio_select_field'
|
19
19
|
require 'eac/common_form_helper/form_builder/searchable_association_field'
|
20
|
+
require 'eac/common_form_helper/form_builder/select_field'
|
20
21
|
require 'eac/common_form_helper/form_builder/year_month_field'
|
21
22
|
require 'eac/common_form_helper/form_builder'
|
22
23
|
require 'eac/common_form_helper'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_rails_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- E.A.C.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel-associations
|
@@ -147,6 +147,7 @@ files:
|
|
147
147
|
- lib/eac/common_form_helper/form_builder/fields_for.rb
|
148
148
|
- lib/eac/common_form_helper/form_builder/radio_select_field.rb
|
149
149
|
- lib/eac/common_form_helper/form_builder/searchable_association_field.rb
|
150
|
+
- lib/eac/common_form_helper/form_builder/select_field.rb
|
150
151
|
- lib/eac/common_form_helper/form_builder/year_month_field.rb
|
151
152
|
- lib/eac/cpf_validator.rb
|
152
153
|
- lib/eac/formatter_helper.rb
|