Class: Refine::Inline::StoredFiltersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/refine/inline/stored_filters_controller.rb

Instance Method Summary collapse

Instance Method Details

#create ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/refine/inline/stored_filters_controller.rb', line 25

def create
  @criterion = Refine::Inline::Criterion.new(criterion_params)
  @stored_filter = Refine::StoredFilter.new(stored_filter_params.merge(
      state: @refine_filter.state,
      filter_type: @refine_filter.type,
      **instance_exec(&Refine::Rails.configuration.custom_stored_filter_attributes)
    )
  )

  if @stored_filter.save
    handle_filter_update @stored_filter.refine_filter.to_stable_id
  else
    respond_to do |format|
      format.turbo_stream { render :new }
    end
  end
end

#find ⇒ Object



12
13
14
15
# File 'app/controllers/refine/inline/stored_filters_controller.rb', line 12

def find
  @stored_filter = Refine::StoredFilter.find_by(id: params[:id], filter_type: @refine_filter.type)
  handle_filter_update @stored_filter.refine_filter.to_stable_id
end

#index ⇒ Object



6
7
8
9
10
# File 'app/controllers/refine/inline/stored_filters_controller.rb', line 6

def index
  @criterion = Refine::Inline::Criterion.new(criterion_params)
  @stored_filters = Refine::StoredFilter.where(filter_type: @refine_filter.type)
  @stored_filters = instance_exec(@stored_filters, &Refine::Rails.configuration.stored_filter_scope)
end

#new ⇒ Object



17
18
19
20
21
22
23
# File 'app/controllers/refine/inline/stored_filters_controller.rb', line 17

def new
  @criterion = Refine::Inline::Criterion.new(criterion_params)
  @stored_filter = Refine::StoredFilter.new(filter_type: @refine_filter.type)
  respond_to do |format|
    format.turbo_stream
  end
end