From b01a2cbfb120d3b32ad3713be8073819d5016c2a Mon Sep 17 00:00:00 2001 From: Chris Huynh Date: Thu, 31 Oct 2024 11:18:06 -0500 Subject: [PATCH] fix remove mb class, add highlighting on search --- .../table_component.html.erb | 21 +++++++++++++++++-- .../workflow_executions/table_component.rb | 2 ++ .../concerns/workflow_execution_actions.rb | 8 +++++++ .../projects/samples_controller.rb | 3 ++- .../workflow_executions/_table.html.erb | 1 + .../workflow_executions/index.html.erb | 5 ++--- app/views/workflow_executions/_table.html.erb | 1 + app/views/workflow_executions/index.html.erb | 2 +- 8 files changed, 36 insertions(+), 7 deletions(-) diff --git a/app/components/workflow_executions/table_component.html.erb b/app/components/workflow_executions/table_component.html.erb index 3d4beb778c..c3b8de6c68 100644 --- a/app/components/workflow_executions/table_component.html.erb +++ b/app/components/workflow_executions/table_component.html.erb @@ -97,13 +97,21 @@ <% end %> <% if column == :id %> <%= link_to( - workflow_execution.id, individual_path(workflow_execution), data: { turbo: false, }, class: "text-slate-900 dark:text-slate-100 font-semibold hover:underline", - ) %> + ) do %> + + <%= highlight( + workflow_execution.id, + defined?(@search_params[:name_or_id_cont]) && + @search_params[:name_or_id_cont], + highlighter: '\1', + ) %> + + <% end %> <% elsif column == :state %> <%= viral_pill( text: t(:"workflow_executions.state.#{workflow_execution[column]}"), @@ -118,6 +126,15 @@ <% if workflow_execution[column].present? %> <%= helpers.local_time_ago(workflow_execution[column]) %> <% end %> + <% elsif column == :name %> + + <%= highlight( + workflow_execution.name, + defined?(@search_params[:name_or_id_cont]) && + @search_params[:name_or_id_cont], + highlighter: '\1', + ) %> + <% else %> <%= workflow_execution[column.to_sym] %> <% end %> diff --git a/app/components/workflow_executions/table_component.rb b/app/components/workflow_executions/table_component.rb index 30f75bfd9c..0a2b9cee51 100644 --- a/app/components/workflow_executions/table_component.rb +++ b/app/components/workflow_executions/table_component.rb @@ -14,6 +14,7 @@ def initialize( q, namespace: nil, row_actions: false, + search_params: nil, abilities: {}, empty: {}, **system_arguments @@ -23,6 +24,7 @@ def initialize( @q = q @namespace = namespace @abilities = abilities + @search_params = search_params @row_actions = row_actions @empty = empty @renders_row_actions = @row_actions.select { |_key, value| value }.count.positive? diff --git a/app/controllers/concerns/workflow_execution_actions.rb b/app/controllers/concerns/workflow_execution_actions.rb index 58c504c9ed..00c87dc559 100644 --- a/app/controllers/concerns/workflow_execution_actions.rb +++ b/app/controllers/concerns/workflow_execution_actions.rb @@ -16,6 +16,8 @@ def index authorize! @namespace, to: :view_workflow_executions? unless @namespace.nil? @q = load_workflows.ransack(params[:q]) + @search_params = search_params + set_default_sort @pagy, @workflow_executions = pagy_with_metadata_sort(@q.result) end @@ -153,4 +155,10 @@ def format_attachment(samplesheet) end attachments end + + def search_params + search_params = {} + search_params[:name_or_id_cont] = params.dig(:q, :name_or_id_cont) + search_params + end end diff --git a/app/controllers/projects/samples_controller.rb b/app/controllers/projects/samples_controller.rb index 985b2e5fff..888fd9a51e 100644 --- a/app/controllers/projects/samples_controller.rb +++ b/app/controllers/projects/samples_controller.rb @@ -151,7 +151,8 @@ def process_samples def search_params updated_params = update_store(search_key, params[:q].present? ? params[:q].to_unsafe_h : {}) - + puts 'hihihihi' + puts updated_params if updated_params[:metadata].to_i.zero? && updated_params[:s].present? && updated_params[:s].match?(/metadata_/) updated_params[:s] = default_sort update_store(search_key, updated_params) diff --git a/app/views/projects/workflow_executions/_table.html.erb b/app/views/projects/workflow_executions/_table.html.erb index e9eb94138c..862ea16023 100644 --- a/app/views/projects/workflow_executions/_table.html.erb +++ b/app/views/projects/workflow_executions/_table.html.erb @@ -4,6 +4,7 @@ pagy, q, namespace: namespace, + search_params: @search_params, abilities: { select_workflow_executions: allowed_to?(:export_data?, namespace) }, diff --git a/app/views/projects/workflow_executions/index.html.erb b/app/views/projects/workflow_executions/index.html.erb index 435d741368..b806f2121d 100644 --- a/app/views/projects/workflow_executions/index.html.erb +++ b/app/views/projects/workflow_executions/index.html.erb @@ -28,7 +28,7 @@
<% if allowed_to?(:export_data?, @project.namespace) %> -
+
<%= search_form_for( @q, url: select_namespace_project_workflow_executions_url(**request.query_parameters), @@ -62,11 +62,10 @@
- <%= render partial: "table", locals: { workflow_executions: @workflow_executions, pagy: @pagy, q: @q, - namespace: @namespace, + namespace: @namespace } %> diff --git a/app/views/workflow_executions/_table.html.erb b/app/views/workflow_executions/_table.html.erb index 95984a7c58..61f4e5f778 100644 --- a/app/views/workflow_executions/_table.html.erb +++ b/app/views/workflow_executions/_table.html.erb @@ -3,6 +3,7 @@ workflow_executions, pagy, q, + search_params: @search_params, abilities: { select_workflow_executions: true }, diff --git a/app/views/workflow_executions/index.html.erb b/app/views/workflow_executions/index.html.erb index 9638580ea6..26390ea9aa 100644 --- a/app/views/workflow_executions/index.html.erb +++ b/app/views/workflow_executions/index.html.erb @@ -60,5 +60,5 @@ locals: { workflow_executions: @workflow_executions, pagy: @pagy, - q: @q, + q: @q } %>