Skip to content

Commit a33d473

Browse files
committed
Merge remote-tracking branch 'origin/main' into ftr/custom-icons
2 parents a147d76 + 479a3c1 commit a33d473

File tree

5 files changed

+34
-6
lines changed

5 files changed

+34
-6
lines changed

app/views/projects/show.api.rsb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ api.project do
1414
api.geojson ""
1515
end
1616

17-
if @project.gtt_tile_sources.present?
18-
api.gttLayer @project.gtt_tile_sources
19-
end
20-
2117
render_api_custom_values @project.visible_custom_field_values, api
2218
render_api_includes(@project, api)
2319

app/views/projects/show/_map.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<% if @project.nil? or @project.module_enabled?(:gtt) %>
22
<div class="usermap box">
3-
<h3><%= l(:label_project_map) %></h3>
3+
<h3 class="icon icon-gtt-map"><%= l(:label_project_map) %></h3>
44

55
<%= map_tag map: @project.map %>
66
</div>

init.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
menu :admin_menu,
4141
:gtt_tile_sources,
4242
{ controller: 'gtt_tile_sources', action: 'index' },
43-
caption: :label_gtt_tile_source_plural, :html => {:class => 'icon'}
43+
caption: :label_gtt_tile_source_plural, :html => {:class => 'icon icon-gtt-map'}
4444
end
4545

4646
# Register MIME Types

lib/redmine_gtt/patches/projects_helper_patch.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,21 @@ module Patches
88
module ProjectsHelperPatch
99

1010
def self.apply
11+
ProjectsHelper.prepend self unless ProjectsHelper < self
1112
ProjectsController.class_eval do
1213
helper SettingsMenuItem
1314
end
1415
end
1516

17+
def render_api_includes(project, api)
18+
super
19+
api.array :layers do
20+
project.gtt_tile_sources.each do |gtt_tile_source|
21+
api.layer(gtt_tile_source.attributes)
22+
end
23+
end if include_in_api_response?('layers')
24+
end
25+
1626
module SettingsMenuItem
1727
def project_settings_tabs
1828
super.tap do |tabs|

test/integration/projects_api_test.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,28 @@ class ProjectsApiTest < Redmine::IntegrationTest
164164
assert_equal 1, projects.xpath('geojson').size, projects.to_s
165165
end
166166

167+
test 'GET /projects.xml with include=layers should return layers' do
168+
ts = RedmineGtt::Actions::CreateTileSource.(type: 'ol.source.OSM', name: 'default', default: true).tile_source
169+
@project.gtt_tile_sources = [ts]
170+
get '/projects.xml?include=layers'
171+
assert_response :success
172+
xml = xml_data
173+
assert projects = xml.xpath('/projects/project')
174+
assert layer = projects.xpath('layers/layer').first
175+
assert_equal 'ol.source.OSM', layer['type']
176+
end
177+
178+
test 'GET /projects/1.xml with include=layers should return layers' do
179+
ts = RedmineGtt::Actions::CreateTileSource.(type: 'ol.source.OSM', name: 'default', default: true).tile_source
180+
@project.gtt_tile_sources = [ts]
181+
get '/projects/1.xml?include=layers'
182+
assert_response :success
183+
xml = xml_data
184+
assert project = xml.xpath('/project')
185+
assert layer = project.xpath('layers/layer').first
186+
assert_equal 'ol.source.OSM', layer['type']
187+
end
188+
167189
def xml_data
168190
Nokogiri::XML(@response.body)
169191
end

0 commit comments

Comments
 (0)