Merge pull request #2295 from wairbut-m2c/aperez-mappable-objects

Improvements for Mappable objects
This commit is contained in:
BertoCQ
2018-02-02 19:26:47 +01:00
committed by GitHub
7 changed files with 57 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ module Budgets
before_action :set_random_seed, only: :index
before_action :load_categories, only: [:index, :new, :create]
before_action :set_default_budget_filter, only: :index
before_action :destroy_map_location_association, only: :update
feature_flag :budgets
@@ -141,6 +142,13 @@ module Budgets
end
end
def destroy_map_location_association
map_location = params[:budget_investment][:map_location_attributes]
if map_location && (map_location[:longitude] && map_location[:latitude]).blank? && !map_location[:id].blank?
MapLocation.destroy(map_location[:id])
end
end
end
end

View File

@@ -7,6 +7,7 @@ class ProposalsController < ApplicationController
before_action :load_categories, only: [:index, :new, :create, :edit, :map, :summary]
before_action :load_geozones, only: [:edit, :map, :summary]
before_action :authenticate_user!, except: [:index, :show, :map, :summary]
before_action :destroy_map_location_association, only: :update
feature_flag :proposals
@@ -130,4 +131,11 @@ class ProposalsController < ApplicationController
@proposal_successful_exists = Proposal.successful.exists?
end
def destroy_map_location_association
map_location = params[:proposal][:map_location_attributes]
if map_location && (map_location[:longitude] && map_location[:latitude]).blank? && !map_location[:id].blank?
MapLocation.destroy(map_location[:id])
end
end
end