Move poll shifts form partial to a component

Thanks to it, we can move a few helper methods to the component.
This commit is contained in:
Javi Martín
2024-10-12 18:23:54 +02:00
parent 9ab6c15975
commit ee34ead4ee
7 changed files with 67 additions and 54 deletions

View File

@@ -1,42 +0,0 @@
<%= form_for @shift, as: :shift, url: admin_booth_shifts_path do |f| %>
<%= render "shared/errors", resource: @shift %>
<fieldset class="fieldset">
<legend>
<%= t("admin.poll_shifts.new.new_shift") %>
</legend>
<div class="small-12 medium-3 column highlight padding">
<strong><%= t("admin.poll_shifts.new.officer") %></strong>
<br><%= @officer.name %>
<%= f.hidden_field :officer_id, value: @officer.id %>
</div>
<div class="small-12 medium-3 column">
<%= f.select :task,
Poll::Shift.tasks.map { |k, v| [t("admin.poll_shifts.#{k}"), k] },
{ prompt: t("admin.poll_shifts.new.select_task") },
class: "js-poll-shifts" %>
</div>
<div class="small-12 medium-3 column">
<label><%= t("admin.poll_shifts.new.date") %></label>
<%= select "shift[date]", "vote_collection_date",
options_for_select(shift_vote_collection_dates(@booth, @voting_polls)),
{ 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" %>
<%= select "shift[date]", "recount_scrutiny_date",
options_for_select(shift_recount_scrutiny_dates(@booth, @recount_polls)),
{ prompt: t("admin.poll_shifts.new.select_date") },
class: "js-shift-recount-scrutiny-dates",
hidden: "hidden" %>
</div>
<%= f.hidden_field :booth_id, value: @booth.id %>
<div class="small-12 medium-3 column">
<%= f.submit t("admin.poll_shifts.new.add_shift"),
class: "button expanded margin-top" %>
</div>
</fieldset>
<% end %>

View File

@@ -8,7 +8,7 @@
</p>
<%= render "search_officers" %>
<% else %>
<%= render "form" %>
<%= render Admin::Poll::Shifts::FormComponent.new(@shift, booth: @booth, officer: @officer) %>
<% end %>
<div id="shifts">