Displaying only quantities for current project
This commit is contained in:
parent
d74b721ee5
commit
ddac5d9aa8
@ -5,6 +5,7 @@ class QuantitiesController < ApplicationController
|
||||
|
||||
def index
|
||||
@quantity = Quantity.new
|
||||
@quantities = @project.quantities
|
||||
end
|
||||
|
||||
def create
|
||||
@ -13,6 +14,7 @@ class QuantitiesController < ApplicationController
|
||||
flash[:notice] = 'Created new quantity'
|
||||
redirect_to project_quantities_url(@project)
|
||||
else
|
||||
@quantities = @project.quantities
|
||||
render :index
|
||||
end
|
||||
end
|
||||
|
@ -7,7 +7,7 @@ module QuantitiesHelper
|
||||
end
|
||||
|
||||
def parent_options
|
||||
options = nested_set_options(Quantity, @quantity) do |i|
|
||||
options = nested_set_options(@quantities, @quantity) do |i|
|
||||
raw("#{' ' * i.level}#{i.name}")
|
||||
end
|
||||
options.unshift([t('.null_parent'), nil])
|
||||
|
@ -23,7 +23,7 @@
|
||||
</div>
|
||||
|
||||
<h2><%= t ".heading" %></h2>
|
||||
<% if Quantity.roots.any? %>
|
||||
<% if @quantities.any? %>
|
||||
<table class="list">
|
||||
<thead>
|
||||
<tr>
|
||||
@ -34,8 +34,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% Quantity.roots.each do |r| %>
|
||||
<% Quantity.each_with_level(r.self_and_descendants) do |q, level| %>
|
||||
<% Quantity.each_with_level(@quantities) do |q, level| %>
|
||||
<tr id="quantity-<%= q.id %>"
|
||||
class="quantity <%= "project idnt idnt-#{level}" if level > 0 %>">
|
||||
<td class="name"><span><%= q.name %></span></td>
|
||||
@ -44,7 +43,6 @@
|
||||
<td><%= delete_link quantity_path(q), data: {} %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
|
Reference in New Issue
Block a user