Created ingredients controller
command: rails generate redmine_plugin_controller body_tracking ingredients index create destroy
This commit is contained in:
11
app/controllers/ingredients_controller.rb
Normal file
11
app/controllers/ingredients_controller.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class IngredientsController < ApplicationController
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
def destroy
|
||||
end
|
||||
end
|
||||
2
app/helpers/ingredients_helper.rb
Normal file
2
app/helpers/ingredients_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module IngredientsHelper
|
||||
end
|
||||
@@ -3,6 +3,11 @@
|
||||
<li><%= link_to t(".link_summary"), project_body_trackers_path(@project) %></li>
|
||||
</ul>
|
||||
|
||||
<h3><%= t ".heading_diet" %></h3>
|
||||
<ul>
|
||||
<li><%= link_to t(".link_ingredients"), project_ingredients_path(@project) %></li>
|
||||
</ul>
|
||||
|
||||
<h3><%= t ".heading_common" %></h3>
|
||||
<ul>
|
||||
<li><%= link_to t(".link_quantities"), project_quantities_path(@project) %></li>
|
||||
@@ -12,4 +17,3 @@
|
||||
<li><p><%= link_to t(".link_defaults"), defaults_project_body_trackers_path(@project),
|
||||
method: :post, data: {confirm: t(".confirm_defaults")} %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
||||
1
app/views/ingredients/create.html.erb
Normal file
1
app/views/ingredients/create.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<h2>IngredientsController#create</h2>
|
||||
1
app/views/ingredients/destroy.html.erb
Normal file
1
app/views/ingredients/destroy.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<h2>IngredientsController#destroy</h2>
|
||||
47
app/views/ingredients/index.html.erb
Normal file
47
app/views/ingredients/index.html.erb
Normal file
@@ -0,0 +1,47 @@
|
||||
<% 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_new_unit"), '#', :class => 'icon icon-add',
|
||||
:onclick => 'showAndScrollTo("add-unit", "unit_shortname"); return false;' %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="add-unit" <%= 'style=display:none;' if @unit.errors.empty? %>>
|
||||
<h2><%= t ".heading_new_unit" %></h2>
|
||||
|
||||
<%= labelled_form_for @unit,
|
||||
:url => project_units_path(@project),
|
||||
:html => {:id => 'unit-form'} do |f| %>
|
||||
<%= render :partial => 'units/form', :locals => { :f => f } %>
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-unit").hide()' %>
|
||||
<% end %>
|
||||
<hr>
|
||||
</div>
|
||||
|
||||
<h2><%= t ".heading" %></h2>
|
||||
<% if @units.any? %>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= l(:field_shortname) %></th>
|
||||
<th><%= l(:field_name) %></th>
|
||||
<th style="width:15%"><%= l(:field_action) %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @units.each do |u| %>
|
||||
<tr id="unit-<%= u.id %>" class="unit">
|
||||
<td class="shortname"><%= u.shortname %></td>
|
||||
<td class="unitname"><%= u.name %></td>
|
||||
<td><%= delete_link unit_path(u), data: {} %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user