feat(instructeurs import): display submit button only if file uploaded
This commit is contained in:
parent
ec7aea50b3
commit
7af934daf5
2 changed files with 23 additions and 2 deletions
|
@ -0,0 +1,21 @@
|
|||
import { Controller } from '@hotwired/stimulus';
|
||||
import { enable, disable } from '@utils';
|
||||
|
||||
export class EnableSubmitIfUploadedController extends Controller {
|
||||
connect() {
|
||||
const fileInput = document.querySelector(
|
||||
'input[type="file"]'
|
||||
) as HTMLInputElement;
|
||||
const submitButton = document.getElementById(
|
||||
'submit-button'
|
||||
) as HTMLButtonElement;
|
||||
|
||||
fileInput.addEventListener('change', function () {
|
||||
if (fileInput.files && fileInput.files.length > 0) {
|
||||
enable(submitButton);
|
||||
} else {
|
||||
disable(submitButton);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue