← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~benji/launchpad/bug-pre-search-2 into lp:launchpad

 

Benji York has proposed merging lp:~benji/launchpad/bug-pre-search-2 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #809508 in Launchpad itself: "Suggest branches with current bug number when associating a bug with a branch."
  https://bugs.launchpad.net/launchpad/+bug/809508

For more details, see:
https://code.launchpad.net/~benji/launchpad/bug-pre-search-2/+merge/69787

While doing QA of this branch I found that if the user submits a query before the automated prefetch query finishes then the search box will be reenabled and the spinner will stop prematurely.  This change makes the picker keep up with how many searches are outstanding and only reenabling the search box and disactivating the spinner once all searches are finished.
-- 
https://code.launchpad.net/~benji/launchpad/bug-pre-search-2/+merge/69787
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~benji/launchpad/bug-pre-search-2 into lp:launchpad.
=== modified file 'lib/lp/app/javascript/picker/picker.js'
--- lib/lp/app/javascript/picker/picker.js	2011-07-22 01:12:20 +0000
+++ lib/lp/app/javascript/picker/picker.js	2011-07-29 13:28:35 +0000
@@ -55,6 +55,7 @@
     FOOTER_SLOT = 'footer_slot',
     SELECTED_BATCH = 'selected_batch',
     SEARCH_MODE = 'search_mode',
+    NUM_SEARCHES = 'num_searches',
     NO_RESULTS_SEARCH_MESSAGE = 'no_results_search_message',
     RENDERUI = "renderUI",
     BINDUI = "bindUI",
@@ -636,7 +637,8 @@
         // clear the search mode.
         this.after('resultsChange', function (e) {
             this._syncResultsUI();
-            this.set(SEARCH_MODE, false);
+            this.set(NUM_SEARCHES, this.get(NUM_SEARCHES)-1);
+            this.set(SEARCH_MODE, this._isSearchOngoing());
         }, this);
 
         // Update the search slot box whenever the "search_slot" property
@@ -751,7 +753,18 @@
      */
     _defaultSearch: function(e) {
         this.set(ERROR, null);
-        this.set(SEARCH_MODE, true);
+        this.set(NUM_SEARCHES, this.get(NUM_SEARCHES)+1);
+        this.set(SEARCH_MODE, this._isSearchOngoing());
+    },
+
+    /**
+     * Are there any outstanding searches at the moment?
+     *
+     * @method _isSearchOngoing
+     * @protected
+     */
+    _isSearchOngoing: function() {
+        return this.get(NUM_SEARCHES) !== 0;
     },
 
     /**
@@ -784,17 +797,6 @@
         if ( this.get('clear_on_save') ) {
             this._clear();
         }
-    },
-
-    /**
-     * By default, the select-batch event turns on search-mode.
-     *
-     * @method _defaultSelectBatch
-     * @param e {Event.Facade} An Event Facade object.
-     * @protected
-     */
-    _defaultSelectBatch: function(e) {
-        this.set(SEARCH_MODE, true);
     }
     });
 
@@ -993,6 +995,14 @@
     search_mode: { value: false },
 
     /**
+     * The current number of outstanding searches.
+     *
+     * @attribute num_searches
+     * @type Integer
+     */
+    num_searches: { value: 0 },
+
+    /**
      * The current error message. This puts the widget in 'error-mode',
      * setting this value to null clears that state.
      *