summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
Diffstat (limited to 'extensions')
-rw-r--r--extensions/ProdCompSearch/Config.pm7
-rw-r--r--extensions/ProdCompSearch/Extension.pm7
-rw-r--r--extensions/ProdCompSearch/lib/WebService.pm21
-rw-r--r--extensions/ProdCompSearch/template/en/default/pages/prodcompsearch.html.tmpl12
-rw-r--r--extensions/ProdCompSearch/template/en/default/prodcompsearch/form.html.tmpl8
-rw-r--r--extensions/ProdCompSearch/web/js/prod_comp_search.js12
6 files changed, 46 insertions, 21 deletions
diff --git a/extensions/ProdCompSearch/Config.pm b/extensions/ProdCompSearch/Config.pm
index 880cb1892..c28b6d8f6 100644
--- a/extensions/ProdCompSearch/Config.pm
+++ b/extensions/ProdCompSearch/Config.pm
@@ -1,3 +1,10 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
package Bugzilla::Extension::ProdCompSearch;
use strict;
diff --git a/extensions/ProdCompSearch/Extension.pm b/extensions/ProdCompSearch/Extension.pm
index 83e6118d3..4a4fae355 100644
--- a/extensions/ProdCompSearch/Extension.pm
+++ b/extensions/ProdCompSearch/Extension.pm
@@ -1,3 +1,10 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
package Bugzilla::Extension::ProdCompSearch;
use strict;
use base qw(Bugzilla::Extension);
diff --git a/extensions/ProdCompSearch/lib/WebService.pm b/extensions/ProdCompSearch/lib/WebService.pm
index f972b80f7..bbc355e00 100644
--- a/extensions/ProdCompSearch/lib/WebService.pm
+++ b/extensions/ProdCompSearch/lib/WebService.pm
@@ -1,3 +1,10 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
+
package Bugzilla::Extension::ProdCompSearch::WebService;
use strict;
@@ -17,13 +24,13 @@ sub prod_comp_search {
$search || ThrowCodeError('param_required',
{ function => 'Bug.prod_comp_search', param => 'search' });
- my $limit = detaint_natural($params->{'limit'})
- ? $dbh->sql_limit($params->{'limit'})
+ my $limit = detaint_natural($params->{'limit'})
+ ? $dbh->sql_limit($params->{'limit'})
: '';
# We do this in the DB directly as we want it to be fast and
# not have the overhead of loading full product objects
-
+
# All products which the user has "Entry" access to.
my $enterable_ids = $dbh->selectcol_arrayref(
'SELECT products.id FROM products
@@ -55,7 +62,7 @@ sub prod_comp_search {
if ($word ne "") {
my $sql_word = $dbh->quote($word);
trick_taint($sql_word);
- # XXX CONCAT_WS is MySQL specific
+ # note: CONCAT_WS is MySQL specific
my $field = "CONCAT_WS(' ', products.name, components.name, components.description)";
push(@list, $dbh->sql_iposition($sql_word, $field) . " > 0");
}
@@ -64,11 +71,11 @@ sub prod_comp_search {
my $products = $dbh->selectall_arrayref("
SELECT products.name AS product,
components.name AS component
- FROM products
+ FROM products
INNER JOIN components ON products.id = components.product_id
WHERE (" . join(" AND ", @list) . ")
AND products.id IN (" . join(",", @$enterable_ids) . ")
- ORDER BY products.name $limit",
+ ORDER BY products.name $limit",
{ Slice => {} });
# To help mozilla staff file bmo administration bugs into the right
@@ -90,5 +97,3 @@ sub prod_comp_search {
}
1;
-
-
diff --git a/extensions/ProdCompSearch/template/en/default/pages/prodcompsearch.html.tmpl b/extensions/ProdCompSearch/template/en/default/pages/prodcompsearch.html.tmpl
index 0948fd1a0..533ade888 100644
--- a/extensions/ProdCompSearch/template/en/default/pages/prodcompsearch.html.tmpl
+++ b/extensions/ProdCompSearch/template/en/default/pages/prodcompsearch.html.tmpl
@@ -1,13 +1,21 @@
+[%# This Source Code Form is subject to the terms of the Mozilla Public
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ #
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
+ #%]
+
[% PROCESS global/variables.none.tmpl %]
[% PROCESS global/header.html.tmpl
- title = "File a $terms.Bug"
+ title = "File a $terms.Bug"
javascript_urls = [ "extensions/ProdCompSearch/web/js/prod_comp_search.js" ]
style_urls = [ "extensions/ProdCompSearch/web/styles/prod_comp_search.css" ]
%]
<div id="prod_comp_search_main">
- [% PROCESS prodcompsearch/form.html.tmpl
+ [% PROCESS prodcompsearch/form.html.tmpl
query_header = "File a $terms.Bug:"
%]
</div>
diff --git a/extensions/ProdCompSearch/template/en/default/prodcompsearch/form.html.tmpl b/extensions/ProdCompSearch/template/en/default/prodcompsearch/form.html.tmpl
index 79693fcec..a9f05d9ba 100644
--- a/extensions/ProdCompSearch/template/en/default/prodcompsearch/form.html.tmpl
+++ b/extensions/ProdCompSearch/template/en/default/prodcompsearch/form.html.tmpl
@@ -1,9 +1,9 @@
[%# This Source Code Form is subject to the terms of the Mozilla Public
- # License, v. 2.0. If a copy of the MPL was not distributed with this
- # file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ # License, v. 2.0. If a copy of the MPL was not distributed with this
+ # file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
- # This Source Code Form is "Incompatible With Secondary Licenses", as
- # defined by the Mozilla Public License, v. 2.0.
+ # This Source Code Form is "Incompatible With Secondary Licenses", as
+ # defined by the Mozilla Public License, v. 2.0.
#%]
<div id="prod_comp_search_form" class="yui3-skin-sam">
diff --git a/extensions/ProdCompSearch/web/js/prod_comp_search.js b/extensions/ProdCompSearch/web/js/prod_comp_search.js
index 4d31437ad..77ef28124 100644
--- a/extensions/ProdCompSearch/web/js/prod_comp_search.js
+++ b/extensions/ProdCompSearch/web/js/prod_comp_search.js
@@ -3,8 +3,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This Source Code Form is "Incompatible With Secondary Licenses", as
- * defined by the Mozilla Public License, v. 2.0.
- */
+ * defined by the Mozilla Public License, v. 2.0. */
// Product and component search to file a new bug
@@ -19,15 +18,14 @@ YUI({
}).use("node", "json-stringify", "autocomplete", "escape",
"datasource-io", "datasource-jsonschema", "array-extras", function (Y) {
var counter = 0,
- current_query = null,
dataSource = null,
autoComplete = null;
var resultListFormat = function(query, results) {
return Y.Array.map(results, function (result) {
var data = result.raw;
- return Y.Escape.html(data.product) + " :: " +
- Y.Escape.html(data.component);
+ result.text = data.product + ' :: ' + data.component;
+ return Y.Escape.html(result.text);
});
};
@@ -60,6 +58,7 @@ YUI({
var input = Y.one('#prod_comp_search');
input.plug(Y.Plugin.AutoComplete, {
+ activateFirstItem: false,
enableCache: true,
source: dataSource,
minQueryLength: 3,
@@ -71,14 +70,13 @@ YUI({
requestTemplate: requestTemplate,
on: {
query: function(e) {
- current_query = e.inputValue;
Y.one("#prod_comp_throbber").removeClass('bz_default_hidden');
},
results: function(e) {
Y.one("#prod_comp_throbber").addClass('bz_default_hidden');
+ input.ac.set('activateFirstItem', e.results.length == 1);
},
select: function(e) {
- input.value = current_query;
var data = e.result.raw;
var url = "enter_bug.cgi?product=" + encodeURIComponent(data.product) +
"&component=" + encodeURIComponent(data.component);