Redmine 4.1.1
This commit is contained in:
parent
33e7b881a5
commit
3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -23,12 +25,16 @@ class TimeEntryQuery < Query
|
|||
self.available_columns = [
|
||||
QueryColumn.new(:project, :sortable => "#{Project.table_name}.name", :groupable => true),
|
||||
QueryColumn.new(:spent_on, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :default_order => 'desc', :groupable => true),
|
||||
TimestampQueryColumn.new(:created_on, :sortable => "#{TimeEntry.table_name}.created_on", :default_order => 'desc', :groupable => true),
|
||||
QueryColumn.new(:tweek, :sortable => ["#{TimeEntry.table_name}.spent_on", "#{TimeEntry.table_name}.created_on"], :caption => :label_week),
|
||||
QueryColumn.new(:author, :sortable => lambda {User.fields_for_order_statement}),
|
||||
QueryColumn.new(:user, :sortable => lambda {User.fields_for_order_statement}, :groupable => true),
|
||||
QueryColumn.new(:activity, :sortable => "#{TimeEntryActivity.table_name}.position", :groupable => true),
|
||||
QueryColumn.new(:issue, :sortable => "#{Issue.table_name}.id"),
|
||||
QueryAssociationColumn.new(:issue, :tracker, :caption => :field_tracker, :sortable => "#{Tracker.table_name}.position"),
|
||||
QueryAssociationColumn.new(:issue, :status, :caption => :field_status, :sortable => "#{IssueStatus.table_name}.position"),
|
||||
QueryAssociationColumn.new(:issue, :category, :caption => :field_category, :sortable => "#{IssueCategory.table_name}.name"),
|
||||
QueryAssociationColumn.new(:issue, :fixed_version, :caption => :field_fixed_version, :sortable => Version.fields_for_order_statement),
|
||||
QueryColumn.new(:comments),
|
||||
QueryColumn.new(:hours, :sortable => "#{TimeEntry.table_name}.hours", :totalable => true),
|
||||
]
|
||||
|
@ -40,39 +46,57 @@ class TimeEntryQuery < Query
|
|||
|
||||
def initialize_available_filters
|
||||
add_available_filter "spent_on", :type => :date_past
|
||||
|
||||
add_available_filter("project_id",
|
||||
add_available_filter(
|
||||
"project_id",
|
||||
:type => :list, :values => lambda { project_values }
|
||||
) if project.nil?
|
||||
|
||||
if project && !project.leaf?
|
||||
add_available_filter "subproject_id",
|
||||
add_available_filter(
|
||||
"subproject_id",
|
||||
:type => :list_subprojects,
|
||||
:values => lambda { subproject_values }
|
||||
:values => lambda { subproject_values })
|
||||
end
|
||||
|
||||
add_available_filter("issue_id", :type => :tree, :label => :label_issue)
|
||||
add_available_filter("issue.tracker_id",
|
||||
add_available_filter(
|
||||
"issue.tracker_id",
|
||||
:type => :list,
|
||||
:name => l("label_attribute_of_issue", :name => l(:field_tracker)),
|
||||
:values => lambda { trackers.map {|t| [t.name, t.id.to_s]} })
|
||||
add_available_filter("issue.status_id",
|
||||
add_available_filter(
|
||||
"issue.status_id",
|
||||
:type => :list,
|
||||
:name => l("label_attribute_of_issue", :name => l(:field_status)),
|
||||
:values => lambda { issue_statuses_values })
|
||||
add_available_filter("issue.fixed_version_id",
|
||||
add_available_filter(
|
||||
"issue.fixed_version_id",
|
||||
:type => :list,
|
||||
:name => l("label_attribute_of_issue", :name => l(:field_fixed_version)),
|
||||
:values => lambda { fixed_version_values })
|
||||
|
||||
add_available_filter("user_id",
|
||||
add_available_filter(
|
||||
"issue.category_id",
|
||||
:type => :list_optional,
|
||||
:name => l("label_attribute_of_issue", :name => l(:field_category)),
|
||||
:values => lambda { project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
|
||||
) if project
|
||||
add_available_filter(
|
||||
"user_id",
|
||||
:type => :list_optional, :values => lambda { author_values }
|
||||
)
|
||||
add_available_filter(
|
||||
"author_id",
|
||||
:type => :list_optional, :values => lambda { author_values }
|
||||
)
|
||||
|
||||
activities = (project ? project.activities : TimeEntryActivity.shared)
|
||||
add_available_filter("activity_id",
|
||||
add_available_filter(
|
||||
"activity_id",
|
||||
:type => :list, :values => activities.map {|a| [a.name, a.id.to_s]}
|
||||
)
|
||||
add_available_filter(
|
||||
"project.status",
|
||||
:type => :list,
|
||||
:name => l(:label_attribute_of_project, :name => l(:field_status)),
|
||||
:values => lambda { project_statuses_values }
|
||||
) if project.nil? || !project.leaf?
|
||||
|
||||
add_available_filter "comments", :type => :text
|
||||
add_available_filter "hours", :type => :float
|
||||
|
@ -97,14 +121,13 @@ class TimeEntryQuery < Query
|
|||
|
||||
def default_columns_names
|
||||
@default_columns_names ||= begin
|
||||
default_columns = [:spent_on, :user, :activity, :issue, :comments, :hours]
|
||||
|
||||
default_columns = Setting.time_entry_list_defaults.symbolize_keys[:column_names].map(&:to_sym)
|
||||
project.present? ? default_columns : [:project] | default_columns
|
||||
end
|
||||
end
|
||||
|
||||
def default_totalable_names
|
||||
[:hours]
|
||||
Setting.time_entry_list_defaults.symbolize_keys[:totalable_names].map(&:to_sym)
|
||||
end
|
||||
|
||||
def default_sort_criteria
|
||||
|
@ -130,6 +153,7 @@ class TimeEntryQuery < Query
|
|||
def results_scope(options={})
|
||||
order_option = [group_by_sort_order, (options[:order] || sort_clause)].flatten.reject(&:blank?)
|
||||
|
||||
order_option << "#{TimeEntry.table_name}.id ASC"
|
||||
base_scope.
|
||||
order(order_option).
|
||||
joins(joins_for_order_statement(order_option.join(',')))
|
||||
|
@ -177,8 +201,6 @@ class TimeEntryQuery < Query
|
|||
end
|
||||
|
||||
def sql_for_activity_id_field(field, operator, value)
|
||||
condition_on_id = sql_for_field(field, operator, value, Enumeration.table_name, 'id')
|
||||
condition_on_parent_id = sql_for_field(field, operator, value, Enumeration.table_name, 'parent_id')
|
||||
ids = value.map(&:to_i).join(',')
|
||||
table_name = Enumeration.table_name
|
||||
if operator == '='
|
||||
|
@ -196,8 +218,16 @@ class TimeEntryQuery < Query
|
|||
sql_for_field("status_id", operator, value, Issue.table_name, "status_id")
|
||||
end
|
||||
|
||||
def sql_for_issue_category_id_field(field, operator, value)
|
||||
sql_for_field("category_id", operator, value, Issue.table_name, "category_id")
|
||||
end
|
||||
|
||||
def sql_for_project_status_field(field, operator, value, options={})
|
||||
sql_for_field(field, operator, value, Project.table_name, "status")
|
||||
end
|
||||
|
||||
# Accepts :from/:to params as shortcut filters
|
||||
def build_from_params(params)
|
||||
def build_from_params(params, defaults={})
|
||||
super
|
||||
if params[:from].present? && params[:to].present?
|
||||
add_filter('spent_on', '><', [params[:from], params[:to]])
|
||||
|
@ -219,6 +249,12 @@ class TimeEntryQuery < Query
|
|||
if order_options.include?('trackers')
|
||||
joins << "LEFT OUTER JOIN #{Tracker.table_name} ON #{Tracker.table_name}.id = #{Issue.table_name}.tracker_id"
|
||||
end
|
||||
if order_options.include?('issue_categories')
|
||||
joins << "LEFT OUTER JOIN #{IssueCategory.table_name} ON #{IssueCategory.table_name}.id = #{Issue.table_name}.category_id"
|
||||
end
|
||||
if order_options.include?('versions')
|
||||
joins << "LEFT OUTER JOIN #{Version.table_name} ON #{Version.table_name}.id = #{Issue.table_name}.fixed_version_id"
|
||||
end
|
||||
end
|
||||
|
||||
joins.compact!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue