From a85e850542ca2c16a8be753c18cff7d335281483 Mon Sep 17 00:00:00 2001 From: Katherine Thiessen Date: Tue, 14 Jan 2025 13:46:29 -0600 Subject: [PATCH] utilizing the ListFilterComponent to display the value for 'in' and 'not_in' operators --- .../advanced_search/condition.html.erb | 16 +-- app/components/advanced_search/condition.rb | 4 +- app/components/advanced_search/group.html.erb | 4 +- app/components/advanced_search/value.html.erb | 77 +++++++++++++ app/components/advanced_search/value.rb | 13 +++ .../advanced_search_component.html.erb | 106 ++++++++++++++++-- .../controllers/advanced_search_controller.js | 31 ++++- .../controllers/list_filter_controller.js | 14 ++- app/models/sample/condition.rb | 4 +- app/models/sample/query.rb | 10 +- .../advanced_search_group_validator.rb | 5 +- test/system/groups/samples_test.rb | 2 +- 12 files changed, 250 insertions(+), 36 deletions(-) create mode 100644 app/components/advanced_search/value.html.erb create mode 100644 app/components/advanced_search/value.rb diff --git a/app/components/advanced_search/condition.html.erb b/app/components/advanced_search/condition.html.erb index ffbcbc5f30..7f1b3aa315 100644 --- a/app/components/advanced_search/condition.html.erb +++ b/app/components/advanced_search/condition.html.erb @@ -9,7 +9,7 @@ { "aria-label": t("advanced_search_component.field"), class: - "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500", + "h-10 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500", } %> <%= conditions_form.select :operator, @operations, @@ -18,15 +18,15 @@ }, { "aria-label": t("advanced_search_component.operator"), + "data-action": "advanced-search#handleOperatorChange", class: - "bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500", + "h-10 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-500 focus:border-primary-500 block p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500", } %> - <%= conditions_form.text_field( - :value, - placeholder: t("advanced_search_component.value"), - "aria-label": t("advanced_search_component.value"), - class: - "keyInput block py-2.5 px-0 w-full text-sm text-slate-900 bg-transparent border-0 border-b-2 border-slate-300 appearance-none dark:text-white dark:border-slate-600 dark:focus:border-primary-500 focus:outline-none focus:ring-0 focus:border-primary-500 peer", + <%= render AdvancedSearch::Value.new( + conditions_form: conditions_form, + group_index: @group_index, + condition: @condition, + condition_index: @condition_index, ) %> <% end %> + + +<% else %> + <%= @conditions_form.text_field( + :value, + placeholder: t("advanced_search_component.value"), + "aria-label": t("advanced_search_component.value"), + class: + "keyInput block py-2.5 px-0 w-full text-sm text-slate-900 bg-transparent border-0 border-b-2 border-slate-300 appearance-none dark:text-white dark:border-slate-600 dark:focus:border-primary-500 focus:outline-none focus:ring-0 focus:border-primary-500 peer value", + ) %> +<% end %> diff --git a/app/components/advanced_search/value.rb b/app/components/advanced_search/value.rb new file mode 100644 index 0000000000..7778e72f21 --- /dev/null +++ b/app/components/advanced_search/value.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module AdvancedSearch + # Component for rendering an advanced search value + class Value < Component + def initialize(conditions_form:, group_index:, condition:, condition_index:) + @conditions_form = conditions_form + @group_index = group_index + @condition = condition + @condition_index = condition_index + end + end +end diff --git a/app/components/advanced_search_component.html.erb b/app/components/advanced_search_component.html.erb index 1ccc78709f..7bab5c9887 100644 --- a/app/components/advanced_search_component.html.erb +++ b/app/components/advanced_search_component.html.erb @@ -1,4 +1,7 @@ -
+
<%= viral_dialog(id: 'advanced-search-dialog', size: :large, open: @open) do |dialog| %> <%= dialog.with_trigger do %>