Fixed addFile form when uploading with no files selected

Review Request #5803 — Created May 12, 2014 and discarded

Information

Review Board
master
634ebba...

Reviewers

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 …

daviddavid

Javascript should be indented 4 spaces. Your indentation here is inconsistent.

daviddavid

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 …

daviddavid

It might be nice to just define the function inline here, instead of giving it a name.

daviddavid

Add a blank line before this.

daviddavid

Trailing whitespace.

daviddavid

Add a space between () and {

daviddavid

This needs to be indented to align with 'disabled' on the line above it (since it's another parameter to the …

daviddavid

Trailing whitespace.

daviddavid

.attr(...) should go on the next line.

daviddavid

This is somewhat expensive. Can we fetch the input up-front and hold onto that, so we don't have to search …

chipx86chipx86
david
  1. Instead of letting the user click the "Upload" button and then showing them an error, how about disabling that button unless there are valid files selected?

    1. thats a good idea, I'll dig deeper in the code and try to make the button disabled until a file is selected

  2. 
      
VO
  1. 
      
  2. reviewboard/static/rb/js/common.js (Diff revision 1)
     
     

    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

    1. Volodymyr is right - we will definitely be harping on style. Might be a good idea to go over it with a fine-tooth comb and resubmit.

    2. thank you, I'll be more careful in future posts

  3. 
      
SA
SA
david
  1. 
      
  2. reviewboard/static/rb/js/common.js (Diff revision 2)
     
     
     

    Make sure that the first sentence here is capitalized and ends in a period. Please also wrap this to fit in 80 columns.

  3. reviewboard/static/rb/js/common.js (Diff revision 2)
     
     
     
     
     
     
     
     
     
     

    Javascript should be indented 4 spaces. Your indentation here is inconsistent.

  4. reviewboard/static/rb/js/common.js (Diff revision 2)
     
     
     
     
     
     
     

    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.

  5. reviewboard/static/rb/js/common.js (Diff revision 2)
     
     

    It might be nice to just define the function inline here, instead of giving it a name.

  6. reviewboard/static/rb/js/common.js (Diff revision 2)
     
     

    Add a blank line before this.

    1. It looks like this is fixed, but you haven't closed out the issue. We'll often hold off on re-reviewing a change while there are still open issues, so make sure you mark them as fixed as you work through them.

  7. 
      
david
  1. Please also fix your summary, description, and testing done to use full sentences with capitalization and punctuation.

  2. 
      
SA
david
  1. 
      
  2. reviewboard/static/rb/js/common.js (Diff revision 3)
     
     

    Trailing whitespace.

  3. reviewboard/static/rb/js/common.js (Diff revision 3)
     
     

    Add a space between () and {

  4. reviewboard/static/rb/js/common.js (Diff revision 3)
     
     

    This needs to be indented to align with 'disabled' on the line above it (since it's another parameter to the attr())

  5. reviewboard/static/rb/js/common.js (Diff revision 3)
     
     

    Trailing whitespace.

  6. 
      
SA
david
  1. 
      
  2. reviewboard/static/rb/js/common.js (Diff revision 4)
     
     

    .attr(...) should go on the next line.

  3. 
      
SA
david
  1. This looks good now. I'm going to hold off on pushing it because we're frozen for release.

  2. 
      
chipx86
  1. 
      
  2. reviewboard/static/rb/js/common.js (Diff revision 5)
     
     
     
     

    This is somewhat expensive. Can we fetch the input up-front and hold onto that, so we don't have to search for it every time we get a change event from the text field?

    Same with id_path.

  3. 
      
SA
Review request changed

Status: Discarded

Loading...