Sha256: 3781d9fd879f13474e3e88a706618871efb4ffdacfa068f4b759642a7ea3f48f

Contents?: true

Size: 1.76 KB

Versions: 5

Compression:

Stored size: 1.76 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.yesterday")   => "yesterday" ,
      t("time_periods.this_week")   => "this_week",
      t("time_periods.last_week")   => "last_week",
      t("time_periods.this_month")  => "this_month",
      t("time_periods.last_month")  => "last_month",
      t("time_periods.this_year")   => "this_year",
      t("time_periods.last_year")   => "last_year",
      t("time_periods.custom_date") => "custom_date",
    }
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dorsale-3.4.0 app/helpers/dorsale/filters_helper.rb
dorsale-3.3.0 app/helpers/dorsale/filters_helper.rb
dorsale-3.2.0 app/helpers/dorsale/filters_helper.rb
dorsale-3.1.7 app/helpers/dorsale/filters_helper.rb
dorsale-3.1.6 app/helpers/dorsale/filters_helper.rb