add some improvements on budget headings

Show information about longitude and latitude in a budget heading
Show information about custom content in a budget heading
Fix render of map (zoom scrollable and points clickable)
Fix typo in app/models/map_location.rb
This commit is contained in:
Julian Herrero
2018-12-27 19:48:47 +01:00
parent 2081269a67
commit c5a7492128
10 changed files with 31 additions and 21 deletions

View File

@@ -74,7 +74,7 @@ App.Map =
openMarkerPopup = (e) -> openMarkerPopup = (e) ->
marker = e.target marker = e.target
$.ajax 'investments/' + marker.options['id'] + '/json_data', $.ajax '/investments/' + marker.options['id'] + '/json_data',
type: 'GET' type: 'GET'
dataType: 'json' dataType: 'json'
success: (data) -> success: (data) ->

View File

@@ -881,7 +881,7 @@ footer {
.sidebar-map { .sidebar-map {
.map { .map {
z-index: -1; z-index: 0;
} }
} }

View File

@@ -22,7 +22,7 @@ class MapLocation < ActiveRecord::Base
map = new map = new
map.zoom = Budget::Heading::OSM_DISTRICT_LEVEL_ZOOM map.zoom = Budget::Heading::OSM_DISTRICT_LEVEL_ZOOM
map.latitude = heading.latitude.to_f if heading.latitude.present? map.latitude = heading.latitude.to_f if heading.latitude.present?
map.longitude = heading.longitude.to_f if heading.latitude.present? map.longitude = heading.longitude.to_f if heading.longitude.present?
map map
end end

View File

@@ -1,3 +1,3 @@
<%= render "header", action: "edit" %> <%= render "header", action: "edit" %>
<%= render "form", path: admin_budget_group_path(@budget, @group), action: "edit" %> <%= render "form", path: admin_budget_group_path(@budget, @group), action: "submit" %>

View File

@@ -32,8 +32,14 @@
label: t("admin.budget_headings.form.longitude"), label: t("admin.budget_headings.form.longitude"),
maxlength: 22, maxlength: 22,
placeholder: "longitude" %> placeholder: "longitude" %>
<p class="help-text" id="budgets-coordinates-help-text">
<%= t("admin.budget_headings.form.coordinates_info") %>
</p>
<%= f.check_box :allow_custom_content, label: t("admin.budget_headings.form.allow_content_block") %> <%= f.check_box :allow_custom_content, label: t("admin.budget_headings.form.allow_content_block") %>
<p class="help-text" id="budgets-content-blocks-help-text">
<%= t("admin.budget_headings.form.content_blocks_info") %>
</p>
<%= f.submit t("admin.budget_headings.form.#{action}"), class: "button success" %> <%= f.submit t("admin.budget_headings.form.#{action}"), class: "button success" %>
<% end %> <% end %>

View File

@@ -1,3 +1,3 @@
<%= render "header", action: "edit" %> <%= render "header", action: "edit" %>
<%= render "form", path: admin_budget_group_heading_path(@budget, @group, @heading), action: "edit" %> <%= render "form", path: admin_budget_group_heading_path(@budget, @group, @heading), action: "submit" %>

View File

@@ -151,9 +151,11 @@ en:
amount: "Amount" amount: "Amount"
population: "Population (optional)" population: "Population (optional)"
population_info: "Budget Heading population field is used for Statistic purposes at the end of the Budget to show for each Heading that represents an area with population what percentage voted. The field is optional so you can leave it empty if it doesn't apply." population_info: "Budget Heading population field is used for Statistic purposes at the end of the Budget to show for each Heading that represents an area with population what percentage voted. The field is optional so you can leave it empty if it doesn't apply."
latitude: "Latitude" latitude: "Latitude (optional)"
longitude: "Longitude" longitude: "Longitude (optional)"
coordinates_info: "If latitude and longitude are provided, the investments page for this heading will include a map. This map will be centered using those coordinates."
allow_content_block: "Allow content block" allow_content_block: "Allow content block"
content_blocks_info: "If allow content block is checked, you will be able to create custom content related to this heading from the section Settings > Custom content blocks. This content will appear on the investments page for this heading."
create: "Create new heading" create: "Create new heading"
edit: "Edit heading" edit: "Edit heading"
submit: "Save heading" submit: "Save heading"

View File

@@ -151,9 +151,11 @@ es:
amount: "Cantidad" amount: "Cantidad"
population: "Población (opcional)" population: "Población (opcional)"
population_info: "El campo población de las partidas presupuestarias se usa con fines estadísticos únicamente, con el objetivo de mostrar el porcentaje de votos habidos en cada partida que represente un área con población. Es un campo opcional, así que puedes dejarlo en blanco si no aplica." population_info: "El campo población de las partidas presupuestarias se usa con fines estadísticos únicamente, con el objetivo de mostrar el porcentaje de votos habidos en cada partida que represente un área con población. Es un campo opcional, así que puedes dejarlo en blanco si no aplica."
latitude: "Latitud" latitude: "Latitud (opcional)"
longitude: "Longitud" longitude: "Longitud (opcional)"
coordinates_info: "Si se añaden los campos latitud y longitud, en la página de proyectos de esta partida aparecerá un mapa, que estará centrado en esas coordenadas."
allow_content_block: "Permitir bloque de contenidos" allow_content_block: "Permitir bloque de contenidos"
content_blocks_info: "Si se permite el bloque de contenidos, se tendrá la oportunidad de crear bloques de contenido relativos a esta partida desde la sección Configuración > Personalizar bloques. Este contenido aparecerá en la página de proyectos de esta partida."
create: "Crear nueva partida" create: "Crear nueva partida"
edit: "Editar partida" edit: "Editar partida"
submit: "Guardar partida" submit: "Guardar partida"

View File

@@ -154,7 +154,7 @@ feature "Admin budget groups" do
fill_in "Group name", with: "Districts" fill_in "Group name", with: "Districts"
select "2", from: "Maximum number of headings in which a user can vote" select "2", from: "Maximum number of headings in which a user can vote"
click_button "Edit group" click_button "Save group"
expect(page).to have_content "Group updated successfully" expect(page).to have_content "Group updated successfully"
@@ -170,7 +170,7 @@ feature "Admin budget groups" do
expect(page).to have_field "Group name", with: "All City" expect(page).to have_field "Group name", with: "All City"
fill_in "Group name", with: "Districts" fill_in "Group name", with: "Districts"
click_button "Edit group" click_button "Save group"
expect(page).not_to have_content "Group updated successfully" expect(page).not_to have_content "Group updated successfully"
expect(page).to have_css("label.error", text: "Group name") expect(page).to have_css("label.error", text: "Group name")

View File

@@ -147,8 +147,8 @@ feature "Admin budget headings" do
expect(page).to have_field "Heading name", with: heading.name expect(page).to have_field "Heading name", with: heading.name
expect(page).to have_field "Amount", with: heading.price expect(page).to have_field "Amount", with: heading.price
expect(page).to have_field "Population (optional)", with: heading.population expect(page).to have_field "Population (optional)", with: heading.population
expect(page).to have_field "Longitude", with: heading.longitude expect(page).to have_field "Longitude (optional)", with: heading.longitude
expect(page).to have_field "Latitude", with: heading.latitude expect(page).to have_field "Latitude (optional)", with: heading.latitude
expect(find_field("Allow content block")).not_to be_checked expect(find_field("Allow content block")).not_to be_checked
end end
@@ -170,17 +170,17 @@ feature "Admin budget headings" do
expect(page).to have_field "Heading name", with: "All City" expect(page).to have_field "Heading name", with: "All City"
expect(page).to have_field "Amount", with: 1000 expect(page).to have_field "Amount", with: 1000
expect(page).to have_field "Population (optional)", with: 10000 expect(page).to have_field "Population (optional)", with: 10000
expect(page).to have_field "Longitude", with: 20.50 expect(page).to have_field "Longitude (optional)", with: 20.50
expect(page).to have_field "Latitude", with: -10.50 expect(page).to have_field "Latitude (optional)", with: -10.50
expect(find_field("Allow content block")).to be_checked expect(find_field("Allow content block")).to be_checked
fill_in "Heading name", with: "Districts" fill_in "Heading name", with: "Districts"
fill_in "Amount", with: "2000" fill_in "Amount", with: "2000"
fill_in "Population (optional)", with: "20000" fill_in "Population (optional)", with: "20000"
fill_in "Longitude", with: "-40.47" fill_in "Longitude (optional)", with: "-40.47"
fill_in "Latitude", with: "25.25" fill_in "Latitude (optional)", with: "25.25"
uncheck "Allow content block" uncheck "Allow content block"
click_button "Edit heading" click_button "Save heading"
expect(page).to have_content "Heading updated successfully" expect(page).to have_content "Heading updated successfully"
@@ -188,8 +188,8 @@ feature "Admin budget headings" do
expect(page).to have_field "Heading name", with: "Districts" expect(page).to have_field "Heading name", with: "Districts"
expect(page).to have_field "Amount", with: 2000 expect(page).to have_field "Amount", with: 2000
expect(page).to have_field "Population (optional)", with: 20000 expect(page).to have_field "Population (optional)", with: 20000
expect(page).to have_field "Longitude", with: -40.47 expect(page).to have_field "Longitude (optional)", with: -40.47
expect(page).to have_field "Latitude", with: 25.25 expect(page).to have_field "Latitude (optional)", with: 25.25
expect(find_field("Allow content block")).not_to be_checked expect(find_field("Allow content block")).not_to be_checked
end end
@@ -200,7 +200,7 @@ feature "Admin budget headings" do
expect(page).to have_field "Heading name", with: "All City" expect(page).to have_field "Heading name", with: "All City"
fill_in "Heading name", with: "Districts" fill_in "Heading name", with: "Districts"
click_button "Edit heading" click_button "Save heading"
expect(page).not_to have_content "Heading updated successfully" expect(page).not_to have_content "Heading updated successfully"
expect(page).to have_css("label.error", text: "Heading name") expect(page).to have_css("label.error", text: "Heading name")