Refactors design of comments order selector into a partial with i18n
This commit is contained in:
@@ -1937,7 +1937,7 @@ table {
|
||||
opacity: 0.4;
|
||||
}
|
||||
|
||||
.filter-comments {
|
||||
.wide-order-selector {
|
||||
float: none;
|
||||
margin-top: 0;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ class DebatesController < ApplicationController
|
||||
before_action :authenticate_user!, except: [:index, :show]
|
||||
|
||||
has_orders %w{hot_score confidence_score created_at most_commented random}, only: :index
|
||||
has_orders %w{most_voted created_at}, only: :show
|
||||
|
||||
load_and_authorize_resource
|
||||
respond_to :html, :js
|
||||
|
||||
@@ -7,6 +7,7 @@ class ProposalsController < ApplicationController
|
||||
before_action :authenticate_user!, except: [:index, :show]
|
||||
|
||||
has_orders %w{hot_score confidence_score created_at most_commented random}, only: :index
|
||||
has_orders %w{most_voted created_at}, only: :show
|
||||
|
||||
load_and_authorize_resource
|
||||
respond_to :html, :js
|
||||
|
||||
@@ -7,22 +7,7 @@
|
||||
<span class="js-comments-count">(<%= @debate.comments_count %>)</span>
|
||||
</h2>
|
||||
|
||||
<!-- Filter for comments -->
|
||||
<div class="filter-comments small-12 medium-8">
|
||||
<form>
|
||||
<div class="small-12 medium-8 left">
|
||||
<label for="order-selector-participation"><%= t("debates.index.select_order") %></label>
|
||||
</div>
|
||||
<div class="small-12 medium-4 left">
|
||||
<select class="js-location-changer js-order-selector select-order" data-order="<%= @current_order %>" name="order-selector" id="order-selector-participation">
|
||||
<option>Más votados</option>
|
||||
<option>Más nuevos</option>
|
||||
<option>Aleatorios</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!-- /. Filter for comments -->
|
||||
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
|
||||
|
||||
<% if user_signed_in? %>
|
||||
<%= render 'comments/form', {commentable: @debate, parent_id: nil, toggeable: false} %>
|
||||
|
||||
@@ -8,22 +8,7 @@
|
||||
<span class="js-comments-count">(<%= @proposal.comments_count %>)</span>
|
||||
</h2>
|
||||
|
||||
<!-- Filter for comments -->
|
||||
<div class="filter-comments small-12 medium-8">
|
||||
<form>
|
||||
<div class="small-12 medium-8 left">
|
||||
<label for="order-selector-participation"><%= t("debates.index.select_order") %></label>
|
||||
</div>
|
||||
<div class="small-12 medium-4 left">
|
||||
<select class="js-location-changer js-order-selector select-order" data-order="<%= @current_order %>" name="order-selector" id="order-selector-participation">
|
||||
<option>Más votados</option>
|
||||
<option>Más nuevos</option>
|
||||
<option>Aleatorios</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!-- /. Filter for comments -->
|
||||
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
|
||||
|
||||
<% if user_signed_in? %>
|
||||
<%= render 'comments/form', {commentable: @proposal, parent_id: nil, toggeable: false} %>
|
||||
|
||||
24
app/views/shared/_wide_order_selector.html.erb
Normal file
24
app/views/shared/_wide_order_selector.html.erb
Normal file
@@ -0,0 +1,24 @@
|
||||
<% # Params:
|
||||
#
|
||||
# i18n_namespace: for example "moderation.debates.index"
|
||||
%>
|
||||
|
||||
<div class="wide-order-selector small-12 medium-8">
|
||||
<form>
|
||||
<div class="small-12 medium-8 left">
|
||||
<label for="order-selector-participation">
|
||||
<%= t("#{i18n_namespace}.select_order") %>
|
||||
</label>
|
||||
</div>
|
||||
<div class="small-12 medium-4 left">
|
||||
<select class="js-location-changer js-order-selector select-order" data-order="<%= @current_order %>" name="order-selector" id="order-selector-participation">
|
||||
<% @valid_orders.each do |order| %>
|
||||
<option <%= 'selected' if order == @current_order %>
|
||||
value='<%= current_path_with_query_params(order: order, page: 1) %>'>
|
||||
<%= t("#{i18n_namespace}.orders.#{order}") %>
|
||||
</option>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
16
app/views/shared/_wide_order_selector.rb
Normal file
16
app/views/shared/_wide_order_selector.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
<% # Params:
|
||||
#
|
||||
# i18n_namespace: for example "moderation.debates.index"
|
||||
%>
|
||||
|
||||
<form class="inline-block">
|
||||
<label for="order-selector-participation" class="sr-only"><%= t("debates.index.select_order") %></label>
|
||||
<select class="js-location-changer js-order-selector select-order" data-order="<%= @current_order %>" name="order-selector" id="order-selector-participation">
|
||||
<% @valid_orders.each do |order| %>
|
||||
<option <%= 'selected' if order == @current_order %>
|
||||
value='<%= current_path_with_query_params(order: order, page: 1) %>'>
|
||||
<%= t("#{i18n_namespace}.orders.#{order}") %>
|
||||
</option>
|
||||
<% end %>
|
||||
</select>
|
||||
</form>
|
||||
@@ -243,6 +243,10 @@ en:
|
||||
form:
|
||||
submit_button: "Save changes"
|
||||
comments:
|
||||
select_order: "Sort by"
|
||||
orders:
|
||||
most_voted: "Most voted"
|
||||
created_at: "Newest"
|
||||
form:
|
||||
leave_comment: Write a comment
|
||||
comment_as_moderator: Comment as moderator
|
||||
|
||||
@@ -243,6 +243,10 @@ es:
|
||||
form:
|
||||
submit_button: "Guardar cambios"
|
||||
comments:
|
||||
select_order: "Ordenar por"
|
||||
orders:
|
||||
most_voted: "Más votados"
|
||||
created_at: "Más nuevos"
|
||||
form:
|
||||
leave_comment: Deja tu comentario
|
||||
comment_as_moderator: Comentar como moderador
|
||||
|
||||
Reference in New Issue
Block a user