From 91260e28679ca6a8c640f997950fde5de13c6cf3 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Thu, 2 Apr 2020 17:30:59 +0200 Subject: [PATCH] dossier: fix upload route of piece_justificative in repetitions In repetitions, `form.index` doesn't make much sense. Turns out we don't really need the index of the champ: we can just use the champ id. --- app/helpers/champ_helper.rb | 2 +- app/javascript/new_design/dossiers/auto-upload-controller.js | 2 +- config/routes.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/champ_helper.rb b/app/helpers/champ_helper.rb index ca6aa40b6..3eb709454 100644 --- a/app/helpers/champ_helper.rb +++ b/app/helpers/champ_helper.rb @@ -34,7 +34,7 @@ module ChampHelper def auto_attach_url(form, object) if feature_enabled?(:autoupload_dossier_attachments) && object.is_a?(Champ) && object.public? - champs_piece_justificative_url(form.index) + champs_piece_justificative_url(object.id) end end end diff --git a/app/javascript/new_design/dossiers/auto-upload-controller.js b/app/javascript/new_design/dossiers/auto-upload-controller.js index 1a5b91282..3707f4078 100644 --- a/app/javascript/new_design/dossiers/auto-upload-controller.js +++ b/app/javascript/new_design/dossiers/auto-upload-controller.js @@ -70,7 +70,7 @@ export default class AutoUploadController { const attachmentRequest = { url: autoAttachUrl, type: 'PUT', - data: `champ_id=${champId}&blob_signed_id=${blobSignedId}` + data: `blob_signed_id=${blobSignedId}` }; await ajax(attachmentRequest); diff --git a/config/routes.rb b/config/routes.rb index 273880d2f..4081570cb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -121,7 +121,7 @@ Rails.application.routes.draw do get ':position/dossier_link', to: 'dossier_link#show', as: :dossier_link post ':position/carte', to: 'carte#show', as: :carte post ':position/repetition', to: 'repetition#show', as: :repetition - put ':position/piece_justificative', to: 'piece_justificative#update', as: :piece_justificative + put 'piece_justificative/:champ_id', to: 'piece_justificative#update', as: :piece_justificative end get 'attachments/:id', to: 'attachments#show', as: :attachment