Skip to content

Commit

Permalink
Merge branch 'next' into dkastl/issue312
Browse files Browse the repository at this point in the history
  • Loading branch information
dkastl authored Jun 5, 2024
2 parents d7a276a + 9a5152b commit f00db66
Show file tree
Hide file tree
Showing 28 changed files with 1,079 additions and 341 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/test-postgis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ jobs:
strategy:
fail-fast: false
matrix:
redmine_version: [5.0-stable, master]
ruby_version: ['3.0', '3.1']
redmine_version: ${{ fromJSON(vars.PLUGIN_TEST_MATRIX_REDMINE_VERSION) }}
ruby_version: ${{ fromJSON(vars.PLUGIN_TEST_MATRIX_RUBY_VERSION) }}
db_version: [12-3.0, 15-3.3]
exclude:
- redmine_version: 5.0-stable
ruby_version: '3.2'
- redmine_version: master

services:
postgres:
Expand Down Expand Up @@ -62,7 +66,7 @@ jobs:
- name: Install Node/Yarn packages
run: |
curl -sL https://deb.nodesource.com/setup_16.x | bash -
curl -sL https://deb.nodesource.com/setup_20.x | bash -
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt-get update --yes --quiet
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/gtt_map_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def map_tag(map: nil, layers: map&.layers,
data[:upload] = upload
data[:collapsed] = collapsed if collapsed
data[:geocoding] = true if Setting.plugin_redmine_gtt['enable_geocoding_on_map'] == 'true'
data[:measure] = true if Setting.plugin_redmine_gtt['default_measure_enabled'] == 'true'
data[:target] = true if Setting.plugin_redmine_gtt['default_target_enabled'] == 'true'

uid = "ol-" + rand(36**8).to_s(36)

Expand Down
19 changes: 17 additions & 2 deletions app/views/gtt_map_layers/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<p>
<%= f.select :layer,
options_for_select(
['Image','Tile','MapboxVector','Vector','VectorTile'],
['Image','Tile','MapboxVector','Vector','VectorTile','WebGLTile'],
selected: f.object.layer ),
{ include_blank: t('map_layer.layer_options_select'), required: true }
%>
Expand All @@ -22,7 +22,7 @@
<p>
<%= f.select :source,
options_for_select(
['BingMaps','CartoDB','ImageStatic','ImageWMS','OSM','Raster','Stamen',
['BingMaps','CartoDB','Google','ImageStatic','ImageWMS','OSM','Raster','Stamen',
'TileJSON','TileWMS','UTFGrid','Vector','VectorTile','WMTS','XYZ'],
selected: f.object.source ),
{ include_blank: t('map_layer.source_options_select') }
Expand Down Expand Up @@ -55,6 +55,7 @@
'MapboxVector': [],
'Vector': ['Vector'],
'VectorTile': ['VectorTile'],
'WebGLTile': ['Google'],
};

const map_format_config = {
Expand Down Expand Up @@ -211,5 +212,19 @@
},
'format': 'ol.format.MVT',
'format_options': {}
},{
'name': 'Google Maps',
'layer': 'WebGLTile',
'layer_options': {},
'source': 'Google',
'source_options': {
'key': 'YOUR_API_KEY',
'mapType': 'roadmap',
'language': 'ja_JP',
'scale': 'scaleFactor2x',
'layerTypes': ['layerTraffic'],
},
'format': '',
'format_options': {}
}];
</script>
2 changes: 1 addition & 1 deletion app/views/issues/show.api.rsb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ api.issue do
api.total_spent_hours(@issue.total_spent_hours)
end

if @issue.geom
if @issue.geom.present?
api.geojson (params[:format] == "json") ? @issue.geojson : @issue.geojson.to_json
else
api.geojson nil
Expand Down
8 changes: 7 additions & 1 deletion app/views/issues/show/_map.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<% if @project.nil? or @project.module_enabled?(:gtt) %>
<%= map_tag map: @issue.map, geom: (@issue.as_geojson(include_properties: { only: %i(tracker_id status_id) }) if @issue), rotation: @project.map_rotation %>
<% if @issue.geom.present? or !Setting.plugin_redmine_gtt['hide_map_for_invalid_geom'] %>
<%= map_tag map: @issue.map,
geom: (@issue.as_geojson(include_properties: { only: %i(tracker_id status_id) }) if @issue),
rotation: @project.map_rotation %>
<% else %>
<div class="flash nodata"><%= l(:gtt_hide_map_for_invalid_geom_info) %></div>
<% end %>
<% end %>
20 changes: 20 additions & 0 deletions app/views/settings/gtt/_general.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
@settings['default_map_fit_maxzoom_level'],
:size => 10) %>
</p>

</div>

<div class="box tabular settings">
Expand All @@ -62,3 +63,22 @@
<%= check_box_tag 'settings[enable_geojson_upload_on_issue_map]', true, @settings[:enable_geojson_upload_on_issue_map] %>
</p>
</div>

<div class="box tabular settings">
<h3><%= l(:select_other_gtt_settings) %></h3>

<p>
<%= content_tag(:label, l(:label_default_target_enabled)) %>
<%= check_box_tag 'settings[default_target_enabled]', true, @settings[:default_target_enabled] %>
</p>

<p>
<%= content_tag(:label, l(:label_default_measure_enabled)) %>
<%= check_box_tag 'settings[default_measure_enabled]', true, @settings[:default_measure_enabled] %>
</p>

<p>
<%= content_tag(:label, l(:label_hide_map_for_invalid_geom)) %>
<%= check_box_tag 'settings[hide_map_for_invalid_geom]', 1, Setting.plugin_redmine_gtt['hide_map_for_invalid_geom'] %>
</p>
</div>
40 changes: 40 additions & 0 deletions app/views/settings/gtt/_geocoder.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
<%= check_box_tag 'settings[enable_geocoding_on_map]', true, @settings[:enable_geocoding_on_map] %>
</p>

<p>
<%= content_tag(:label, l(:geocoder_provider)) %>
<%= select_tag 'settings[default_geocoder_provider]',
options_for_select([
['Google', 'google'],
['Nominatim (OSM)', 'nominatim'],
['Photon', 'photon'],
['Custom', 'custom', {disabled: true}]
], @settings['default_geocoder_provider']),
include_blank: true %>
<%= link_to t('geocoder_load_example'), '#', id: 'geocoder_load_example', class: 'info' %>
</p>

<p>
<%= content_tag(:label, l(:geocoder_options)) %>
<%= text_area_tag('settings[default_geocoder_options]',
Expand All @@ -15,3 +28,30 @@
:cols => 100) %>
</p>
</div>

<script>
document.getElementById('geocoder_load_example').addEventListener('click', (event) => {
event.preventDefault();
const provider = document.getElementById('settings_default_geocoder_provider').value;
const example = geocoder_examples.find((example) => example.name === provider);
document.getElementById('settings_default_geocoder_options').value = example?.options ? JSON.stringify(example.options, undefined, 2) : "{}";
});

const geocoder_examples = [{
'name': 'nominatim',
'options': {}
}, {
'name': 'google',
'options': {
'apiKey': 'YOUR_API_KEY'
}
}, {
'name': 'photon',
'options': {}
}, {
'name': 'custom',
'options': {
'url': 'https://example.com/geocoder'
}
}];
</script>
26 changes: 25 additions & 1 deletion app/views/settings/gtt/_settings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,33 @@
{ :name => :geocoder, :partial => 'settings/gtt/geocoder', :label => :gtt_settings_label_geocoder }
] %>
<%= render_tabs plugin_tabs %>
<%= javascript_tag do %>
// Read query parameter
function getQueryParam(param) {
var urlParams = new URLSearchParams(window.location.search);
return urlParams.get(param);
}

// Activate tab by name
function activateTab(tabName) {
var tabLinks = document.querySelectorAll('.tabs a');
tabLinks.forEach(function(link) {
if (link.href.includes('tab=' + tabName)) {
link.click();
}
});
}

// Activate tab if it is specified in the URL
document.addEventListener('DOMContentLoaded', function() {
var tab = getQueryParam('tab');
if (tab) {
activateTab(tab);
}
});

// Apply settings
window.gtt_setting()
<% end %>
29 changes: 22 additions & 7 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ de:
label_gtt_select_icon: Icon auswählen
label_parameters: Parameter
label_tab_geocoder: Geocoder
geocoder_options: Geocoder Optionen
geocoder_provider: "Anbieter"
geocoder_options: Optionen
geocoder_load_example: "Load example options"
gtt_settings_general_maxzoom_level: Standardwert für die maximale Zoomstufe der
Karte
label_default_collapsed_issues_page_map: Standardmäßig ausgeblendete Karte für Tickets
Expand All @@ -21,7 +23,7 @@ de:
field_geom: Geomtrie
field_global: Allgemein verfügbar
label_geotask_map: GTT Karte
label_global: Allgemein
label_global: Global
label_project_map: Projektkarte
label_user_map: Benutzer-Karte
label_name: Name
Expand All @@ -41,6 +43,7 @@ de:
label_enable_geojson_upload_on_issue_map: Aktivieren von GeoJSON-Upload auf der
Themenkarte
label_enable_geocoding_on_map: Geokodierung auf der Karte aktivieren
label_default_target_enabled: "Show target on map center"
select_default_status_color: 'Auswahl der Standard-Statusfarbe:'
select_default_map_settings: 'Standardmäßige Kartenvoreinstellungen festlegen:'
select_edit_geometry_settings: 'Einstellungen für die Geometriebearbeitung:'
Expand All @@ -56,6 +59,9 @@ de:
control:
geocoding: Standort-Suche
geolocation: Mein Standort
search_location: "Search location"
reverse_location: "Click on the map to get location…"
search_placeholder: "Type a location…"
maximize: Zoom auf alle Objekte
upload: GeoJSON hochladen
fullscreen: Vollbildmodus umschalten
Expand All @@ -65,18 +71,23 @@ de:
point: Punkteditor
linestring: Linieneditor
polygon: Flächeneditor
clear_map: "Clear map"
geolocation_activated: Geolokalisierung aktiviert
geolocation_deactivated: Geolokalisierung deaktiviert
copied_location_to_clipboard: Standort in die Zwischenablage kopiert
modal:
load: Laden
cancel: Abbrechen
messages:
baselayer_missing: "There is no baselayer available!"
zoom_in_more: "Zoom in to view objects."
baselayer_missing: "Es ist kein Baselayer verfügbar!"
zoom_in_more: "Zoomen Sie hinein, um die Objekte zu sehen."
gtt_map_rotate_label: Kartenrotation
gtt_map_rotate_info_html: Hold down <code>Shift+Alt</code> and drag the map to rotate.
gtt_map_rotate_info_html: Halten Sie <code>Shift+Alt</code> gedrückt und ziehen
Sie die Karte, um sie zu drehen.
gtt_settings_label_general: "General"
gtt_settings_label_styling: "Styling"
gtt_settings_label_geocoder: "Geocoder"
label_layer: Layer-Typ
label_layer: Layer Typ
map_layer:
plural: Karten-Layer
project:
Expand All @@ -91,11 +102,15 @@ de:
load_example: 'Beispiele: '
field_format_options_string: Formatoptionen
field_styles: Style-Einstellungen
label_source: Source-Typ
label_source: Source Typ
permission_view_gtt_settings: GTT-Einstellungen anzeigen
field_name: Name
field_layer: Layer-Typ
field_layer_options_string: Layer-Optionen
field_source: Source-Typ
field_source_options_string: Source-Optionen
field_format: Format-Typ
select_other_gtt_settings: Andere GTT-Einstellungen
label_hide_map_for_invalid_geom: Ausblenden der Ausgabekarte für ungültige Geometrie
gtt_hide_map_for_invalid_geom_info: Bitte bearbeiten Sie die Anfrage und stellen
Sie die Geometrie ein, um die Karte zu sehen.
27 changes: 23 additions & 4 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# English strings go here for Rails i18n
en:
error_invalid_json: Must be valid JSON
error_unable_to_update_project_gtt_settings: "Unable to update project GTT settings (%{value})"
error_unable_to_update_project_gtt_settings: "Unable to update project GTT settings
(%{value})"

field_geometry: "Geometry"
field_location: "Location"
Expand All @@ -28,10 +29,13 @@ en:
label_tab_general: "General"
label_tab_geocoder: "Geocoder"

geocoder_options: "Geocoder Options"
geocoder_provider: "Provider"
geocoder_options: "Options"
geocoder_load_example: "Load example options"

gtt_map_rotate_label: "Map rotation"
gtt_map_rotate_info_html: "Hold down <code>Shift+Alt</code> and drag the map to rotate."
gtt_map_rotate_info_html: "Hold down <code>Shift+Alt</code> and drag the map to
rotate."

gtt_settings_general_center_lon: "Default map center longitude"
gtt_settings_general_center_lat: "Default map center latitude"
Expand All @@ -51,6 +55,13 @@ en:
label_editable_geometry_types_on_issue_map: "Editable geometry types on issue map"
label_enable_geojson_upload_on_issue_map: "Enable GeoJSON upload on issue map"
label_enable_geocoding_on_map: "Enable geocoding on map"
label_default_target_enabled: "Show target on map center"
label_default_measure_enabled: "Show measure control"

select_other_gtt_settings: "Other GTT settings"
label_hide_map_for_invalid_geom: "Hide issue map for invalid geometry"
gtt_hide_map_for_invalid_geom_info: "Please edit the issue and set the geometry
to see the map."

select_default_tracker_icon: "Select default tracker icon:"
select_default_status_color: "Select default status color:"
Expand All @@ -63,7 +74,8 @@ en:
permission_view_gtt_settings: "View GTT settings"

title_geojson_upload: "Import GeoJSON"
placeholder_geojson_upload: "Please paste a GeoJSON geometry here, or import the GeoJSON data from a file."
placeholder_geojson_upload: "Please paste a GeoJSON geometry here, or import the
GeoJSON data from a file."

map_layer:
title: "Map Layers"
Expand Down Expand Up @@ -96,6 +108,11 @@ en:
control:
geocoding: "Location search"
geolocation: "My location"
search_location: "Search location"
reverse_location: "Click on the map to get location…"
search_placeholder: "Type a location…"
geolocation_activated: "Geolocation activated"
geolocation_deactivated: "Geolocation deactivated"
maximize: "Zoom to all features"
upload: "Upload GeoJSON"
fullscreen: "Toggle full-screen"
Expand All @@ -105,6 +122,8 @@ en:
point: "Point editor"
linestring: "Line editor"
polygon: "Area editor"
clear_map: "Clear map"
copied_location_to_clipboard: "Copied location to clipboard"
modal:
load: "Load"
cancel: "Cancel"
Expand Down
Loading

0 comments on commit f00db66

Please sign in to comment.