Remove skip map checkbox
This commit is contained in:
@@ -6,11 +6,6 @@
|
||||
$("*[data-map]:visible").each(function() {
|
||||
App.Map.initializeMap(this);
|
||||
});
|
||||
$(".js-toggle-map").on({
|
||||
click: function() {
|
||||
App.Map.toggleMap();
|
||||
}
|
||||
});
|
||||
},
|
||||
destroy: function() {
|
||||
App.Map.maps.forEach(function(map) {
|
||||
@@ -149,10 +144,6 @@
|
||||
});
|
||||
}
|
||||
},
|
||||
toggleMap: function() {
|
||||
$(".map").toggle();
|
||||
$(".js-location-map-remove-marker").toggle();
|
||||
},
|
||||
cleanInvestmentCoordinates: function(element) {
|
||||
var clean_markers, markers;
|
||||
markers = $(element).attr("data-marker-investments-coordinates");
|
||||
|
||||
@@ -135,7 +135,7 @@ module Budgets
|
||||
|
||||
def investment_params
|
||||
attributes = [:heading_id, :tag_list, :organization_name, :location,
|
||||
:terms_of_service, :skip_map, :related_sdg_list,
|
||||
:terms_of_service, :related_sdg_list,
|
||||
image_attributes: image_attributes,
|
||||
documents_attributes: document_attributes,
|
||||
map_location_attributes: map_location_attributes]
|
||||
|
||||
@@ -60,7 +60,7 @@ class Management::Budgets::InvestmentsController < Management::BaseController
|
||||
end
|
||||
|
||||
def investment_params
|
||||
attributes = [:external_url, :heading_id, :tag_list, :organization_name, :location, :skip_map,
|
||||
attributes = [:external_url, :heading_id, :tag_list, :organization_name, :location,
|
||||
image_attributes: image_attributes,
|
||||
documents_attributes: document_attributes,
|
||||
map_location_attributes: map_location_attributes]
|
||||
|
||||
@@ -57,7 +57,7 @@ class Management::ProposalsController < Management::BaseController
|
||||
def proposal_params
|
||||
attributes = [:video_url, :responsible_name, :tag_list,
|
||||
:terms_of_service, :geozone_id,
|
||||
:skip_map, map_location_attributes: map_location_attributes]
|
||||
map_location_attributes: map_location_attributes]
|
||||
params.require(:proposal).permit(attributes, translation_params(Proposal))
|
||||
end
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ class ProposalsController < ApplicationController
|
||||
|
||||
def proposal_params
|
||||
attributes = [:video_url, :responsible_name, :tag_list, :terms_of_service,
|
||||
:geozone_id, :skip_map, :related_sdg_list,
|
||||
:geozone_id, :related_sdg_list,
|
||||
image_attributes: image_attributes,
|
||||
documents_attributes: document_attributes,
|
||||
map_location_attributes: map_location_attributes]
|
||||
|
||||
@@ -2,28 +2,11 @@ module Mappable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
attr_accessor :skip_map
|
||||
|
||||
has_one :map_location, dependent: :destroy
|
||||
accepts_nested_attributes_for :map_location, allow_destroy: true, reject_if: :all_blank
|
||||
|
||||
validate :map_must_be_valid, on: :create, if: :feature_maps?
|
||||
|
||||
def map_must_be_valid
|
||||
return true if skip_map?
|
||||
|
||||
unless map_location&.available?
|
||||
skip_map_error = I18n.t("activerecord.errors.models.map_location.attributes.map.invalid")
|
||||
errors.add(:skip_map, skip_map_error)
|
||||
end
|
||||
end
|
||||
|
||||
def feature_maps?
|
||||
Setting["feature.map"].present?
|
||||
end
|
||||
|
||||
def skip_map?
|
||||
skip_map == "1"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -16,10 +16,4 @@
|
||||
<%= m_l_fields.hidden_field :zoom,
|
||||
value: map_location.zoom,
|
||||
id: map_location_input_id(parent_class, "zoom") %>
|
||||
|
||||
<div>
|
||||
<%= form.check_box :skip_map,
|
||||
label: t("#{i18n_namespace}.form.map_skip_checkbox"),
|
||||
class: "js-toggle-map" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
@@ -536,10 +536,6 @@ en:
|
||||
attributes:
|
||||
segment_recipient:
|
||||
invalid: "The user recipients segment is invalid"
|
||||
map_location:
|
||||
attributes:
|
||||
map:
|
||||
invalid: Map location can't be blank. Place a marker or select the checkbox if geolocalization is not needed
|
||||
poll/voter:
|
||||
attributes:
|
||||
document_number:
|
||||
|
||||
@@ -85,7 +85,6 @@ en:
|
||||
map_location: "Map location"
|
||||
map_location_instructions: "Navigate the map to the location and place the marker."
|
||||
map_remove_marker: "Remove map marker"
|
||||
map_skip_checkbox: "This investment doesn't have a concrete location or I'm not aware of it."
|
||||
index:
|
||||
title: Participatory budgeting
|
||||
unfeasible: Unfeasible investment projects
|
||||
|
||||
@@ -347,7 +347,6 @@ en:
|
||||
map_location: "Map location"
|
||||
map_location_instructions: "Navigate the map to the location and place the marker."
|
||||
map_remove_marker: "Remove map marker"
|
||||
map_skip_checkbox: "This proposal doesn't have a concrete location or I'm not aware of it."
|
||||
index:
|
||||
featured_proposals: Featured
|
||||
orders:
|
||||
|
||||
@@ -536,10 +536,6 @@ es:
|
||||
attributes:
|
||||
segment_recipient:
|
||||
invalid: "El usuario del destinatario es inválido"
|
||||
map_location:
|
||||
attributes:
|
||||
map:
|
||||
invalid: El mapa no puede estar en blanco. Añade un punto al mapa o marca la casilla si no hace falta un mapa.
|
||||
poll/voter:
|
||||
attributes:
|
||||
document_number:
|
||||
|
||||
@@ -85,7 +85,6 @@ es:
|
||||
map_location: "Ubicación en el mapa"
|
||||
map_location_instructions: "Navega por el mapa hasta la ubicación y coloca el marcador."
|
||||
map_remove_marker: "Eliminar el marcador"
|
||||
map_skip_checkbox: "Este proyecto no tiene una ubicación concreta o no la conozco."
|
||||
index:
|
||||
title: Presupuestos participativos
|
||||
unfeasible: Proyectos de gasto no viables
|
||||
|
||||
@@ -347,7 +347,6 @@ es:
|
||||
map_location: "Ubicación en el mapa"
|
||||
map_location_instructions: "Navega por el mapa hasta la ubicación y coloca el marcador."
|
||||
map_remove_marker: "Eliminar el marcador"
|
||||
map_skip_checkbox: "Esta propuesta no tiene una ubicación concreta o no la conozco."
|
||||
index:
|
||||
featured_proposals: Destacadas
|
||||
orders:
|
||||
|
||||
@@ -140,7 +140,6 @@ section "Creating Investments" do
|
||||
valuation_finished: [false, true].sample,
|
||||
tag_list: tags.sample(3).join(","),
|
||||
price: rand(1..100) * 100000,
|
||||
skip_map: "1",
|
||||
terms_of_service: "1"
|
||||
}.merge(translation_attributes))
|
||||
|
||||
@@ -187,7 +186,6 @@ section "Winner Investments" do
|
||||
valuation_finished: true,
|
||||
selected: true,
|
||||
price: rand(10000..heading.price),
|
||||
skip_map: "1",
|
||||
terms_of_service: "1"
|
||||
)
|
||||
add_image_to(investment) if Random.rand > 0.3
|
||||
|
||||
@@ -37,7 +37,6 @@ section "Creating Proposals" do
|
||||
created_at: rand((Time.current - 1.week)..Time.current),
|
||||
tag_list: tags.sample(3).join(","),
|
||||
geozone: Geozone.all.sample,
|
||||
skip_map: "1",
|
||||
terms_of_service: "1",
|
||||
published_at: Time.current)
|
||||
random_locales.map do |locale|
|
||||
@@ -65,7 +64,6 @@ section "Creating Archived Proposals" do
|
||||
description: description,
|
||||
tag_list: tags.sample(3).join(","),
|
||||
geozone: Geozone.all.sample,
|
||||
skip_map: "1",
|
||||
terms_of_service: "1",
|
||||
created_at: months_to_archive_proposals.to_i.months.ago,
|
||||
published_at: months_to_archive_proposals.to_i.months.ago)
|
||||
@@ -94,7 +92,6 @@ section "Creating Successful Proposals" do
|
||||
created_at: rand((Time.current - 1.week)..Time.current),
|
||||
tag_list: tags.sample(3).join(","),
|
||||
geozone: Geozone.all.sample,
|
||||
skip_map: "1",
|
||||
terms_of_service: "1",
|
||||
cached_votes_up: Setting["votes_for_proposal_success"],
|
||||
published_at: Time.current)
|
||||
@@ -121,7 +118,6 @@ section "Creating Successful Proposals" do
|
||||
created_at: rand((Time.current - 1.week)..Time.current),
|
||||
tag_list: tags.sample(3).join(","),
|
||||
geozone: Geozone.all.sample,
|
||||
skip_map: "1",
|
||||
terms_of_service: "1",
|
||||
published_at: Time.current)
|
||||
random_locales.map do |locale|
|
||||
|
||||
@@ -398,7 +398,6 @@ namespace :proposal_actions do
|
||||
created_at: Time.current - expected_supports.length.days,
|
||||
tag_list: "Example",
|
||||
geozone: Geozone.all.sample,
|
||||
skip_map: "1",
|
||||
terms_of_service: "1",
|
||||
published_at: Time.current - expected_supports.length.days)
|
||||
|
||||
|
||||
@@ -105,7 +105,6 @@ FactoryBot.define do
|
||||
description { "Spend money on this" }
|
||||
price { 10 }
|
||||
unfeasibility_explanation { "" }
|
||||
skip_map { "1" }
|
||||
terms_of_service { "1" }
|
||||
incompatible { false }
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ FactoryBot.define do
|
||||
video_url { "https://youtu.be/nhuNb0XtRhQ" }
|
||||
responsible_name { "John Snow" }
|
||||
terms_of_service { "1" }
|
||||
skip_map { "1" }
|
||||
published_at { Time.current }
|
||||
|
||||
association :author, factory: :user
|
||||
|
||||
@@ -8,13 +8,11 @@ shared_examples "map validations" do
|
||||
|
||||
it "is valid with a map location" do
|
||||
mappable.map_location = build(:map_location)
|
||||
mappable.skip_map = nil
|
||||
|
||||
expect(mappable).to be_valid
|
||||
end
|
||||
|
||||
it "is valid accepting that the mappable has no map" do
|
||||
mappable.skip_map = "1"
|
||||
it "is valid without a location" do
|
||||
mappable.map_location = nil
|
||||
|
||||
expect(mappable).to be_valid
|
||||
@@ -24,23 +22,9 @@ shared_examples "map validations" do
|
||||
Setting["feature.map"] = nil
|
||||
|
||||
mappable.map_location = nil
|
||||
mappable.skip_map = nil
|
||||
|
||||
expect(mappable).to be_valid
|
||||
end
|
||||
|
||||
it "is not valid without a map location" do
|
||||
mappable.map_location = nil
|
||||
mappable.skip_map = nil
|
||||
|
||||
expect(mappable).not_to be_valid
|
||||
end
|
||||
|
||||
it "is not valid without accepting that the mappable has no map" do
|
||||
mappable.skip_map = nil
|
||||
|
||||
expect(mappable).not_to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
describe "cache" do
|
||||
|
||||
@@ -54,7 +54,6 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
||||
|
||||
send("fill_in_#{mappable_factory_name}_form")
|
||||
expect(page).to have_css ".map_location"
|
||||
check "#{mappable_factory_name}_skip_map"
|
||||
send("submit_#{mappable_factory_name}_form")
|
||||
|
||||
expect(page).not_to have_css(".map_location")
|
||||
@@ -72,15 +71,6 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
||||
expect(page).not_to have_css(".map_location")
|
||||
end
|
||||
|
||||
scenario "Errors on create" do
|
||||
do_login_for user
|
||||
visit send(mappable_new_path, arguments)
|
||||
|
||||
send("submit_#{mappable_factory_name}_form")
|
||||
|
||||
expect(page).to have_content "Map location can't be blank"
|
||||
end
|
||||
|
||||
describe "When restoring the page from browser history" do
|
||||
before { Setting["org_name"] = "CONSUL" }
|
||||
|
||||
@@ -177,26 +167,10 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
||||
visit send(mappable_new_path, arguments)
|
||||
|
||||
send("fill_in_#{mappable_factory_name}_form")
|
||||
check "#{mappable_factory_name}_skip_map"
|
||||
send("submit_#{mappable_factory_name}_form")
|
||||
|
||||
expect(page).not_to have_content "Map location can't be blank"
|
||||
end
|
||||
|
||||
scenario "Toggle map" do
|
||||
do_login_for user
|
||||
visit send(mappable_new_path, arguments)
|
||||
|
||||
check "#{mappable_factory_name}_skip_map"
|
||||
|
||||
expect(page).not_to have_css(".map")
|
||||
expect(page).not_to have_content("Remove map marker")
|
||||
|
||||
uncheck "#{mappable_factory_name}_skip_map"
|
||||
|
||||
expect(page).to have_css(".map")
|
||||
expect(page).to have_content("Remove map marker")
|
||||
end
|
||||
end
|
||||
|
||||
describe "At #{mappable_edit_path}" do
|
||||
@@ -242,7 +216,6 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name,
|
||||
|
||||
visit send(mappable_edit_path, id: mappable.id)
|
||||
click_link "Remove map marker"
|
||||
check "#{mappable_factory_name}_skip_map"
|
||||
click_on "Save changes"
|
||||
|
||||
expect(page).not_to have_css(".map_location")
|
||||
|
||||
Reference in New Issue
Block a user