Class: Mensa::Tables::FiltersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/mensa/tables/filters_controller.rb

Defined Under Namespace

Classes: Filter

Instance Method Summary collapse

Instance Method Details

#indexObject



12
13
14
15
# File 'app/controllers/mensa/tables/filters_controller.rb', line 12

def index
  config = {}.merge(params.permit(:id, :page, :table_id, :target, :table_view_id, :turbo_frame_id, order: {}, filters: {}).to_h)
  @table = Mensa.for_name(params[:table_id], config)
end

#showObject

Returns the filter information on the column-name



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/mensa/tables/filters_controller.rb', line 18

def show
  config = {}.merge(params.permit(:id, :value, :operator, :page, :table_id, :target, :table_view_id, :turbo_frame_id, order: {}, filters: {}).to_h)
  @table = Mensa.for_name(params[:table_id], config)
  @table.original_view_context = helpers
  @column = @table.column(params[:id])
  @operator = params[:operator].presence || "is"
  @multiple = @column.filter.multiple?
  @values = Array(params[:value]).flatten.compact
  respond_to do |format|
    format.turbo_stream
    format.html
  end
end