1
0

Created ingredients controller

command: rails generate redmine_plugin_controller body_tracking
ingredients index create destroy
This commit is contained in:
cryptogopher 2019-09-13 14:03:39 +02:00
parent 7062652d0d
commit c916e7fd3c
10 changed files with 80 additions and 2 deletions

View File

@ -0,0 +1,11 @@
class IngredientsController < ApplicationController
def index
end
def create
end
def destroy
end
end

View File

@ -0,0 +1,2 @@
module IngredientsHelper
end

View File

@ -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>

View File

@ -0,0 +1 @@
<h2>IngredientsController#create</h2>

View File

@ -0,0 +1 @@
<h2>IngredientsController#destroy</h2>

View 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 %>

View File

@ -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'

View File

@ -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

View File

@ -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

View 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