Created ingredients controller
command: rails generate redmine_plugin_controller body_tracking ingredients index create destroy
This commit is contained in:
parent
7062652d0d
commit
c916e7fd3c
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 %>
|
@ -17,8 +17,10 @@ en:
|
||||
heading: 'Summary'
|
||||
sidebar:
|
||||
heading_body_trackers: 'Body trackers'
|
||||
heding_diet: 'Diet'
|
||||
heading_common: 'Common'
|
||||
link_summary: 'Summary'
|
||||
link_ingredients: 'Ingredients'
|
||||
link_quantities: 'Quantities'
|
||||
link_units: 'Units'
|
||||
link_defaults: 'Load defaults'
|
||||
|
@ -6,7 +6,8 @@ resources :projects do
|
||||
resources :body_trackers, :only => [:index] do
|
||||
post 'defaults', on: :collection
|
||||
end
|
||||
resources :units, :only => [:index, :create, :destroy]
|
||||
resources :ingredients, :only => [:index, :create, :destroy]
|
||||
resources :quantities, :only => [:index, :create, :destroy]
|
||||
resources :units, :only => [:index, :create, :destroy]
|
||||
end
|
||||
end
|
||||
|
@ -18,6 +18,7 @@ class CreateUnits < ActiveRecord::Migration
|
||||
end
|
||||
|
||||
create_table :ingredients do |t|
|
||||
t.references :project
|
||||
t.string :name
|
||||
t.decimal :ref_amount
|
||||
t.references :ref_unit
|
||||
|
8
test/functional/ingredients_controller_test.rb
Normal file
8
test/functional/ingredients_controller_test.rb
Normal file
@ -0,0 +1,8 @@
|
||||
require File.expand_path('../../test_helper', __FILE__)
|
||||
|
||||
class IngredientsControllerTest < ActionController::TestCase
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user