simple_admin 0.5.1 → 0.5.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.
@@ -1,5 +1,16 @@
1
1
  module SimpleAdmin
2
2
  module AdminHelper
3
+ def expand_block_options!(options)
4
+ options.each do |key, val|
5
+ case val
6
+ when Proc
7
+ options[key] = instance_exec(@resource, &val)
8
+ else
9
+ options[key] = val
10
+ end
11
+ end
12
+ end
13
+
3
14
  include SimpleAdmin::TitleHelper
4
15
  include SimpleAdmin::HeaderHelper
5
16
  include SimpleAdmin::TableHelper
@@ -4,6 +4,7 @@ module SimpleAdmin
4
4
  options ||= {}
5
5
  options = options.dup
6
6
  options[:as] ||= default_filter_type(klass, method)
7
+ expand_block_options!(options)
7
8
  return "" unless options[:as]
8
9
  field_type = options.delete(:as)
9
10
  wrapper_options = options[:wrapper_html] || {}
@@ -2,20 +2,23 @@ module SimpleAdmin
2
2
  module FormHelper
3
3
  def form_fields(form, attributes)
4
4
  attributes.map do |col|
5
+ options = (col.options || {}).dup
6
+ expand_block_options!(options)
7
+
5
8
  case col.kind
6
9
  when :attribute
7
- form.input col.attribute, (col.options || {}).dup
10
+ form.input col.attribute, options
8
11
  when :content
9
12
  instance_exec(@resource, &col.data)
10
13
  when :fieldset
11
- content_tag :fieldset, col.options do
14
+ content_tag :fieldset, options do
12
15
  content_tag :legend do
13
- col.options[:legend]
14
- end unless col.options[:legend].blank
16
+ options[:legend]
17
+ end unless options[:legend].blank
15
18
  form_fields(form, col.attributes)
16
19
  end
17
20
  else
18
- content_tag :div, col.options do
21
+ content_tag :div, options do
19
22
  form_fields(form, col.attributes)
20
23
  end
21
24
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleAdmin
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_admin
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 1
10
- version: 0.5.1
9
+ - 2
10
+ version: 0.5.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeff Rafter
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-15 00:00:00 -07:00
18
+ date: 2011-08-17 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency