~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/javascript/bugtask_index.js

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-07-29 00:43:37 UTC
  • mfrom: (13546.1.1 bug-pre-search-2)
  • Revision ID: launchpad@pqm.canonical.com-20110729004337-rghfyl8k33penwen
[r=jcsackett][bug=809508] Do a pre-emptive search when associating a
        branch with a bug for branches with the current bug's number.

Show diffs side-by-side

added added

removed removed

Lines of Context:
428
428
    lp_bug_entry.lp_save(config);
429
429
};
430
430
 
 
431
 
 
432
/**
 
433
 * Do a preemptive search for branches that contain the current bug's ID.
 
434
 */
 
435
function do_pre_search(picker, bug_id) {
 
436
    if (!Y.Lang.isValue(bug_id)) {
 
437
        bug_id = LP.cache.bug.id;
 
438
    }
 
439
    picker.set('footer_slot', 'Loading suggestions...');
 
440
    // A very few bugs have small IDs.
 
441
    var original_min_search_chars = picker.get('min_search_chars');
 
442
    picker.set('min_search_chars', 0);
 
443
    picker.fire('search', bug_id.toString());
 
444
    // Don't disable the search input box or the search button while
 
445
    // doing our search.
 
446
    picker.set('search_mode', false);
 
447
    picker.set('min_search_chars', original_min_search_chars);
 
448
}
 
449
// Expose to the namespace for testing.
 
450
namespace._do_pre_search = do_pre_search;
 
451
 
 
452
 
431
453
/**
432
454
 * Set up the link-a-related-branch picker.
433
455
 */
469
491
 
470
492
        config.save = get_branch_and_link_to_bug;
471
493
        var picker = Y.lp.app.picker.create('Branch', config);
 
494
        // When the user clicks on "Link a related branch" do a search for
 
495
        // branches that contain the bug number.
 
496
        link_branch_link.subscribe('click', function (e) {
 
497
            do_pre_search(picker);
 
498
        });
472
499
    }
473
500
}
474
501