diff --git a/app/controllers/concerns/commentable_actions.rb b/app/controllers/concerns/commentable_actions.rb
index 1c00c7e5c..855ad1de5 100644
--- a/app/controllers/concerns/commentable_actions.rb
+++ b/app/controllers/concerns/commentable_actions.rb
@@ -30,13 +30,8 @@ module CommentableActions
end
def suggest
+ @limit = 5
@resources = @search_terms.present? ? resource_model.search(@search_terms) : nil
- set_resources_instance
- if @resources
- @resources_count = @resources.count
- @reg_show = 5
- render layout: false
- end
end
def create
diff --git a/app/controllers/debates_controller.rb b/app/controllers/debates_controller.rb
index c0365d310..e1173f749 100644
--- a/app/controllers/debates_controller.rb
+++ b/app/controllers/debates_controller.rb
@@ -15,6 +15,7 @@ class DebatesController < ApplicationController
has_orders %w{most_voted newest oldest}, only: :show
load_and_authorize_resource
+ helper_method :resource_model, :resource_name
respond_to :html, :js
def vote
diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb
index 92a302a49..224b16bb9 100644
--- a/app/controllers/proposals_controller.rb
+++ b/app/controllers/proposals_controller.rb
@@ -14,6 +14,7 @@ class ProposalsController < ApplicationController
has_orders %w{most_voted newest oldest}, only: :show
load_and_authorize_resource
+ helper_method :resource_model, :resource_name
respond_to :html, :js
def index_customization
diff --git a/app/views/debates/_suggest.html.erb b/app/views/debates/_suggest.html.erb
deleted file mode 100644
index c043a7e93..000000000
--- a/app/views/debates/_suggest.html.erb
+++ /dev/null
@@ -1,22 +0,0 @@
-
- <% if @search_terms && @resources_count > 0 %>
-
-
- <%= t("debates.new.suggestions.found", count: @resources_count, query: @search_terms)%>
-
-
- <% @debates.take(@reg_show).each do |debate| %>
- - <%= link_to debate.title, debate %>
- <% end %>
-
- <% if @resources_count > @reg_show %>
-
- <%= t("debates.new.suggestions.message", count: @resources_count,
- query: @search_terms,
- limit: @reg_show) %>
- <%= link_to t("debates.new.suggestions.see_all"), debates_path(search: @search_terms)%>
-
- <% end %>
-
- <% end %>
-
\ No newline at end of file
diff --git a/app/views/debates/suggest.js.erb b/app/views/debates/suggest.js.erb
index de10bc0ad..819af2b16 100644
--- a/app/views/debates/suggest.js.erb
+++ b/app/views/debates/suggest.js.erb
@@ -1 +1 @@
-<%= render "suggest" %>
\ No newline at end of file
+<%= render "shared/suggest" %>
\ No newline at end of file
diff --git a/app/views/proposals/_suggest.html.erb b/app/views/proposals/_suggest.html.erb
deleted file mode 100644
index fe94f7fc9..000000000
--- a/app/views/proposals/_suggest.html.erb
+++ /dev/null
@@ -1,22 +0,0 @@
-
- <% if @search_terms && @resources_count > 0 %>
-
-
- <%= t("proposals.new.suggestions.found", count: @resources_count, query: @search_terms)%>
-
-
- <% @proposals.take(@reg_show).each do |proposal| %>
- - <%= link_to proposal.title, proposal %>
- <% end %>
-
- <% if @resources_count > @reg_show %>
-
- <%= t("proposals.new.suggestions.message", count: @resources_count,
- query: @search_terms,
- limit: @reg_show) %>
- <%= link_to t("proposals.new.suggestions.see_all"), proposals_path(search: @search_terms)%>
-
- <% end %>
-
- <% end %>
-
\ No newline at end of file
diff --git a/app/views/proposals/suggest.js.erb b/app/views/proposals/suggest.js.erb
index de10bc0ad..819af2b16 100644
--- a/app/views/proposals/suggest.js.erb
+++ b/app/views/proposals/suggest.js.erb
@@ -1 +1 @@
-<%= render "suggest" %>
\ No newline at end of file
+<%= render "shared/suggest" %>
\ No newline at end of file
diff --git a/app/views/shared/_suggest.html.erb b/app/views/shared/_suggest.html.erb
new file mode 100644
index 000000000..03d14296c
--- /dev/null
+++ b/app/views/shared/_suggest.html.erb
@@ -0,0 +1,29 @@
+
+ <% if @search_terms && @resources.any? %>
+
+
+ <%= t("shared.suggest.#{resource_name}.found",
+ count: @resources.count,
+ query: @search_terms)%>
+
+
+
+ <% @resources.limit(@limit).each do |resource| %>
+ - <%= link_to resource.title, resource %>
+ <% end %>
+
+
+ <% if @resources.count > @limit %>
+
+ <%= t("shared.suggest.#{resource_name}.message",
+ count: @resources.count,
+ query: @search_terms,
+ limit: @limit) %>
+ <%= link_to t("shared.suggest.#{resource_name}.see_all"),
+ polymorphic_url(resource_model, search: @search_terms)%>
+
+ <% end %>
+
+
+ <% end %>
+
\ No newline at end of file
diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml
index 05355ec7c..e003e2842 100644
--- a/config/i18n-tasks.yml
+++ b/config/i18n-tasks.yml
@@ -133,6 +133,7 @@ ignore_unused:
- 'notifications.index.replies_to*'
- 'helpers.page_entries_info.*' # kaminari
- 'views.pagination.*' # kaminari
+ - 'shared.suggest.*'
# - '{devise,kaminari,will_paginate}.*'
# - 'simple_form.{yes,no}'
# - 'simple_form.{placeholders,hints,labels}.*'
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 583fcf496..6db80f30f 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -121,12 +121,6 @@ en:
recommendation_two: Any debate or comment suggesting illegal action will be deleted, as well as those intending to sabotage the debate spaces. Anything else is allowed.
recommendations_title: Recommendations for creating a debate
start_new: Start a debate
- suggestions:
- found:
- one: "There is a debate with the term '%{query}', you can participate in it instead of opening a new one."
- other: "There are debates with the term '%{query}', you can participate in them instead of opening a new one."
- message: "You are seeing %{limit} of %{count} debates containing the term '%{query}'"
- see_all: "See all"
show:
author_deleted: User deleted
back_link: Go back
@@ -306,12 +300,6 @@ en:
recommendation_two: Any proposal or comment suggesting illegal action will be deleted, as well as those intending to sabotage the debate spaces. Anything else is allowed.
recommendations_title: Recommendations for creating a proposal
start_new: Create new proposal
- suggestions:
- found:
- one: "There is a proposal with the term '%{query}', you can contribute to it instead of creating a new"
- other: "There are proposals with the term '%{query}', you can contribute to them instead of creating a new"
- message: "You are seeing %{limit} of %{count} proposals containing the term '%{query}'"
- see_all: "See all"
proposal:
already_supported: You have already supported this proposal. Share it!
comments:
@@ -376,6 +364,19 @@ en:
flag: Flag as inappropriate
print:
print_button: Print this info
+ suggest:
+ debate:
+ found:
+ one: "There is a debate with the term '%{query}', you can participate in it instead of opening a new one."
+ other: "There are debates with the term '%{query}', you can participate in them instead of opening a new one."
+ message: "You are seeing %{limit} of %{count} debates containing the term '%{query}'"
+ see_all: "Ver todos"
+ proposal:
+ found:
+ one: "There is a proposal with the term '%{query}', you can contribute to it instead of creating a new"
+ other: "There are proposals with the term '%{query}', you can contribute to them instead of creating a new"
+ message: "You are seeing %{limit} of %{count} proposals containing the term '%{query}'"
+ see_all: "See all"
tags_cloud:
tags: Trending
districts: "Districts"
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 227add811..7051d47d0 100755
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -122,12 +122,6 @@ es:
recommendation_two: Cualquier debate o comentario que implique una acción ilegal será eliminado, también los que tengan la intención de sabotear los espacios de debate, todo lo demás está permitido.
recommendations_title: Recomendaciones para crear un debate
start_new: Empezar un debate
- suggestions:
- found:
- one: "Existe un debate con el término '%{query}', puedes participar en él en vez de abrir uno nuevo."
- other: "Existen debates con el término '%{query}', puedes participar en ellos en vez de abrir uno nuevo."
- message: "Estás viendo %{limit} de %{count} debates que contienen el término '%{query}'"
- see_all: "Ver todos"
show:
author_deleted: Usuario eliminado
back_link: Volver
@@ -307,12 +301,6 @@ es:
recommendation_two: Cualquier propuesta o comentario que implique una acción ilegal será eliminada, también las que tengan la intención de sabotear los espacios de propuesta, todo lo demás está permitido.
recommendations_title: Recomendaciones para crear una propuesta
start_new: Crear una propuesta
- suggestions:
- found:
- one: "Existe una propuesta con el término '%{query}', puedes contribuir en ella en vez de crear una nueva."
- other: "Existen propuestas con el término '%{query}', puedes contribuir en ellas en vez de crear una nueva."
- message: "Estás viendo %{limit} de %{count} propuestas que contienen el término '%{query}'"
- see_all: "Ver todas"
proposal:
already_supported: "¡Ya has apoyado esta propuesta, compártela!"
comments:
@@ -377,6 +365,19 @@ es:
flag: Denunciar como inapropiado
print:
print_button: Imprimir esta información
+ suggest:
+ debate:
+ found:
+ one: "Existe un debate con el término '%{query}', puedes participar en él en vez de abrir uno nuevo."
+ other: "Existen debates con el término '%{query}', puedes participar en ellos en vez de abrir uno nuevo."
+ message: "Estás viendo %{limit} de %{count} debates que contienen el término '%{query}'"
+ see_all: "Ver todos"
+ proposal:
+ found:
+ one: "Existe una propuesta con el término '%{query}', puedes participar en ella en vez de abrir uno nuevo."
+ other: "Existen propuestas con el término '%{query}', puedes participar en ellas en vez de abrir uno nuevo."
+ message: "Estás viendo %{limit} de %{count} propuestas que contienen el término '%{query}'"
+ see_all: "Ver todas"
tags_cloud:
tags: Tendencias
districts: "Distritos"