Refactors search form

It only appears when the page asks for it.
Also, the i18n namespace and the path used for the form are parameters
now
This commit is contained in:
kikito
2015-09-12 18:32:13 +02:00
parent 3bcea097c6
commit c44e709f24
6 changed files with 35 additions and 17 deletions

View File

@@ -1,3 +1,9 @@
<% content_for :header_addon do %>
<%= render "shared/search_form_header",
search_path: debates_path(page: 1),
i18n_namespace: "debates.index.search_form" %>
<% end %>
<section role="main"> <section role="main">
<div class="wrap row"> <div class="wrap row">

View File

@@ -43,7 +43,7 @@
<% end %> <% end %>
</div> </div>
<div class="small-12 medium-4 column right"> <div class="small-12 medium-4 column right">
<%= render "shared/search_form_header" %> <%= yield :header_addon %>
</div> </div>
</section> </section>
</div> </div>

View File

@@ -1,17 +1,23 @@
<% # Params:
#
# search_path: for example debates_path
# i18n_namespace: for example "debates.index.search_form"
%>
<div class="search-form"> <div class="search-form">
<div class="sidebar-divider"></div> <div class="sidebar-divider"></div>
<h3><%= t("shared.search_form.search_title") %></h3> <h3><%= t("#{i18n_namespace}.title") %></h3>
<br> <br>
<div class="row"> <div class="row">
<%= form_tag debates_path, method: :get do %> <%= form_tag search_path, method: :get do %>
<div class="small-12 columns"> <div class="small-12 columns">
<div class="row collapse"> <div class="row collapse">
<div class="small-9 medium-12 large-9 columns"> <div class="small-9 medium-12 large-9 columns">
<input type="text" name="search" placeholder="<%= t("shared.search_form.search_placeholder") %>" class="search-form"> <input type="text" name="search" placeholder="<%= t("#{i18n_namespace}.placeholder") %>" class="search-form">
</div> </div>
<div class="small-3 medium-12 large-3 columns"> <div class="small-3 medium-12 large-3 columns">
<input type="submit" class="button secondary postfix" value="<%= t('shared.search_form.search_button') %>"> <input type="submit" class="button secondary postfix" value="<%= t("#{i18n_namespace}.button") %>">
</div> </div>
</div> </div>

View File

@@ -1,14 +1,20 @@
<% # Params:
#
# i18n_namespace: for example "debates.index.search_form"
# search_path: for example debates_path
%>
<div class="search-form"> <div class="search-form">
<div class="row"> <div class="row">
<%= form_tag debates_path, method: :get do %> <%= form_tag search_path, method: :get do %>
<div class="small-12 columns"> <div class="small-12 columns">
<div class="row collapse"> <div class="row collapse">
<div class="small-10 column"> <div class="small-10 column">
<input type="text" name="search" placeholder="<%= t("shared.search_form.search_placeholder") %>" class="search-form"> <input type="text" name="search" placeholder="<%= t("#{i18n_namespace}.placeholder") %>" class="search-form">
</div> </div>
<div class="small-2 column"> <div class="small-2 column">
<button type="submit" class="button postfix" title="<%= t('shared.search_form.search_button') %>"> <button type="submit" class="button postfix" title="<%= t("#{i18n_namespace}.button") %>">
<i class="icon-search"></i> <i class="icon-search"></i>
</button> </button>
</div> </div>

View File

@@ -76,6 +76,10 @@ en:
filter_topic: filter_topic:
one: " with the topic '%{topic}'" one: " with the topic '%{topic}'"
other: " with the topic '%{topic}'" other: " with the topic '%{topic}'"
search_form:
title: Search
button: Search
placeholder: "Search debates..."
search_results: search_results:
one: " containing '%{search_term}'" one: " containing '%{search_term}'"
other: " containing '%{search_term}'" other: " containing '%{search_term}'"
@@ -283,10 +287,6 @@ en:
flag: Flag as inappropriate flag: Flag as inappropriate
unflag: Undo flag unflag: Undo flag
collective: Collective collective: Collective
search_form:
search_title: Search
search_button: Search
search_placeholder: "Search on debates..."
mailer: mailer:
comment: comment:
subject: Someone has commented on your debate subject: Someone has commented on your debate

View File

@@ -76,6 +76,10 @@ es:
filter_topic: filter_topic:
one: " con el tema '%{topic}'" one: " con el tema '%{topic}'"
other: " con el tema '%{topic}'" other: " con el tema '%{topic}'"
search_form:
title: Buscar
button: Buscar
placeholder: "Buscar debates..."
search_results: search_results:
one: " que contiene '%{search_term}'" one: " que contiene '%{search_term}'"
other: " que contienen '%{search_term}'" other: " que contienen '%{search_term}'"
@@ -283,10 +287,6 @@ es:
flag: Denunciar como inapropiado flag: Denunciar como inapropiado
unflag: Deshacer denuncia unflag: Deshacer denuncia
collective: Colectivo collective: Colectivo
search_form:
search_title: Buscar
search_button: Buscar
search_placeholder: "Buscar en debates..."
mailer: mailer:
comment: comment:
subject: Alguien ha comentado en tu propuesta subject: Alguien ha comentado en tu propuesta