Refactors design of comments order selector into a partial with i18n

This commit is contained in:
kikito
2015-10-28 15:48:48 +01:00
parent 82eb0bd902
commit e4bfc72649
9 changed files with 56 additions and 36 deletions

View File

@@ -1937,7 +1937,7 @@ table {
opacity: 0.4;
}
.filter-comments {
.wide-order-selector {
float: none;
margin-top: 0;
@@ -1993,4 +1993,4 @@ table {
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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} %>
@@ -43,4 +28,4 @@
</div>
</div>
</section>
<% end %>
<% end %>

View File

@@ -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} %>
@@ -44,4 +29,4 @@
</div>
</div>
</section>
<% end %>
<% end %>

View 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>

View 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>

View File

@@ -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

View File

@@ -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