refactor(champ): simplify carte champ

This commit is contained in:
Paul Chavard 2022-04-28 15:05:18 +02:00
parent 3384b535c5
commit 4604be0796
4 changed files with 3 additions and 5 deletions

View file

@ -2,7 +2,6 @@ class Champs::CarteController < ApplicationController
before_action :authenticate_logged_user!
def index
@selector = ".carte-#{params[:champ_id]}"
@champ = policy_scope(Champ).find(params[:champ_id])
@focus = params[:focus].present?
end

View file

@ -1,6 +1,6 @@
<%= render_flash(timeout: 5000, fixed: true) %>
<%= render_to_element("#{@selector} + .geo-areas",
<%= render_to_element("##{@champ.input_group_id} .geo-areas",
partial: 'shared/champs/carte/geo_areas',
locals: { champ: @champ, editing: true }) %>

View file

@ -1,4 +1,4 @@
= react_component("MapEditor", { featureCollection: champ.to_feature_collection, url: champs_carte_features_path(champ), options: champ.render_options }, class: "carte-#{champ.id}")
= react_component("MapEditor", featureCollection: champ.to_feature_collection, url: champs_carte_features_path(champ), options: champ.render_options)
.geo-areas
= render partial: 'shared/champs/carte/geo_areas', locals: { champ: champ, editing: true }

View file

@ -142,12 +142,11 @@ Rails.application.routes.draw do
namespace :champs do
get ':position/dossier_link', to: 'dossier_link#show', as: :dossier_link
post ':position/carte', to: 'carte#show', as: :carte
get ':champ_id/siret', to: 'siret#show', as: :siret
post ':champ_id/carte', to: 'carte#show', as: :carte
get ':champ_id/carte/features', to: 'carte#index', as: :carte_features
post ':champ_id/carte/features', to: 'carte#create'
post ':champ_id/carte/features/import', to: 'carte#import'
patch ':champ_id/carte/features/:id', to: 'carte#update'
delete ':champ_id/carte/features/:id', to: 'carte#destroy'