Sha256: 845b1cc3b85014eaed8846e5a90277dee312e29a4c3bacb319e8d3cba023f635

Contents?: true

Size: 1.43 KB

Versions: 6

Compression:

Stored size: 1.43 KB

Contents

module Dorsale::FiltersHelper
  def filter_submit_button(options = {})
    options[:class] ||= "btn submit filter-submit"
    options[:type]  ||= "submit"
    options[:value] ||= "submit"

    text = options.delete(:text) || t("actions.filter")
    icon = options.delete(:icon) || "filter"

    content_tag(:button, options) do
      icon(icon) + " " + text
    end
  end

  def filter_reset_button(options = {})
    options[:class] ||= "btn reset filter-reset"
    options[:type]  ||= "submit"
    options[:value] ||= "reset"

    text = options.delete(:text) || t("actions.reset")
    icon = options.delete(:icon) || "rotate-left"

    content_tag(:button, options) do
      icon(icon) + " " + text
    end
  end

  def filter_buttons
    filter_reset_button + filter_submit_button
  end

  def filters_form(options = {}, &block)
    if options.key?(:buttons)
      buttons = optins.delete(:buttons)
    else
      buttons = true
    end

    options = {
      :url     => dorsale.small_data_filters_path,
      :wrapper => :inline_form,
    }.merge(options)

    html = simple_form_for(:filters, options, &block)

    if buttons
      html = html.gsub("</form>", "#{filter_buttons}</form>").html_safe
    end

    html
  end

  def dorsale_time_periods_for_select
    {
      t("time_periods.all_time") => "",
      t("time_periods.today")    => "today",
      t("time_periods.week")     => "week" ,
      t("time_periods.month")    => "month",
    }
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dorsale-3.1.5 app/helpers/dorsale/filters_helper.rb
dorsale-3.1.4 app/helpers/dorsale/filters_helper.rb
dorsale-3.1.3 app/helpers/dorsale/filters_helper.rb
dorsale-3.1.2 app/helpers/dorsale/filters_helper.rb
dorsale-3.1.1 app/helpers/dorsale/filters_helper.rb
dorsale-3.1.0 app/helpers/dorsale/filters_helper.rb