adds question, booth and officer tabs for a poll
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
class Poll < ActiveRecord::Base
|
||||
has_many :booths
|
||||
has_many :voters, through: :booths, class_name: "Poll::Voter"
|
||||
has_many :officers, through: :booths, class_name: "Poll::Officer"
|
||||
has_many :questions
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
26
app/views/admin/poll/polls/_booths.html.erb
Normal file
26
app/views/admin/poll/polls/_booths.html.erb
Normal file
@@ -0,0 +1,26 @@
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<% if @poll.booths.empty? %>
|
||||
<div class="callout primary text-center">
|
||||
<%= t("admin.polls.show.no_booths") %>
|
||||
</div>
|
||||
<% else %>
|
||||
|
||||
<h2><%= t("admin.polls.show.booths_title") %></h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<th><%= t("admin.polls.show.name") %></th>
|
||||
<th><%= t("admin.polls.show.location") %></th>
|
||||
<th><%= t("admin.polls.show.officers") %></th>
|
||||
<th> </th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @poll.booths.each do |booth| %>
|
||||
<%= render partial: "admin/poll/booths/booth", locals: { booth: booth } %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
33
app/views/admin/poll/polls/_filter_subnav.html.erb
Normal file
33
app/views/admin/poll/polls/_filter_subnav.html.erb
Normal file
@@ -0,0 +1,33 @@
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<ul class="tabs" data-tabs id="example-tabs">
|
||||
<li class="tabs-title is-active">
|
||||
<%= link_to "#tab-questions" do %>
|
||||
<h2>
|
||||
<%# t("proposals.show.comments_tab") %>
|
||||
Preguntas
|
||||
<span class="js-comments-count">(<%= @poll.questions.count %>)</span>
|
||||
</h2>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="tabs-title">
|
||||
<%= link_to "#tab-booths" do %>
|
||||
<h2>
|
||||
<%# t("proposals.show.notifications_tab") %>
|
||||
Urnas
|
||||
(<%= @poll.booths.count %>)
|
||||
</h2>
|
||||
<% end %>
|
||||
</li>
|
||||
<li class="tabs-title">
|
||||
<%= link_to "#tab-officers" do %>
|
||||
<h2>
|
||||
<%# t("proposals.show.notifications_tab") %>
|
||||
Presidentes
|
||||
(<%= @poll.officers.count %>)
|
||||
</h2>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
43
app/views/admin/poll/polls/_officers.html.erb
Normal file
43
app/views/admin/poll/polls/_officers.html.erb
Normal file
@@ -0,0 +1,43 @@
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<% if @poll.officers.empty? %>
|
||||
<div class="callout primary text-center">
|
||||
<%= t("admin.polls.show.no_booths") %>
|
||||
</div>
|
||||
<% else %>
|
||||
|
||||
<h2><%= t("admin.polls.show.booths_title") %></h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<th><%= t("admin.polls.show.name") %></th>
|
||||
<th><%= t("admin.polls.show.location") %></th>
|
||||
<th><%= t("admin.polls.show.officers") %></th>
|
||||
<th> </th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @poll.officers.each do |officer| %>
|
||||
<tr id="officer_<%= officer.id %>" class="officer">
|
||||
<td>
|
||||
<strong>
|
||||
<%= link_to officer.name, admin_poll_officer_path(@poll, booth) %>
|
||||
</strong>
|
||||
</td>
|
||||
<td>
|
||||
<%= officer.name %>
|
||||
</td>
|
||||
<td>
|
||||
N <%= t("admin.booths.index.officers") %>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<%= link_to t("admin.actions.edit"),
|
||||
edit_admin_poll_officer_path(@poll, officer),
|
||||
class: "button hollow" %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
29
app/views/admin/poll/polls/_questions.html.erb
Normal file
29
app/views/admin/poll/polls/_questions.html.erb
Normal file
@@ -0,0 +1,29 @@
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<%= link_to "Añadir pregunta",
|
||||
new_admin_question_path(poll_id: @poll.id),
|
||||
class: "button success" %>
|
||||
</div>
|
||||
<% if @poll.questions.count == 0 %>
|
||||
<div class="callout primary text-center">
|
||||
<%= t('admin.questions.index.no_questions') %>
|
||||
</div>
|
||||
<% else %>
|
||||
<table>
|
||||
<% @poll.questions.each do |question| %>
|
||||
<tr id="<%= dom_id(question) %>">
|
||||
<td><%= link_to question.title, admin_question_path(question) %></td>
|
||||
<td class="text-right">
|
||||
<%= link_to t('shared.edit'),
|
||||
edit_admin_question_path(question),
|
||||
class: "button hollow" %>
|
||||
<%= link_to t('shared.delete'),
|
||||
admin_question_path(question),
|
||||
class: "button hollow alert",
|
||||
method: :delete %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -9,28 +9,18 @@
|
||||
edit_admin_poll_path(@poll),
|
||||
class: "button hollow float-right" %>
|
||||
|
||||
<%= link_to t("admin.polls.show.add_booth"),
|
||||
new_admin_poll_booth_path(@poll),
|
||||
class: "button success" %>
|
||||
<div class="tabs-content" data-tabs-content="example-tabs">
|
||||
<%= render "filter_subnav" %>
|
||||
|
||||
<% if @poll.booths.empty? %>
|
||||
<div class="callout primary">
|
||||
<%= t("admin.polls.show.no_booths") %>
|
||||
<div class="tabs-panel is-active" id="tab-questions">
|
||||
<%= render "questions" %>
|
||||
</div>
|
||||
<% else %>
|
||||
<h2><%= t("admin.polls.show.booths_title") %></h2>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<th><%= t("admin.polls.show.name") %></th>
|
||||
<th><%= t("admin.polls.show.location") %></th>
|
||||
<th><%= t("admin.polls.show.officers") %></th>
|
||||
<th> </th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @poll.booths.each do |booth| %>
|
||||
<%= render partial: "admin/poll/booths/booth", locals: { booth: booth } %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
<div class="tabs-panel" id="tab-booths">
|
||||
<%= render "booths" %>
|
||||
</div>
|
||||
|
||||
<div class="tabs-panel" id="tab-officers">
|
||||
<%= render 'officers' %>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user