Adds a lot of views (WIP)

This commit is contained in:
kikito
2016-06-07 11:12:58 +02:00
parent 43aec952bf
commit 630a4878a8
12 changed files with 351 additions and 6 deletions

View File

@@ -0,0 +1,16 @@
<div class="add in-favor">
<p class="investment-project-amount">
<%= format_price(@budget, investment.price) %>
</p>
<% if @budget.balloting? %>
<%= link_to budget_ballot_lines_url(investment_id: investment.id,
investments_ids: @ballot.investment_ids),
class: "button button-support small expanded",
title: t('investments.investment.support_title'),
method: "post",
remote: true do %>
<%= t("investments.investment.add") %>
<% end %>
<% end %>
</div>

View File

@@ -0,0 +1,97 @@
<div class="row ballot">
<%= link_to :back, class: "back" do %>
<span class="icon-angle-left"></span>
<%= t("shared.back") %>
<% end %>
<h1 class="text-center"><%= t("budgets.ballots.show.title") %></h1>
<div class="small-12 medium-8 column small-centered text-center">
<h2>
<%= t("budgets.ballots.show.voted_html",
count: @ballot.investments.count) %>
</h2>
<% if @ballot.geozone.present? && district_wide_amount_spent(@ballot) > 0 %>
<%= social_share_button_tag("#{t('budgets.ballots.show.social_share',
amount: format_price(district_wide_amount_spent(@ballot)),
geozone: @ballot.geozone.name)} #{setting['twitter_hashtag']}",
url: participatory_budget_url) %>
<% end %>
<h3>
<%= t("ballots.show.remaining_city_html",
amount_city: format_price(@ballot.amount_available(nil))) %>
</h3>
<% if @ballot.geozone.present? %>
<h3>
<%= t("budgets.ballots.show.remaining_district_html",
amount_district: format_price(@ballot.amount_available(@ballot.geozone)),
geozone: @ballot.geozone.name) %>
</h3>
<% end %>
<p>
<small>
<%= t("budgets.ballots.show.voted_info_html") %>
</small>
</p>
</div>
<hr>
<div class="margin-top">
<div id="city_wide" class="small-12 medium-6 column">
<h3 class="subtitle">
<%= t("budgets.ballots.show.city_wide") %>
</h3>
<% if @ballot.investments.by_geozone(nil).count > 0 %>
<h4 class="amount-spent text-right">
<%= t("budgets.ballots.show.amount_spent") %>
<span><%= format_price(city_wide_amount_spent(@ballot)) %></span>
</h4>
<% else %>
<p>
<%= t("budgets.ballots.show.zero") %><br>
<%= link_to t("ballots.show.city_link"),
investments_path(geozone: 'all'),
data: { no_turbolink: true } %>
</p>
<% end %>
<ul class="ballot-list">
<%= render partial: 'budgets/ballots/investment',
collection: @ballot.investments.no_heading %>
</ul>
</div>
<div id="district_wide" class="small-12 medium-6 column">
<h3 class="subtitle">
<%= t("ballots.show.district_wide") %>
<span>
<% if @ballot.geozone.present? %>
(<%= @ballot.geozone.name %>)
<% end %>
</span>
</h3>
<% if @ballot.geozone.present? %>
<h4 class="amount-spent text-right">
<%= t("ballots.show.amount_spent") %>
<span><%= format_price(district_wide_amount_spent(@ballot)) %></span>
</h4>
<% else %>
<p>
<%= t("ballots.show.zero") %><br>
<%= link_to t("budget.ballots.show.districts_link"), select_district_path %>
</p>
<% end %>
<ul class="ballot-list">
<%= render partial: 'budgets/ballots/investment',
collection: @ballot.investments.with_heading %>
</ul>
</div>
</div>
</div>

View File

@@ -0,0 +1,14 @@
<li id="<%= dom_id(investment) %>">
<%= link_to investment.title, investment %>
<span><%= format_price(investment.price) %></span>
<% if @budget.balloting? %>
<%= link_to ballot_line_path(id: investment.id),
title: t('ballots.show.remove'),
class: "remove-investment-project",
method: :delete,
remote: true do %>
<span class="icon-x"></span>
<% end %>
<% end %>
</li>

View File

@@ -0,0 +1,15 @@
<li id="<%= dom_id(investment) %>_sidebar">
<%= investment.title %>
<span><%= format_price(investment.price) %></span>
<% if @budget.balloting? %>
<%= link_to ballot_line_path(id: investment.id,
investments_ids: investment_ids),
title: t('ballots.show.remove'),
class: "remove-investment-project",
method: :delete,
remote: true do %>
<span class="icon-x delete"></span>
<% end %>
<% end %>
</li>

View File

@@ -0,0 +1,18 @@
<div class="remove supported inline-block">
<span class="icon-check-circle bounceIn animated"
title="<%= t("budget.investments.investment.already_added") %>">
</span>
<p class="investment-project-amount">
<%= format_price(investment.price) %>
</p>
<% if @budget.balloting? %>
<%= link_to t('ballots.show.remove'),
ballot_line_path(id: investment.id,
investments_ids: investment_ids),
class: "delete small expanded",
method: :delete,
remote: true %>
<% end %>
</div>

View File

@@ -0,0 +1,3 @@
<div id="ballot">
<%= render partial: "ballots/ballot" %>
</div>

View File

@@ -2,6 +2,9 @@
<ul>
<% @budgets.each do |budget| %>
<li><%= link_to budget.name, budget %></li>
<li><%= link_to budget do %>
<%= budget.name %>,
<%= budget.phase %>
<% end %></li>
<% end %>
</ul>

View File

@@ -0,0 +1,23 @@
<% reason = investment.reason_for_not_being_ballotable_by(current_user, @ballot) %>
<div class="supports ballot">
<% if @ballot.has_investment?(investment) %>
<%= render 'budgets/ballots/remove', investment: investment %>
<% else %>
<%= render 'budgets/ballots/add', investment: investment %>
<% end %>
<% if reason.present? && !@ballot.has_investment?(investment) %>
<div class="no-supports-allowed" style='display:none'>
<p>
<%= t("votes.budget_investments.#{reason}",
verify_account: link_to(t("votes.verify_account"), verification_path),
signin: link_to(t("votes.signin"), new_user_session_path),
signup: link_to(t("votes.signup"), new_user_registration_path),
my_heading: link_to(@ballot.heading.try(:name), budget_investments_path(budget_id: @budget.id, heading_id: @ballot.heading_id))
).html_safe %>
</p>
</div>
<% end %>
</div>

View File

@@ -0,0 +1,31 @@
<% cache [locale_and_user_status, @current_order, commentable_cache_key(@investment), @comment_tree.comments, @comment_tree.comment_authors, @investment.comments_count, @comment_flags] do %>
<section class="expanded comments">
<div class="row">
<div id="comments" class="small-12 column">
<h2>
<%= t("debates.show.comments_title") %>
<span class="js-comments-count">(<%= @investment.comments_count %>)</span>
</h2>
<%= render 'shared/wide_order_selector', i18n_namespace: "comments" %>
<% if user_signed_in? %>
<%= render 'comments/form', {commentable: @investment, parent_id: nil, toggeable: false} %>
<% 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 %>
<% end %>
<%= paginate @comment_tree.root_comments %>
</div>
</div>
</section>
<% end %>

View File

@@ -1,9 +1,9 @@
<div id="<%= dom_id(investment) %>" class="investment-project clear">
<div id="<%= dom_id(investment) %>" class="budget-investment clear">
<div class="panel">
<div class="row">
<div class="small-12 medium-9 column">
<div class="investment-project-content">
<div class="budget-investment-content">
<% cache [locale_and_user_status(investment), 'index', investment, investment.author] do %>
<span class="label-budget-investment float-left"><%= t("budget.investments.investment.title") %></span>

View File

@@ -0,0 +1,46 @@
<% reason = investment.reason_for_not_being_selectable_by(current_user) %>
<% voting_allowed = true unless reason.presence == :not_voting_allowed %>
<% user_voted_for = voted_for?(@budget_investment_votes, investment) %>
<div class="supports">
<span class="total-supports <%= 'no-button' unless voting_allowed || user_voted_for %>">
<%= t("budget.investments.investment.supports", count: investment.total_votes) %>
</span>
<div class="in-favor">
<% if user_voted_for %>
<div class="supported">
<%= t("budget.investments.investment.already_supported") %>
</div>
<% elsif voting_allowed %>
<%= link_to vote_url,
class: "button button-support small expanded",
title: t('budget.investments.investment.support_title'),
method: "post",
remote: true,
"aria-hidden" => css_for_aria_hidden(reason) do %>
<%= t("budget.investments.investment.vote") %>
<% end %>
<% end %>
</div>
<% if reason.present? && !user_voted_for %>
<div class="no-supports-allowed" style='display:none' aria-hidden="false">
<p>
<%= t("votes.budget_investments.#{reason}",
verify_account: link_to(t("votes.verify_account"), verification_path),
signin: link_to(t("votes.signin"), new_user_session_path),
signup: link_to(t("votes.signup"), new_user_registration_path)
).html_safe %>
</p>
</div>
<% end %>
<% if user_voted_for && setting['twitter_handle'] %>
<div class="share-supported">
<%= social_share_button_tag("#{investment.title} #{setting['twitter_hashtag']}", url: budget_investment_url(budget_id: @budget.id, id: investment.id), via: setting['twitter_handle']) %>
</div>
<% end %>
</div>

View File

@@ -1,4 +1,83 @@
<h1><%= @investment.title %></h1>
<% provide :title do %><%= @investment.title %><% end %>
<p><%= @investment.author.username %>
<%= @investment.price %></p>
<section class="budget-investment-show">
<div id="<%= dom_id(@investment) %>" class="row">
<div class="small-12 medium-9 column">
<%= link_to :back, class: "back" do %>
<span class="icon-angle-left"></span>
<%= t("shared.back") %>
<% end %>
<h1><%= @investment.title %></h1>
<div class="budget-investment-info">
<%= render '/shared/author_info', resource: @investment %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<%= l @investment.created_at.to_date %>
<span class="bullet">&nbsp;&bull;&nbsp;</span>
<%= heading_name(@investment.heading) %>
</div>
<br>
<p id="investment_code">
<%= t("budget.investments.show.code") %>
<strong><%= @investment.id %></strong>
</p>
<%= safe_html_with_links @investment.description.html_safe %>
<% if @investment.external_url.present? %>
<div class="document-link">
<%= text_with_links @investment.external_url %>
</div>
<% end %>
<% if @investment.unfeasible? && @investment.feasible_explanation.present? %>
<h2><%= t('budget.investments.show.unfeasibility_explanation') %></h2>
<p><%= @investment.feasible_explanation %></p>
<% end %>
<% if @investment.feasible? && @investment.price_explanation.present? %>
<h2><%= t('budget.investments.show.price_explanation') %></h2>
<p><%= @investment.price_explanation %></p>
<% end %>
</div>
<% if (@budget.selecting? && !@investment.unfeasible?) ||
(@budget.balloting? && @investment.feasible?) %>
<aside class="small-12 medium-3 column">
<div class="sidebar-divider"></div>
<h3><%= t("votes.supports") %></h3>
<div class="text-center">
<% if @budget.selecting? %>
<div id="<%= dom_id(@investment) %>_votes">
<%= render 'votes',
{ investment: @investment, vote_url: vote_budget_investment_path(budget_id: @budget.id, id: @investment.id) } %>
</div>
<% else %>
<div id="<%= dom_id(@investment) %>_ballot">
<%= render 'ballot', investment: @investment %>
</div>
<% end %>
</div>
<div class="sidebar-divider"></div>
<h3><%= t("budget.investments.show.share") %></h3>
<div class="social-share-full">
<%= social_share_button_tag("#{@investment.title} #{setting['twitter_hashtag']}") %>
<% if browser.device.mobile? %>
<a href="whatsapp://send?text=<%= @investment.title %> <%= budget_investment_url(budget_id: budget.id, id: @investment.id) %>" data-action="share/whatsapp/share">
<span class="icon-whatsapp whatsapp"></span>
</a>
<% end %>
</div>
</aside>
<% end %>
</div>
</section>
<% unless namespace == 'management' %>
<%= render "budgets/investments/comments" %>
<% end %>