Use order links in legislation proposals admin

As mentioned in the previous commits, a `<select>` field which submits
its form on change causes many accessibility and usability issues, so
we're replacing it with the order links we use everywhere else.

Since the links "Id" and "Title" by themselves don't have enough
information to let users know they're used to sort by ID or title, we
have to update them somehow. We could add a "Sort by:" prefix before the
list of links (and associate it with the `aria-labelledby` attribute);
however, we don't do this anywhere else and might look weird depending
on the screen size.

So we're simply adding "Sort by" before each link.

Now that we don't use the `wide_order_selector` partial anymore, we can
remove it alongside the styles for the `select-order` class.
This commit is contained in:
Javi Martín
2021-06-27 23:40:04 +02:00
parent d672a4294a
commit bc0f040758
9 changed files with 10 additions and 75 deletions

View File

@@ -340,10 +340,6 @@ $table-header: #ecf1f6;
.is-featured {
margin-top: rem-calc(36);
}
.select-order {
min-width: rem-calc(160);
}
}
.for-print-only {

View File

@@ -2039,25 +2039,6 @@ table {
opacity: 0.4;
}
.wide-order-selector {
float: none;
margin-top: 0;
@include breakpoint(medium) {
float: right;
margin-top: rem-calc(-24);
}
label {
padding-right: $line-height / 2;
float: none;
@include breakpoint(medium) {
float: right;
}
}
}
.comment-form {
display: inline-block;
width: 100%;

View File

@@ -44,18 +44,6 @@ input[type="submit"] { display: none !important; }
.admin h2 { font-size: 20px !important; line-height: 20px !important; }
.select-order {
border: 0 !important;
font-size: 20px !important;
font-weight: bold !important;
line-height: 20px !important;
margin-left: 10px !important;
margin-top: 0 !important;
margin-bottom: 0 !important;
margin-right: 0 !important;
padding: 0 !important;
}
p.proposal-info { margin-left: -6px; }
a { text-decoration: none !important; }

View File

@@ -1,7 +1,7 @@
<% if proposals.any? %>
<h3><%= page_entries_info proposals %></h3>
<%= render "shared/wide_order_selector", i18n_namespace: "admin.legislation.processes.proposals" %>
<%= render "shared/order_links", i18n_namespace: "admin.legislation.processes.proposals" %>
<table class="stack" id="legislation_proposals_list">
<thead>

View File

@@ -1,27 +0,0 @@
<% # Params:
#
# i18n_namespace: for example "moderation.debates.index" %>
<% if @valid_orders.present? && @valid_orders.count > 1 %>
<div class="wide-order-selector small-12 medium-8">
<form>
<div class="small-12 medium-6 float-left">
<label for="order-selector-participation">
<%= t("#{i18n_namespace}.select_order") %>
</label>
</div>
<div class="small-12 medium-6 float-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| %>
<% value = current_path_with_query_params(order: order, page: 1) %>
<option value="<%= value %>" <%= "selected" if order == @current_order %>>
<%= t("#{i18n_namespace}.orders.#{order}") %>
</option>
<% end %>
</select>
</div>
</form>
</div>
<% end %>

View File

@@ -157,7 +157,6 @@ ignore_unused:
- "admin.legislation.processes.index.filter*"
- "admin.legislation.processes.*.submit_button"
- "admin.legislation.processes.proposals.orders.*"
- "admin.legislation.processes.proposals.select_order"
- "admin.legislation.draft_versions.*.submit_button"
- "admin.legislation.questions.*.submit_button"
- "admin.hidden_comments.index.hidden_*"

View File

@@ -584,11 +584,10 @@ en:
title: Create new collaborative legislation process
submit_button: Create process
proposals:
select_order: Sort by
orders:
id: Id
title: Title
supports: Total supports
id: "Sort by ID"
title: "Sort by title"
supports: "Sort by total supports"
process:
title: Process
comments: Comments

View File

@@ -584,11 +584,10 @@ es:
title: Crear nuevo proceso de legislación colaborativa
submit_button: Crear proceso
proposals:
select_order: Ordenar por
orders:
id: Id
title: Título
supports: Apoyos totales
id: "Ordenar por ID"
title: "Ordenar por título"
supports: "Ordenar por apoyos totales"
process:
title: Proceso
comments: Comentarios

View File

@@ -33,7 +33,7 @@ describe "Admin collaborative legislation", :admin do
create(:legislation_proposal, title: "cccc", legislation_process_id: process.id)
visit admin_legislation_process_proposals_path(process.id)
select "Title", from: "order-selector-participation"
click_link "Sort by title"
within("#legislation_proposals_list") do
within all(".legislation_proposal")[0] { expect(page).to have_content("aaaa") }
@@ -49,7 +49,7 @@ describe "Admin collaborative legislation", :admin do
create(:legislation_proposal, cached_votes_score: 20, legislation_process_id: process.id)
visit admin_legislation_process_proposals_path(process.id)
select "Total supports", from: "order-selector-participation"
click_link "Sort by total supports"
within("#legislation_proposals_list") do
within all(".legislation_proposal")[0] { expect(page).to have_content("30") }
@@ -65,7 +65,7 @@ describe "Admin collaborative legislation", :admin do
proposal3 = create(:legislation_proposal, title: "cccc", legislation_process_id: process.id)
visit admin_legislation_process_proposals_path(process.id, order: :title)
select "Id", from: "order-selector-participation"
click_link "Sort by ID"
within("#legislation_proposals_list") do
within all(".legislation_proposal")[0] { expect(page).to have_content(proposal1.id) }