From f8b984852ae27f14a5f44e651193f00977737ab1 Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 26 May 2015 23:59:57 +0800 Subject: Bug 1146782: backport bug 1159589 to bmo (migrate autocomplete from yui to jquery) --- extensions/ProdCompSearch/lib/WebService.pm | 11 +- .../en/default/prodcompsearch/form.html.tmpl | 4 +- .../ProdCompSearch/web/js/prod_comp_search.js | 238 ++++++++++++--------- 3 files changed, 146 insertions(+), 107 deletions(-) (limited to 'extensions/ProdCompSearch') diff --git a/extensions/ProdCompSearch/lib/WebService.pm b/extensions/ProdCompSearch/lib/WebService.pm index a28b5d059..521d1588f 100644 --- a/extensions/ProdCompSearch/lib/WebService.pm +++ b/extensions/ProdCompSearch/lib/WebService.pm @@ -113,7 +113,7 @@ sub prod_comp_search { unshift @order, "products.name != 'bugzilla.mozilla.org'"; } - my $products = $dbh->selectall_arrayref(" + my $components = $dbh->selectall_arrayref(" SELECT products.name AS product, components.name AS component FROM products @@ -124,6 +124,15 @@ sub prod_comp_search { ORDER BY " . join(", ", @order) . " $limit", { Slice => {} }); + my $products = []; + my $current_product; + foreach my $component (@$components) { + if (!$current_product || $component->{product} ne $current_product) { + $current_product = $component->{product}; + push @$products, { product => $current_product }; + } + push @$products, $component; + } return { products => $products }; } diff --git a/extensions/ProdCompSearch/template/en/default/prodcompsearch/form.html.tmpl b/extensions/ProdCompSearch/template/en/default/prodcompsearch/form.html.tmpl index 39919510c..c232f677d 100644 --- a/extensions/ProdCompSearch/template/en/default/prodcompsearch/form.html.tmpl +++ b/extensions/ProdCompSearch/template/en/default/prodcompsearch/form.html.tmpl @@ -35,10 +35,10 @@ -