Merge pull request #24223 from shariquerik/disabled-button-on-upload
fix: added validation if upload is clicked without uploading file
This commit is contained in:
commit
004359ad6e
2 changed files with 10 additions and 4 deletions
|
|
@ -473,7 +473,7 @@ function check_restrictions(file) {
|
|||
|
||||
return is_correct_type && valid_file_size;
|
||||
}
|
||||
function upload_files() {
|
||||
function upload_files(dialog) {
|
||||
if (show_file_browser.value) {
|
||||
return upload_via_file_browser();
|
||||
}
|
||||
|
|
@ -483,6 +483,14 @@ function upload_files() {
|
|||
if (props.as_dataurl) {
|
||||
return return_as_dataurl();
|
||||
}
|
||||
if (!files.value.length) {
|
||||
frappe.msgprint(__("Please select a file first."));
|
||||
return Promise.reject();
|
||||
}
|
||||
|
||||
dialog?.get_primary_btn().prop("disabled", true);
|
||||
dialog?.get_secondary_btn().prop("disabled", true);
|
||||
|
||||
return frappe.run_serially(files.value.map((file, i) => () => upload_file(file, i)));
|
||||
}
|
||||
function upload_via_file_browser() {
|
||||
|
|
|
|||
|
|
@ -113,9 +113,7 @@ class FileUploader {
|
|||
}
|
||||
|
||||
upload_files() {
|
||||
this.dialog && this.dialog.get_primary_btn().prop("disabled", true);
|
||||
this.dialog && this.dialog.get_secondary_btn().prop("disabled", true);
|
||||
return this.uploader.upload_files();
|
||||
return this.uploader.upload_files(this.dialog);
|
||||
}
|
||||
|
||||
make_dialog(title) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue