Add proper labels to shift date selectors
We were using one label for both date selectors, but it wasn't associated with any of them. So we're now rendering one label per control and, just like we only show one of these date selectors at a time, we're only showing one label at a time.
This commit is contained in:
@@ -6,12 +6,12 @@
|
||||
change: function() {
|
||||
switch ($(this).val()) {
|
||||
case "vote_collection":
|
||||
$("select[class='js-shift-vote-collection-dates']").show();
|
||||
$("select[class='js-shift-recount-scrutiny-dates']").hide();
|
||||
$(".js-shift-vote-collection-dates").show();
|
||||
$(".js-shift-recount-scrutiny-dates").hide();
|
||||
break;
|
||||
case "recount_scrutiny":
|
||||
$("select[class='js-shift-recount-scrutiny-dates']").show();
|
||||
$("select[class='js-shift-vote-collection-dates']").hide();
|
||||
$(".js-shift-recount-scrutiny-dates").show();
|
||||
$(".js-shift-vote-collection-dates").hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -20,11 +20,18 @@
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-3 column">
|
||||
<label><%= t("admin.poll_shifts.new.date") %></label>
|
||||
<%= label_tag :shift_date_vote_collection_date,
|
||||
t("admin.poll_shifts.new.date"),
|
||||
class: "js-shift-vote-collection-dates" %>
|
||||
<%= select "shift[date]", "vote_collection_date",
|
||||
options_for_select(shift_vote_collection_dates),
|
||||
{ prompt: voting_polls.present? ? t("admin.poll_shifts.new.select_date") : t("admin.poll_shifts.new.no_voting_days") },
|
||||
class: "js-shift-vote-collection-dates" %>
|
||||
|
||||
<%= label_tag :shift_date_recount_scrutiny_date,
|
||||
t("admin.poll_shifts.new.date"),
|
||||
class: "js-shift-recount-scrutiny-dates",
|
||||
hidden: "hidden" %>
|
||||
<%= select "shift[date]", "recount_scrutiny_date",
|
||||
options_for_select(shift_recount_scrutiny_dates),
|
||||
{ prompt: t("admin.poll_shifts.new.select_date") },
|
||||
|
||||
@@ -53,10 +53,10 @@ describe "Admin shifts", :admin do
|
||||
click_button "Search"
|
||||
click_link "Edit shifts"
|
||||
|
||||
expect(page).to have_select("shift_date_vote_collection_date",
|
||||
options: ["Select day", *vote_collection_dates])
|
||||
expect(page).not_to have_select("shift_date_recount_scrutiny_date")
|
||||
select I18n.l(Date.current, format: :long), from: "shift_date_vote_collection_date"
|
||||
expect(page).to have_select "Date", options: ["Select day", *vote_collection_dates]
|
||||
expect(page).not_to have_select with_options: recount_scrutiny_dates
|
||||
|
||||
select I18n.l(Date.current, format: :long), from: "Date"
|
||||
click_button "Add shift"
|
||||
|
||||
expect(page).to have_content "Shift added"
|
||||
@@ -82,10 +82,9 @@ describe "Admin shifts", :admin do
|
||||
|
||||
select "Recount & Scrutiny", from: "shift_task"
|
||||
|
||||
expect(page).to have_select("shift_date_recount_scrutiny_date",
|
||||
options: ["Select day", *recount_scrutiny_dates])
|
||||
expect(page).not_to have_select("shift_date_vote_collection_date")
|
||||
select I18n.l(poll.ends_at.to_date + 4.days, format: :long), from: "shift_date_recount_scrutiny_date"
|
||||
expect(page).to have_select "Date", options: ["Select day", *recount_scrutiny_dates]
|
||||
expect(page).not_to have_select with_options: vote_collection_dates
|
||||
select I18n.l(poll.ends_at.to_date + 4.days, format: :long), from: "Date"
|
||||
click_button "Add shift"
|
||||
|
||||
expect(page).to have_content "Shift added"
|
||||
@@ -126,11 +125,9 @@ describe "Admin shifts", :admin do
|
||||
click_button "Search"
|
||||
click_link "Edit shifts"
|
||||
|
||||
expect(page).to have_select("shift_date_vote_collection_date",
|
||||
options: ["Select day", *vote_collection_dates])
|
||||
expect(page).to have_select "Date", options: ["Select day", *vote_collection_dates]
|
||||
select "Recount & Scrutiny", from: "shift_task"
|
||||
expect(page).to have_select("shift_date_recount_scrutiny_date",
|
||||
options: ["Select day", *recount_scrutiny_dates])
|
||||
expect(page).to have_select "Date", options: ["Select day", *recount_scrutiny_dates]
|
||||
end
|
||||
|
||||
scenario "Change option from Recount & Scrutinity to Collect Votes" do
|
||||
@@ -144,11 +141,11 @@ describe "Admin shifts", :admin do
|
||||
|
||||
select "Recount & Scrutiny", from: "shift_task"
|
||||
|
||||
expect(page).to have_select("shift_date_recount_scrutiny_date", options: ["Select day"])
|
||||
expect(page).to have_select "Date", options: ["Select day"]
|
||||
|
||||
select "Collect Votes", from: "shift_task"
|
||||
|
||||
expect(page).to have_select("shift_date_vote_collection_date", options: ["Voting days ended"])
|
||||
expect(page).to have_select "Date", options: ["Voting days ended"]
|
||||
end
|
||||
|
||||
scenario "Error on create" do
|
||||
|
||||
Reference in New Issue
Block a user