diff --git a/Gemfile b/Gemfile index 592bc32ba..757457a27 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,6 @@ gem 'delayed_cron_job' # Cron jobs gem 'delayed_job_active_record' gem 'delayed_job_web', '>= 1.4.4' gem 'devise' # Gestion des comptes utilisateurs -gem 'devise-async' gem 'devise-i18n' gem 'devise-two-factor' gem 'discard' diff --git a/Gemfile.lock b/Gemfile.lock index 0387b05f1..2ac8dcb78 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -200,9 +200,6 @@ GEM railties (>= 4.1.0) responders warden (~> 1.2.3) - devise-async (1.0.0) - activejob (>= 5.0) - devise (>= 4.0) devise-i18n (1.9.2) devise (>= 4.7.1) devise-two-factor (4.0.2) @@ -820,7 +817,6 @@ DEPENDENCIES delayed_job_active_record delayed_job_web (>= 1.4.4) devise - devise-async devise-i18n devise-two-factor discard diff --git a/app/controllers/administrateurs/procedures_controller.rb b/app/controllers/administrateurs/procedures_controller.rb index 2388508db..96d6847fb 100644 --- a/app/controllers/administrateurs/procedures_controller.rb +++ b/app/controllers/administrateurs/procedures_controller.rb @@ -44,7 +44,7 @@ module Administrateurs end def apercu - @dossier = procedure_without_control.draft_revision.new_dossier + @dossier = procedure_without_control.draft_revision.dossier_for_preview(current_user) @tab = apercu_tab end diff --git a/app/controllers/champs/siret_controller.rb b/app/controllers/champs/siret_controller.rb index 0d790704a..aaeaeac5b 100644 --- a/app/controllers/champs/siret_controller.rb +++ b/app/controllers/champs/siret_controller.rb @@ -45,11 +45,9 @@ class Champs::SiretController < ApplicationController end def find_etablisement - if params[:champ_id].present? - @champ = policy_scope(Champ).find(params[:champ_id]) - @etablissement = @champ&.etablissement - end - @procedure_id = @champ&.dossier&.procedure&.id || 'aperçu' + @champ = policy_scope(Champ).find(params[:champ_id]) + @etablissement = @champ.etablissement + @procedure_id = @champ.dossier.procedure.id end def find_etablissement_with_siret @@ -57,7 +55,7 @@ class Champs::SiretController < ApplicationController end def clear_siret_and_etablissement - @champ&.update!(value: '') + @champ.update!(value: '') @etablissement&.destroy end diff --git a/app/controllers/users/commencer_controller.rb b/app/controllers/users/commencer_controller.rb index 5d29d07c4..93893dedd 100644 --- a/app/controllers/users/commencer_controller.rb +++ b/app/controllers/users/commencer_controller.rb @@ -84,8 +84,8 @@ module Users def generate_empty_pdf(revision) @dossier = revision.new_dossier - s = render_to_string(template: 'dossiers/dossier_vide', formats: [:pdf]) - send_data(s, :filename => "#{revision.procedure.libelle}.pdf") + data = render_to_string(template: 'dossiers/dossier_vide', formats: [:pdf]) + send_data(data, filename: "#{revision.procedure.libelle}.pdf") end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 39f04b140..6572b58bb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -62,7 +62,7 @@ module ApplicationHelper def render_champ(champ) champ_selector = "##{champ.input_group_id}" - form_html = render 'shared/dossiers/edit', dossier: champ.dossier, apercu: false + form_html = render 'shared/dossiers/edit', dossier: champ.dossier champ_html = Nokogiri::HTML.fragment(form_html).at_css(champ_selector).to_s # rubocop:disable Rails/OutputSafety raw("document.querySelector('#{champ_selector}').outerHTML = \"#{escape_javascript(champ_html)}\";") diff --git a/app/javascript/components/MapEditor/hooks.ts b/app/javascript/components/MapEditor/hooks.ts index 8c941ac58..9380a28fc 100644 --- a/app/javascript/components/MapEditor/hooks.ts +++ b/app/javascript/components/MapEditor/hooks.ts @@ -23,7 +23,7 @@ export type DeleteFeatures = (params: { export function useFeatureCollection( initialFeatureCollection: FeatureCollection, - { url, enabled = true }: { url: string; enabled: boolean } + { url }: { url: string } ) { const [error, onError] = useError(); const [featureCollection, setFeatureCollection] = useState( @@ -96,9 +96,6 @@ export function useFeatureCollection( source = SOURCE_SELECTION_UTILISATEUR, external = false }) => { - if (!enabled) { - return; - } try { const newFeatures: Feature[] = []; for (const feature of features) { @@ -117,7 +114,7 @@ export function useFeatureCollection( onError('Le polygone dessiné n’est pas valide.'); } }, - [enabled, url, updateFeatureCollection, addFeatures, onError] + [url, updateFeatureCollection, addFeatures, onError] ); const updateFeatures = useCallback( @@ -126,9 +123,6 @@ export function useFeatureCollection( source = SOURCE_SELECTION_UTILISATEUR, external = false }) => { - if (!enabled) { - return; - } try { const newFeatures: Feature[] = []; for (const feature of features) { @@ -154,14 +148,11 @@ export function useFeatureCollection( onError('Le polygone dessiné n’est pas valide.'); } }, - [enabled, url, updateFeatureCollection, addFeatures, onError] + [url, updateFeatureCollection, addFeatures, onError] ); const deleteFeatures = useCallback( async ({ features, external = false }) => { - if (!enabled) { - return; - } try { const deletedFeatures = []; for (const feature of features) { @@ -183,7 +174,7 @@ export function useFeatureCollection( onError('Le polygone n’a pas pu être supprimé.'); } }, - [enabled, url, updateFeatureCollection, removeFeatures, onError] + [url, updateFeatureCollection, removeFeatures, onError] ); return { diff --git a/app/javascript/components/MapEditor/index.tsx b/app/javascript/components/MapEditor/index.tsx index a5d81741e..d5acd5710 100644 --- a/app/javascript/components/MapEditor/index.tsx +++ b/app/javascript/components/MapEditor/index.tsx @@ -16,19 +16,17 @@ import { FlashMessage } from '../shared/FlashMessage'; export default function MapEditor({ featureCollection: initialFeatureCollection, url, - options, - preview + options }: { featureCollection: FeatureCollection; url: string; - preview: boolean; options: { layers: string[] }; }) { const [cadastreEnabled, setCadastreEnabled] = useState(false); const { featureCollection, error, ...actions } = useFeatureCollection( initialFeatureCollection, - { url, enabled: !preview } + { url } ); return ( @@ -54,14 +52,14 @@ export default function MapEditor({ {options.layers.includes('cadastres') ? ( <>