Fixed addFile form when uploading with no files selected
Review Request #5803 — Created May 12, 2014 and discarded
If a file was not selected and the user clicks Upload button, the form sends an empty submit request. The form then changes to a loading state, while its waiting for a response. Since the request is empty, the form never gets a response.
1 - If you click Upload button without selecting files, the modal box will gets destroyed: this can be fixed in gravy.modalBox.
2 - The Upload button is enabled when files are selected.
2a - The form is submitted normally when clicking the Upload button.
3 - The Upload button is disabled when files are not selected.
Description | From | Last Updated |
---|---|---|
Make sure that the first sentence here is capitalized and ends in a period. Please also wrap this to fit … |
david | |
Javascript should be indented 4 spaces. Your indentation here is inconsistent. |
david | |
All of this could be one statement: $('input[type="button"][value="Upload"]') .attr('disabled', $('#id_path').get(0).files.length > 0); Please also include quotes around the type/value in … |
david | |
It might be nice to just define the function inline here, instead of giving it a name. |
david | |
Add a blank line before this. |
david | |
Trailing whitespace. |
david | |
Add a space between () and { |
david | |
This needs to be indented to align with 'disabled' on the line above it (since it's another parameter to the … |
david | |
Trailing whitespace. |
david | |
.attr(...) should go on the next line. |
david | |
This is somewhat expensive. Can we fetch the input up-front and hold onto that, so we don't have to search … |
chipx86 |
-
-
I bet that reviewboard people are pretty picky about code styles (well, they are building a code review tool after all :) ), so most likely you should fix indentation. I haven't found reviewboard's javascript conventions, but this is probably a pretty similar guide: http://javascript.crockford.com/code.html
- Change Summary:
-
disable or enable the upload button on files selected
- Description:
-
fixed bug where the form starts loading after clicking submit, when no files are selected for upload.
~ there was no check on input files wheather they're empty or not, and no error message is displayed to the user. ~ there was no check on input files wheather they're empty or not, and no error message is displayed to the user. + The upload button now is initially disabled. It toggles as files get selected and unselected - Testing Done:
-
~ 1- submit form with empty files,error message displayed, then select a file and submit it and check that they are uploaded.
~ 2- submit form with files, check it proceeds normally, and files uploaded ~ 1- try to click upload with no file selected, the modal box gets destroyed: this can be fixed in gravy.modalBox
~ 2- select a file, check button is enabled + 3- unselect a file, check button is disabled + 4- submit form with files, check it proceeds normally, and files uploaded - Commit:
-
7174e6736f319028106e44c3e6801de99f9d2df10a3729a4c60be1e5800360b51a5cf03e4e0da215
- Diff:
-
Revision 2 (+14 -1)
-
-
Make sure that the first sentence here is capitalized and ends in a period. Please also wrap this to fit in 80 columns.
-
-
All of this could be one statement:
$('input[type="button"][value="Upload"]') .attr('disabled', $('#id_path').get(0).files.length > 0);
Please also include quotes around the type/value in the jquery selector.
-
-
-
Please also fix your summary, description, and testing done to use full sentences with capitalization and punctuation.
- Change Summary:
-
The code is rewritten to fit one statement.
- Commit:
-
0a3729a4c60be1e5800360b51a5cf03e4e0da215e2ebca1a0adb9e18d72261a56c2d9a29303fe102
- Diff:
-
Revision 3 (+13 -1)
- Change Summary:
-
Fixed formatting issues
- Summary:
-
fixed bug where it starts loading when no files selected for uploadFixed addFile form when uploading with no files selected
- Description:
-
~ fixed bug where the form starts loading after clicking submit, when no files are selected for upload.
~ If a file was not selected and the user clicks Upload button, the form sends an empty submit request. The form then changes to a loading state, while its waiting for a response. Since the request is empty, the form never gets a response.
- there was no check on input files wheather they're empty or not, and no error message is displayed to the user. - The upload button now is initially disabled. It toggles as files get selected and unselected - Testing Done:
-
~ 1- try to click upload with no file selected, the modal box gets destroyed: this can be fixed in gravy.modalBox
~ 2- select a file, check button is enabled ~ 3- unselect a file, check button is disabled ~ 4- submit form with files, check it proceeds normally, and files uploaded ~ 1 - If you click Upload button without selecting files, the modal box will gets destroyed: this can be fixed in gravy.modalBox.
~ 2 - The Upload button is enabled when files are selected. ~ 2a - The form is submitted normally when clicking the Upload button. ~ 3- The Upload button is disabled when files are not selected. - Commit:
-
e2ebca1a0adb9e18d72261a56c2d9a29303fe102fdf840f438686e83a4e95e179963fe2651f36bae
- Diff:
-
Revision 4 (+13 -1)
- Testing Done:
-
1 - If you click Upload button without selecting files, the modal box will gets destroyed: this can be fixed in gravy.modalBox.
2 - The Upload button is enabled when files are selected. 2a - The form is submitted normally when clicking the Upload button. ~ 3- The Upload button is disabled when files are not selected. ~ 3 - The Upload button is disabled when files are not selected. - Commit:
-
fdf840f438686e83a4e95e179963fe2651f36bae634ebba628ef07c1e26bed9a72119966a8a4e48e