Skip to content

Commit

Permalink
Extract releaf_has_many_association_attributes as a separate method i…
Browse files Browse the repository at this point in the history
…n FormBuilder
  • Loading branch information
guntis committed Dec 28, 2016
1 parent 287be9d commit fa5b7b3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog

### 1.0.7 (2016.12.28)
* `Releaf::Builders::FormBuilder` now has a separate `releaf_has_many_association_attributes` method that can be overridden in custom builders to add extra HTML attributes to a nested item section

### 1.0.6 (2016.12.18)
* Make possible to safely use translations in routes while using `releaf-i18n_database` gem

Expand Down Expand Up @@ -792,4 +795,3 @@ end
```:ajax``` parameter is removed from ```params``` has in ```manage_ajax```
before filter in ```Releaf::BaseApplicationController```
2 changes: 1 addition & 1 deletion lib/releaf/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Releaf
VERSION = "1.0.6"
VERSION = "1.0.7"
end
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ def releaf_has_one_or_belongs_to_association(reflector)
end

def releaf_has_many_association(reflector)
item_template = releaf_has_many_association_fields(reflector, reflector.klass.new, '_template_', true)

tag(:section, class: "nested", data: {name: reflector.name, "releaf-template" => html_escape(item_template.to_str)}) do
tag(:section, releaf_has_many_association_attributes(reflector)) do
[
releaf_has_many_association_header(reflector),
releaf_has_many_association_body(reflector),
Expand All @@ -57,6 +55,14 @@ def releaf_has_many_association(reflector)
end
end

def releaf_has_many_association_attributes reflector
item_template = releaf_has_many_association_fields(reflector, reflector.klass.new, '_template_', true)
{
class: "nested",
data: { name: reflector.name, "releaf-template" => html_escape(item_template.to_str) }
}
end

def releaf_has_many_association_header(reflector)
tag(:header) do
tag(:h1, translate_attribute(reflector.name))
Expand Down

0 comments on commit fa5b7b3

Please sign in to comment.