diff --git a/engine/app/controllers/good_job/dashboards_controller.rb b/engine/app/controllers/good_job/dashboards_controller.rb index 8e707065a..d1b05c7e5 100644 --- a/engine/app/controllers/good_job/dashboards_controller.rb +++ b/engine/app/controllers/good_job/dashboards_controller.rb @@ -42,11 +42,11 @@ def job_classes GoodJob::Job.group("serialized_params->>'job_class'").count end - def to_query(override) + def to_params(override) { state: params[:state], job_class: params[:job_class], - }.merge(override).delete_if { |_, v| v.nil? }.to_query + }.merge(override).delete_if { |_, v| v.nil? } end end diff --git a/engine/app/views/good_job/dashboards/index.html.erb b/engine/app/views/good_job/dashboards/index.html.erb index 225822392..b2dc6c01a 100644 --- a/engine/app/views/good_job/dashboards/index.html.erb +++ b/engine/app/views/good_job/dashboards/index.html.erb @@ -8,18 +8,30 @@ Filter by job class
<% @filter.job_classes.each do |name, count| %> - - <%= name %> (<%= count %>) - + <% if params[:job_class] == name %> + <%= link_to(root_path(@filter.to_params(job_class: nil)), class: 'btn btn-sm btn-outline-secondary active', role: "button", "aria-pressed": true) do %> + <%= name %> (<%= count %>) + <% end %> + <% else %> + <%= link_to(root_path(@filter.to_params(job_class: name)), class: 'btn btn-sm btn-outline-secondary', role: "button") do %> + <%= name %> (<%= count %>) + <% end %> + <% end %> <% end %>
Filter by state
<% @filter.states.each do |name, count| %> - - <%= name %> (<%= count %>) - + <% if params[:state] == name %> + <%= link_to(root_path(@filter.to_params(state: nil)), class: 'btn btn-sm btn-outline-secondary active', role: "button", "aria-pressed": true) do %> + <%= name %> (<%= count %>) + <% end %> + <% else %> + <%= link_to(root_path(@filter.to_params(state: name)), class: 'btn btn-sm btn-outline-secondary', role: "button") do %> + <%= name %> (<%= count %>) + <% end %> + <% end %> <% end %>
@@ -28,7 +40,7 @@ <% if @filter.jobs.present? %> <%= render 'shared/jobs_table', jobs: @filter.jobs %> -