Skip to content

Commit 355a797

Browse files
committed
Saves rotation field
Signed-off-by: Daniel Kastl <[email protected]>
1 parent ff5bc3d commit 355a797

File tree

6 files changed

+11
-8
lines changed

6 files changed

+11
-8
lines changed

app/models/gtt_configuration.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
class GttConfiguration
22
include ActiveModel::Model
33

4-
attr_accessor :project, :geojson, :gtt_tile_source_ids
4+
attr_accessor :project, :geojson, :gtt_tile_source_ids, :map_rotation
55

66
def self.for(project)
77
new(
88
project: project,
99
geojson: project.geojson,
10+
map_rotation: project.map_rotation,
1011
gtt_tile_source_ids: project.gtt_tile_source_ids
1112
)
1213
end
1314

1415
def self.from_params(params)
1516
new geojson: params[:geojson],
17+
map_rotation: params[:map_rotation],
1618
gtt_tile_source_ids: params[:gtt_tile_source_ids]
1719
end
1820

1921
def map
20-
GttMap.new json: geojson, layers: project.gtt_tile_sources.sorted
22+
GttMap.new json: geojson, layers: project.gtt_tile_sources.sorted, rotation: map_rotation
2123
end
2224

2325
end

app/models/gtt_map.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
class GttMap
22

3-
attr_reader :layers, :json, :bounds
3+
attr_reader :layers, :json, :bounds, :rotation
44

5-
def initialize(geom: nil, json: nil, layers:, bounds: nil)
5+
def initialize(geom: nil, json: nil, layers:, bounds: nil, rotation: nil)
66
unless @json = json
77
@json = RedmineGtt::Conversions.geom_to_json geom if geom
88
end
99

10+
@rotation = rotation || 0
1011
@bounds = bounds || @json
1112
@layers = layers
1213
end

app/views/projects/settings/_gtt.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</p>
1515
<p>
1616
<%= content_tag(:label, l(:gtt_map_rotate_label)) %>
17-
<%= number_field_tag('settings[project_map_rotation]', 0, min: 1, max: 360, size: 10, readonly: true ) %>
17+
<%= number_field_tag('gtt_configuration[map_rotation]', @project.map_rotation, min: 1, max: 360, size: 10 ) %>
1818
<br /><em><%= t :gtt_map_rotate_info_html %></em>
1919
</p>
2020
</div>

lib/redmine_gtt/actions/update_project_settings.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def update_project
2929

3030
begin
3131
@project.geojson = @form.geojson
32+
@project.map_rotation = @form.map_rotation
3233
rescue RGeo::Error::InvalidGeometry => e
3334
@project.errors.add(:geom, :invalid)
3435
return false

lib/redmine_gtt/patches/project_patch.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def self.apply
88
Project.prepend GeojsonAttribute
99
Project.prepend self
1010
Project.class_eval do
11-
safe_attributes "geojson"
11+
safe_attributes :geojson, :map_rotation
1212
has_and_belongs_to_many :gtt_tile_sources
1313
after_create :set_default_tile_sources
1414
end
@@ -35,4 +35,3 @@ def set_default_tile_sources
3535

3636
end
3737
end
38-

src/components/gtt-client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export class GttClient {
345345
return degrees * (Math.PI / 180)
346346
}
347347

348-
const rotation_field = document.querySelector('#settings_project_map_rotation')
348+
const rotation_field = document.querySelector('#gtt_configuration_map_rotation')
349349
if (rotation_field !== null) {
350350
this.map.getView().on('change:rotation', (evt) => {
351351
rotation_field.setAttribute(

0 commit comments

Comments
 (0)