Merge branch 'master' into legislation-module-stable

This commit is contained in:
Amaia Castro
2017-01-11 22:54:41 +01:00
235 changed files with 9717 additions and 656 deletions

View File

@@ -35,6 +35,14 @@
</li>
<% end %>
<% if feature?(:budgets) %>
<li <%= "class=active" if controller_name == "budgets" %>>
<%= link_to admin_budgets_path do %>
<span class="icon-budget"></span><%= t("admin.menu.budgets") %>
<% end %>
</li>
<% end %>
<% if feature?(:signature_sheets) %>
<li <%= "class=active" if controller_name == "signature_sheets" %>>
<%= link_to admin_signature_sheets_path do %>

View File

@@ -0,0 +1,2 @@
$("#<%= dom_id(@budget) %>_groups").html('<%= j render("admin/budgets/groups", groups: @groups) %>');
App.Forms.toggleLink();

View File

@@ -0,0 +1,2 @@
$("#<%= dom_id(@budget_group) %>").html('<%= j render("admin/budgets/group", group: @budget_group, headings: @headings) %>');
App.Forms.toggleLink();

View File

@@ -0,0 +1,77 @@
<h3><%= page_entries_info @investments %></h3>
<table>
<thead>
<tr>
<th><%= t("admin.budget_investments.index.table_id") %></th>
<th><%= t("admin.budget_investments.index.table_title") %></th>
<th><%= t("admin.budget_investments.index.table_admin") %></th>
<th><%= t("admin.budget_investments.index.table_valuator") %></th>
<th><%= t("admin.budget_investments.index.table_geozone") %></th>
<th><%= t("admin.budget_investments.index.table_feasibility") %></th>
<th class="text-center"><%= t("admin.budget_investments.index.table_valuation_finished") %></th>
<th class="text-center"><%= t("admin.budget_investments.index.table_selection") %></th>
</tr>
</thead>
<% @investments.each do |investment| %>
<tr id="<%= dom_id(investment) %>" class="budget_investment">
<td class="text-right">
<strong><%= investment.id %></strong>
</td>
<td>
<%= link_to investment.title, admin_budget_budget_investment_path(budget_id: @budget.id, id: investment.id, params: Budget::Investment.filter_params(params)) %>
</td>
<td class="small">
<% if investment.administrator.present? %>
<span title="<%= t('admin.budget_investments.index.assigned_admin') %>"><%= investment.administrator.name %></span>
<% else %>
<%= t("admin.budget_investments.index.no_admin_assigned") %>
<% end %>
</td>
<td class="small">
<% if investment.valuators.size == 0 %>
<%= t("admin.budget_investments.index.no_valuators_assigned") %>
<% else %>
<%= investment.valuators.collect(&:description_or_name).join(', ') %>
<% end %>
</td>
<td class="small">
<%= investment.heading.name %>
</td>
<td class="small">
<%= t("admin.budget_investments.index.feasibility.#{investment.feasibility}",
price: investment.formatted_price)
%>
</td>
<td class="small text-center">
<%= investment.valuation_finished? ? t('shared.yes'): t('shared.no') %>
</td>
<td class="small">
<% if investment.selected? %>
<%= link_to toggle_selection_admin_budget_budget_investment_path(@budget,
investment,
filter: params[:filter],
page: params[:page]),
method: :patch,
remote: true,
class: "button small expanded" do %>
<%= t("admin.budget_investments.index.selected") %>
<% end %>
<% elsif investment.feasible? && investment.valuation_finished? %>
<%= link_to toggle_selection_admin_budget_budget_investment_path(@budget,
investment,
filter: params[:filter],
page: params[:page]),
method: :patch,
remote: true,
class: "button small hollow expanded" do %>
<%= t("admin.budget_investments.index.select") %>
<% end %>
<% end %>
</td>
</tr>
<% end %>
</table>
<%= paginate @investments %>

View File

@@ -0,0 +1,36 @@
<div class="callout primary float-right">
<%= t "admin.budget_investments.show.info", budget_name: @budget.name, group_name: @investment.group.name, id: @investment.id %>
</div>
<br>
<h1 class="inline-block"><%= @investment.title %></h1>
<div class="row small-collapse spending-proposal-info">
<div class="small-12 medium-4 column">
<p title="<%= t("admin.budget_investments.show.group") %>: <%= @investment.group.name %>">
<strong><%= t("admin.budget_investments.show.heading") %>:</strong>
<%= @investment.heading.name %>
</p>
</div>
<div class="small-12 medium-4 column">
<p>
<strong><%= t("admin.budget_investments.show.by") %>:</strong>
<%= link_to @investment.author.name, admin_user_path(@investment.author) %>
</p>
</div>
<div class="small-12 medium-4 column">
<p>
<strong><%= t("admin.budget_investments.show.sent") %>:</strong>
<%= l @investment.created_at, format: :datetime %>
</p>
</div>
</div>
<% if @investment.external_url.present? %>
<p><%= text_with_links @investment.external_url %>&nbsp;<span class="icon-external small"></span></p>
<% end %>
<%= safe_html_with_links @investment.description %>

View File

@@ -0,0 +1,70 @@
<%= link_to admin_budget_budget_investment_path(@budget, @investment, Budget::Investment.filter_params(params)), class: 'back' do %>
<span class="icon-angle-left"></span> <%= t("shared.back") %>
<% end %>
<%= form_for @investment,
url: admin_budget_budget_investment_path(@budget, @investment) do |f| %>
<% Budget::Investment.filter_params(params).each do |filter_name, filter_value| %>
<%= hidden_field_tag filter_name, filter_value %>
<% end %>
<div class="row">
<div class="small-12 column">
<%= f.text_field :title, maxlength: Budget::Investment.title_max_length %>
</div>
<div class="ckeditor small-12 column">
<%= f.cktext_area :description, maxlength: Budget::Investment.description_max_length, ckeditor: { language: I18n.locale } %>
</div>
<div class="small-12 column">
<%= f.text_field :external_url %>
</div>
<div class="small-12 column">
<%= f.select :heading_id, budget_heading_select_options(@budget), include_blank: t("admin.budget_investments.edit.select_heading") %>
</div>
</div>
<h2 id="classification"><%= t("admin.budget_investments.edit.classification") %></h2>
<div class="row">
<div class="small-12 column">
<%= f.select(:administrator_id,
@admins.collect{ |a| [a.name_and_email, a.id ] },
{ include_blank: t("admin.budget_investments.edit.undefined") }) %>
</div>
<div class="small-12 column">
<%= f.label :tag_list, t("admin.budget_investments.edit.tags") %>
<div class="tags">
<% @tags.each do |tag| %>
<a class="js-add-tag-link"><%= tag.name %></a>
<% end %>
</div>
<%= f.text_field :valuation_tag_list,
value: @investment.tag_list_on(:valuation).sort.join(','),
label: false,
placeholder: t("admin.budget_investments.edit.tags_placeholder"),
class: 'js-tag-list' %>
</div>
<div class="small-12 column">
<%= f.label :valuator_ids, t("admin.budget_investments.edit.assigned_valuators") %>
<%= f.collection_check_boxes :valuator_ids, @valuators, :id, :email do |b| %>
<%= b.label(title: valuator_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %>
<% end %>
</div>
</div>
<p class="clear">
<%= f.submit(class: "button", value: t("admin.budget_investments.edit.submit_button")) %>
</p>
<% end %>
<hr>
<%# render 'valuation/budget_investments/written_by_valuators' %>

View File

@@ -0,0 +1,44 @@
<h2 class="inline-block"><%= @budget.name %> - <%= t("admin.budget_investments.index.title") %></h2>
<div class="row margin">
<%= form_tag admin_budget_budget_investments_path(budget: @budget), method: :get, enforce_utf8: false do %>
<div class="small-12 medium-3 column">
<%= select_tag :administrator_id,
options_for_select(admin_select_options, params[:administrator_id]),
{ prompt: t("admin.budget_investments.index.administrator_filter_all"),
label: false,
class: "js-submit-on-change" } %>
</div>
<div class="small-12 medium-3 column">
<%= select_tag :valuator_id,
options_for_select(valuator_select_options, params[:valuator_id]),
{ prompt: t("admin.budget_investments.index.valuator_filter_all"),
label: false,
class: "js-submit-on-change" } %>
</div>
<div class="small-12 medium-3 column">
<%= select_tag :heading_id,
options_for_select(budget_heading_select_options(@budget), params[:heading_id]),
{ prompt: t("admin.budget_investments.index.heading_filter_all"),
label: false,
class: "js-submit-on-change" } %>
</div>
<div class="small-12 medium-3 column">
<%= select_tag :tag_name,
options_for_select(spending_proposal_tags_select_options, params[:tag_name]),
{ prompt: t("admin.budget_investments.index.tags_filter_all"),
label: false,
class: "js-submit-on-change" } %>
</div>
<% end %>
</div>
<%= render '/shared/filter_subnav', i18n_namespace: "admin.budget_investments.index" %>
<div id="investments">
<%= render '/admin/budget_investments/investments' %>
</div>

View File

@@ -0,0 +1,49 @@
<%= link_to admin_budget_budget_investments_path(Budget::Investment.filter_params(params)), data: {no_turbolink: true} do %>
<span class="icon-angle-left"></span> <%= t("shared.back") %>
<% end %>
<%= render 'written_by_author' %>
<%= link_to t("admin.budget_investments.show.edit"),
edit_admin_budget_budget_investment_path(@budget, @investment,
Budget::Investment.filter_params(params)) %>
<hr>
<h2 id="classification"><%= t("admin.budget_investments.show.classification") %></h2>
<p><strong><%= t("admin.budget_investments.show.assigned_admin") %>:</strong>
<%= @investment.administrator.try(:name_and_email) || t("admin.budget_investments.show.undefined") %>
</p>
<p id="tags">
<strong><%= t("admin.budget_investments.show.tags") %>:</strong>
<%= @investment.tags_on(:valuation).pluck(:name).join(', ') %>
</p>
<p id="assigned_valuators">
<strong><%= t("admin.budget_investments.show.assigned_valuators") %>:</strong>
<% if @investment.valuators.any? %>
<%= @investment.valuators.collect(&:name_and_email).join(', ') %>
<% else %>
<%= t("admin.budget_investments.show.undefined") %>
<% end %>
</p>
<p>
<%= link_to t("admin.budget_investments.show.edit_classification"),
edit_admin_budget_budget_investment_path(@budget, @investment,
{anchor: 'classification'}.merge(Budget::Investment.filter_params(params))) %>
</p>
<hr>
<h2><%= t("admin.budget_investments.show.dossier") %></h2>
<%= render 'valuation/budget_investments/written_by_valuators' %>
<p>
<%= link_to t("admin.budget_investments.show.edit_dossier"), edit_valuation_budget_budget_investment_path(@budget, @investment) %>
</p>

View File

@@ -0,0 +1 @@
$("#investments").html('<%= j render("admin/budget_investments/investments") %>');

View File

@@ -0,0 +1,20 @@
<%= form_for [:admin, @budget] do |f| %>
<%= f.text_field :name, maxlength: Budget.title_max_length %>
<% Budget::PHASES.each do |phase| %>
<div class="margin-top">
<%= f.cktext_area "description_#{phase}", maxlength: Budget.description_max_length, ckeditor: { language: I18n.locale } %>
</div>
<% end %>
<div class="row margin-top">
<div class="small-12 medium-9 column">
<%= f.select :phase, budget_phases_select_options %>
</div>
<div class="small-12 medium-3 column">
<%= f.select :currency_symbol, budget_currency_symbol_select_options %>
</div>
</div>
<%= f.submit nil, class: "button success" %>
<% end %>

View File

@@ -0,0 +1,67 @@
<table>
<thead>
<tr>
<th colspan="3" class="with-button">
<%= group.name %>
<%= link_to t("admin.budgets.form.add_heading"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#group-#{group.id}-new-heading-form" } %>
</th>
</tr>
<% if headings.blank? %>
<tbody>
<tr>
<td colspan="3">
<div class="callout primary">
<%= t("admin.budgets.form.no_heading") %>
</div>
</td>
</tr>
<% else %>
<tr>
<th><%= t("admin.budgets.form.table_heading") %></th>
<th><%= t("admin.budgets.form.table_amount") %></th>
</tr>
</thead>
<tbody>
<% end %>
<!-- new heading form -->
<tr id="group-<%= group.id %>-new-heading-form" style="display:none">
<td colspan="3">
<%= form_for [:admin, @budget, group, Budget::Heading.new], remote: true do |f| %>
<label><%= t("admin.budgets.form.heading") %></label>
<%= f.text_field :name,
label: false,
maxlength: 50,
placeholder: t("admin.budgets.form.heading") %>
<div class="row">
<div class="small-12 medium-6 column">
<label><%= t("admin.budgets.form.amount") %></label>
<%= f.text_field :price,
label: false,
maxlength: 8,
placeholder: t("admin.budgets.form.amount") %>
</div>
</div>
<%= f.submit t("admin.budgets.form.save_heading"), class: "button success" %>
<% end %>
</td>
</tr>
<!-- /. new heading form -->
<!-- headings list -->
<% headings.each do |heading| %>
<tr>
<td>
<%= heading.name %>
</td>
<td>
<%= heading.price %>
</td>
</tr>
<% end %>
<!-- /. headings list -->
</tbody>
</table>
</div>

View File

@@ -0,0 +1,32 @@
<h3 class="inline-block"><%= t('admin.budgets.show.groups', count: groups.count) %></h3>
<% if groups.blank? %>
<div class="callout primary">
<%= t("admin.budgets.form.no_groups") %>
<strong><%= link_to t("admin.budgets.form.add_group"), "#",
class: "js-toggle-link",
data: { "toggle-selector" => "#new-group-form" } %></strong>
</div>
<% else %>
<%= link_to t("admin.budgets.form.add_group"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#new-group-form" } %>
<% end %>
<%= form_for [:admin, @budget, Budget::Group.new], html: {id: "new-group-form", style: "display:none"}, remote: true do |f| %>
<div class="input-group">
<span class="input-group-label">
<label><%= f.label :name,t("admin.budgets.form.group") %></label>
</span>
<%= f.text_field :name,
label: false,
maxlength: 50,
placeholder: t("admin.budgets.form.group") %>
<div class="input-group-button">
<%= f.submit t("admin.budgets.form.create_group"), class: "button success" %>
</div>
</div>
<% end %>
<% groups.each do |group| %>
<div id="<%= dom_id(group) %>">
<%= render "admin/budgets/group", group: group, headings: group.headings %>
</div>
<% end %>

View File

@@ -0,0 +1,9 @@
<%= back_link_to admin_budgets_path %>
<div class="row">
<div class="small-12 medium-9 column">
<h2><%= t("admin.budgets.edit.title") %></h2>
<%= render '/admin/budgets/form' %>
</div>
</div>

View File

@@ -0,0 +1,44 @@
<h2 class="inline-block"><%= t("admin.budgets.index.title") %></h2>
<%= link_to t("admin.budgets.index.new_link"),
new_admin_budget_path,
class: "button float-right margin-right" %>
<%= render 'shared/filter_subnav', i18n_namespace: "admin.budgets.index" %>
<h3><%= page_entries_info @budgets %></h3>
<table>
<thead>
<tr>
<th><%= t("admin.budgets.index.table_name") %></th>
<th><%= t("admin.budgets.index.table_phase") %></th>
<th><%= t("admin.budgets.index.table_investments") %></th>
<th><%= t("admin.budgets.index.table_edit_groups") %></th>
<th><%= t("admin.budgets.index.table_edit_budget") %></th>
</tr>
</thead>
<tbody>
<% @budgets.each do |budget| %>
<tr id="<%= dom_id(budget) %>" class="budget">
<td>
<%= budget.name %>
</td>
<td class="small">
<%= t("budgets.phase.#{budget.phase}") %>
</td>
<td class="small">
<%= link_to t("admin.budgets.index.budget_investments"), admin_budget_budget_investments_path(budget_id: budget.id) %>
</td>
<td class="small">
<%= link_to t("admin.budgets.index.edit_groups"), admin_budget_path(budget) %>
</td>
<td class="small">
<%= link_to t("admin.budgets.index.edit_budget"), edit_admin_budget_path(budget) %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @budgets %>

View File

@@ -0,0 +1,7 @@
<div class="row">
<div class="small-12 medium-9 column">
<h2><%= t("admin.budgets.new.title") %></h2>
<%= render '/admin/budgets/form' %>
</div>
</div>

View File

@@ -0,0 +1,7 @@
<%= back_link_to admin_budgets_path %>
<h2><%= @budget.name %></h2>
<div id="<%= dom_id @budget %>_groups">
<%= render "groups", groups: @budget.groups %>
</div>

View File

@@ -0,0 +1,25 @@
<%= form_for(Budget::Investment.new, url: url, as: :budget_investment, method: :get) do |f| %>
<div class="row">
<div class="small-12 medium-6 column">
<%= text_field_tag :search, "" %>
</div>
<div class="small-12 medium-6 column">
<%= select_tag :heading_id,
options_for_select(budget_heading_select_options(@budget),
params[:heading_id]),
include_blank: true
%>
</div>
</div>
<div class="row">
<div class="small-12 medium-6 column">
<%= check_box_tag :unfeasible, "1", params[:unfeasible].present? %>
</div>
</div>
<div class="row">
<div class="form-inline small-12 medium-3 column end">
<%= f.submit t("shared.search"), class: "button" %>
</div>
</div>
<% end %>