Skip to content

@nicolnx improved and zh.yml translation file #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

app/views/issues/show.html.erb

.idea
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in your global environment, not in a project's gitignore. Not everyone uses RubyMine.


#ignore vim files
*.swp
*.swo
*.swo
2 changes: 1 addition & 1 deletion app/views/issues/3.0.0.show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
end
end
if User.current.allowed_to?(:view_time_entries, @project)
rows.right l(:label_spent_time), (@issue.total_spent_hours > 0 ? link_to(l_hours(@issue.total_spent_hours), issue_time_entries_path(@issue)) : "-"), :class => 'spent-time'
rows.right l(:label_spent_time), (@issue.total_spent_hours > 0 ? link_to(l_hours(@total_hours), issue_time_entries_path(@issue)) : '-'), :class => 'spent-time'
end
end %>
<%= render_custom_fields_rows(@issue) %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/issues/3.0.1.show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
end
end
if User.current.allowed_to?(:view_time_entries, @project)
rows.right l(:label_spent_time), (@issue.total_spent_hours > 0 ? link_to(l_hours(@issue.total_spent_hours), issue_time_entries_path(@issue)) : "-"), :class => 'spent-time'
rows.right l(:label_spent_time), (@issue.total_spent_hours > 0 ? link_to(l_hours(@total_hours), issue_time_entries_path(@issue)) : '-'), :class => 'spent-time'
end
end %>
<%= render_custom_fields_rows(@issue) %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/issues/3.2.0.show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
rows.right l(:field_estimated_hours), issue_estimated_hours_details(@issue), :class => 'estimated-hours'
end
end
if User.current.allowed_to_view_all_time_entries?(@project)
if User.current.allowed_to?(:view_time_entries, @project)
if @issue.total_spent_hours > 0
rows.right l(:label_spent_time), issue_spent_hours_details(@issue), :class => 'spent-time'
rows.right l(:label_spent_time), (@issue.total_spent_hours > 0 ? link_to(l_hours(@total_hours), issue_time_entries_path(@issue)) : '-'), :class => 'spent-time'
end
end
end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/issues/_floating_report.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div id="issue-spenttime" >
<h3>Spent Time Report</h3>

<% @issue.time_entries.last( Setting.plugin_redmine_spent_time_in_issue_description['spent_time_max_display'].to_i ).each_with_index do |entry, index| %>
<% @time_entries.last( Setting.plugin_redmine_spent_time_in_issue_description['spent_time_max_display'].to_i ).each_with_index do |entry, index| %>
<div class="spenttimeentry <%= (index % 2 == 0 ? "even" : "odd") %>">
<p>
<%= content_tag(:span, format_date( entry.spent_on ) ) if spent_on_shown? %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/issues/_time_spent_report.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<hr />
<p>
<strong><%= t('plugin_spent_time_in_issue.timeEntries') %></strong>
<% if @issue.time_entries.count > Setting.plugin_redmine_spent_time_in_issue_description['spent_time_max_display'].to_i %>
<%= link_to "#{t "plugin_spent_time_in_issue.seeAllCount", count: @issue.time_entries.count}", issue_time_entries_path( @issue ) %>
<% if @time_entries.count > Setting.plugin_redmine_spent_time_in_issue_description['spent_time_max_display'].to_i %>
<%= link_to "#{t "plugin_spent_time_in_issue.seeAllCount", count: @time_entries.count}", issue_time_entries_path( @issue ) %>
<% end %>
</p>

Expand All @@ -14,7 +14,7 @@
<%= content_tag(:th ) %>
</thead>
<tbody>
<% @issue.time_entries.last( Setting.plugin_redmine_spent_time_in_issue_description['spent_time_max_display'].to_i ).each do |entry| %>
<% @time_entries.last( Setting.plugin_redmine_spent_time_in_issue_description['spent_time_max_display'].to_i ).each do |entry| %>
<tr>
<%= content_tag(:td, format_date( entry.spent_on ) ) if spent_on_shown? %>
<%= content_tag(:td, link_to_user( entry.user )) if user_shown? %>
Expand Down
25 changes: 25 additions & 0 deletions config/locales/zh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
zh:
plugin_spent_time_in_issue:
timeEntries: 工时记录
spentOn: 工时发生日期
max_display: 显示最大记录数
time_format: 工时显示格式
time_format_decimal: 小时-含小数 (如:1.5 )
time_format_human: 自适应格式 ( 如:1小时 )
datetime:
hours:
one: 1 小时
other: "%{hours} 小时"
minutes:
one: 1 分钟
other: "%{minutes} 分钟"
user: 用户
hours: 工时
comments: 备注
display_cols: 显示列
activity: 活动
seeAllCount: "( 查看所有 %{count} 个工时记录 )"
error: "系统错误"
error_description: "该插件不能向问题写入信息。"
error_from_file: "请复制并重命名文件:"
error_to_file: "至文件:"
2 changes: 2 additions & 0 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
partial: 'settings/spent_time_in_issue_description_settings')

ActionDispatch::Callbacks.to_prepare do
require 'issues_controller_patch'
SetupIssueShow.new.replace
IssuesController.send(:include, TimeEntriesPatch::IssuesControllerPatch)
end
Rails.application.config.after_initialize do
require 'issue_helper_patch'
Expand Down
61 changes: 61 additions & 0 deletions lib/issues_controller_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
module TimeEntriesPatch
module IssuesControllerPatch

def self.included(base)
base.class_eval do

def show_with_plugin
@journals = @issue.journals.includes(:user, :details).
references(:user, :details).
reorder(:created_on, :id).to_a
@journals.each_with_index { |j, i| j.indice = i+1 }
@journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project)
Journal.preload_journals_details_custom_fields(@journals)
@journals.select! { |journal| journal.notes? || journal.visible_details.any? }
@journals.reverse! if User.current.wants_comments_in_reverse_order?

@changesets = @issue.changesets.visible.preload(:repository, :user).to_a
@changesets.reverse! if User.current.wants_comments_in_reverse_order?

@relations = @issue.relations.select { |r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
@priorities = IssuePriority.active
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
@relation = IssueRelation.new

@time_query = TimeEntryQuery.build_from_params(params)
scope = time_entry_scope().
includes(:project, :user, :issue).
preload(:issue => [:project, :tracker, :status, :assigned_to, :priority])
@total_hours = scope.sum(:hours).to_f
@time_entries = scope

respond_to do |format|
format.html {
retrieve_previous_and_next_issue_ids
render :template => 'issues/show'
}
format.api
format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
format.pdf {
send_file_headers! :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf"
}
end
end

alias_method_chain :show, :plugin

private

def time_entry_scope(options={})
scope = @time_query.results_scope(options)
if @issue
scope = scope.on_issue(@issue)
end
scope
end

end
end
end
end