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