Show the time when a poll starts and ends

This is consistent with the way we show the duration of a budget and its
phases. Since budgets are the section with the most recent changes in
the admin area, we're using it as a reference.

Note that, unlike budgets (which are shown to finish at the beginning of
their ending day), a poll has always been considered to finish at the
end of their ending day, so we're showing it this way.

We're also solving a minor usability issue. While it's pretty intuitive
that a poll starting on a certain date will start at the beginning of
the day, a poll ending on a certain date isn't clear about when it
finishes exactly: is it at the beginning of the day, or at the end of
the day?

So now we're making this point clear.
This commit is contained in:
Javi Martín
2022-09-06 01:50:00 +02:00
parent eaafc7a438
commit 67d13d2899
4 changed files with 8 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
<tr id="<%= dom_id(poll) %>" class="poll">
<td><strong><%= poll.name %></strong></td>
<td class="text-center"><%= l poll.starts_at.to_date %></td>
<td class="text-center"><%= l poll.ends_at.to_date %></td>
<td class="text-center"><%= l poll.starts_at.beginning_of_day, format: :short_datetime %></td>
<td class="text-center"><%= l poll.ends_at.end_of_day, format: :short_datetime %></td>
<% if feature?(:sdg) %>
<td class="text-center"><%= poll.sdg_goal_list %></td>
<td class="text-center"><%= poll.sdg_target_list %></td>

View File

@@ -12,7 +12,7 @@
<div class="inline-block">
<strong><%= t("admin.polls.index.dates") %></strong>
<br>
<%= l @poll.starts_at.to_date %> - <%= l @poll.ends_at.to_date %>
<%= render Admin::DateRangeComponent.new(@poll.starts_at.beginning_of_day, @poll.ends_at.end_of_day) %>
</div>
<% if @poll.geozone_restricted %>

View File

@@ -67,8 +67,8 @@ describe "Admin polls", :admin do
expect(page).to have_content "Poll created successfully"
expect(page).to have_content "Upcoming poll"
expect(page).to have_content I18n.l(start_date)
expect(page).to have_content I18n.l(end_date)
expect(page).to have_content "#{I18n.l(start_date)} 00:00"
expect(page).to have_content "#{I18n.l(end_date)} 23:59"
visit poll_path(id: "upcoming-poll")
@@ -93,7 +93,7 @@ describe "Admin polls", :admin do
expect(page).to have_content "Poll updated successfully"
expect(page).to have_content "Next Poll"
expect(page).to have_content I18n.l(end_date.to_date)
expect(page).to have_content "#{I18n.l(end_date)} 23:59"
end
scenario "Edit from index" do

View File

@@ -12,8 +12,8 @@ describe "Admin Budgets", :admin do
expect(page).to have_current_path(/admin\/polls\/\d+/)
expect(page).to have_content(budget.name)
expect(page).to have_content(balloting_phase.starts_at.to_date)
expect(page).to have_content(balloting_phase.ends_at.to_date)
expect(page).to have_content("#{balloting_phase.starts_at.to_date} 00:00")
expect(page).to have_content("#{balloting_phase.ends_at.to_date} 23:59")
end
scenario "Create poll in current locale if the budget does not have a poll associated" do