Skip to content

Commit

Permalink
No submit if no photo is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
tclaus committed Sep 14, 2021
1 parent 676834b commit f4a3e09
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
25 changes: 17 additions & 8 deletions app/assets/javascripts/archive-uploader.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
const profileFileBtn = document.getElementById("profile-file-btn");

const checkProfileUploadButton = function() {
let photoFiles = $("#profile-file-btn")[0].files;
let profileFiles = $("#photos-file-btn")[0].files;
if ((photoFiles.size + profileFiles.size) === 0) {
$("#upload_profile_files").attr("disabled", "disabled");
} else {
$("#upload_profile_files").removeAttr("disabled");
}
};
const profileFileButton = document.getElementById("profile-file-btn");
const profileFileChosen = document.getElementById("profile-file-chosen");

profileFileBtn.addEventListener("change", function() {
const photosFileButton = document.getElementById("photos-file-btn");
const photosFileChosen = document.getElementById("photos-file-chosen");

profileFileButton.addEventListener("change", function() {
profileFileChosen.textContent = this.files[0].name;
checkProfileUploadButton();
});

const photosFileBtn = document.getElementById("photos-file-btn");

const photosFileChosen = document.getElementById("photos-file-chosen");

photosFileBtn.addEventListener("change", function() {
photosFileButton.addEventListener("change", function() {
photosFileChosen.textContent = this.files[0].name;
checkProfileUploadButton();
});
5 changes: 4 additions & 1 deletion app/views/users/_import_account_modal.haml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
.clearfix
.btn.btn-default{data: {dismiss: "modal"}}
= t("users.import_modal.cancel")
= f.submit t("users.import_modal.start_import"), class: "btn btn-primary.pull-right", id: "change_email_preferences"
= f.submit t("users.import_modal.start_import"),
class: "btn btn-primary.pull-right",
id: "upload_profile_files",
disabled: true
= javascript_include_tag "archive-uploader"

0 comments on commit f4a3e09

Please sign in to comment.