parent
9a18a154ea
commit
aad685bb79
4 changed files with 30 additions and 10 deletions
|
@ -13,19 +13,16 @@ class Champs::CarteController < ApplicationController
|
||||||
coordinates = params[:dossier][:champs_private_attributes][params[:position]][:value]
|
coordinates = params[:dossier][:champs_private_attributes][params[:position]][:value]
|
||||||
end
|
end
|
||||||
|
|
||||||
if params[:champ_id].present?
|
@champ = if params[:champ_id].present?
|
||||||
@champ = Champ
|
Champ
|
||||||
.joins(:dossier)
|
.joins(:dossier)
|
||||||
.where(dossiers: { user_id: logged_user_ids })
|
.where(dossiers: { user_id: logged_user_ids })
|
||||||
.find(params[:champ_id])
|
.find(params[:champ_id])
|
||||||
else
|
else
|
||||||
@champ = Champs::CarteChamp.new(type_de_champ: TypeDeChamp.new(
|
TypeDeChamp
|
||||||
type_champ: TypeDeChamp.type_champs.fetch(:carte),
|
.joins(:procedure)
|
||||||
options: {
|
.where(procedures: { administrateur_id: logged_user_ids })
|
||||||
quartiers_prioritaires: true,
|
.find(params[:type_de_champ_id]).champ.build
|
||||||
cadastres: true
|
|
||||||
}
|
|
||||||
))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
geo_areas = []
|
geo_areas = []
|
||||||
|
|
|
@ -9,4 +9,12 @@ module ChampHelper
|
||||||
raw(champ.to_render_data.to_json)
|
raw(champ.to_render_data.to_json)
|
||||||
# rubocop:enable Rails/OutputSafety
|
# rubocop:enable Rails/OutputSafety
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def champ_carte_params(champ)
|
||||||
|
if champ.persisted?
|
||||||
|
{ champ_id: champ.id }
|
||||||
|
else
|
||||||
|
{ type_de_champ_id: champ.type_de_champ_id }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,4 +8,4 @@
|
||||||
= render partial: 'shared/champs/carte/geo_areas', locals: { champ: champ, error: false }
|
= render partial: 'shared/champs/carte/geo_areas', locals: { champ: champ, error: false }
|
||||||
|
|
||||||
= form.hidden_field :value,
|
= form.hidden_field :value,
|
||||||
data: { remote: true, url: champs_carte_path(form.index), params: { champ_id: champ&.id }.to_query, method: 'post' }
|
data: { remote: true, url: champs_carte_path(form.index), params: champ_carte_params(champ).to_query, method: 'post' }
|
||||||
|
|
|
@ -117,4 +117,19 @@ feature 'As an administrateur I can edit types de champ', js: true do
|
||||||
|
|
||||||
expect(page).to have_content('Supprimer', count: 3)
|
expect(page).to have_content('Supprimer', count: 3)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "Add carte champ" do
|
||||||
|
select('Carte', from: 'procedure_types_de_champ_attributes_0_type_champ')
|
||||||
|
fill_in 'procedure_types_de_champ_attributes_0_libelle', with: 'libellé de champ carte'
|
||||||
|
blur
|
||||||
|
check 'Quartiers prioritaires'
|
||||||
|
expect(page).to have_content('Formulaire enregistré')
|
||||||
|
|
||||||
|
preview_window = window_opened_by { click_on 'Prévisualiser le formulaire' }
|
||||||
|
within_window(preview_window) do
|
||||||
|
expect(page).to have_content('libellé de champ carte')
|
||||||
|
expect(page).to have_content('Quartiers prioritaires')
|
||||||
|
expect(page).not_to have_content('Cadastres')
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue