dossier: remove the now unused champId in auto-upload

This commit is contained in:
Pierre de La Morinerie 2020-04-02 17:44:48 +02:00
parent 91260e2867
commit c506402dcb

View file

@ -23,18 +23,12 @@ export default class AutoUploadController {
throw new Error('Lattribut "data-auto-attach-url" est manquant'); throw new Error('Lattribut "data-auto-attach-url" est manquant');
} }
const champ = this.input.closest('.editable-champ[data-champ-id]');
if (!champ) {
throw new Error('Impossible de trouver lélément ".editable-champ"');
}
const champId = champ.dataset.champId;
// Upload the file (using Direct Upload) // Upload the file (using Direct Upload)
let blobSignedId = await this._upload(); let blobSignedId = await this._upload();
// Attach the blob to the champ // Attach the blob to the champ
// (The request responds with Javascript, which displays the attachment HTML fragment). // (The request responds with Javascript, which displays the attachment HTML fragment).
await this._attach(champId, blobSignedId, autoAttachUrl); await this._attach(blobSignedId, autoAttachUrl);
// Everything good: clear the original file input value // Everything good: clear the original file input value
this.input.value = null; this.input.value = null;
@ -60,10 +54,14 @@ export default class AutoUploadController {
return await uploader.start(); return await uploader.start();
} }
async _attach(champId, blobSignedId, autoAttachUrl) { async _attach(blobSignedId, autoAttachUrl) {
// Now that the upload is done, display a new progress bar // Now that the upload is done, display a new progress bar
// to show that the attachment request is still pending. // to show that the attachment request is still pending.
const progressBar = new ProgressBar(this.input, champId, this.file); const progressBar = new ProgressBar(
this.input,
`${this.input.id}-progress-bar`,
this.file
);
progressBar.progress(100); progressBar.progress(100);
progressBar.end(); progressBar.end();