Skip to content

Commit 14d2ef1

Browse files
committed
refs #38 adjusted print format
1 parent e00eeb6 commit 14d2ef1

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

lib/redmine_supply/hooks.rb

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,43 @@ def redmine_gtt_print_issue_to_json(context)
66
issue = context[:issue]
77
json = context[:json]
88
attributes = json[:attributes] ||= {}
9+
910
attributes[:supply_items] = IssueSupplyItemsPresenter.(issue.issue_supply_items).join("\r\n")
11+
supply_items = IssueSupplyItemsPresenter.(issue.issue_supply_items)
12+
if supply_items.size > 5
13+
attributes[:supply_items_1] = supply_items[0..4].join("\r\n")
14+
attributes[:supply_items_2] = supply_items[5..-1].join("\r\n")
15+
else
16+
attributes[:supply_items_1] = supply_items.join("\r\n")
17+
attributes[:supply_items_2] = ""
18+
end
1019
items_by_type = issue.resource_items_by_type
11-
attributes[:asset_resource_items] = ResourceItemsPresenter.(items_by_type['asset']).join("\r\n")
12-
attributes[:human_resource_items] = ResourceItemsPresenter.(items_by_type['human']).join("\r\n")
20+
asset_resource_items_value = ""
21+
ResourceItemsPresenter.(items_by_type['asset']).each_with_index{|item, idx|
22+
if idx == 0
23+
asset_resource_items_value = item
24+
else
25+
if idx % 2 != 0
26+
asset_resource_items_value += "  " + item
27+
else
28+
asset_resource_items_value += "\r\n" + item
29+
end
30+
end
31+
}
32+
attributes[:asset_resource_items] = asset_resource_items_value
33+
human_resource_items_value = ""
34+
ResourceItemsPresenter.(items_by_type['human']).each_with_index{|item, idx|
35+
if idx == 0
36+
human_resource_items_value = item
37+
else
38+
if idx % 5 != 0
39+
human_resource_items_value += "  " + item
40+
else
41+
human_resource_items_value += "\r\n" + item
42+
end
43+
end
44+
}
45+
attributes[:human_resource_items] = human_resource_items_value
1346
end
1447
end
1548
end

0 commit comments

Comments
 (0)