Skip to content

Commit 474ede7

Browse files
committed
do not show resource category when no categories present #30
- in form - in list view
1 parent f31a5ea commit 474ede7

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed

app/controllers/asset_resource_items_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
class AssetResourceItemsController < ResourceItemsController
22
menu_item :asset_resource_items
33

4+
private
5+
46
def resource_class
57
Asset
68
end

app/controllers/human_resource_items_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
class HumanResourceItemsController < ResourceItemsController
22
menu_item :human_resource_items
33

4+
private
5+
46
def resource_class
57
Human
68
end

app/views/asset_resource_items/index.html.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<% categories_present = ResourceCategory.for_assets.where(project: @project).any? %>
12
<div class="contextual">
23
<% if User.current.allowed_to? :manage_resource_items, @project %>
34
<%= link_to l(:label_asset_resource_item_new), new_project_asset_resource_item_path(@project), class: 'icon icon-add' %>
@@ -10,15 +11,19 @@
1011
<table class="list resource_items">
1112
<thead>
1213
<tr>
14+
<% if categories_present %>
1315
<th><%= l :label_resource_item_category %></th>
16+
<% end %>
1417
<th><%= l :label_resource_item_name %></th>
1518
<th></th>
1619
</tr>
1720
</thead>
1821
<tbody>
1922
<% for i in @resource_items %>
2023
<tr>
24+
<% if categories_present %>
2125
<td class="category"><%= i.category&.name %>
26+
<% end %>
2227
<td class="name"><%= link_to i.name, edit_project_asset_resource_item_path(@project, i) %></td>
2328
<td><%= delete_link project_asset_resource_item_path(@project, i) %></td>
2429
</tr>

app/views/human_resource_items/index.html.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<% categories_present = ResourceCategory.for_humans.where(project: @project).any? %>
12
<div class="contextual">
23
<% if User.current.allowed_to? :manage_resource_items, @project %>
34
<%= link_to l(:label_human_resource_item_new), new_project_human_resource_item_path(@project), class: 'icon icon-add' %>
@@ -10,15 +11,19 @@
1011
<table class="list resource_items">
1112
<thead>
1213
<tr>
14+
<% if categories_present %>
1315
<th><%= l :label_resource_item_category %></th>
16+
<% end %>
1417
<th><%= l :label_resource_item_name %></th>
1518
<th></th>
1619
</tr>
1720
</thead>
1821
<tbody>
1922
<% for i in @resource_items %>
2023
<tr>
24+
<% if categories_present %>
2125
<td class="category"><%= i.category&.name %>
26+
<% end %>
2227
<td class="name"><%= link_to i.name, edit_project_human_resource_item_path(@project, i) %></td>
2328
<td><%= delete_link project_human_resource_item_path(@project, i) %></td>
2429
</tr>

app/views/resource_items/_form.html.erb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
<div class="box tabular">
44
<p><%= f.text_field :name, required: true, size: 25 %></p>
5-
<p><%= f.select :category_id, categories.sorted.map{|c|[c.name, c.id]}, label: l(:field_resource_category), include_blank: true %></p>
5+
<% if categories.any? %>
6+
<p><%= f.select :category_id, categories.sorted.map{|c|[c.name, c.id]}, label: l(:field_resource_category), include_blank: true %></p>
7+
<% end %>
68
</div>
79

810

0 commit comments

Comments
 (0)