Sha256: 33a5c6cb5b452dcad12f2e3391f14f9b67ccd1d95e46d7dcec7af47765573388

Contents?: true

Size: 1.13 KB

Versions: 25

Compression:

Stored size: 1.13 KB

Contents

class Agilibox::SmallData::FiltersController < ::Agilibox::ApplicationController
  skip_after_action  :verify_authorized,         raise: false
  skip_after_action  :verify_policy_scoped,      raise: false
  skip_before_action :verify_authenticity_token, raise: false

  def create
    skip_authorization if respond_to?(:skip_authorization)
    skip_policy_scope  if respond_to?(:skip_policy_scope)

    filters = ::Agilibox::SmallData::Filter.new(cookies)
    new_filters = params.fetch(:filters, {}).permit!.to_h
    filters.merge new_filters

    # Rewrite cookie with 1 year expiry
    cookies[:filters] = {
      :value   => cookies[:filters],
      :expires => 1.year.from_now,
      :path    => "/",
    }

    redirect_to back_url
  end

  private

  def back_url
    url = [
      params[:form_url],
      request.referer,
      main_app.try(:root_path),
      "/",
    ].find(&:present?)

    # Delete page param
    base, query_string = url.split("?")
    query_string = query_string.to_s.split("&").delete_if { |p| p.include?("page=") }.join("&")
    query_string = "?#{query_string}" if query_string.present?
    base + query_string
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
agilibox-1.7.2 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.7.1 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.7.0 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.6.2 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.6.1 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.6.0 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.5.13 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.5.12 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.5.11 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.5.10 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.5.9 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.5.8 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.5.7 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.5.6 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.5.5 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.5.4 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.5.3 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.5.2 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.5.1 app/controllers/agilibox/small_data/filters_controller.rb
agilibox-1.5.0 app/controllers/agilibox/small_data/filters_controller.rb