refactor(champ): simplify piece justificative champ
This commit is contained in:
parent
2d1370d123
commit
9b12178bbd
3 changed files with 4 additions and 11 deletions
|
@ -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}');"
|
||||
|
|
|
@ -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? %>
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue