diff --git a/app/controllers/ingredients_controller.rb b/app/controllers/ingredients_controller.rb new file mode 100644 index 0000000..f97a4d3 --- /dev/null +++ b/app/controllers/ingredients_controller.rb @@ -0,0 +1,11 @@ +class IngredientsController < ApplicationController + + def index + end + + def create + end + + def destroy + end +end diff --git a/app/helpers/ingredients_helper.rb b/app/helpers/ingredients_helper.rb new file mode 100644 index 0000000..dd54783 --- /dev/null +++ b/app/helpers/ingredients_helper.rb @@ -0,0 +1,2 @@ +module IngredientsHelper +end diff --git a/app/views/body_trackers/_sidebar.html.erb b/app/views/body_trackers/_sidebar.html.erb index d3c965b..9f50063 100644 --- a/app/views/body_trackers/_sidebar.html.erb +++ b/app/views/body_trackers/_sidebar.html.erb @@ -3,6 +3,11 @@
  • <%= link_to t(".link_summary"), project_body_trackers_path(@project) %>
  • +

    <%= t ".heading_diet" %>

    + +

    <%= t ".heading_common" %>

    diff --git a/app/views/ingredients/create.html.erb b/app/views/ingredients/create.html.erb new file mode 100644 index 0000000..7936ded --- /dev/null +++ b/app/views/ingredients/create.html.erb @@ -0,0 +1 @@ +

    IngredientsController#create

    diff --git a/app/views/ingredients/destroy.html.erb b/app/views/ingredients/destroy.html.erb new file mode 100644 index 0000000..0e45f4e --- /dev/null +++ b/app/views/ingredients/destroy.html.erb @@ -0,0 +1 @@ +

    IngredientsController#destroy

    diff --git a/app/views/ingredients/index.html.erb b/app/views/ingredients/index.html.erb new file mode 100644 index 0000000..01c25b5 --- /dev/null +++ b/app/views/ingredients/index.html.erb @@ -0,0 +1,47 @@ +<% content_for :sidebar do %> + <%= render :partial => 'body_trackers/sidebar' %> +<% end %> + +
    + <% 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 %> +
    + +
    > +

    <%= t ".heading_new_unit" %>

    + + <%= 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 %> +
    +
    + +

    <%= t ".heading" %>

    +<% if @units.any? %> + + + + + + + + + + <% @units.each do |u| %> + + + + + + <% end %> + +
    <%= l(:field_shortname) %><%= l(:field_name) %><%= l(:field_action) %>
    <%= u.shortname %><%= u.name %><%= delete_link unit_path(u), data: {} %>
    +<% else %> +

    <%= l(:label_no_data) %>

    +<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index d0efc19..41127d3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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' diff --git a/config/routes.rb b/config/routes.rb index 938673d..9cfaa3e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/db/migrate/001_create_units.rb b/db/migrate/001_create_units.rb index 413357f..c07cab2 100644 --- a/db/migrate/001_create_units.rb +++ b/db/migrate/001_create_units.rb @@ -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 diff --git a/test/functional/ingredients_controller_test.rb b/test/functional/ingredients_controller_test.rb new file mode 100644 index 0000000..abd52e2 --- /dev/null +++ b/test/functional/ingredients_controller_test.rb @@ -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