~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/app/javascript/picker/picker.js

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-01 13:08:25 UTC
  • mfrom: (13546.1.5 bug-pre-search-2)
  • Revision ID: launchpad@pqm.canonical.com-20110801130825-ci4nv2vvmmm3uhil
[r=benji][bug=809508] [r=benji] Make the search box stay disabled and
        the spinner visible until all outstanding searches are finished.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
    FOOTER_SLOT = 'footer_slot',
56
56
    SELECTED_BATCH = 'selected_batch',
57
57
    SEARCH_MODE = 'search_mode',
 
58
    NUM_SEARCHES = 'num_searches',
58
59
    NO_RESULTS_SEARCH_MESSAGE = 'no_results_search_message',
59
60
    RENDERUI = "renderUI",
60
61
    BINDUI = "bindUI",
636
637
        // clear the search mode.
637
638
        this.after('resultsChange', function (e) {
638
639
            this._syncResultsUI();
639
 
            this.set(SEARCH_MODE, false);
 
640
            this.set(NUM_SEARCHES, this.get(NUM_SEARCHES)-1);
 
641
            this.set(SEARCH_MODE, this._isSearchOngoing());
 
642
        }, this);
 
643
 
 
644
        this.after('search', function (e) {
 
645
            this.set(NUM_SEARCHES, this.get(NUM_SEARCHES)+1);
 
646
            this.set(SEARCH_MODE, this._isSearchOngoing());
640
647
        }, this);
641
648
 
642
649
        // Update the search slot box whenever the "search_slot" property
751
758
     */
752
759
    _defaultSearch: function(e) {
753
760
        this.set(ERROR, null);
754
 
        this.set(SEARCH_MODE, true);
 
761
        this.set(SEARCH_MODE, this._isSearchOngoing());
 
762
    },
 
763
 
 
764
    /**
 
765
     * Are there any outstanding searches at the moment?
 
766
     *
 
767
     * @method _isSearchOngoing
 
768
     * @protected
 
769
     */
 
770
    _isSearchOngoing: function() {
 
771
        return this.get(NUM_SEARCHES) !== 0;
755
772
    },
756
773
 
757
774
    /**
784
801
        if ( this.get('clear_on_save') ) {
785
802
            this._clear();
786
803
        }
787
 
    },
788
 
 
789
 
    /**
790
 
     * By default, the select-batch event turns on search-mode.
791
 
     *
792
 
     * @method _defaultSelectBatch
793
 
     * @param e {Event.Facade} An Event Facade object.
794
 
     * @protected
795
 
     */
796
 
    _defaultSelectBatch: function(e) {
797
 
        this.set(SEARCH_MODE, true);
798
804
    }
799
805
    });
800
806
 
993
999
    search_mode: { value: false },
994
1000
 
995
1001
    /**
 
1002
     * The current number of outstanding searches.
 
1003
     *
 
1004
     * @attribute num_searches
 
1005
     * @type Integer
 
1006
     */
 
1007
    num_searches: { value: 0 },
 
1008
 
 
1009
    /**
996
1010
     * The current error message. This puts the widget in 'error-mode',
997
1011
     * setting this value to null clears that state.
998
1012
     *