-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathproperty_select.rb
149 lines (143 loc) · 4.34 KB
/
property_select.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2024 the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++
class Queries::WorkPackages::Selects::PropertySelect < Queries::WorkPackages::Selects::WorkPackageSelect
def caption
WorkPackage.human_attribute_name(name)
end
class_attribute :property_selects
self.property_selects = {
id: {
sortable: "#{WorkPackage.table_name}.id",
groupable: false
},
project: {
association: "project",
sortable: "name",
groupable: "#{WorkPackage.table_name}.project_id"
},
subject: {
sortable: "#{WorkPackage.table_name}.subject"
},
type: {
association: "type",
sortable: "position",
groupable: "#{WorkPackage.table_name}.type_id"
},
parent: {
association: "ancestors_relations",
default_order: "asc",
sortable: false
},
status: {
association: "status",
sortable: "position",
highlightable: true,
groupable: "#{WorkPackage.table_name}.status_id"
},
priority: {
association: "priority",
sortable: "position",
default_order: "desc",
highlightable: true,
groupable: "#{WorkPackage.table_name}.priority_id"
},
author: {
association: "author",
sortable: %w(lastname firstname id),
groupable: "#{WorkPackage.table_name}.author_id"
},
assigned_to: {
association: "assigned_to",
sortable: %w(lastname firstname id),
groupable: "#{WorkPackage.table_name}.assigned_to_id"
},
responsible: {
association: "responsible",
sortable: %w(lastname firstname id),
groupable: "#{WorkPackage.table_name}.responsible_id"
},
updated_at: {
sortable: "#{WorkPackage.table_name}.updated_at",
default_order: "desc"
},
category: {
association: "category",
sortable: "name",
groupable: "#{WorkPackage.table_name}.category_id"
},
version: {
association: "version",
sortable: [->(table_name = Version.table_name) { Version.semver_sql(table_name) }, "name"],
default_order: "ASC",
null_handling: "NULLS LAST",
groupable: "#{WorkPackage.table_name}.version_id"
},
start_date: {
sortable: "#{WorkPackage.table_name}.start_date",
null_handling: "NULLS LAST"
},
due_date: {
highlightable: true,
sortable: "#{WorkPackage.table_name}.due_date",
null_handling: "NULLS LAST"
},
estimated_hours: {
sortable: "#{WorkPackage.table_name}.estimated_hours",
summable: true
},
remaining_hours: {
sortable: "#{WorkPackage.table_name}.remaining_hours",
summable: true
},
spent_hours: {
sortable: false,
summable: false
},
done_ratio: {
sortable: "#{WorkPackage.table_name}.done_ratio",
groupable: true
},
created_at: {
sortable: "#{WorkPackage.table_name}.created_at",
default_order: "desc"
},
duration: {
sortable: "#{WorkPackage.table_name}.duration"
},
shared_with_users: {
sortable: false,
groupable: false
}
}
def self.instances(_context = nil)
property_selects.filter_map do |name, options|
next unless !options[:if] || options[:if].call
new(name, options.except(:if))
end
end
end