Skip to content

Commit 64ef56f

Browse files
committed
refs #35, #37 adding start/end_date and adjusting name uniqueness
1 parent 0c726dc commit 64ef56f

File tree

7 files changed

+31
-1
lines changed

7 files changed

+31
-1
lines changed

app/models/resource_item.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ class ResourceItem < ActiveRecord::Base
77
validates :project_id, presence: true
88
#validates :category_id, presence: true
99
validates :name, presence: true,
10-
uniqueness: { case_sensitive: false, scope: :category_id }
10+
uniqueness: { case_sensitive: false, scope: [:project_id, :category_id] }
11+
12+
validates :start_date, :date => true
13+
validates :end_date, :date => true
1114

1215
scope :sorted, ->{ order name: :asc}
1316
scope :humans, ->{ where type: 'Human' }

app/views/asset_resource_items/index.html.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<th><%= l :label_resource_item_category %></th>
1616
<% end %>
1717
<th><%= l :label_resource_item_name %></th>
18+
<th><%= l :label_resource_item_start_date %></th>
19+
<th><%= l :label_resource_item_end_date %></th>
1820
<th></th>
1921
</tr>
2022
</thead>
@@ -25,6 +27,8 @@
2527
<td class="category"><%= i.category&.name %>
2628
<% end %>
2729
<td class="name"><%= link_to i.name, edit_project_asset_resource_item_path(@project, i) %></td>
30+
<td class="date"><%= format_date(i.start_date) %></td>
31+
<td class="date"><%= format_date(i.end_date) %></td>
2832
<td><%= delete_link project_asset_resource_item_path(@project, i) %></td>
2933
</tr>
3034
<% end %>

app/views/human_resource_items/index.html.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<th><%= l :label_resource_item_category %></th>
1616
<% end %>
1717
<th><%= l :label_resource_item_name %></th>
18+
<th><%= l :label_resource_item_start_date %></th>
19+
<th><%= l :label_resource_item_end_date %></th>
1820
<th></th>
1921
</tr>
2022
</thead>
@@ -25,6 +27,8 @@
2527
<td class="category"><%= i.category&.name %>
2628
<% end %>
2729
<td class="name"><%= link_to i.name, edit_project_human_resource_item_path(@project, i) %></td>
30+
<td class="date"><%= format_date(i.start_date) %></td>
31+
<td class="date"><%= format_date(i.end_date) %></td>
2832
<td><%= delete_link project_human_resource_item_path(@project, i) %></td>
2933
</tr>
3034
<% end %>

app/views/resource_items/index.html.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
<tr>
1313
<th><%= l :label_resource_item_category %></th>
1414
<th><%= l :label_resource_item_name %></th>
15+
<th><%= l :label_resource_item_start_date %></th>
16+
<th><%= l :label_resource_item_end_date %></th>
1517
<th></th>
1618
</tr>
1719
</thead>
@@ -20,6 +22,8 @@
2022
<tr>
2123
<td class="category"><%= i.category.name %>
2224
<td class="name"><%= link_to i.name, edit_project_resource_item_path(@project, i) %></td>
25+
<td class="date"><%= format_date(i.start_date) %></td>
26+
<td class="date"><%= format_date(i.end_date) %></td>
2327
<td><%= delete_link project_resource_item_path(@project, i) %></td>
2428
</tr>
2529
<% end %>

config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,5 @@ en:
6161
text_supply_item_nochange: no change
6262
text_issue_supply_item_changed:
6363
"Issue #%{id}: %{name} was changed (%{change})"
64+
label_resource_item_start_date: Start date
65+
label_resource_item_end_date: End date

config/locales/ja.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,5 @@ ja:
6161
text_supply_item_nochange: 変更なし
6262
text_issue_supply_item_changed:
6363
"チケット #%{id}: %{name} が変更されました (%{change})"
64+
label_resource_item_start_date: 開始日
65+
label_resource_item_end_date: 終了日
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class AddStartDateAndEndDateToResourceItems < ActiveRecord::Migration[5.2]
2+
def self.up
3+
add_column :resource_items, :start_date, :date
4+
add_column :resource_items, :end_date, :date
5+
end
6+
7+
def self.down
8+
remove_column :resource_items, :start_date
9+
remove_column :resource_items, :end_date
10+
end
11+
end

0 commit comments

Comments
 (0)