Skip to content

Commit 8a0a324

Browse files
committed
add section config for tags json API endpoint
1 parent fe2fecf commit 8a0a324

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

app/controllers/smash_tags_controller.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,31 @@ def build_tags
117117
end
118118
# Trackers
119119
tracker_project_ids = valid_tracker_project_ids()
120+
121+
simple_notes = Tracker.where(id: Setting.plugin_redmine_gtt_smash['tracker_simple_notes'])
122+
photo_notes = Tracker.where(id: Setting.plugin_redmine_gtt_smash['tracker_photo_notes'])
123+
gps_logs = Tracker.where(id: Setting.plugin_redmine_gtt_smash['tracker_gps_logs'])
124+
default_subject = Setting.plugin_redmine_gtt_smash['default_subject']
125+
126+
if simple_notes.length() > 0
127+
simple_notes = {
128+
tracker_id: simple_notes[0].id,
129+
tracker_name: simple_notes[0].name
130+
}
131+
end
132+
if photo_notes.length() > 0
133+
photo_notes = {
134+
tracker_id: photo_notes[0].id,
135+
tracker_name: photo_notes[0].name
136+
}
137+
end
138+
if gps_logs.length() > 0
139+
gps_logs = {
140+
tracker_id: gps_logs[0].id,
141+
tracker_name: gps_logs[0].name
142+
}
143+
end
144+
120145
Tracker.where(id: tracker_project_ids.keys).sort.each do |tracker|
121146
# Projects
122147
project_ids = tracker_project_ids[tracker.id]
@@ -135,6 +160,16 @@ def build_tags
135160
sectionname: tracker.name,
136161
sectiondescription: "GTT",
137162
sectionicon: "image",
163+
sectionconfig: {
164+
defaultnotetracker: {
165+
simple_notes: simple_notes,
166+
photo_notes: photo_notes,
167+
gps_logs: gps_logs
168+
},
169+
defaults: {
170+
subject: default_subject
171+
}
172+
},
138173
forms: [{
139174
formname: tracker.name,
140175
formitems: [

app/views/gtt_smash/_settings.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<%= content_tag(:label, l(:field_tracker_simple_note)) %>
66
<%
77
@options = []
8-
Tracker.all.each do |t|
8+
Tracker.all.sort.each do |t|
99
@options.push([t.name,t.id])
1010
end
1111
%>
@@ -17,7 +17,7 @@
1717
<%= content_tag(:label, l(:field_tracker_photo_note)) %>
1818
<%
1919
@options = []
20-
Tracker.all.each do |t|
20+
Tracker.all.sort.each do |t|
2121
@options.push([t.name,t.id])
2222
end
2323
%>
@@ -29,7 +29,7 @@
2929
<%= content_tag(:label, l(:field_tracker_gps_log)) %>
3030
<%
3131
@options = []
32-
Tracker.all.each do |t|
32+
Tracker.all.sort.each do |t|
3333
@options.push([t.name,t.id])
3434
end
3535
%>

0 commit comments

Comments
 (0)