Class: Nquery::Dashboard::ChartsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Nquery::Dashboard::ChartsController
- Includes:
- ChartActions
- Defined in:
- app/controllers/nquery/dashboard/charts_controller.rb
Constant Summary
Constants included from AuthorizesCollection
AuthorizesCollection::COLLECTION_REQUIREMENTS
Instance Method Summary collapse
Methods included from ChartActions
#archive, #destroy, #edit, #embed, #show, #update
Methods included from Breadcrumbs
#breadcrumbs, #set_breadcrumbs
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/nquery/dashboard/charts_controller.rb', line 17 def create @chart = Chart.new( chart_params.merge( creator: current_nquery_user, collection: @dashboard.collection ) ) @chart.name = @chart.name.presence || @chart.query&.name @chart.visualization = { "type" => "table" } if @chart.visualization.blank? @chart.query&.creator = current_nquery_user @chart.query&.collection = @dashboard.collection if @chart.save @dashboard.dashboard_cards.create!( chart: @chart, pos_x: 0, pos_y: 0, width: 6, height: 4 ) redirect_to edit_dashboard_chart_path(@dashboard, @chart), notice: "Chart created." else load_chart_builder_assigns render :new, status: :unprocessable_content end end |
#new ⇒ Object
11 12 13 14 15 |
# File 'app/controllers/nquery/dashboard/charts_controller.rb', line 11 def new @chart = Chart.new @chart.build_query(statement: "SELECT 1 AS example") load_chart_builder_assigns end |