From 630a4878a8d87bf7d43258e877ccee7905248ff2 Mon Sep 17 00:00:00 2001 From: kikito Date: Tue, 7 Jun 2016 11:12:58 +0200 Subject: [PATCH] Adds a lot of views (WIP) --- app/views/budgets/ballots/_add.html.erb | 16 +++ app/views/budgets/ballots/_ballot.html.erb | 97 +++++++++++++++++++ .../budgets/ballots/_investment.html.erb | 14 +++ .../ballots/_investment_for_sidebar.html.erb | 15 +++ app/views/budgets/ballots/_remove.html.erb | 18 ++++ app/views/budgets/ballots/show.html.erb | 3 + app/views/budgets/index.html.erb | 5 +- .../budgets/investments/_ballot.html.erb | 23 +++++ .../budgets/investments/_comments.html.erb | 31 ++++++ .../budgets/investments/_investment.html.erb | 4 +- app/views/budgets/investments/_votes.html.erb | 46 +++++++++ app/views/budgets/investments/show.html.erb | 85 +++++++++++++++- 12 files changed, 351 insertions(+), 6 deletions(-) create mode 100644 app/views/budgets/ballots/_add.html.erb create mode 100644 app/views/budgets/ballots/_ballot.html.erb create mode 100644 app/views/budgets/ballots/_investment.html.erb create mode 100644 app/views/budgets/ballots/_investment_for_sidebar.html.erb create mode 100644 app/views/budgets/ballots/_remove.html.erb create mode 100644 app/views/budgets/ballots/show.html.erb create mode 100644 app/views/budgets/investments/_ballot.html.erb create mode 100644 app/views/budgets/investments/_comments.html.erb create mode 100644 app/views/budgets/investments/_votes.html.erb diff --git a/app/views/budgets/ballots/_add.html.erb b/app/views/budgets/ballots/_add.html.erb new file mode 100644 index 000000000..c6b1e7476 --- /dev/null +++ b/app/views/budgets/ballots/_add.html.erb @@ -0,0 +1,16 @@ +
+

+ <%= format_price(@budget, investment.price) %> +

+ + <% 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 %> +
diff --git a/app/views/budgets/ballots/_ballot.html.erb b/app/views/budgets/ballots/_ballot.html.erb new file mode 100644 index 000000000..5187c5eaa --- /dev/null +++ b/app/views/budgets/ballots/_ballot.html.erb @@ -0,0 +1,97 @@ +
+ + <%= link_to :back, class: "back" do %> + + <%= t("shared.back") %> + <% end %> + +

<%= t("budgets.ballots.show.title") %>

+ +
+

+ <%= t("budgets.ballots.show.voted_html", + count: @ballot.investments.count) %> +

+ + <% 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 %> + +

+ <%= t("ballots.show.remaining_city_html", + amount_city: format_price(@ballot.amount_available(nil))) %> +

+ + <% if @ballot.geozone.present? %> +

+ <%= t("budgets.ballots.show.remaining_district_html", + amount_district: format_price(@ballot.amount_available(@ballot.geozone)), + geozone: @ballot.geozone.name) %> +

+ <% end %> + +

+ + <%= t("budgets.ballots.show.voted_info_html") %> + +

+
+ +
+ +
+
+

+ <%= t("budgets.ballots.show.city_wide") %> +

+ <% if @ballot.investments.by_geozone(nil).count > 0 %> +

+ <%= t("budgets.ballots.show.amount_spent") %> + <%= format_price(city_wide_amount_spent(@ballot)) %> +

+ <% else %> +

+ <%= t("budgets.ballots.show.zero") %>
+ <%= link_to t("ballots.show.city_link"), + investments_path(geozone: 'all'), + data: { no_turbolink: true } %> +

+ <% end %> + +
    + <%= render partial: 'budgets/ballots/investment', + collection: @ballot.investments.no_heading %> +
+
+ +
+

+ <%= t("ballots.show.district_wide") %> + + <% if @ballot.geozone.present? %> + (<%= @ballot.geozone.name %>) + <% end %> + +

+ <% if @ballot.geozone.present? %> +

+ <%= t("ballots.show.amount_spent") %> + <%= format_price(district_wide_amount_spent(@ballot)) %> +

+ <% else %> +

+ <%= t("ballots.show.zero") %>
+ <%= link_to t("budget.ballots.show.districts_link"), select_district_path %> +

+ <% end %> + +
    + <%= render partial: 'budgets/ballots/investment', + collection: @ballot.investments.with_heading %> +
+
+
+
diff --git a/app/views/budgets/ballots/_investment.html.erb b/app/views/budgets/ballots/_investment.html.erb new file mode 100644 index 000000000..93c934bd5 --- /dev/null +++ b/app/views/budgets/ballots/_investment.html.erb @@ -0,0 +1,14 @@ +
  • + <%= link_to investment.title, investment %> + <%= format_price(investment.price) %> + + <% 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 %> + + <% end %> + <% end %> +
  • diff --git a/app/views/budgets/ballots/_investment_for_sidebar.html.erb b/app/views/budgets/ballots/_investment_for_sidebar.html.erb new file mode 100644 index 000000000..c0bde5d34 --- /dev/null +++ b/app/views/budgets/ballots/_investment_for_sidebar.html.erb @@ -0,0 +1,15 @@ +
  • + <%= investment.title %> + <%= format_price(investment.price) %> + + <% 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 %> + + <% end %> + <% end %> +
  • diff --git a/app/views/budgets/ballots/_remove.html.erb b/app/views/budgets/ballots/_remove.html.erb new file mode 100644 index 000000000..a02ac9966 --- /dev/null +++ b/app/views/budgets/ballots/_remove.html.erb @@ -0,0 +1,18 @@ +
    + "> + + +

    + <%= format_price(investment.price) %> +

    + + <% 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 %> +
    diff --git a/app/views/budgets/ballots/show.html.erb b/app/views/budgets/ballots/show.html.erb new file mode 100644 index 000000000..393444368 --- /dev/null +++ b/app/views/budgets/ballots/show.html.erb @@ -0,0 +1,3 @@ +
    + <%= render partial: "ballots/ballot" %> +
    diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb index d1f9ebd63..6d83adbbb 100644 --- a/app/views/budgets/index.html.erb +++ b/app/views/budgets/index.html.erb @@ -2,6 +2,9 @@ diff --git a/app/views/budgets/investments/_ballot.html.erb b/app/views/budgets/investments/_ballot.html.erb new file mode 100644 index 000000000..6634ae1fa --- /dev/null +++ b/app/views/budgets/investments/_ballot.html.erb @@ -0,0 +1,23 @@ +<% reason = investment.reason_for_not_being_ballotable_by(current_user, @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) %> + + + + <% end %> +
    diff --git a/app/views/budgets/investments/_comments.html.erb b/app/views/budgets/investments/_comments.html.erb new file mode 100644 index 000000000..6970e64f4 --- /dev/null +++ b/app/views/budgets/investments/_comments.html.erb @@ -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 %> +
    +
    +
    +

    + <%= t("debates.show.comments_title") %> + (<%= @investment.comments_count %>) +

    + + <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> + + <% if user_signed_in? %> + <%= render 'comments/form', {commentable: @investment, parent_id: nil, toggeable: false} %> + <% else %> +
    + +
    + <%= 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 %> +
    + <% end %> + + <% @comment_tree.root_comments.each do |comment| %> + <%= render 'comments/comment', comment: comment %> + <% end %> + <%= paginate @comment_tree.root_comments %> +
    +
    +
    +<% end %> diff --git a/app/views/budgets/investments/_investment.html.erb b/app/views/budgets/investments/_investment.html.erb index 3432bed49..84f105c18 100644 --- a/app/views/budgets/investments/_investment.html.erb +++ b/app/views/budgets/investments/_investment.html.erb @@ -1,9 +1,9 @@ -
    +
    -
    +
    <% cache [locale_and_user_status(investment), 'index', investment, investment.author] do %> <%= t("budget.investments.investment.title") %> diff --git a/app/views/budgets/investments/_votes.html.erb b/app/views/budgets/investments/_votes.html.erb new file mode 100644 index 000000000..62ea74283 --- /dev/null +++ b/app/views/budgets/investments/_votes.html.erb @@ -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) %> + +
    + + + <%= t("budget.investments.investment.supports", count: investment.total_votes) %> + + +
    + <% if user_voted_for %> +
    + <%= t("budget.investments.investment.already_supported") %> +
    + <% 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 %> +
    + + <% if reason.present? && !user_voted_for %> + + <% end %> + + <% if user_voted_for && setting['twitter_handle'] %> + + <% end %> +
    diff --git a/app/views/budgets/investments/show.html.erb b/app/views/budgets/investments/show.html.erb index 55cd12a6f..58e6027ea 100644 --- a/app/views/budgets/investments/show.html.erb +++ b/app/views/budgets/investments/show.html.erb @@ -1,4 +1,83 @@ -

    <%= @investment.title %>

    +<% provide :title do %><%= @investment.title %><% end %> -

    <%= @investment.author.username %> - <%= @investment.price %>

    +
    +
    +
    + <%= link_to :back, class: "back" do %> + + <%= t("shared.back") %> + <% end %> + +

    <%= @investment.title %>

    + +
    + <%= render '/shared/author_info', resource: @investment %> + +  •  + <%= l @investment.created_at.to_date %> +  •  + <%= heading_name(@investment.heading) %> +
    + +
    +

    + <%= t("budget.investments.show.code") %> + <%= @investment.id %> +

    + + <%= safe_html_with_links @investment.description.html_safe %> + + <% if @investment.external_url.present? %> + + <% end %> + + <% if @investment.unfeasible? && @investment.feasible_explanation.present? %> +

    <%= t('budget.investments.show.unfeasibility_explanation') %>

    +

    <%= @investment.feasible_explanation %>

    + <% end %> + + <% if @investment.feasible? && @investment.price_explanation.present? %> +

    <%= t('budget.investments.show.price_explanation') %>

    +

    <%= @investment.price_explanation %>

    + <% end %> +
    + + <% if (@budget.selecting? && !@investment.unfeasible?) || + (@budget.balloting? && @investment.feasible?) %> + + <% end %> + +
    +
    + +<% unless namespace == 'management' %> + <%= render "budgets/investments/comments" %> +<% end %>