Parcourir la source

Keep variables after editing dashboard

Andrew Kane il y a 9 ans
Parent
commit
4601ac8b1f

+ 1 - 1
app/controllers/blazer/base_controller.rb

@@ -42,7 +42,7 @@ module Blazer
     helper_method :extract_vars
 
     def variable_params
-      params.except(:controller, :action, :id, :host, :query, :query_id, :table_names, :authenticity_token, :utf8, :_method, :commit, :statement, :data_source, :name)
+      params.except(:controller, :action, :id, :host, :query, :dashboard, :query_id, :query_ids, :table_names, :authenticity_token, :utf8, :_method, :commit, :statement, :data_source, :name)
     end
     helper_method :variable_params
 

+ 1 - 1
app/controllers/blazer/dashboards_controller.rb

@@ -47,7 +47,7 @@ module Blazer
 
     def update
       if update_dashboard(@dashboard)
-        redirect_to dashboard_path(@dashboard)
+        redirect_to dashboard_path(@dashboard, variable_params)
       else
         render :edit
       end

+ 1 - 1
app/views/blazer/dashboards/_form.html.erb

@@ -18,7 +18,7 @@ li:hover .glyphicon-remove {
 }
 </style>
 
-<%= form_for @dashboard do |f| %>
+<%= form_for @dashboard, url: (@dashboard.persisted? ? dashboard_path(@dashboard, variable_params) : dashboards_path(variable_params)) do |f| %>
   <div class="form-group">
     <%= f.label :name %>
     <%= f.text_field :name, class: "form-control" %>

+ 1 - 1
app/views/blazer/dashboards/show.html.erb

@@ -24,7 +24,7 @@
         </h3>
       </div>
       <div class="col-sm-3 text-right">
-        <%= link_to "Edit", edit_dashboard_path(@dashboard), class: "btn btn-info" %>
+        <%= link_to "Edit", edit_dashboard_path(@dashboard, variable_params), class: "btn btn-info" %>
       </div>
     </div>
   </div>