Skip to content

Commit df4a75c

Browse files
committed
adds default flag to tile sources.
1 parent 16c3bd9 commit df4a75c

File tree

8 files changed

+20
-2
lines changed

8 files changed

+20
-2
lines changed

app/controllers/gtt_tile_sources_controller.rb

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

53-
params[:tile_source].permit( :name, :type, :global, :options_string )
53+
params[:tile_source].permit( :name, :type, :global,
54+
:default, :options_string )
5455
end
5556
end

app/models/gtt_tile_source.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class GttTileSource < ActiveRecord::Base
1111
# globally available tile sources
1212
scope :global, ->{ where global: true }
1313

14+
# default tile sources for new projects
15+
scope :default, ->{ where default: true }
16+
1417
attr_writer :options_string
1518
def options_string
1619
@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
@@ -5,6 +5,7 @@
55
<p><%= f.text_field :name, required: true, size: 25 %></p>
66
<p><%= f.text_field :type, required: true, size: 25 %></p>
77
<p><%= f.check_box :global %></p>
8+
<p><%= f.check_box :default %></p>
89
<p> <%= f.text_area :options_string, rows: 10, cols: 80 %> </p>
910
</div>
1011

app/views/gtt_tile_sources/_tile_source.html.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
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>
4+
<td><%= checked_image tile_source.global? %></td>
5+
<td><%= checked_image tile_source.default? %></td>
56
<td><%= tile_source_options tile_source %></td>
67
<td class="buttons">
78
<%= 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
@@ -11,6 +11,7 @@
1111
<th><%= l :label_type %></th>
1212
<th><%= l :label_name %></th>
1313
<th><%= l :label_global %></th>
14+
<th><%= l :label_default %></th>
1415
<th><%= l :label_config %></th>
1516
<th></th>
1617
</tr>

config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
en:
33
error_invalid_json: must be valid JSON
44

5+
field_default: Default for new projects
56
field_geometry: "Geometry"
67
field_location: "Location"
78
field_geom: "Geometry"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddDefaultToTileSources < ActiveRecord::Migration
2+
def change
3+
add_column :gtt_tile_sources, :default, :boolean, default: false
4+
end
5+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddDefaultValueToGlobalTileSourceField < ActiveRecord::Migration
2+
def change
3+
change_column :gtt_tile_sources, :global, :boolean, default: false
4+
end
5+
end

0 commit comments

Comments
 (0)