adds successful proposals list on admin questions index

This commit is contained in:
Alberto Garcia Cabeza
2016-12-23 14:16:29 +01:00
parent e26b6db584
commit c0c76b67c2
7 changed files with 75 additions and 20 deletions

View File

@@ -9,6 +9,8 @@ class Admin::Poll::QuestionsController < Admin::BaseController
@search = search_params[:search] @search = search_params[:search]
@questions = @questions.search(search_params).page(params[:page]).order("created_at DESC") @questions = @questions.search(search_params).page(params[:page]).order("created_at DESC")
@proposals = Proposal.successful.sort_by_confidence_score
end end
def new def new
@@ -51,6 +53,10 @@ class Admin::Poll::QuestionsController < Admin::BaseController
redirect_to admin_questions_path, notice: notice redirect_to admin_questions_path, notice: notice
end end
def successful?
total_votes >= Proposal.votes_needed_for_success
end
private private
def load_geozones def load_geozones

View File

@@ -0,0 +1,12 @@
<ul class="tabs" data-tabs id="questions-tabs">
<li class="tabs-title is-active">
<%= link_to "#tab-questions" do %>
<%= t("admin.questions.index.questions_tab") %>
<% end %>
</li>
<li class="tabs-title">
<%= link_to "#tab-successful-proposals" do %>
<%= t("admin.questions.index.successful_proposals_tab") %>
<% end %>
</li>
</ul>

View File

@@ -0,0 +1,23 @@
<div class="small-12 medium-4 large-3">
<%= render 'filter' %>
</div>
<% if @questions.count == 0 %>
<div class="callout primary margin-top">
<%= t('admin.questions.index.no_questions') %>
</div>
<% else %>
<table>
<% @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>
<%= paginate @questions %>
<% end %>

View File

@@ -0,0 +1,20 @@
<table>
<tbody>
<% @proposals.each do |proposal| %>
<tr id="<%= dom_id(proposal) %>">
<td>
<%= link_to proposal.title, proposal_path(proposal) %>
<p>
<%= proposal.summary %><br>
<strong><%= proposal.question %></strong>
</p>
</td>
<td class="text-right">
<%= link_to t("admin.questions.index.create_question"),
new_admin_question_path(proposal_id: proposal.id),
class: "button hollow" %>
</td>
</tr>
<% end %>
</tbody>
</table>

View File

@@ -9,26 +9,14 @@
</div> </div>
</div> </div>
<div class="small-12 medium-4 large-3"> <div class="tabs-content" data-tabs-content="questions-tabs">
<%= render 'filter' %> <%= render "filter_subnav" %>
</div>
<% if @questions.count == 0 %> <div class="tabs-panel is-active" id="tab-questions">
<div class="callout primary margin-top"> <%= render "questions" %>
<%= t('admin.questions.index.no_questions') %>
</div> </div>
<% else %>
<table>
<% @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>
<%= paginate @questions %> <div class="tabs-panel" id="tab-successful-proposals">
<% end %> <%= render "successful_proposals" %>
</div>
</div>

View File

@@ -200,6 +200,9 @@ en:
no_questions: "There are no questions." no_questions: "There are no questions."
filter_poll: Filter by Poll filter_poll: Filter by Poll
select_poll: Select Poll select_poll: Select Poll
questions_tab: "Questions"
successful_proposals_tab: "Successful proposals"
create_question: "Create question"
edit: edit:
title: "Edit Question" title: "Edit Question"
new: new:

View File

@@ -200,6 +200,9 @@ es:
no_questions: "No hay ninguna pregunta ciudadana." no_questions: "No hay ninguna pregunta ciudadana."
filter_poll: "Filtrar por votación" filter_poll: "Filtrar por votación"
select_poll: "Seleccionar votación" select_poll: "Seleccionar votación"
questions_tab: "Preguntas ciudadanas"
successful_proposals_tab: "Propuestas que han superado el umbral"
create_question: "Crear pregunta para votación"
edit: edit:
title: "Editar pregunta ciudadana" title: "Editar pregunta ciudadana"
new: new: