Added new Unit form
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
class BodyTrackersController < ApplicationController
|
||||
before_action :find_project, only: [:index, :units]
|
||||
before_action :find_project, only: [:index]
|
||||
before_action :authorize
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def units
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# :find_* methods are called before :authorize,
|
||||
|
||||
@@ -1,7 +1,28 @@
|
||||
class UnitsController < ApplicationController
|
||||
before_action :find_project, only: [:new, :index, :create]
|
||||
before_action :authorize
|
||||
|
||||
def new
|
||||
@unit = Unit.new
|
||||
end
|
||||
|
||||
def index
|
||||
@unit = Unit.new
|
||||
end
|
||||
|
||||
def create
|
||||
end
|
||||
|
||||
def destroy
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# :find_* methods are called before :authorize,
|
||||
# @project is required for :authorize to succeed
|
||||
def find_project
|
||||
@project = Project.find(params[:project_id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render_404
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,5 +5,5 @@
|
||||
|
||||
<h3><%= t ".heading_common" %></h3>
|
||||
<ul>
|
||||
<li><%= link_to t(".link_units"), units_project_body_trackers_path(@project) %></li>
|
||||
<li><%= link_to t(".link_units"), project_units_path(@project) %></li>
|
||||
</ul>
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<h2><%= t ".heading" %></h2>
|
||||
|
||||
<% content_for :sidebar do %>
|
||||
<%= render :partial => 'body_trackers/sidebar' %>
|
||||
<% end %>
|
||||
7
app/views/units/_form.html.erb
Normal file
7
app/views/units/_form.html.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<%= error_messages_for @unit %>
|
||||
|
||||
<div class="box tabular">
|
||||
<p><%= f.text_field :name, :required => true, :size => 40 %></p>
|
||||
<p><%= f.text_field :shortname, :required => true, :size => 10 %></p>
|
||||
<p><%#= f.select :summary, :cols => 60, :rows => 2 %></p>
|
||||
</div>
|
||||
26
app/views/units/index.html.erb
Normal file
26
app/views/units/index.html.erb
Normal file
@@ -0,0 +1,26 @@
|
||||
<% content_for :sidebar do %>
|
||||
<%= render :partial => 'body_trackers/sidebar' %>
|
||||
<% end %>
|
||||
|
||||
<div class="contextual">
|
||||
<% if @project && User.current.allowed_to?(:manage_units, @project) %>
|
||||
<%= link_to t(".heading_new_unit"), new_project_unit_path(@project),
|
||||
:class => 'icon icon-add',
|
||||
:onclick => 'showAndScrollTo("add-unit", "unit_name"); return false;' %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="add-unit" style="display:none;">
|
||||
<h2><%= t ".heading_new_unit" %></h2>
|
||||
|
||||
<%= labelled_form_for @unit,
|
||||
:url => project_units_path(@project),
|
||||
:html => { :id => 'unit-form', :multipart => true } 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>
|
||||
Reference in New Issue
Block a user