Skip to content

Commit cc5c5d2

Browse files
committed
adds global flag and scope to gtt tile sources #52.
1 parent 27c02f4 commit cc5c5d2

File tree

7 files changed

+15
-3
lines changed

7 files changed

+15
-3
lines changed

app/controllers/gtt_tile_sources_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ def destroy
5050
def tile_source_params
5151
return {} unless params[:tile_source]
5252

53-
params[:tile_source].permit( :name, :type, :options_string )
53+
params[:tile_source].permit( :name, :type, :global, :options_string )
5454
end
5555
end

app/models/gtt_tile_source.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Tile source model
22
#
3-
# Configuration is stored as json, this can be extended to support
4-
# tile sources other than ol.source.OSM
3+
# Configuration is stored as json
54
class GttTileSource < ActiveRecord::Base
65
self.inheritance_column = 'none'
76

87
validates :name, presence: true
98
validates :type, presence: true
109
validate :take_json_options
1110

11+
# globally available tile sources
12+
scope :global, ->{ where global: true }
13+
1214
attr_writer :options_string
1315
def options_string
1416
@options_string ||= JSON.pretty_generate(options || {})

app/views/gtt_tile_sources/_form.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<div class="box tabular">
55
<p><%= f.text_field :name, required: true, size: 25 %></p>
66
<p><%= f.text_field :type, required: true, size: 25 %></p>
7+
<p><%= f.check_box :global %></p>
78
<p> <%= f.text_area :options_string, rows: 10, cols: 80 %> </p>
89
</div>
910

app/views/gtt_tile_sources/_tile_source.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<tr class="<%= cycle("odd", "even") %>">
22
<td><%= tile_source.type %></td>
33
<td><%= link_to tile_source.name, edit_gtt_tile_source_path(tile_source) %></td>
4+
<td><%= format_object tile_source.global %></td>
45
<td><%= tile_source_options tile_source %></td>
56
<td class="buttons">
67
<%= delete_link gtt_tile_source_path(tile_source) %>

app/views/gtt_tile_sources/index.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<tr>
1111
<th><%= l :label_type %></th>
1212
<th><%= l :label_name %></th>
13+
<th><%= l :label_global %></th>
1314
<th><%= l :label_config %></th>
1415
<th></th>
1516
</tr>

config/locales/en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ en:
55
field_geometry: "Geometry"
66
field_location: "Location"
77
field_geom: "Geometry"
8+
field_global: Globally available
89
field_options_string: Options
910
field_gtt_tile_source_ids: Tile Sources
1011

1112
label_geotask_map: "Geotask Map"
13+
label_global: Global
1214
label_project_map: "Project Map"
1315
label_user_map: "User Map"
1416
label_name: Name
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddGlobalToTileSources < ActiveRecord::Migration
2+
def change
3+
add_column :gtt_tile_sources, :global, :boolean
4+
end
5+
end

0 commit comments

Comments
 (0)