@@ -7,6 +7,7 @@ class SmashTagsController < ApplicationController
7
7
8
8
def index
9
9
smash_tags = [ ]
10
+ # Issue priorities
10
11
priorities = [ ]
11
12
default_priority = nil
12
13
# SMASH (Geopaparazzi) form spec: https://www.geopaparazzi.org/geopaparazzi/index.html#_using_form_based_notes
@@ -18,15 +19,34 @@ def index
18
19
default_priority = priority . name
19
20
end
20
21
end
22
+ # Issue categories
23
+ categories = [ ]
24
+ @project . issue_categories . each do |category |
25
+ categories . append ( {
26
+ item : category . name
27
+ } )
28
+ end
29
+ # Versions
30
+ versions = [ ]
31
+ default_version = nil
32
+ @project . versions . each do |version |
33
+ versions . append ( {
34
+ item : version . name
35
+ } )
36
+ end
37
+ if @project . default_version . present?
38
+ default_version = @project . default_version . name
39
+ end
40
+ # Trackers
21
41
@project . trackers . sort . each do |tracker |
22
42
section = {
23
43
sectionname : tracker . name ,
24
- sectiondescription : "" ,
44
+ sectiondescription : tracker . description ,
25
45
sectionicon : "image" ,
26
46
forms : [ {
27
47
formname : tracker . name ,
28
48
formitems : [
29
- # Default fields
49
+ # Core fields (undisablable)
30
50
{
31
51
key : "project_id" ,
32
52
value : @project . id . to_s ,
@@ -61,28 +81,105 @@ def index
61
81
label : l ( :field_is_private ) ,
62
82
type : "boolean" ,
63
83
mandatory : "yes"
64
- } ,
65
- # TODO: Need to check
66
- # assigned_to_id, category_id, fixed_version_id, parent_issue_id,
67
- # start_date, due_date, estimated_hours, done_ratio
68
- {
69
- key : "description" ,
70
- label : l ( :field_description ) ,
71
- value : "" ,
72
- type : "string"
73
84
}
74
85
]
75
86
} ]
76
87
}
88
+ formitems = section [ :forms ] [ 0 ] [ :formitems ]
89
+ # Standard (core) fields
90
+ if tracker . core_fields . present?
91
+ # assigned_to_id (don't support)
92
+ # category_id
93
+ if tracker . core_fields . include? ( "category_id" )
94
+ formitems . append ( {
95
+ key : "category_id" ,
96
+ label : l ( :field_category ) ,
97
+ values : {
98
+ items : categories
99
+ } ,
100
+ value : "" ,
101
+ type : "stringcombo" ,
102
+ # mandatory: "yes"
103
+ } )
104
+ end
105
+ # fixed_version_id
106
+ if tracker . core_fields . include? ( "fixed_version_id" )
107
+ formitems . append ( {
108
+ key : "fixed_version_id" ,
109
+ label : l ( :field_version ) ,
110
+ values : {
111
+ items : versions
112
+ } ,
113
+ value : default_version ,
114
+ type : "stringcombo" ,
115
+ # mandatory: "yes"
116
+ } )
117
+ end
118
+ # parent_issue_id (don't support)
119
+ # start_date
120
+ if tracker . core_fields . include? ( "start_date" )
121
+ formitems . append ( {
122
+ key : "start_date" ,
123
+ label : l ( :field_start_date ) ,
124
+ value : "" ,
125
+ type : "date"
126
+ } )
127
+ end
128
+ # due_date
129
+ if tracker . core_fields . include? ( "due_date" )
130
+ formitems . append ( {
131
+ key : "due_date" ,
132
+ label : l ( :field_due_date ) ,
133
+ value : "" ,
134
+ type : "date"
135
+ } )
136
+ end
137
+ # estimated_hours
138
+ if tracker . core_fields . include? ( "estimated_hours" )
139
+ formitems . append ( {
140
+ key : "estimated_hours" ,
141
+ label : l ( :field_estimated_hours ) ,
142
+ value : "" ,
143
+ type : "integer"
144
+ } )
145
+ end
146
+ # done_ratio
147
+ if tracker . core_fields . include? ( "done_ratio" )
148
+ done_ratios = [ ]
149
+ 0 . step ( 100 , 10 ) { |ratio |
150
+ done_ratios . append ( {
151
+ item : "#{ ratio } %"
152
+ } )
153
+ }
154
+ formitems . append ( {
155
+ key : "done_ratio" ,
156
+ label : l ( :field_done_ratio ) ,
157
+ values : {
158
+ items : done_ratios
159
+ } ,
160
+ value : "0 %" ,
161
+ type : "stringcombo"
162
+ } )
163
+ end
164
+ # description
165
+ if tracker . core_fields . include? ( "description" )
166
+ formitems . append ( {
167
+ key : "description" ,
168
+ label : l ( :field_description ) ,
169
+ value : "" ,
170
+ type : "string"
171
+ } )
172
+ end
173
+ end
77
174
# Attachments
78
- section [ :forms ] [ 0 ] [ : formitems] . append ( {
175
+ formitems . append ( {
79
176
key : "attachments" ,
80
177
value : "" ,
81
178
type : "pictures"
82
179
} )
83
180
# IssueCustomField mapping
84
181
# Redmine: https://github.com/redmine/redmine/blob/master/lib/redmine/field_format.rb
85
- IssueCustomField . where ( is_for_all : true ) . sort . each do |icf |
182
+ tracker . custom_fields . each do |icf |
86
183
type = "string"
87
184
values = [ ]
88
185
case icf . field_format
@@ -134,7 +231,7 @@ def index
134
231
}
135
232
end
136
233
137
- section [ :forms ] [ 0 ] [ : formitems] . append ( formitem )
234
+ formitems . append ( formitem )
138
235
end
139
236
smash_tags . append ( section )
140
237
end
0 commit comments