lib/polygallery/simple_form_helper.rb in polygallery-0.4.5 vs lib/polygallery/simple_form_helper.rb in polygallery-0.4.6

- old
+ new

@@ -6,12 +6,20 @@ def self.simple_fields_for_polygallery(fb, title=:gallery, *args, &block) ( '<div class="polygallery-fields">' << fb.simple_fields_for(title, *args, &block) << '</div>' ).html_safe end def simple_fields_for_polygallery(fb, title=:gallery, *args, &block) - defaults = { label: nil } + defaults = { + label: nil, + add_btn: { + text: 'Add Photo', + partial: 'polygallery/photos/simple_fields_for', + class: 'btn btn-default btn-sm pull-right', + data: { association_insertion_method: 'append', + association_insertion_node: "##{fb.object.send(title).polygallery_settings[:association_names][:photos]} .photo-receptacle" }}, + remove_btn: { class: 'btn btn-default btn-sm' }} settings = if (options = args.find{|a| a.is_a? Hash }).nil? then defaults - else defaults.merge options end + else defaults.deep_merge options end new_block = block_given? ? block : ->(fb2) { render partial: 'polygallery/galleries/simple_fields_for', locals: { f: fb2, settings: settings } } SimpleFormHelper.simple_fields_for_polygallery( fb, title, *args, &new_block)