assigns officers to booths
This commit is contained in:
@@ -8,6 +8,7 @@ class Admin::Poll::BoothsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def show
|
||||
@officers = Poll::Officer.all
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -35,7 +36,7 @@ class Admin::Poll::BoothsController < Admin::BaseController
|
||||
private
|
||||
|
||||
def booth_params
|
||||
params.require(:poll_booth).permit(:name, :location)
|
||||
params.require(:poll_booth).permit(:name, :location, officer_ids: [])
|
||||
end
|
||||
|
||||
def load_polls
|
||||
|
||||
7
app/helpers/officers_helper.rb
Normal file
7
app/helpers/officers_helper.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
module OfficersHelper
|
||||
|
||||
def officer_label(officer)
|
||||
truncate([officer.name, officer.email].compact.join(' - '), length: 100)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -2,6 +2,8 @@ class Poll
|
||||
class Booth < ActiveRecord::Base
|
||||
belongs_to :poll
|
||||
has_many :voters
|
||||
has_many :officing_booths, dependent: :destroy
|
||||
has_many :officers, through: :officing_booths
|
||||
|
||||
validates :name, presence: true
|
||||
end
|
||||
|
||||
6
app/models/poll/officing_booth.rb
Normal file
6
app/models/poll/officing_booth.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
class Poll
|
||||
class OfficingBooth < ActiveRecord::Base
|
||||
belongs_to :officer
|
||||
belongs_to :booth
|
||||
end
|
||||
end
|
||||
@@ -15,34 +15,32 @@
|
||||
|
||||
<h3><%= t("admin.booths.show.officers_list") %></h3>
|
||||
|
||||
<!-- If officers in this booth == 0 -->
|
||||
<div class="callout primary">
|
||||
<%= t("admin.booths.show.no_officers") %>
|
||||
</div>
|
||||
<!-- end -->
|
||||
|
||||
<%= link_to t("admin.booths.show.assign_officer"), "#", class: "button success" %>
|
||||
<% if @booth.officers.empty? %>
|
||||
<div class="callout primary">
|
||||
<%= t("admin.booths.show.no_officers") %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="small-12 column">
|
||||
<!-- List of officers, something like:
|
||||
"/admin/spending_proposals/_assigned_valuators.html.erb" -->
|
||||
<%# f.label :valuator_ids, t("admin.spending_proposals.edit.assigned_valuators") %>
|
||||
<%= form_for @booth, url: admin_poll_booth_path(@poll, @booth) do |f| %>
|
||||
|
||||
<%# f.collection_check_boxes :valuator_ids, @valuators, :id, :email do |b| %>
|
||||
<%# b.label(title: valuator_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %>
|
||||
<%# end %>
|
||||
<%= f.label :officer_ids, t("admin.spending_proposals.edit.assigned_valuators") %>
|
||||
<%= f.collection_check_boxes :officer_ids, @officers, :id, :email do |b| %>
|
||||
<% b.label { b.check_box + truncate(officer_label(b.object), length: 60) } %>
|
||||
<% end %>
|
||||
|
||||
<%= f.submit t("admin.booths.show.assign_officer"), class: "button success" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<table>
|
||||
<%# @officers.each do |officer| %>
|
||||
<tr>
|
||||
<table id="assigned_officers">
|
||||
<% @booth.officers.each do |officer| %>
|
||||
<tr id="officer_<%= officer.id %>" class="officer">
|
||||
<td>
|
||||
<%# officer.name %>
|
||||
Admin
|
||||
<%= officer.name %>
|
||||
</td>
|
||||
<td>
|
||||
admin@consul.dev
|
||||
<%# officer.email %>
|
||||
<%= officer.email %>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<%= link_to t('admin.poll_officers.officer.delete'), "#", class: "button hollow alert" %>
|
||||
@@ -53,5 +51,5 @@
|
||||
%>
|
||||
</td>
|
||||
</tr>
|
||||
<%# end %>
|
||||
<% end %>
|
||||
</table>
|
||||
Reference in New Issue
Block a user