Sha256: b4f3d047415d06d760f6c287938cbe36cd44e7e2a741dbd79b5d108cdb63a111

Contents?: true

Size: 1.78 KB

Versions: 16

Compression:

Stored size: 1.78 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

    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) || :undo

    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 = options.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>", "#{form_hidden_submit + 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

16 entries across 16 versions & 1 rubygems

Version Path
agilibox-1.11.0 app/helpers/agilibox/filters_helper.rb
agilibox-1.10.5 app/helpers/agilibox/filters_helper.rb
agilibox-1.10.2 app/helpers/agilibox/filters_helper.rb
agilibox-1.10.1 app/helpers/agilibox/filters_helper.rb
agilibox-1.10.0 app/helpers/agilibox/filters_helper.rb
agilibox-1.9.20 app/helpers/agilibox/filters_helper.rb
agilibox-1.9.19 app/helpers/agilibox/filters_helper.rb
agilibox-1.9.18 app/helpers/agilibox/filters_helper.rb
agilibox-1.9.17 app/helpers/agilibox/filters_helper.rb
agilibox-1.9.16 app/helpers/agilibox/filters_helper.rb
agilibox-1.9.15 app/helpers/agilibox/filters_helper.rb
agilibox-1.9.14 app/helpers/agilibox/filters_helper.rb
agilibox-1.9.13 app/helpers/agilibox/filters_helper.rb
agilibox-1.9.12 app/helpers/agilibox/filters_helper.rb
agilibox-1.9.11 app/helpers/agilibox/filters_helper.rb
agilibox-1.9.10 app/helpers/agilibox/filters_helper.rb