Skip to content

Commit 50b24ac

Browse files
committed
Show error message when updating project geometry with invalid multi polygon
Signed-off-by: Ko Nagase <[email protected]>
1 parent 855c50f commit 50b24ac

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# English strings go here for Rails i18n
22
en:
33
error_invalid_json: must be valid JSON
4+
error_unable_to_update_project_gtt_settings: "Unable to update project GTT settings (%{value})"
45

56
field_default: Default for new projects
67
field_geometry: "Geometry"

config/locales/ja.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Japanese strings go here for Rails i18n
22
ja:
33
error_invalid_json: "正しいJSONにしてください"
4+
error_unable_to_update_project_gtt_settings: "プロジェクトのGTTの設定を更新できません (%{value})"
45

56
field_default: "新規プロジェクトのデフォルト"
67
field_geometry: "所在地"

lib/redmine_gtt/actions/update_project_settings.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ def update_project
2626
if tile_source_ids = @form.gtt_tile_source_ids
2727
@project.gtt_tile_source_ids = tile_source_ids
2828
end
29-
@project.geojson = @form.geojson
29+
30+
begin
31+
@project.geojson = @form.geojson
32+
rescue RGeo::Error::InvalidGeometry => e
33+
@project.errors.add(:geom, :invalid)
34+
return false
35+
end
3036

3137
@project.save
3238
end

lib/redmine_gtt/patches/projects_controller_patch.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def update_gtt_configuration
4747
if r.settings_saved?
4848
flash.now[:notice] = l(:notice_successful_update)
4949
else
50-
flash.now[:error] = r.error
50+
flash.now[:error] = l(:error_unable_to_update_project_gtt_settings, "#{r.error}")
5151
end
5252

5353
end

0 commit comments

Comments
 (0)