Add Task selection on Poll Shift creation, and on shifts table

This commit is contained in:
Bertocq
2017-09-27 14:05:25 +02:00
parent 1dde4cb3ec
commit ce92dcd088
5 changed files with 22 additions and 4 deletions

View File

@@ -54,7 +54,7 @@ class Admin::Poll::ShiftsController < Admin::Poll::BaseController
end
def shift_params
params.require(:shift).permit(:booth_id, :officer_id, :date)
params.require(:shift).permit(:booth_id, :officer_id, :date, :task)
end
end

View File

@@ -6,13 +6,21 @@
<%= t("admin.poll_shifts.new.new_shift") %>
</legend>
<div class="small-12 medium-4 column highlight padding">
<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-4 column">
<div class="small-12 medium-3 column">
<label><%= t("admin.poll_shifts.new.task") %></label>
<%= f.select :task,
Poll::Shift.tasks.map {|k,v| [t("admin.poll_shifts.#{k}"), k]},
prompt: t("admin.poll_shifts.new.select_task"),
label: false %>
</div>
<div class="small-12 medium-3 column">
<label><%= t("admin.poll_shifts.new.date") %></label>
<%= f.select :date,
shift_dates_select_options(@polls),
@@ -22,7 +30,7 @@
<%= f.hidden_field :booth_id, value: @booth.id %>
<div class="small-12 medium-4 column">
<div class="small-12 medium-3 column">
<%= f.submit t("admin.poll_shifts.new.add_shift"),
class: "button expanded margin-top" %>
</div>

View File

@@ -4,6 +4,7 @@
<tr>
<th><%= t("admin.poll_shifts.new.date") %></th>
<th><%= t("admin.poll_shifts.new.officer") %></th>
<th><%= t("admin.poll_shifts.new.task") %></th>
<th class="text-right"><%= t("admin.poll_shifts.new.shift") %></th>
</tr>
</thead>
@@ -12,6 +13,7 @@
<tr id="shift_<%= shift.id %>" class="shift">
<td><%= l(shift.date.to_date, format: :long) %></td>
<td><%= shift.officer_name %></td>
<td><%= t("admin.poll_shifts.#{shift.task}") %></td>
<td class="text-right">
<%= link_to t("admin.poll_shifts.new.remove_shift"),
admin_booth_shift_path(@booth, shift),