Skip to content

Commit e19877d

Browse files
authored
Merge pull request #45 from gtt-project/ftr/add-configuration-setting
Ftr/add configuration setting
2 parents 22716c5 + b8362b8 commit e19877d

File tree

11 files changed

+171
-11
lines changed

11 files changed

+171
-11
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ http://localhost:3000/projects/(project_id)/smash/tags.json
5858
http://localhost:3000/smash/tags.json
5959
```
6060

61+
**Default tracker setting API endpoint**
62+
63+
```
64+
http://localhost:3000/smash/settings.json
65+
```
66+
6167
## Contributing and Support
6268

6369
The GTT Project appreciates any [contributions](https://github.com/gtt-project/.github/blob/main/CONTRIBUTING.md)! Feel free to contact us for [reporting problems and support](https://github.com/gtt-project/.github/blob/main/CONTRIBUTING.md).

app/controllers/smash_tags_controller.rb

Lines changed: 94 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class SmashTagsController < ApplicationController
22

33
before_action :find_optional_project_and_authorize
44

5-
accept_api_auth :project_tags, :global_tags
5+
accept_api_auth :project_tags, :global_tags, :default_notes_tags
66

77
def project_tags
88
smash_tags = build_tags
@@ -18,6 +18,13 @@ def global_tags
1818
end
1919
end
2020

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+
2128
private
2229

2330
def find_optional_project_and_authorize
@@ -117,6 +124,7 @@ def build_tags
117124
end
118125
# Trackers
119126
tracker_project_ids = valid_tracker_project_ids()
127+
120128
Tracker.where(id: tracker_project_ids.keys).sort.each do |tracker|
121129
# Projects
122130
project_ids = tracker_project_ids[tracker.id]
@@ -335,4 +343,89 @@ def build_tags
335343
end
336344
return smash_tags
337345
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
338431
end
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<div class="box tabular settings">
2+
<%
3+
@options = ["None"]
4+
Tracker.all.sort.each do |t|
5+
@options.push([t.name,t.id])
6+
end
7+
%>
8+
<h3><%= l(:setting_message) %></h3>
9+
10+
<p>
11+
<%= content_tag(:label, l(:field_tracker_simple_note)) %>
12+
<%= select_tag "settings[tracker_simple_notes]",
13+
options_for_select(@options, @settings['tracker_simple_notes']) %>
14+
</p>
15+
16+
<p>
17+
<%= content_tag(:label, l(:field_tracker_photo_note)) %>
18+
<%= select_tag "settings[tracker_photo_notes]",
19+
options_for_select(@options, @settings['tracker_photo_notes']) %>
20+
</p>
21+
22+
<p>
23+
<%= content_tag(:label, l(:field_tracker_gps_log)) %>
24+
<%= select_tag "settings[tracker_gps_logs]",
25+
options_for_select(@options, @settings['tracker_gps_logs']) %>
26+
</p>
27+
28+
<p>
29+
<%= content_tag(:label, l(:field_default_subject)) %>
30+
<%= text_field_tag 'settings[default_subject]', @settings['default_subject'], :size => 30 %>
31+
</p>
32+
</div>

config/locales/en.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
en:
22
permission_view_gtt_smash: "View GTT SMASH"
33
project_module_gtt_smash: "GTT SMASH"
4+
5+
field_tracker_simple_note: "Tracker for Simple Notes"
6+
field_tracker_photo_note: "Tracker for Photo Notes"
7+
field_tracker_gps_log: "Tracker for GPS Logs"
8+
field_default_subject: "Default subject"
9+
10+
setting_message: "Caution: ensure that selected trackers do not have required custom fields!"

config/locales/ja.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
ja:
22
permission_view_gtt_smash: "GTT SMASHの閲覧"
33
project_module_gtt_smash: "GTT SMASH"
4+
5+
tracker_simple_note: "Tracker for Simple Notes"
6+
tracker_photo_note: "Tracker for Photo Notes"
7+
tracker_gps_log: "Tracker for GPS Logs"
8+
default_subject: "Default subject"
9+
10+
setting_message: "Caution: ensure that selected trackers do not have required custom fields!"

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
scope 'smash' do
55
get 'tags', to: 'smash_tags#global_tags', as: :smash_tags
6+
get 'settings', to: 'smash_tags#default_notes_tags', as: :default_notes_smash_tags
67
end
78

89
scope 'projects/:project_id' do

doc/getting-started.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,26 @@ SMASH is a digital field mapping application developed to perform fast qualitati
88

99
You can install the SMASH app from the app stores:
1010

11-
* *SMASH Digital field mapping* for iOS devices on the [Apple store](https://apps.apple.com/us/app/smash-digital-field-mapping/id1475079936).
11+
* *SMASH Digital field mapping* for iOS devices on the [Apple Store](https://apps.apple.com/us/app/smash-digital-field-mapping/id1475079936).
1212
* *SMASH field mapping* for Android devices on the [Google Play store](https://play.google.com/store/apps/details?id=eu.hydrologis.smash&hl=en).
1313

14-
The following plugin documentation gives a brief introduction in how to use SMASH with Redmine.
14+
The following plugin documentation gives a brief introduction to how to use SMASH with Redmine.
1515

1616
SMASH provides additional functionality that is available in the [SMASH User Manual](https://www.geopaparazzi.org/smash/index.html).
1717

1818
## Integration in Redmine GTT
1919

20-
To get projects connected with SMASH mobile application make sure to enable the **GTT SMASH** module in your Redmine project settings.
20+
To get projects connected with the SMASH mobile application make sure to enable the **GTT SMASH** module in your Redmine project settings.
2121

2222
![Project Modules](project_modules.png)
2323

24+
25+
Set the trackers and default subject for the notes or logs in the plugin setting of **Redmine GTT SMASH** so that the issue can be created based on the setting.
26+
27+
![GTT SMASH Setting](gtt_smash_setting.png)
28+
29+
30+
2431
## Connect SMASH mobile application to Redmine
2532

2633
### Connect Redmine account
@@ -35,15 +42,15 @@ In SMASH mobile application top menu go to **Export** or **Import**. Click on th
3542

3643
### Import Redmine projects
3744

38-
In menu again go to **Import** &#8594; **GTT** &#8594; Select Project &#8594; Click **Import**
45+
In menu again go to **Import** &#8594; **GTT** &#8594; Click **Import**
3946

4047
![GTT Import](gtt_import.png)
4148

4249
This will import your project's form configuration to mobile storage.
4350

4451
### Create issue
4552

46-
In SMASH application you can create Simple Notes, Form Notes, etc. Form Notes can be exported to your Redmine project as **issue**.
53+
In the SMASH application you can create Simple Notes, Form Notes, etc. Form Notes can be exported to your Redmine project as **issue**.
4754

4855
:::caution
4956
Only *Form Notes* are currently supported in combination with Redmine GTT!
@@ -52,8 +59,8 @@ Only *Form Notes* are currently supported in combination with Redmine GTT!
5259
Follow these steps to upload your notes as issues or synchronize changes:
5360

5461
1. Go to top menu **Export** &#8594; **GTT**
55-
2. It will inidicate if there is new data to be uploaded
56-
3. Choose a project for creating the issue(s)
62+
2. It will indicate if there is new data to be uploaded
63+
3. Choose a project for each note or GPS log to create the issue(s) *(unselected will be ignored)*
5764
4. Click on **Upload** to export the issue(s)
5865

5966
![GTT Export](gtt_export.png)

doc/gtt_export.png

5.58 KB
Loading

doc/gtt_import.png

3.94 KB
Loading

doc/gtt_smash_setting.png

31.5 KB
Loading

0 commit comments

Comments
 (0)