@@ -2,7 +2,7 @@ class SmashTagsController < ApplicationController
2
2
3
3
before_action :find_optional_project_and_authorize
4
4
5
- accept_api_auth :project_tags , :global_tags
5
+ accept_api_auth :project_tags , :global_tags , :default_notes_tags
6
6
7
7
def project_tags
8
8
smash_tags = build_tags
@@ -18,6 +18,13 @@ def global_tags
18
18
end
19
19
end
20
20
21
+ def default_notes_tags
22
+ smash_tags = build_default_notes_tags
23
+ respond_to do |format |
24
+ format . api { render json : smash_tags }
25
+ end
26
+ end
27
+
21
28
private
22
29
23
30
def find_optional_project_and_authorize
@@ -118,30 +125,6 @@ def build_tags
118
125
# Trackers
119
126
tracker_project_ids = valid_tracker_project_ids ( )
120
127
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
-
145
128
Tracker . where ( id : tracker_project_ids . keys ) . sort . each do |tracker |
146
129
# Projects
147
130
project_ids = tracker_project_ids [ tracker . id ]
@@ -160,16 +143,6 @@ def build_tags
160
143
sectionname : tracker . name ,
161
144
sectiondescription : "GTT" ,
162
145
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
- } ,
173
146
forms : [ {
174
147
formname : tracker . name ,
175
148
formitems : [
@@ -370,4 +343,89 @@ def build_tags
370
343
end
371
344
return smash_tags
372
345
end
346
+
347
+ def build_default_notes_tags
348
+ simple_notes = Tracker . where ( id : Setting . plugin_redmine_gtt_smash [ 'tracker_simple_notes' ] )
349
+ photo_notes = Tracker . where ( id : Setting . plugin_redmine_gtt_smash [ 'tracker_photo_notes' ] )
350
+ gps_logs = Tracker . where ( id : Setting . plugin_redmine_gtt_smash [ 'tracker_gps_logs' ] )
351
+ default_subject = Setting . plugin_redmine_gtt_smash [ 'default_subject' ]
352
+
353
+ # Trackers
354
+ tracker_project_ids = valid_tracker_project_ids ( )
355
+
356
+ simple_notes_projects = [ ]
357
+ photo_notes_projects = [ ]
358
+ gps_logs_projects = [ ]
359
+
360
+ if simple_notes . length ( ) > 0
361
+ project_ids = tracker_project_ids [ simple_notes [ 0 ] . id ]
362
+ if @project . blank? and project_ids . present?
363
+ Project . where ( id : project_ids ) . sort . each { |project |
364
+ simple_notes_projects . append ( {
365
+ id : project . id . to_s ,
366
+ name : project . name
367
+ } )
368
+ }
369
+ end
370
+
371
+ simple_notes = {
372
+ id : simple_notes [ 0 ] . id . to_s ,
373
+ name : simple_notes [ 0 ] . name
374
+ }
375
+ end
376
+ if photo_notes . length ( ) > 0
377
+ project_ids = tracker_project_ids [ photo_notes [ 0 ] . id ]
378
+ if @project . blank? and project_ids . present?
379
+ Project . where ( id : project_ids ) . sort . each { |project |
380
+ photo_notes_projects . append ( {
381
+ id : project . id . to_s ,
382
+ name : project . name
383
+ } )
384
+ }
385
+ end
386
+
387
+ photo_notes = {
388
+ id : photo_notes [ 0 ] . id . to_s ,
389
+ name : photo_notes [ 0 ] . name
390
+ }
391
+ end
392
+ if gps_logs . length ( ) > 0
393
+ project_ids = tracker_project_ids [ gps_logs [ 0 ] . id ]
394
+ if @project . blank? and project_ids . present?
395
+ Project . where ( id : project_ids ) . sort . each { |project |
396
+ gps_logs_projects . append ( {
397
+ id : project . id . to_s ,
398
+ name : project . name
399
+ } )
400
+ }
401
+ end
402
+
403
+ gps_logs = {
404
+ id : gps_logs [ 0 ] . id . to_s ,
405
+ name : gps_logs [ 0 ] . name
406
+ }
407
+ end
408
+
409
+ section = {
410
+ notes : {
411
+ simple : {
412
+ tracker : simple_notes ,
413
+ projects : simple_notes_projects
414
+ } ,
415
+ photo : {
416
+ tracker : photo_notes ,
417
+ projects : photo_notes_projects
418
+ } ,
419
+ gps : {
420
+ tracker : gps_logs ,
421
+ projects : gps_logs_projects
422
+ }
423
+ } ,
424
+ defaults : {
425
+ subject : default_subject
426
+ }
427
+ }
428
+
429
+ return section
430
+ end
373
431
end
0 commit comments