Add milestones to investments show.

This commit is contained in:
taitus
2017-06-22 17:04:21 +02:00
parent 87eeb45584
commit c58371a5fe
7 changed files with 126 additions and 2 deletions

View File

@@ -0,0 +1,41 @@
<% commentable = comment_tree.commentable %>
<% current_order = comment_tree.order %>
<% cache [locale_and_user_status, current_order, commentable_cache_key(commentable), comment_tree.comments, comment_tree.comment_authors, commentable.comments_count, comment_flags] do %>
<section class="expanded comments">
<div class="row">
<div id="comments" class="small-12 column">
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
<% if user_signed_in? %>
<% if comments_closed_for_commentable?(commentable) %>
<br>
<div data-alert class="callout primary">
<%= comments_closed_text(commentable) %>
</div>
<% elsif require_verified_resident_for_commentable?(commentable, current_user) %>
<br>
<div data-alert class="callout primary">
<%= t("comments.verified_only", verify_account: link_to(t("comments.verify_account"), verification_path )).html_safe %>
</div>
<% else %>
<%= render 'comments/form', {commentable: commentable, parent_id: nil, toggeable: false} %>
<% end %>
<% else %>
<br>
<div data-alert class="callout primary">
<%= t("debates.show.login_to_comment",
signin: link_to(t("votes.signin"), new_user_session_path),
signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %>
</div>
<% end %>
<% comment_tree.root_comments.each do |comment| %>
<%= render 'comments/comment', {comment: comment, comment_flags: comment_flags} %>
<% end %>
<%= paginate comment_tree.root_comments %>
</div>
</div>
</section>
<% end %>

View File

@@ -0,0 +1,22 @@
<div class="row">
<div class="small-12 column">
<ul class="tabs" data-tabs id="investments-tabs">
<li class="tabs-title is-active">
<%= link_to "#tab-comments" do %>
<h3>
<%= t("budgets.investments.show.comments_tab") %>
<span class="js-comments-count">(<%= @investment.comments_count %>)</span>
</h3>
<% end %>
</li>
<li class="tabs-title">
<%= link_to "#tab-milestones" do %>
<h3>
<%= t("budgets.investments.show.milestones_tab") %>
(<%= @investment.milestones.count %>)
</h3>
<% end %>
</li>
</ul>
</div>
</div>

View File

@@ -0,0 +1,16 @@
<div class="tabs-panel" id="tab-milestones">
<div class="row">
<div class="small-12 column">
<% if @investment.milestones.blank? %>
<div class="callout primary text-center">
<%= t('budgets.investments.show.no_milestones') %>
</div>
<% end %>
<% @investment.milestones.each do |milestone| %>
<h3><%= milestone.title %></h3>
<p><%= milestone.description %></p>
<% end %>
</div>
</div>
</div>

View File

@@ -10,4 +10,11 @@
ballot: @ballot ballot: @ballot
} %> } %>
<%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, comment_flags: @comment_flags } %> <div class="tabs-content" data-tabs-content="investments-tabs" role="tablist">
<%= render "budgets/investments/filter_subnav" %>
<%= render "budgets/investments/milestones" %>
<div class="tabs-panel is-active" id="tab-comments">
<%= render partial: 'budgets/investments/comments', locals: { comment_tree: @comment_tree, comment_flags: @comment_flags } %>
</div>
</div>

View File

@@ -93,6 +93,9 @@ en:
supports: Supports supports: Supports
votes: Votes votes: Votes
price: Price price: Price
comments_tab: Comments
milestones_tab: Milestones
no_milestones: Don't have defined milestones
wrong_price_format: Only integer numbers wrong_price_format: Only integer numbers
investment: investment:
add: Vote add: Vote
@@ -131,4 +134,4 @@ en:
price: Cost price: Cost
amount_available: Available budget amount_available: Available budget
accepted: "Accepted spending proposal: " accepted: "Accepted spending proposal: "
discarded: "Discarded spending proposal: " discarded: "Discarded spending proposal: "

View File

@@ -93,6 +93,9 @@ es:
supports: Apoyos supports: Apoyos
votes: Votos votes: Votos
price: Coste price: Coste
comments_tab: Comentarios
milestones_tab: Seguimiento
no_milestones: No hay hitos definidos
wrong_price_format: Solo puede incluir caracteres numéricos wrong_price_format: Solo puede incluir caracteres numéricos
investment: investment:
add: Votar add: Votar

View File

@@ -389,6 +389,38 @@ feature 'Budget Investments' do
expect(page).to have_content(investment.unfeasibility_explanation) expect(page).to have_content(investment.unfeasibility_explanation)
end end
scenario "Show milestones", :js do
user = create(:user)
login_as(user)
investment = create(:budget_investment)
milestone = create(:budget_investment_milestone, investment: investment, title: "New text to show")
visit budget_investment_path(budget_id: investment.budget.id, id: investment.id)
find("#tab-milestones-label").trigger('click')
within("#tab-milestones") do
expect(page).to have_content(milestone.title)
expect(page).to have_content(milestone.description)
end
end
scenario "Show no_milestones text", :js do
user = create(:user)
login_as(user)
investment = create(:budget_investment)
visit budget_investment_path(budget_id: investment.budget.id, id: investment.id)
find("#tab-milestones-label").trigger('click')
within("#tab-milestones") do
expect(page).to have_content("Don't have defined milestones")
end
end
context "Destroy" do context "Destroy" do
scenario "Admin cannot destroy budget investments" do scenario "Admin cannot destroy budget investments" do