|
1 |
| -<% if params[:controller].eql? "IssueController" 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") and params[:action].eql? "show" and User.current.allowed_to?(:view_time_entries, @project) and @issue.present? and @issue.time_entries.present? %> |
| 1 | +<% if params[:controller].eql? "issues" and params[:action].eql? "show" 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") and User.current.allowed_to?(:view_time_entries, @project) and @issue.present? and @issue.time_entries.present? %> |
2 | 2 |
|
3 | 3 | <script type="text/javascript">
|
4 | 4 | $(document).ready(function() {
|
|
12 | 12 | var spent_time = [
|
13 | 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 | 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 %>", |
| 15 | + |
| 16 | + <% # Repeating code from _report.html.erb |
| 17 | + |
| 18 | + if Setting.plugin_redmine_spent_time_in_issue_description['time_format'].eql? "human" |
| 19 | + hours = entry.hours.to_i |
| 20 | + minutes = entry.hours * 60 |
| 21 | + minutes = (minutes - hours * 60 ).to_i |
| 22 | + |
| 23 | + time_spent = "" |
| 24 | + |
| 25 | + if hours == 1 |
| 26 | + time_spent = t('plugin_spent_time_in_issue.datetime.hours.one') |
| 27 | + elsif hours > 1 |
| 28 | + time_spent = t('plugin_spent_time_in_issue.datetime.hours.other', hours: hours ) |
| 29 | + end |
| 30 | + |
| 31 | + if minutes == 1 |
| 32 | + time_spent << " " << t('plugin_spent_time_in_issue.datetime.minutes.one') |
| 33 | + elsif minutes > 1 |
| 34 | + time_spent << " " << t('plugin_spent_time_in_issue.datetime.minutes.other', minutes: minutes ) |
| 35 | + end |
| 36 | + else |
| 37 | + time_spent = entry.hours |
| 38 | + end |
| 39 | + |
| 40 | + %> |
| 41 | + |
| 42 | + <%=raw '"spent_on":"' << entry.spent_on.strftime("%m/%d/%Y") << '",' if Setting.plugin_redmine_spent_time_in_issue_description['display_columns'].include? 'spentOn' %> |
| 43 | + <%=raw '"user":"' << entry.user.to_s << '",' if Setting.plugin_redmine_spent_time_in_issue_description['display_columns'].include? 'user' %> |
| 44 | + <%=raw '"hours":"' << time_spent << '",' if Setting.plugin_redmine_spent_time_in_issue_description['display_columns'].include? 'hours' %> |
| 45 | + <%=raw '"activity":"' << entry.activity.to_s << '",' if Setting.plugin_redmine_spent_time_in_issue_description['display_columns'].include? 'activity' %> |
| 46 | + <%=raw '"comments":"' << entry.comments << '",' if Setting.plugin_redmine_spent_time_in_issue_description['display_columns'].include? 'comments' %> |
20 | 47 |
|
21 | 48 | }
|
22 | 49 | <% end %>
|
|
27 | 54 | $.each( spent_time, function(idnex,entry){
|
28 | 55 | time_entries += '<div class="spenttimeentry '+toggle+'">'
|
29 | 56 | 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 |
| 57 | + if ( entry.spent_on !== undefined){ time_entries += '<span>' + entry.spent_on + '</span>' } |
| 58 | + if ( entry.user !== undefined){ time_entries += '<span>' + entry.user + '</span>' } |
| 59 | + if ( entry.activity !== undefined){ time_entries += '<span>' + entry.activity + '</span>' } |
| 60 | + if ( entry.hours !== undefined){ time_entries += '<span>' + entry.hours + '</span>' } |
| 61 | + if ( entry.comments !== undefined){ time_entries += '<br /> ' + entry.comments } |
34 | 62 | time_entries += '</p>'
|
35 | 63 | time_entries += '</div>'
|
36 | 64 |
|
|
45 | 73 |
|
46 | 74 | <% if @issue.changesets.present? and Setting.plugin_redmine_spent_time_in_issue_description['report_location'].eql? "below_revisions" %>
|
47 | 75 | $("#issue-changesets").append(time_entries)
|
48 |
| - console.log("below revisions"); |
49 | 76 | <% elsif @issue.changesets.present? %>
|
50 | 77 | $("#issue-changesets").prepend(time_entries)
|
51 |
| - console.log("above revisions"); |
52 | 78 | <% else %>
|
53 |
| - $("#history").before(time_entries) |
| 79 | + if ( $("#history").length < 0 ){ |
| 80 | + $("#history").before(time_entries) |
| 81 | + }else{ |
| 82 | + $("div.issue:first").after(time_entries) |
| 83 | + } |
54 | 84 | <% end %>
|
55 | 85 | });
|
56 | 86 |
|
57 | 87 | </script>
|
58 |
| - |
59 | 88 | <% end %>
|
0 commit comments