Quick Search

Review Request #2199 — Created March 14, 2011 and submitted

Information

Review Board

Reviewers

Wrote an autocomplete wrapper in common.js. This quick search searches for users, groups and review requests. 
The autocomplete widget was modified to accommodate the feature where clicking on a suggestion would open the object's URL in a new window. 
The compressed version of the autocomplete widget is included.
Added the documentation for the search resource as well. I also removed ui.autocomplete in reviews.css to common.css. Added the js scripts that autocomplete needs in base.html and removed duplicate js files from other html templates. 
A lot of manual testing with as many different cases I could think of using different group display names & names, user username/first name/last name, and review request ID/summaries. Caught quite a few bugs through this. Not sure if this is all I should be doing. Am I suppose to be writing some tests as well?
david
  1. 
      
  2. Can you put this and the other resource-related doc changes into the resource change instead of this one?
  3. reviewboard/htdocs/media/rb/css/common.css (Diff revision 1)
     
     
     
    Add a blank line in between these.
  4. reviewboard/htdocs/media/rb/css/common.css (Diff revision 1)
     
     
     
     
     
     
     
    Why is this commented out? If it's temporary, please document the reason. If it's not needed anymore, please remove the block.
  5. reviewboard/htdocs/media/rb/css/common.css (Diff revision 1)
     
     
     
    Add a line of ****s above the "User page hover" line.
  6. Add spaces around the operator.
  7. Add a space between // and the text, and capitalize "Only".
  8. Don't add this line.
  9. Space between if and (. Space between the // and comment, capitalize first word.
  10. Space between the // and comment, capitalize first word.
  11. reviewboard/webapi/resources.py (Diff revision 1)
     
     
    Isn't this contained in your other review request?
  12. 
      
CR
chipx86
  1. 
      
  2. reviewboard/htdocs/media/rb/css/common.css (Diff revision 2)
     
     
     
    Blank line between these.
  3. reviewboard/htdocs/media/rb/css/common.css (Diff revision 2)
     
     
     
    Two blank lines between these.
  4. reviewboard/htdocs/media/rb/css/common.css (Diff revision 2)
     
     
     
     
    Probably didn't mean to add this line.
  5. reviewboard/htdocs/media/rb/js/common.js (Diff revision 2)
     
     
     
     
    The blank line on the comment should go away, and the last line should be "*/" not "* */"
  6. Indentation should be 4 spaces. This looks like 8 or a tab. Make sure everything's using spaces only.
  7. reviewboard/htdocs/media/rb/js/common.js (Diff revision 2)
     
     
     
     
     
    Brace should be on the same line as the if statement.
    
    Same with the following if statements.
    
    Also, you can just do data.username (same with the others)
  8. reviewboard/htdocs/media/rb/js/common.js (Diff revision 2)
     
     
     
    Two blank lines between these.
  9. reviewboard/htdocs/media/rb/js/common.js (Diff revision 2)
     
     
     
    Do you mean to override s each time? If so, please document each case, and make the ifs else ifs.
  10. No spaces around data.
  11. eval is too dangerous. I don't think you should need it anyway. My understanding was that data would be a javascript object anyway.
  12. jsonData.search
  13. reviewboard/htdocs/media/rb/js/common.js (Diff revision 2)
     
     
     
     
     
    Should be able to do:
    
    var objects = ["users", "groups", "review_requests"];
  14. reviewboard/htdocs/media/rb/js/common.js (Diff revision 2)
     
     
     
     
     
    Same.
  15. Space before {
  16. No parens around objects[j]
  17. reviewboard/htdocs/media/rb/js/common.js (Diff revision 2)
     
     
     
    Space around the != operator.
    
    { on the same line as the if.
  18. reviewboard/htdocs/media/rb/js/common.js (Diff revision 2)
     
     
     
     
     
     
    The values should be indented.
  19. This comment should go inside the body.
  20. else if (value.public) {
  21. reviewboard/htdocs/media/rb/js/common.js (Diff revision 2)
     
     
     
     
     
     
    Indentation problems.
  22. Trailing , will break things.
    
    Also, "api/search/". No need to + things.
  23. reviewboard/htdocs/media/rb/js/common.js (Diff revision 2)
     
     
     
    Not aligned. Make sure they're at the proper indentation level.
  24. reviewboard/htdocs/media/rb/js/common.js (Diff revision 2)
     
     
     
    One line.
  25. Indentation is wrong.
    
    I don't know that clickURLChange is right now. The makeItem should be registering this. See below for some fixes that need to be made for makeItem though.
  26. reviewboard/htdocs/media/rb/js/ui.autocomplete.js (Diff revision 2)
     
     
     
     
     
     
    { on the same line as the function.
    
    At this point I'm not going to point them out. I suggest going through your change and making sure they're all correct. Same with the indentation changes.
    
    One important thing: This file should never know how it's going to be used. This handler for makeItem should be overridable through options, just like some of the other functions, and the version for the search field should provide the implementation here.
    
    The default implementation should do exactly what the old default implementation did.
  27. data.summary
    
    You should go through and fix all remaining occurrences.
    
    Also, comment should be in the body.
  28. One line.
  29. Space before {
  30. Comment should be in the body.
  31. One line.
    
    Space before {
  32. Blank line between these.
  33. You can just delete this entirely.
  34. reviewboard/templates/reviews/datagrid.html (Diff revision 2)
     
     
     
     
     
     
    Delete all this. No point in overriding the block now.
  35. 
      
CR
david
  1. The indentation is because some of it is using tabstops and some is using spaces. Make sure there are no tabstops in the code at all, and that all indentation is done via spaces.
  2. 
      
CR
david
  1. 
      
  2. reviewboard/htdocs/media/rb/js/ui.autocomplete.js (Diff revision 4)
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    Indent this the same as the other functions.
  3. reviewboard/htdocs/media/rb/js/ui.autocomplete.js (Diff revision 4)
     
     
     
     
     
     
     
     
     
     
    Can you fix the tabstops in this code?
  4. This is no longer indented correctly.
  5. reviewboard/templates/base.html (Diff revision 4)
     
     
    Is datagrid.js really needed in the base template?
  6. 
      
david
  1. Okay, I just applied the patch to my tree and tried it out, and I have some usability comments:
    
    The drop-down text currently has
        "Review Request Summary        (id)"
    
    - If the summary is too long on any given review request, the text will overlap the (id) and will be ugly and impossible to read. We should make the drop-down for this box wider and give it a limit on the width of the text (overflow: clipped) so it never overlaps.
    - There's a "Press tab to auto-complete" item, which works, but fills in the text of the search box with the summary. I'm not sure how useful that really is.
    - If you hit enter after entering a review request number, even though you saw it in the drop-down, the search results will be empty. The request in bug 1842 (going directly to the review request) seems nice.
  2. 
      
SL
  1. 
      
  2. ???????
  3. 
      
CR
david
  1. Okay, one last user interaction niggle: When I type in the ID of a review request, the drop-down immediately focuses the single item, which means when I press "enter" on the keyboard, instead of searching for that ID, it fills the entry with the text of the drop-down. I'd prefer it if it didn't focus any items, so that unless I press the down arrow on the keyboard, it won't fill anything into the text box that I didn't type.
  2. 
      
CR
Review request changed
david
  1. Pushed to master as d502a61. Thanks for all your hard work!
  2.