$(document).on("turbolinks:load", function() {
    $("#upload_directory_files").on('click', function(e){
        const newFilesCount = $('input[name = "directory[files][]"][type = "hidden"]').length;

        if (newFilesCount === 0){
            e.preventDefault();
        }
    });
});