diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 6572b58bb..5a7a9872a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -60,15 +60,6 @@ module ApplicationHelper end end - def render_champ(champ) - champ_selector = "##{champ.input_group_id}" - 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)}\";") - # rubocop:enable Rails/OutputSafety - end - def remove_element(selector, timeout: 0, inner: false) script = "(function() {"; script << "var el = document.querySelector('#{selector}');" diff --git a/app/views/champs/piece_justificative/show.js.erb b/app/views/champs/piece_justificative/show.js.erb index c8bbaf377..ea8cb9ecb 100644 --- a/app/views/champs/piece_justificative/show.js.erb +++ b/app/views/champs/piece_justificative/show.js.erb @@ -1,4 +1,6 @@ -<%= render_champ(@champ) %> +<%= fields_for @champ.input_name, @champ do |form| %> + <%= render_to_element("##{@champ.input_group_id}", partial: "shared/dossiers/editable_champs/editable_champ", locals: { champ: @champ, form: form }, outer: true) %> +<% end %> <% attachment = @champ.piece_justificative_file.attachment %> <% if attachment.virus_scanner.pending? %> diff --git a/config/routes.rb b/config/routes.rb index b1fcf5bf6..34400251f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -151,7 +151,7 @@ Rails.application.routes.draw do patch ':champ_id/carte/features/:id', to: 'carte#update' delete ':champ_id/carte/features/:id', to: 'carte#destroy' - put 'piece_justificative/:champ_id', to: 'piece_justificative#update', as: :piece_justificative + put ':champ_id/piece_justificative', to: 'piece_justificative#update', as: :piece_justificative end resources :attachments, only: [:show, :destroy]