79 lines
2.7 KiB
Plaintext
79 lines
2.7 KiB
Plaintext
<% content_for :sidebar do %>
|
|
<%= render :partial => 'body_trackers/sidebar' %>
|
|
<% end %>
|
|
|
|
<div class="contextual">
|
|
<% if User.current.allowed_to?(:manage_common, @project) %>
|
|
<%= link_to t(".heading_import_ingredients"), '#', :class => 'icon icon-file',
|
|
:onclick => 'showAndScrollTo("import-ingredients", "filename"); return false;' %>
|
|
<%= link_to t(".heading_new_ingredient"), '#', :class => 'icon icon-add',
|
|
:onclick => 'showAndScrollTo("add-ingredient", "ingredient_name"); return false;' %>
|
|
<% end %>
|
|
</div>
|
|
|
|
<div id="import-ingredients" style="display:none;">
|
|
<h2><%= t ".heading_import_ingredients" %></h2>
|
|
|
|
<%= form_tag import_project_ingredients_path(@project),
|
|
:multipart => true,
|
|
:id => 'import-form' do %>
|
|
<div class="box tabular">
|
|
<p>
|
|
<label><%= t ".label_import_select_csv_file" %></label>
|
|
<%= file_field_tag 'file' %>
|
|
</p>
|
|
<p>
|
|
<%= t ".import_hints" %>
|
|
</p>
|
|
</div>
|
|
<%= submit_tag l(:button_import) %>
|
|
<%= link_to l(:button_cancel), "#", :onclick => '$("#import-ingredients").hide()' %>
|
|
<% end %>
|
|
<hr>
|
|
</div>
|
|
|
|
<div id="add-ingredient" <%= 'style=display:none;' if @ingredient.errors.empty? %>>
|
|
<h2><%= t ".heading_new_ingredient" %></h2>
|
|
|
|
<%= labelled_form_for @ingredient,
|
|
:url => project_ingredients_path(@project),
|
|
:html => {:id => 'ingredient-form'} do |f| %>
|
|
<%= render :partial => 'ingredients/form', :locals => { :f => f } %>
|
|
<%= submit_tag l(:button_create) %>
|
|
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-ingredient").hide()' %>
|
|
<% end %>
|
|
<hr>
|
|
</div>
|
|
|
|
<h2><%= t ".heading" %></h2>
|
|
<% if @ingredients.many? %>
|
|
<table class="list">
|
|
<thead>
|
|
<tr>
|
|
<th><%= l(:field_name) %></th>
|
|
<th><%= l(:field_reference) %></th>
|
|
<th><%= l(:field_group) %></th>
|
|
<th><%= l(:field_source) %></th>
|
|
<th style="width:15%"><%= l(:field_action) %></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% @ingredients.each do |i| %>
|
|
<% next if i.new_record? %>
|
|
<tr id="ingredient-<%= i.id %>" class="ingredient <%= 'hidden' if i.hidden %>">
|
|
<td class="name"><%= i.name %></td>
|
|
<td class="reference"><%= i.ref_amount %> [<%= i.ref_unit.shortname %>]</td>
|
|
<td class="group"><%= i.group %></td>
|
|
<td class="source">
|
|
<%= i.source.name if i.source.present? %>
|
|
<%= ", #{i.source_ident}" if i.source_ident.present? %>
|
|
</td>
|
|
<td><%= delete_link ingredient_path(i), data: {} %></td>
|
|
</tr>
|
|
<% end %>
|
|
</tbody>
|
|
</table>
|
|
<% else %>
|
|
<p class="nodata"><%= l(:label_no_data) %></p>
|
|
<% end %>
|