diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index 4420f2b36..47fc5d7bb 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -34,6 +34,7 @@
@import "moderation_actions";
@import "notification_item";
@import "community";
+@import "search_results_summary";
@import "stats";
@import "sticky_overrides";
@import "tags";
diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss
index 86b891563..be5746ded 100644
--- a/app/assets/stylesheets/participation.scss
+++ b/app/assets/stylesheets/participation.scss
@@ -866,15 +866,6 @@
}
}
-.search-results-summary {
- @include full-width-background;
- background: $highlight;
- margin-bottom: $line-height;
- margin-top: -$line-height;
- padding-bottom: $line-height;
- padding-top: $line-height;
-}
-
// 05. Featured
// ------------
diff --git a/app/assets/stylesheets/search_results_summary.scss b/app/assets/stylesheets/search_results_summary.scss
new file mode 100644
index 000000000..e6864f0db
--- /dev/null
+++ b/app/assets/stylesheets/search_results_summary.scss
@@ -0,0 +1,8 @@
+.search-results-summary {
+ @include full-width-background;
+ background: $highlight;
+ margin-bottom: $line-height;
+ margin-top: -$line-height;
+ padding-bottom: $line-height;
+ padding-top: $line-height;
+}
diff --git a/app/components/shared/search_results_summary_component.html.erb b/app/components/shared/search_results_summary_component.html.erb
new file mode 100644
index 000000000..94ca14bd4
--- /dev/null
+++ b/app/components/shared/search_results_summary_component.html.erb
@@ -0,0 +1,17 @@
+
+
+
+ <% if search_terms || advanced_search_terms %>
+
<%= t("shared.search_results") %>
+
+ <%= page_entries_info results %>
+ <% if advanced_search_terms.blank? %>
+ <%= summary %>
+ <% end %>
+
+ <% else %>
+ <%= content %>
+ <% end %>
+
+
+
diff --git a/app/components/shared/search_results_summary_component.rb b/app/components/shared/search_results_summary_component.rb
new file mode 100644
index 000000000..cc95c691a
--- /dev/null
+++ b/app/components/shared/search_results_summary_component.rb
@@ -0,0 +1,15 @@
+class Shared::SearchResultsSummaryComponent < ApplicationComponent
+ attr_reader :results, :search_terms, :advanced_search_terms
+
+ def initialize(results:, search_terms:, advanced_search_terms:)
+ @results = results
+ @search_terms = search_terms
+ @advanced_search_terms = advanced_search_terms
+ end
+
+ private
+
+ def summary
+ sanitize(t("proposals.index.search_results", count: results.size, search_term: search_terms))
+ end
+end
diff --git a/app/views/budgets/investments/index.html.erb b/app/views/budgets/investments/index.html.erb
index 425e3aeee..3c20c3256 100644
--- a/app/views/budgets/investments/index.html.erb
+++ b/app/views/budgets/investments/index.html.erb
@@ -22,21 +22,11 @@
<% end %>
<% if params[:search].present? || params[:advanced_search].present? %>
-
-
-
-
<%= t("shared.search_results") %>
-
- <%= page_entries_info @investments %>
- <% if params[:advanced_search].blank? %>
- <%= sanitize(t("budgets.investments.index.search_results",
- count: @investments.size,
- search_term: params[:search])) %>
- <% end %>
-
-
-
-
+ <%= render Shared::SearchResultsSummaryComponent.new(
+ results: @investments,
+ search_terms: params[:search],
+ advanced_search_terms: params[:advanced_search]
+ ) %>
<% end %>
diff --git a/app/views/debates/index.html.erb b/app/views/debates/index.html.erb
index a4e347537..08647fee1 100644
--- a/app/views/debates/index.html.erb
+++ b/app/views/debates/index.html.erb
@@ -10,23 +10,11 @@
<% if @search_terms || @advanced_search_terms %>
-
-
-
- <% if @search_terms || @advanced_search_terms %>
-
<%= t("shared.search_results") %>
-
- <%= page_entries_info @debates %>
- <% if !@advanced_search_terms %>
- <%= sanitize(
- t("debates.index.search_results", count: @debates.size, search_term: @search_terms)
- ) %>
- <% end %>
-
- <% end %>
-
-
-
+ <%= render Shared::SearchResultsSummaryComponent.new(
+ results: @debates,
+ search_terms: @search_terms,
+ advanced_search_terms: @advanced_search_terms
+ ) %>
<% else %>
<%= render "shared/section_header", i18n_namespace: "debates.index.section_header", image: "debates" %>
<% end %>
diff --git a/app/views/proposals/index.html.erb b/app/views/proposals/index.html.erb
index 790a256f0..411b0d32b 100644
--- a/app/views/proposals/index.html.erb
+++ b/app/views/proposals/index.html.erb
@@ -15,27 +15,17 @@
params[:retired].present?,
params[:selected].present?
].any? %>
-
-
-
- <% if @search_terms || @advanced_search_terms %>
-
<%= t("shared.search_results") %>
-
- <%= page_entries_info @proposals %>
- <% if !@advanced_search_terms %>
- <%= sanitize(
- t("proposals.index.search_results", count: @proposals.size, search_term: @search_terms)
- ) %>
- <% end %>
-
- <% elsif params[:retired].present? %>
-
<%= t("proposals.index.retired_proposals") %>
- <% elsif params[:selected].present? %>
-
<%= t("proposals.index.selected_proposals") %>
- <% end %>
-
-
-
+ <%= render Shared::SearchResultsSummaryComponent.new(
+ results: @proposals,
+ search_terms: @search_terms,
+ advanced_search_terms: @advanced_search_terms
+ ) do %>
+ <% if params[:retired].present? %>
+ <%= t("proposals.index.retired_proposals") %>
+ <% elsif params[:selected].present? %>
+ <%= t("proposals.index.selected_proposals") %>
+ <% end %>
+ <% end %>
<% else %>
<%= render "shared/section_header", i18n_namespace: "proposals.index.section_header", image: "proposals" %>
<% end %>
diff --git a/config/locales/en/budgets.yml b/config/locales/en/budgets.yml
index 1e3c6b41a..ab3b055d0 100644
--- a/config/locales/en/budgets.yml
+++ b/config/locales/en/budgets.yml
@@ -92,9 +92,6 @@ en:
button: Search
placeholder: Search investment projects...
title: Search
- search_results:
- one: " containing the term '%{search_term}'"
- other: " containing the term '%{search_term}'"
sidebar:
my_ballot: My ballot
voted_info:
diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml
index 049f090f7..8fdff4448 100644
--- a/config/locales/en/general.yml
+++ b/config/locales/en/general.yml
@@ -110,9 +110,6 @@ en:
button: Search
placeholder: Search debates...
title: Search
- search_results:
- one: " containing the term '%{search_term}'"
- other: " containing the term '%{search_term}'"
start_debate: Start a debate
title: Debates
section_header:
diff --git a/config/locales/es/budgets.yml b/config/locales/es/budgets.yml
index 5cf78e3d4..7991b9dd2 100644
--- a/config/locales/es/budgets.yml
+++ b/config/locales/es/budgets.yml
@@ -92,9 +92,6 @@ es:
button: Buscar
placeholder: Buscar proyectos de gasto...
title: Buscar
- search_results:
- one: " que contiene '%{search_term}'"
- other: " que contienen '%{search_term}'"
sidebar:
my_ballot: Mis votos
voted_info:
diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml
index bb1ecca96..a9cc36d3e 100644
--- a/config/locales/es/general.yml
+++ b/config/locales/es/general.yml
@@ -110,9 +110,6 @@ es:
button: Buscar
placeholder: Buscar debates...
title: Buscar
- search_results:
- one: " que contiene '%{search_term}'"
- other: " que contienen '%{search_term}'"
start_debate: Empieza un debate
title: Debates
section_header: