Sha256: bb5aa5c005a2c1423152b25cbd98c348c123400c09a70177a5716164571d8806

Contents?: true

Size: 978 Bytes

Versions: 6

Compression:

Stored size: 978 Bytes

Contents

module Mensa
  class TablesController < ::ApplicationController
    layout :decide_layout

    def index
      render layout: 'mensa/application'
    end

    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

    def decide_layout
      return false if params[:turbo_frame_id]
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mensa-0.1.10 app/controllers/mensa/tables_controller.rb
mensa-0.1.9 app/controllers/mensa/tables_controller.rb
mensa-0.1.7 app/controllers/mensa/tables_controller.rb
mensa-0.1.6 app/controllers/mensa/tables_controller.rb
mensa-0.1.4 app/controllers/mensa/tables_controller.rb
mensa-0.1.3 app/controllers/mensa/tables_controller.rb