Sha256: 0a7eba1bea9e1cfbdf0f7ffc57ce057b21c504d03de304bbd89460dc39dbafcb

Contents?: true

Size: 1.79 KB

Versions: 7

Compression:

Stored size: 1.79 KB

Contents

module Agilibox::FiltersHelper
  def filter_submit_button(options = {})
    options[:class] ||= "btn btn-default 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 btn-default 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     => agilibox.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 agilibox_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

7 entries across 7 versions & 1 rubygems

Version Path
agilibox-1.0.6 app/helpers/agilibox/filters_helper.rb
agilibox-1.0.5 app/helpers/agilibox/filters_helper.rb
agilibox-1.0.4 app/helpers/agilibox/filters_helper.rb
agilibox-1.0.3 app/helpers/agilibox/filters_helper.rb
agilibox-1.0.2 app/helpers/agilibox/filters_helper.rb
agilibox-1.0.1 app/helpers/agilibox/filters_helper.rb
agilibox-1.0.0 app/helpers/agilibox/filters_helper.rb