Files
grecia/app/views/admin/budget_investments/edit.html.erb
Javi Martín 6fa67b5e53 Use active record translations for labels
This way we can simplify the way we generate form fields. In some cases,
we also use the human attribute in table headers, which IMHO makes
sense.

I haven't moved all of them: for example, sometimes a label is
different depending on whether it's shown to administrators, valuators,
or users. And I haven't touched the ones related to devise, since I
wasn't sure about possible side effects.

Note I've also removed placeholders when they had the same text as their
labels, since they weren't helpful. On the contrary, the added redundant
text to the form, potentially distracting users.
2019-10-07 01:56:23 +02:00

129 lines
4.9 KiB
Plaintext

<%= link_to admin_budget_budget_investment_path(@budget, @investment, Budget::Investment.filter_params(params).to_h), class: "back" do %>
<span class="icon-angle-left"></span> <%= t("shared.back") %>
<% end %>
<%= render "shared/globalize_locales", resource: @investment %>
<div class="row">
<%= translatable_form_for @investment,
url: admin_budget_budget_investment_path(@budget, @investment) do |f| %>
<%= render "shared/errors", resource: @investment %>
<% Budget::Investment.filter_params(params).to_h.each do |filter_name, filter_value| %>
<%= hidden_field_tag filter_name, filter_value %>
<% end %>
<div class="row expanded">
<%= f.translatable_fields do |translations_form| %>
<div class="small-12 column">
<%= translations_form.text_field :title,
maxlength: Budget::Investment.title_max_length %>
</div>
<div class="ckeditor small-12 column">
<%= translations_form.cktext_area :description,
maxlength: Budget::Investment.description_max_length,
ckeditor: { language: I18n.locale } %>
</div>
<% end %>
<div class="small-12 column">
<%= f.text_field :tag_list,
value: @investment.tag_list.sort.join(","),
label: t("admin.budget_investments.edit.user_tags") %>
</div>
<div class="small-12 column">
<div class="small-12 medium-6">
<%= f.text_field :external_url %>
</div>
<div class="small-12 medium-6">
<%= f.select :heading_id, budget_heading_select_options(@budget), include_blank: t("admin.budget_investments.edit.select_heading") %>
</div>
</div>
</div>
<div class="row expanded margin-top">
<div class="small-12 column">
<h2 id="classification"><%= t("admin.budget_investments.edit.classification") %></h2>
<div class="small-12 medium-6">
<%= f.select(:administrator_id,
@admins.collect { |a| [a.description_or_name_and_email, a.id] },
{ include_blank: t("admin.budget_investments.edit.undefined") }) %>
</div>
</div>
<div class="small-12 column">
<%= f.label :valuation_tag_list %>
<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.valuation_tag_list.sort.join(","),
label: false,
placeholder: t("admin.budget_investments.edit.tags_placeholder"),
class: "js-tag-list" %>
</div>
<div class="small-12 column margin-top">
<%= f.label :valuator_ids %>
<ul>
<%= f.collection_check_boxes :valuator_group_ids, @valuator_groups, :id, :name do |group| %>
<li><%= group.label(title: group.object.name) { group.check_box + truncate(group.object.name, length: 60) } %></li>
<% end %>
</ul>
</div>
<div class="small-12 column">
<hr>
<%= f.label :valuator_ids, t("admin.budget_investments.edit.assigned_valuators") %>
<ul>
<%= f.collection_check_boxes :valuator_ids, @valuators, :id, :email do |b| %>
<li><%= b.label(title: valuator_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %></li>
<% end %>
</ul>
</div>
<div class="small-12 column">
<hr>
<%= f.label :tracker_ids, t("admin.budget_investments.edit.assigned_trackers") %>
<ul>
<%= f.collection_check_boxes :tracker_ids, @trackers, :id, :email do |b| %>
<li><%= b.label(title: tracker_label(b.object)) { b.check_box + truncate(b.object.description_or_email, length: 60) } %></li>
<% end %>
</ul>
</div>
</div>
<div class="row expanded margin-top">
<% if @investment.incompatible? || @investment.winner? %>
<div class="small-12 medium-3 column">
<h2 id="incompatible"><%= t("admin.budget_investments.edit.compatibility") %></h2>
<%= f.check_box :incompatible,
title: t("admin.budget_investments.edit.compatibility") %>
</div>
<% end %>
<div class="small-12 medium-3 column float-left">
<h2 id="selected"><%= t("admin.budget_investments.edit.selection") %></h2>
<%= f.check_box :selected,
title: t("admin.budget_investments.edit.selection") %>
</div>
</div>
<div class="small-12 column">
<%= f.text_field :milestone_tag_list,
value: @investment.milestone_tag_list.sort.join(", ") %>
</div>
<div class="small-12 column margin-top">
<%= f.submit(class: "button", value: t("admin.budget_investments.edit.submit_button")) %>
</div>
<% end %>
</div>