diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index ae5239b..9b5e496 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -25,26 +25,43 @@ module SettingsHelper
end
def nested_field(html, form, key, opts = {})
- child_data = form.object.class.children[key]
- klass = child_data[:class]
- options = child_data[:options]
+ klass = child_data(form, key)[:class]
+ options = child_data(form, key)[:options]
children = form.object.send(key) || {"0" => {}}
+
children.each_pair do |index, child|
- html << %Q!
!
- if options[:multiple]
- html << %Q!
#{icon('fa-plus')} !
- html << %Q!
#{icon('fa-minus')} !
- end
+ html << open_nested_div(options[:multiple])
+ html << append_and_remove_links if options[:multiple]
html << h(form.label(key))
- form.fields_for("#{key}[#{index}]", klass.new(child)) do |ff|
- klass::KEYS.each do |k|
- html << field(ff, k)
- end
- end
+ html << nested_fields(form, key, index, klass, child)
html << "
"
end
end
+ def open_nested_div(multiple)
+ %Q!!
+ end
+
+ def nested_fields(form, key, index, klass, child)
+ nested_html = ""
+ form.fields_for("#{key}[#{index}]", klass.new(child)) do |ff|
+ klass::KEYS.each do |k|
+ nested_html << field(ff, k)
+ end
+ end
+
+ nested_html
+ end
+
+ def append_and_remove_links
+ %Q!
icon('fa-plus')} ! +
+ %Q!
icon('fa-minus')} !
+ end
+
+ def child_data(form, key)
+ form.object.class.children[key]
+ end
+
def choice_field(html, form, key, opts = {})
html << h(form.label(key))
html << " " # NOTE: Adding space for padding