Class: Mensa::TablesController

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

Instance Method Summary collapse

Instance Method Details

#decide_layoutObject



33
34
35
# File 'app/controllers/mensa/tables_controller.rb', line 33

def decide_layout
  return false if params[:turbo_frame_id]
end

#indexObject



5
6
7
# File 'app/controllers/mensa/tables_controller.rb', line 5

def index
  render layout: 'mensa/application'
end

#showObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/mensa/tables_controller.rb', line 9

def show
  config = if params[:table_view_id]
             @view = Mensa::TableView.find_by(table_name: params[:id], id: params[:table_view_id])
             @view&.data || {}
           else
             {}
           end

  config = config.merge(params.permit(:format, :query, :id, :page, :table_view_id, :turbo_frame_id, order: {}, filters: {}).to_h)

  @table = Mensa.for_name(params[:id], config)
  @table.table_view = @view
  @table.original_view_context = helpers

  respond_to do |format|
    format.turbo_stream
    format.html
    format.xlsx do
      Mensa::ExportJob.perform_async(current_user.id, params[:id])
      head 200
    end
  end
end