Sha256: f37836f331a5a0d534b472c0d718763a05c5b299d7cc9dcbd11bdbe9f14cb4e6

Contents?: true

Size: 1.43 KB

Versions: 10

Compression:

Stored size: 1.43 KB

Contents

module Detour::ApplicationHelper
  def link_to_add_fields(name, f, association, template = nil)
    new_object = f.object.send(association).klass.new
    template ||= "#{association.to_s.singularize}_fields"
    id = new_object.object_id
    fields = f.fields_for(association, new_object, child_index: id) do |builder|
      render("#{template}", f: builder)
    end

    link_to name, "javascript:void(0)", class: "add-fields btn btn-default", data: { id: id, fields: fields.gsub("\n", "") }
  end

  def table(&block)
    content_tag :div, class: "table-responsive" do
      content_tag :table, class: "table table-striped" do
        yield
      end
    end
  end

  def modal(options, &block)
    content_tag :div, id: options[:id], class: "modal #{options[:fade].present?}", tabindex: "-1", role: "dialog", aria_labbeledby: "#{options[:id]}-modal-label", aria_hidden: "true" do
      content_tag :div, class: "modal-dialog" do
        content_tag :div, class: "modal-content" do
          content_tag(:div, class: "modal-header") do
            content_tag :button, "×", class: "close", data_dismiss: "modal", aria_hidden: "true"
            content_tag :h4, options[:title], id: "#{options[:id]}-modal-label"
          end +

          content_tag(:div, class: "modal-body") do
            yield
          end
        end
      end
    end
  end

  def modal_footer(&block)
    content_tag :div, class: "modal-footer" do
      yield
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
detour-0.0.15 app/helpers/detour/application_helper.rb
detour-0.0.14 app/helpers/detour/application_helper.rb
detour-0.0.13 app/helpers/detour/application_helper.rb
detour-0.0.12 app/helpers/detour/application_helper.rb
detour-0.0.11 app/helpers/detour/application_helper.rb
detour-0.0.10 app/helpers/detour/application_helper.rb
detour-0.0.9 app/helpers/detour/application_helper.rb
detour-0.0.7 app/helpers/detour/application_helper.rb
detour-0.0.6 app/helpers/detour/application_helper.rb
detour-0.0.5 app/helpers/detour/application_helper.rb