Redesign of sorting button for projects/experiments cards

This commit is contained in:
Mojca Lorber 2019-09-16 14:43:12 +02:00
parent 7f415a551d
commit 47ccf38662
7 changed files with 33 additions and 25 deletions

View file

@ -529,6 +529,7 @@
if (projectsViewSort !== $(this).data('sort')) {
$('#sortMenuDropdown a').removeClass('disabled');
projectsViewSort = $(this).data('sort');
$('#sortMenu').html(I18n.t('general.sort.' + projectsViewSort + '_html'));
loadCardsView();
$(this).addClass('disabled');
$('#sortMenu').dropdown('toggle');

View file

@ -17,6 +17,18 @@ $color-module-hover: $brand-primary;
}
}
#sortMenu {
border-color: $color-white;
&:not(:focus) {
color: $color-silver-chalice;
}
&:hover {
color: inherit;
}
}
/* Secondary navigation */
.navbar-nav {
@ -483,7 +495,7 @@ li.module-hover {
height: 400px;
margin: 0 auto;
margin-bottom: 35px;
margin-top: 45px;
margin-top: 15px;
max-width: 700px;
.panel-title {

View file

@ -232,7 +232,7 @@ class ProjectsController < ApplicationController
end
# This is the "info" view
current_team_switch(@project.team)
@current_sort = @project.experiments_order
@current_sort = @project.experiments_order || :new
end
def notifications

View file

@ -122,17 +122,16 @@
<!-- project sort -->
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="sortMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="hidden-xs"><%= t'projects.index.sort' %></span>
<span class="visible-xs-inline"><i class="fas fa-sort"></i></span>
<span><%= t("general.sort.#{@current_sort}_html") %></span>
<span class="caret"></span>
</button>
<ul id="sortMenuDropdown" class="dropdown-menu" aria-labelledby="sortMenu">
<% ["new", "old", "atoz", "ztoa"].each do |sort| %>
<li>
<% if @current_sort != sort %>
<a href="#" data-sort="<%= sort %>"><%= t('projects.index.sort_' + sort) %></a>
<a href="#" data-sort="<%= sort %>"><%= t("general.sort.#{sort}_html") %></a>
<% else %>
<a class="disabled" href="#" data-sort="<%= sort %>"><%= t('projects.index.sort_' + sort) %></a>
<a class="disabled" href="#" data-sort="<%= sort %>"><%= t("general.sort.#{sort}_html") %></a>
<% end %>
</li>
<% end %>

View file

@ -12,17 +12,18 @@
<!-- experiment sort -->
<div class="dropdown pull-left">
<button class="btn btn-default dropdown-toggle" type="button" id="sortMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="hidden-xs"><%= t'projects.index.sort' %></span>
<span class="visible-xs-inline"><i class="fas fa-sort"></i></span>
<span><%= t("general.sort.#{@current_sort}_html") %></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="sortMenu">
<% ["new", "old", "atoz", "ztoa"].each do |sort| %>
<% if @current_sort != sort %>
<li><a href="?<%= {sort: sort}.reject{|v| v.to_s == "0"}.to_query %>"><%= t('projects.index.sort_' + sort) %></a></li>
<% else %>
<li class="disabled"><a href="#"><%= t('projects.index.sort_' + sort) %></a></li>
<% end %>
<li>
<% if @current_sort != sort %>
<a href="?<%= {sort: sort}.reject{|v| v.to_s == "0"}.to_query %>"><%= t("general.sort.#{sort}_html") %></a>
<% else %>
<a class="disabled" href="#"><%= t("general.sort.#{sort}_html") %></a>
<% end %>
</li>
<% end %>
</ul>
</div>

View file

@ -19,7 +19,7 @@
<div class="dropdown attachments-order" id="dd-att-step-<%= step.id %>">
<button class="btn btn-default dropdown-toggle" type="button" id="sortMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span id="dd-att-step-<%= step.id %>-label">
<%= t("protocols.steps.attachments.sort.#{step.current_view_state(current_user).state.dig('assets', 'sort')}_html") %>
<%= t("general.sort.#{step.current_view_state(current_user).state.dig('assets', 'sort')}_html") %>
</span>
<span class="caret"></span>
</button>
@ -27,7 +27,7 @@
<% ['new', 'old', 'atoz', 'ztoa'].each do |sort| %>
<li>
<a data-order="<%= sort %>" onClick="reorderAttachments(this, '<%= step.id %>', '<%= sort %>')">
<%= t("protocols.steps.attachments.sort.#{sort}_html") %>
<%= t("general.sort.#{sort}_html") %>
</a>
</li>
<% end %>

View file

@ -266,11 +266,6 @@ en:
delete_user_confirm: "Are you sure you wish to remove user %{user} from project %{project}?"
team_filter: "Show projects from"
all_filter: "All"
sort: "Sort by"
sort_new: "Newest first"
sort_old: "Oldest first"
sort_atoz: "From A to Z"
sort_ztoa: "From Z to A"
start_date: "Start date:"
activity_tab: "Activity"
users_tab: "Users"
@ -1820,11 +1815,6 @@ en:
complete_title: "Complete Step"
uncomplete_title: "Uncomplete Step"
attachments:
sort:
new_html: "Newest first &#8595;"
old_html: "Oldest first &#8593;"
atoz_html: "Name &#8595;"
ztoa_html: "Name &#8593;"
modified_label: "Modified:"
new:
add_step_title: "Add new step"
@ -2029,6 +2019,11 @@ en:
more_comments: "More comments"
comment_placeholder: "Your Message"
comment_placeholder_new: "Add new comment…"
sort:
new_html: "Newest first &#8595;"
old_html: "Oldest first &#8593;"
atoz_html: "Name &#8595;"
ztoa_html: "Name &#8593;"
module:
one: "task"
other: "tasks"