Sha256: 50af95d4e05c22b675bd0af5e88ff6646e0f1a7cafbca3c4bbdc2e2d30864920

Contents?: true

Size: 1006 Bytes

Versions: 1

Compression:

Stored size: 1006 Bytes

Contents

module Workarea
  decorate Admin::SearchSettingsController, with: :flow_io do
    def update
      clean_range_facets = CleanRangeFacets.new(params[:range_facets])
      attributes = {
        synonyms: params[:synonyms],
        boosts: params[:boosts].to_h,
        views_factor: params[:views_factor],
        terms_facets_list: params[:terms_facets_list],
        range_facets: clean_range_facets.result.presence,
        currency_localized_facets: CleanRangeFacets.new(params[:currency_localized_facets]).result
      }.merge(params[:settings] || {}).compact

      Search::Settings.current.update_attributes!(attributes)
      flash[:success] = t('workarea.admin.search_settings.flash_messages.saved')
      redirect_to return_to.presence || search_settings_path
    end

    private

      def currency_localized_facets
        params[:currency_localized_facets].to_h.map do |currency_code, facets|
          [currency_code, CleanRangeFacets.new(facets).result]
        end.to_h
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-flow_io-1.2.1 app/controllers/workarea/admin/search_settings_controller.decorator