Adds views and helpers for investments
This commit is contained in:
@@ -5,4 +5,19 @@ module BudgetHelper
|
||||
locale: I18n.default_locale,
|
||||
unit: budget.currency_symbol)
|
||||
end
|
||||
|
||||
def heading_name(heading)
|
||||
heading.present? ? heading.name : t("budget.headings.none")
|
||||
end
|
||||
|
||||
def namespaced_budget_investment_path(investment, options={})
|
||||
@namespaced_budget_investment_path ||= namespace
|
||||
options[:budget_id] ||= investment.budget.id
|
||||
case @namespace_budget_investment_path
|
||||
when "management"
|
||||
management_budget_investment_path(investment, options)
|
||||
else
|
||||
budget_investment_path(investment, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
49
app/views/budgets/investments/_form.html.erb
Normal file
49
app/views/budgets/investments/_form.html.erb
Normal file
@@ -0,0 +1,49 @@
|
||||
<%= form_for(@investment, url: form_url) do |f| %>
|
||||
<%= render 'shared/errors', resource: @investment %>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<%= f.label :title, t("budget.investments.form.title") %>
|
||||
<%= f.text_field :title, maxlength: SpendingProposal.title_max_length, placeholder: t("budget.investments.form.title"), label: false %>
|
||||
</div>
|
||||
|
||||
<%= f.invisible_captcha :subtitle %>
|
||||
|
||||
<div class="ckeditor small-12 column">
|
||||
<%= f.label :description, t("budget.investments.form.description") %>
|
||||
<%= f.cktext_area :description, maxlength: SpendingProposal.description_max_length, ckeditor: { language: I18n.locale }, label: false %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.label :external_url, t("budget.investments.form.external_url") %>
|
||||
<%= f.text_field :external_url, placeholder: t("budget.investments.form.external_url"), label: false %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.label :heading_id, t("budget.investments.form.heading") %>
|
||||
<%= f.select :heading_id, heading_select_options, {include_blank: t("budget.headings.none"), label: false} %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.label :association_name, t("budget.investments.form.association_name_label") %>
|
||||
<%= f.text_field :association_name, placeholder: t("budget.investments.form.association_name"), label: false %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<% if @investment.new_record? %>
|
||||
<%= f.label :terms_of_service do %>
|
||||
<%= f.check_box :terms_of_service, title: t('form.accept_terms_title'), label: false %>
|
||||
<span class="checkbox">
|
||||
<%= t("form.accept_terms",
|
||||
policy: link_to(t("form.policy"), "/privacy", target: "blank"),
|
||||
conditions: link_to(t("form.conditions"), "/conditions", target: "blank")).html_safe %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="actions small-12 column">
|
||||
<%= f.submit(class: "button", value: t("budget.investments.form.submit_buttons.#{action_name}")) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
56
app/views/budgets/investments/_header.html.erb
Normal file
56
app/views/budgets/investments/_header.html.erb
Normal file
@@ -0,0 +1,56 @@
|
||||
<% if @filter_heading_name.present? %>
|
||||
<section class="no-margin-top margin-bottom">
|
||||
<div class="expanded jumbo-investment-project investment-project-geozone padding">
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<%= link_to @budget, class: "back" do %>
|
||||
<i class="icon-angle-left"></i>
|
||||
<%= t("shared.back") %>
|
||||
<% end %>
|
||||
|
||||
<% if can? :show, @ballot %>
|
||||
<%= link_to t("budget.investments.header.check_ballot"), ballot_path, class: "button float-right" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row progress-votes">
|
||||
<div class="small-12 column">
|
||||
<div class="progress-bar-nav" data-fixed-bar>
|
||||
<h1 class="inline-block"><%= @filter_geozone_name %></h1>
|
||||
<div id="check-ballot" style="display: none;">
|
||||
<% if can? :show, @ballot %>
|
||||
<%= link_to t("budget.investments.header.check_ballot"), ballot_path %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if @heading.present? && @ballot.heading.present? && @ballot.heading != @heading %>
|
||||
<br>
|
||||
<p class="callout warning inline-block">
|
||||
<%= t("budget.investments.header.different_heading_active") %>
|
||||
<%= link_to @ballot.heading.name, budget_investments_path(budget_id: budget.id, heading_id: @ballot.heading_id) %>
|
||||
</p>
|
||||
<% else %>
|
||||
<div id="progress_bar" class="no-margin-top">
|
||||
<%= render 'progress_bar' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<% else %>
|
||||
<div class="expanded jumbo-investment-project padding no-margin-top margin-bottom">
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<%= link_to budget_path(@budget), class: "back" do %>
|
||||
<i class="icon-angle-left"></i>
|
||||
<%= t("shared.back") %>
|
||||
<% end %>
|
||||
|
||||
<h1><%= t('budget.investments.index.title') %></h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
61
app/views/budgets/investments/_investment.html.erb
Normal file
61
app/views/budgets/investments/_investment.html.erb
Normal file
@@ -0,0 +1,61 @@
|
||||
<div id="<%= dom_id(investment) %>" class="investment-project clear">
|
||||
<div class="panel">
|
||||
<div class="row">
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<div class="investment-project-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>
|
||||
<span class="icon-budget"></span>
|
||||
<h3><%= link_to investment.title, namespaced_budget_investment_path(investment) %></h3>
|
||||
<p class="investment-project-info">
|
||||
|
||||
<%= l investment.created_at.to_date %>
|
||||
|
||||
<% if investment.author.hidden? || investment.author.erased? %>
|
||||
<span class="bullet"> • </span>
|
||||
<span class="author">
|
||||
<%= t("budget.investments.show.author_deleted") %>
|
||||
</span>
|
||||
<% else %>
|
||||
<span class="bullet"> • </span>
|
||||
<span class="author">
|
||||
<%= investment.author.name %>
|
||||
</span>
|
||||
<% if investment.author.official? %>
|
||||
<span class="bullet"> • </span>
|
||||
<span class="label round level-<%= investment.author.official_level %>">
|
||||
<%= investment.author.official_position %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<span class="bullet"> • </span>
|
||||
<%= heading_name(investment.heading) %>
|
||||
</p>
|
||||
<div class="investment-project-description">
|
||||
<p><%= link_to investment.description, namespaced_budget_investment_path(investment) %></p>
|
||||
<div class="truncate"></div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% unless investment.unfeasible? %>
|
||||
<% if feature?("investment_features.phase2") %>
|
||||
<div id="<%= dom_id(investment) %>_votes"
|
||||
class="small-12 medium-3 column text-center">
|
||||
<%= render 'votes',
|
||||
{ investment: investment, vote_url: vote_investment_path(investment, value: 'yes') } %>
|
||||
</div>
|
||||
<% elsif feature?("investment_features.phase3") %>
|
||||
<div id="<%= dom_id(investment) %>_ballot"
|
||||
class="small-12 medium-3 column text-center">
|
||||
<%= render 'ballot', investment: investment %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
29
app/views/budgets/investments/_sidebar.html.erb
Normal file
29
app/views/budgets/investments/_sidebar.html.erb
Normal file
@@ -0,0 +1,29 @@
|
||||
<%= link_to @budget, class: "back" do %>
|
||||
<i class="icon-angle-left"></i>
|
||||
<%= t("spending_proposals.index.sidebar.back") %>
|
||||
<% end %>
|
||||
|
||||
<div class="clear"></div>
|
||||
|
||||
<div class="sidebar-divider"></div>
|
||||
<h3 class="sidebar-title"><%= t("spending_proposals.index.sidebar.my_ballot") %></h3>
|
||||
|
||||
<% if @ballot.investments.by_heading(@heading).count > 0 %>
|
||||
<p>
|
||||
<em>
|
||||
<%= t("budget.investments.index.sidebar.voted_html",
|
||||
count: @ballot.investments.by_heading(@heading.id).count,
|
||||
amount_spent: format_price(@ballot.amount_spent(@heading))) %>
|
||||
</em>
|
||||
</p>
|
||||
<% else %>
|
||||
<p><strong><%= t("budget.investments.index.sidebar.zero") %></strong></p>
|
||||
<% end %>
|
||||
|
||||
<ul class="ballot-list">
|
||||
<% @ballot.investments.by_heading(@heading).each do |investment| %>
|
||||
<%= render 'ballots/investment_for_sidebar', investment: investment %>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
<p class="callout primary"><%= t("budget.investments.index.sidebar.voted_info") %></p>
|
||||
49
app/views/budgets/investments/index.html.erb
Normal file
49
app/views/budgets/investments/index.html.erb
Normal file
@@ -0,0 +1,49 @@
|
||||
<% provide :title do %><%= t('budget.investments.index.title') %><% end %>
|
||||
<% content_for :header_addon do %>
|
||||
<%= render "shared/search_form",
|
||||
search_path: budget_investments_path(budget_id: @budget.id, page: 1),
|
||||
i18n_namespace: "budget.investments.index.search_form" %>
|
||||
<% end %>
|
||||
|
||||
<main id="budget-investments-main">
|
||||
|
||||
<%= render 'header' %>
|
||||
|
||||
<div class="wrap row">
|
||||
<div id="budget-investments" class="budget-investments-list small-12 medium-9 column">
|
||||
|
||||
<div class="small-12 search-results margin-bottom">
|
||||
|
||||
<% if params[:unfeasible].present? %>
|
||||
<h2><%= t("budget.investments.index.unfeasible") %></h2>
|
||||
<p>
|
||||
<%= t("budget.investments.index.unfeasible_text",
|
||||
definitions: link_to(t("budget.investments.index.unfeasible_text_definitions"), "https://decide.madrid.es/participatory_budget_info#20")).html_safe %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= content_tag(:h2, t("budget.investments.index.by_heading", heading: @filter_heading_name)) if @filter_heading_name.present? %>
|
||||
<% if params[:search].present? %>
|
||||
<h2>
|
||||
<%= page_entries_info @investments %>
|
||||
<%= t("budget.investments.index.search_results", count: @investments.size, search_term: params[:search]) %>
|
||||
</h2>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%= render('shared/order_links', i18n_namespace: "budget.investments.index") unless params[:unfeasible].present? %>
|
||||
|
||||
<%= render partial: 'investment', collection: @investments %>
|
||||
<%= paginate @investments %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-3 column">
|
||||
<aside class="margin-bottom">
|
||||
<div id="sidebar">
|
||||
<%= render 'sidebar' %>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</main>
|
||||
4
app/views/budgets/investments/show.html.erb
Normal file
4
app/views/budgets/investments/show.html.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
<h1><%= @investment.title %></h1>
|
||||
|
||||
<p><%= @investment.author.username %>
|
||||
<%= @investment.price %></p>
|
||||
Reference in New Issue
Block a user