Skip to content

Commit e925e74

Browse files
committed
Merge branch 'develop' into 'master'
Develop Closes #66 See merge request gtt/redmine_gtt!13
2 parents 3ce6917 + 2aa0ac9 commit e925e74

30 files changed

+14095
-11772
lines changed

Gemfile.lock

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

app/controllers/gtt_tile_sources_controller.rb

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class GttTileSourcesController < ApplicationController
66
self.main_menu = false
77

88
def index
9-
@tile_sources = GttTileSource.order name: :asc
9+
@tile_sources = GttTileSource.sorted
1010
end
1111

1212
def new
@@ -31,10 +31,21 @@ def update
3131
ts = GttTileSource.find params[:id]
3232
r = RedmineGtt::Actions::UpdateTileSource.(ts, tile_source_params)
3333
if r.tile_source_updated?
34-
redirect_to gtt_tile_sources_path
34+
respond_to do |format|
35+
format.html {
36+
flash[:notice] = l(:notice_successful_update)
37+
redirect_to gtt_tile_sources_path
38+
}
39+
format.js { head 200 }
40+
end
3541
else
36-
@tile_source = r.tile_source
37-
render 'edit'
42+
respond_to do |format|
43+
format.html {
44+
@tile_source = r.tile_source
45+
render 'edit'
46+
}
47+
format.js { head 422 }
48+
end
3849
end
3950
end
4051

@@ -50,7 +61,7 @@ def destroy
5061
def tile_source_params
5162
return {} unless params[:tile_source]
5263

53-
params[:tile_source].permit( :name, :type, :global,
64+
params[:tile_source].permit( :name, :type, :global, :position,
5465
:default, :options_string )
5566
end
5667
end

app/helpers/gtt_map_helper.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ def map_tag(map: nil, layers: map&.layers,
3434
content_tag(:div, "", data: data, id: uid, class: 'ol-map'),
3535
javascript_tag("
3636
$(document).ready(function(){
37-
$('div.ol-map').each(function(idx) {
38-
App.init({
39-
target: this
40-
});
37+
App.init({
38+
target: $('##{uid}')[0]
4139
});
4240
});
4341
")

app/models/gtt_configuration.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def self.from_params(params)
1717
end
1818

1919
def map
20-
GttMap.new json: geojson, layers: project.gtt_tile_sources
20+
GttMap.new json: geojson, layers: project.gtt_tile_sources.sorted
2121
end
2222

2323
end

app/models/gtt_tile_source.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ class GttTileSource < ActiveRecord::Base
88
validates :type, presence: true
99
validate :take_json_options
1010

11+
acts_as_positioned
12+
scope :sorted, ->{ order :position }
13+
1114
# globally available tile sources
1215
scope :global, ->{ where global: true }
1316

app/views/gtt_tile_sources/_tile_source.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<td><%= checked_image tile_source.default? %></td>
66
<td><%= tile_source_options tile_source %></td>
77
<td class="buttons">
8+
<%= reorder_handle(tile_source, url: gtt_tile_source_path(tile_source), param: 'tile_source') %>
89
<%= delete_link gtt_tile_source_path(tile_source) %>
910
</td>
1011
</tr>

app/views/gtt_tile_sources/index.html.erb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<%= link_to l(:label_gtt_tile_source_new), new_gtt_tile_source_path, :class => 'icon icon-add' %>
33
</div>
44

5-
<h2><%= l :label_gtt_tile_source_plural %></h2>
5+
<%= title l :label_gtt_tile_source_plural %>
66

77
<% if @tile_sources.any? %>
8-
<table class="list">
8+
<table class="list tile_sources">
99
<thead>
1010
<tr>
1111
<th><%= l :label_type %></th>
@@ -25,4 +25,6 @@
2525
<p class="nodata"><%= l :label_no_data %></p>
2626
<% end %>
2727

28-
<% html_title l :label_gtt_tile_source_plural -%>
28+
<%= javascript_tag do %>
29+
$(function() { $("table.tile_sources tbody").positionedItems(); });
30+
<% end %>

app/views/issues/index.api.rsb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ api.array :issues, api_meta(:total_count => @issue_count, :offset => @offset, :l
2626
api.geojson ""
2727
end
2828

29+
if issue.distance
30+
api.distance issue.distance
31+
end
32+
2933
render_api_custom_values issue.visible_custom_field_values, api
3034

3135
api.created_on issue.created_on

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<fieldset id="location" class="collapsible">
44
<legend onclick="toggleFieldset(this);"><%= l(:field_location) %></legend>
55

6-
<%= map_tag map: @project.map, geom: Issue.array_to_geojson(@issues, include_properties: { only: %i(id subject) }), popup: { href: '/issues/[id]' } %>
6+
<%= map_tag map: @project.map, geom: (Issue.array_to_geojson(@issues, include_properties: { only: %i(id subject) }) if @issues), popup: { href: '/issues/[id]' } %>
77
</fieldset>
88

99
<% end %>
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
<% return '' if @issue.project.nil? %>
2-
<% return '' unless User.current.allowed_to?(:view_issues, @issue.project) %>
3-
41
<% if @project.nil? or @project.module_enabled?(:gtt) %>
5-
<%= content_tag(:div, "", :data => {
6-
:geom => @issue.geojson,
7-
:bounds => @project.geojson,
8-
:layers => @project.gtt_tile_sources,
9-
}, :id => 'ol-' + rand(36**8).to_s(36), :class => 'ol-map')
10-
%>
2+
<%= map_tag map: @issue.map %>
113
<% end %>

0 commit comments

Comments
 (0)