Skip to content

Commit 621f44e

Browse files
committed
Merge branch 'develop' of hub.georepublic.net:gtt/redmine_gtt
2 parents 8ad5b89 + 74e6226 commit 621f44e

28 files changed

+319
-139
lines changed

app/helpers/gtt_map_helper.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,24 @@ def map_form_field(form, map, field: :geojson, edit_mode:)
1111

1212
def map_tag(map: nil, layers: map&.layers,
1313
geom: map.json, bounds: map.bounds,
14-
edit: nil)
14+
edit: nil, popup: nil)
1515

1616
data = {
17-
geom: geom,
18-
layers: layers
17+
geom: geom.is_a?(String) ? geom : geom.to_json
1918
}
20-
data[:bounds] = bounds if bounds
19+
20+
if layers
21+
data[:layers] = layers.is_a?(String) ? layers : layers.to_json
22+
end
23+
24+
if bounds
25+
data[:bounds] = bounds.is_a?(String) ? bounds : bounds.to_json
26+
end
27+
2128
data[:edit] = edit if edit
29+
data[:popup] = popup if popup
2230

23-
map_id = rand(36**8).to_s(36)
24-
content_tag(:div, "", data: data, id: "ol-#{map_id}", class: 'ol-map')
31+
content_tag(:div, "", data: data, id: "ol-#{rand(36**8).to_s(36)}", class: 'ol-map')
2532
end
2633

2734
end

app/overrides/issues.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,6 @@
1212
:partial => "issues/index/geojson"
1313
)
1414

15-
Deface::Override.new(
16-
:virtual_path => "issues/new",
17-
:name => "deface_view_issues_new_map",
18-
:insert_before => "div.box",
19-
:partial => "issues/form/map"
20-
)
21-
22-
Deface::Override.new(
23-
:virtual_path => "issues/_edit",
24-
:name => "deface_view_issues_edit_map",
25-
:insert_before => "div.box",
26-
:partial => "issues/form/map"
27-
)
2815

2916
Deface::Override.new(
3017
:virtual_path => "issues/show",

app/views/issues/form/_map.html.erb

Lines changed: 0 additions & 8 deletions
This file was deleted.

app/views/issues/index.api.rsb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ api.array :issues, api_meta(:total_count => @issue_count, :offset => @offset, :l
2020
api.is_private issue.is_private
2121
api.estimated_hours issue.estimated_hours
2222

23-
unless issue.geom.nil?
24-
api.geom RGeo::GeoJSON.encode RGeo::GeoJSON::EntityFactory.instance.feature(
25-
RGeo::WKRep::WKBParser.new().parse(issue.geom), issue.id)
23+
if issue.geom
24+
api.geojson issue.geojson
2625
else
27-
api.geom ""
26+
api.geojson ""
2827
end
2928

3029
render_api_custom_values issue.visible_custom_field_values, api
Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
1-
<% return '' if @project.nil? %>
2-
<% return '' unless User.current.allowed_to?(:view_issues, @project) %>
1+
<% if @project and @project.module_enabled?(:gtt) %>
32

4-
<% if @project.nil? or @project.module_enabled?(:gtt) %>
53
<fieldset id="location" class="collapsible">
64
<legend onclick="toggleFieldset(this);"><%= l(:field_location) %></legend>
75

8-
<%= tag(:div, :data => {
9-
# TODO: Don't know where to extend "Issues"
10-
:geom => IssuesHelper.get_geojson(@issues),
11-
:bounds => @project.geojson,
12-
:layers => @project.gtt_tile_sources,
13-
:popup => {
14-
:href => '/issues/[id]'
15-
}
16-
}, :id => 'ol-' + rand(36**8).to_s(36), :class => 'ol-map')
17-
%>
6+
<%= map_tag map: @project.map, geom: Issue.array_to_geojson(@issues, include_properties: { only: %i(id subject) }), popup: { href: '/issues/[id]' } %>
187
</fieldset>
8+
199
<% end %>

app/views/issues/show.api.rsb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ api.issue do
2323
api.total_spent_hours(@issue.total_spent_hours)
2424
end
2525

26-
unless @issue.geom.nil?
27-
api.geom RGeo::GeoJSON.encode RGeo::GeoJSON::EntityFactory.instance.feature(
28-
RGeo::WKRep::WKBParser.new().parse(@issue.geom), @issue.id)
26+
if @issue.geom
27+
api.geojson @issue.geojson
2928
else
30-
api.geom ""
29+
api.geojson ""
3130
end
3231

3332
render_api_custom_values @issue.visible_custom_field_values, api

app/views/projects/index.api.rsb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ api.array :projects, api_meta(:total_count => @project_count, :offset => @offset
99
api.status project.status
1010
api.is_public project.is_public?
1111

12-
unless project.geom.nil?
13-
api.geom RGeo::GeoJSON.encode RGeo::GeoJSON::EntityFactory.instance.feature(
14-
RGeo::WKRep::WKBParser.new().parse(project.geom), project.id)
12+
if project.geom
13+
api.geojson project.geojson
1514
else
16-
api.geom ""
15+
api.geojson ""
1716
end
1817

1918
render_api_custom_values project.visible_custom_field_values, api

app/views/projects/show.api.rsb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ api.project do
88
api.status @project.status
99
api.is_public @project.is_public?
1010

11-
unless @project.geom.nil?
12-
api.geom RGeo::GeoJSON.encode RGeo::GeoJSON::EntityFactory.instance.feature(
13-
RGeo::WKRep::WKBParser.new().parse(@project.geom), @project.id)
11+
if @project.geom
12+
api.geojson @project.geojson
1413
else
15-
api.geom ""
14+
api.geojson ""
1615
end
1716

1817
render_api_custom_values @project.visible_custom_field_values, api
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<% if (@project.nil? or @project.module_enabled?(:gtt)) &&
2+
((issue.new_record? && User.current.allowed_to?(:add_issues, issue.project)) ||
3+
User.current.allowed_to?(:edit_issues, issue.project))
4+
%>
5+
<%= map_form_field form, issue.map, edit_mode: 'Point LineString Polygon' %>
6+
<% end %>
7+

app/views/users/index.api.rsb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ api.array :users, api_meta(:total_count => @user_count, :offset => @offset, :lim
99
api.created_on user.created_on
1010
api.last_login_on user.last_login_on
1111

12-
unless user.geom.nil?
13-
api.geom RGeo::GeoJSON.encode RGeo::GeoJSON::EntityFactory.instance.feature(
14-
RGeo::WKRep::WKBParser.new().parse(user.geom), user.id)
12+
if user.geom
13+
api.geojson user.geojson
1514
else
16-
api.geom ""
15+
api.geojson ""
1716
end
1817

1918
render_api_custom_values user.visible_custom_field_values, api

0 commit comments

Comments
 (0)