Skip to content

Commit 33d006a

Browse files
author
travis
committed
Initial commit for #4
Settings allow you to configure where the spent time report appears. Need to bring customizations into floating report. It’s not using localized language or custom columns.
1 parent 7df2004 commit 33d006a

10 files changed

+94
-2
lines changed

app/views/settings/_spent_time_settings.html.erb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,32 @@
3737
</td>
3838
<tr>
3939

40+
<tr>
41+
<th style="vertical-align:top" ><%= t('plugin_spent_time_in_issue.max_display') %></th>
42+
<td>
43+
<div class="placement_examples" >
44+
<input type="radio" name="settings[report_location]" value="below_revisions" <%= "checked" if settings['report_location'].eql? "below_revisions" %> >Below Revisions
45+
<br />
46+
<%= image_tag('spent_time_report_below_revisions.png', :plugin => 'redmine_spent_time_in_issue_description') %>
47+
</div>
48+
<div class="placement_examples" >
49+
<input type="radio" name="settings[report_location]" value="above_revisions" <%= "checked" if settings['report_location'].eql? "above_revisions" %> >Above Revisions
50+
<br />
51+
<%= image_tag("spent_time_report_above_revisions.png", :plugin => 'redmine_spent_time_in_issue_description') %>
52+
</div>
53+
<div class="placement_examples" >
54+
<input type="radio" name="settings[report_location]" value="ticket_body" <%= "checked" if settings['report_location'].eql? "ticket_body" or settings['report_location'].nil? %> >Ticket Body
55+
<br />
56+
<%= image_tag("spent_time_report_in_ticket_body.png", :plugin => 'redmine_spent_time_in_issue_description') %>
57+
</div>
58+
</td>
59+
</tr>
60+
4061
</tbody>
4162
</table>
4263

64+
<%= settings %>
65+
4366

4467

4568
<% content_for :header_tags do %>
@@ -58,5 +81,7 @@
5881
</script>
5982
<style type="text/css">
6083
label.error{ color: red; }
84+
div.placement_examples{ float: right; padding-right: 15px }
85+
div.placement_examples > img { border: 1px solid #505050; margin-top: 10px; }
6186
</style>
6287
<% end %>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<% if User.current.allowed_to?(:view_time_entries, @project) and @issue.time_entries.present? and ( Setting.plugin_redmine_spent_time_in_issue_description['report_location'].eql? "below_revisions" or Setting.plugin_redmine_spent_time_in_issue_description['report_location'].eql? "above_revisions") %>
2+
3+
<script type="text/javascript">
4+
$(document).ready(function() {
5+
6+
<% if @issue.changesets.present? %>
7+
lonely_spenttime = ""
8+
<% else %>
9+
lonely_spenttime = " lonely_spenttime"
10+
<% end %>
11+
12+
var spent_time = [
13+
<% @issue.time_entries.last( Setting.plugin_redmine_spent_time_in_issue_description['spent_time_max_display'].to_i ).each_with_index do |entry, index| %>
14+
<%= "," if index > 0 %> {
15+
"spent_on":"<%= entry.spent_on.strftime("%m/%d/%Y") %>",
16+
"user":" <%= entry.user %>",
17+
"hours":"<%= entry.hours %>",
18+
"activity":"<%= entry.activity %>",
19+
"comments":"<%= entry.comments %>",
20+
21+
}
22+
<% end %>
23+
];
24+
25+
var toggle = "odd"
26+
var time_entries = ' <div id="issue-spenttime" class="'+lonely_spenttime+'"><h3>Spent Time Report</h3>'
27+
$.each( spent_time, function(idnex,entry){
28+
time_entries += '<div class="spenttimeentry '+toggle+'">'
29+
time_entries += '<p>'
30+
time_entries += '<span>' + entry.spent_on + '</span>'
31+
time_entries += '<span>' + entry.user + '</span>'
32+
time_entries += '<span>' + entry.hours + '</span>'
33+
time_entries += '<br /> ' + entry.comments
34+
time_entries += '</p>'
35+
time_entries += '</div>'
36+
37+
if( toggle === "odd" ){
38+
toggle = "even"
39+
}else{
40+
toggle = "odd"
41+
}
42+
43+
});
44+
time_entries += '</div>'
45+
46+
<% if @issue.changesets.present? and Setting.plugin_redmine_spent_time_in_issue_description['report_location'].eql? "below_revisions" %>
47+
$("#issue-changesets").append(time_entries)
48+
console.log("below revisions");
49+
<% elsif @issue.changesets.present? %>
50+
$("#issue-changesets").prepend(time_entries)
51+
console.log("above revisions");
52+
<% else %>
53+
$("#history").before(time_entries)
54+
<% end %>
55+
});
56+
57+
</script>
58+
59+
<% end %>

app/views/spent_time/_report.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<% if User.current.allowed_to?(:view_time_entries, @project) and @issue.time_entries.present? %>
1+
<% if User.current.allowed_to?(:view_time_entries, @project) and @issue.time_entries.present? and (Setting.plugin_redmine_spent_time_in_issue_description['report_location'].eql? "ticket_body" or Setting.plugin_redmine_spent_time_in_issue_description['report_location'].nil? )%>
22

33
<hr />
44
<p><strong><%= t('plugin_spent_time_in_issue.timeEntries') %></strong> <%= link_to "#{t "plugin_spent_time_in_issue.seeAllCount", count: @issue.time_entries.count}", project_issue_time_entries_path( @project , @issue ) if @issue.time_entries.count > Setting.plugin_redmine_spent_time_in_issue_description['spent_time_max_display'].to_i %> </p>
Loading
Loading
Loading

assets/javascripts/spent_time_report_builder.js

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
table.issue-spent-time-description { width: 100%; text-align: left; }
2+
.spenttimeentry { border-bottom: 1px solid #ddd }
3+
#issue-spenttime { float: right; margin-left: 13m; margin-bottom: 1em; background: #fff; font-size: 90% }
4+
div.lonely_spenttime { padding-left: 1em; width: 45%;}
5+
#issue-spenttime > div > p { margin: 0px; margin-bottom: 1em; }
6+
#issue-spenttime > div > p > span { padding-right: 20px; }
7+

init.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
url 'https://github.com/TravisSpangle/redmine_spent_time_in_issue_description'
1212
settings( :default => { 'spent_time_max_display' => 5,
1313
'display_columns' => ["spentOn", "user", "hours", "comments"],
14-
'time_format' => 'decimal'
14+
'time_format' => 'decimal',
15+
'report_location' => 'ticket_body'
1516
},
1617
:partial => 'settings/spent_time_settings' )
1718
end
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class IssueDescriptionWithSpentTimeHookListener < Redmine::Hook::ViewListener
22
render_on :view_issues_show_description_bottom, :partial => "spent_time/report"
3+
render_on :view_layouts_base_html_head, :partial => "spent_time/javascript_report"
34
end
45

0 commit comments

Comments
 (0)