diff options
author | Byron Jones <bjones@mozilla.com> | 2012-05-30 06:06:55 +0200 |
---|---|---|
committer | Byron Jones <bjones@mozilla.com> | 2012-05-30 06:06:55 +0200 |
commit | 61ab486097a60756792bc031c836f0e55393295c (patch) | |
tree | 98d674d833a08d7cedafde8c2349b091163f4459 /extensions | |
parent | ce8f837dcd1ccd23cd5f63f258efd257e3de70f3 (diff) | |
download | bugzilla-61ab486097a60756792bc031c836f0e55393295c.tar.gz bugzilla-61ab486097a60756792bc031c836f0e55393295c.tar.xz |
Bug 758141: add component searching to guided bug entry
Diffstat (limited to 'extensions')
10 files changed, 153 insertions, 206 deletions
diff --git a/extensions/BMO/template/en/default/global/choose-product.html.tmpl b/extensions/BMO/template/en/default/global/choose-product.html.tmpl index 159919169..d0d115621 100644 --- a/extensions/BMO/template/en/default/global/choose-product.html.tmpl +++ b/extensions/BMO/template/en/default/global/choose-product.html.tmpl @@ -68,7 +68,7 @@ <div id="prod_comp_search_label"> Type to find product and component by name or description </div> - <input id="prod_comp_search" id="prod_comp_search" type="text" size="60"> + <input id="prod_comp_search" type="text" size="60"> <div id="prod_comp_search_autocomplete_container"></div> </div> </div> diff --git a/extensions/BMO/web/js/choose_product.js b/extensions/BMO/web/js/choose_product.js index 7298a6b92..507d1458b 100644 --- a/extensions/BMO/web/js/choose_product.js +++ b/extensions/BMO/web/js/choose_product.js @@ -10,6 +10,7 @@ YAHOO.bugzilla.prodCompSearch = { counter : 0, format : '', dataSource : null, + autoComplete: null, generateRequest : function (enteredText) { YAHOO.bugzilla.prodCompSearch.counter = YAHOO.bugzilla.prodCompSearch.counter + 1; YAHOO.util.Connect.setDefaultPostHeader('application/json', true); @@ -50,16 +51,16 @@ YAHOO.bugzilla.prodCompSearch = { this.init_ds(); } this.format = format; - var prodCompSearch = new YAHOO.widget.AutoComplete(field, container, this.dataSource); - prodCompSearch.generateRequest = this.generateRequest; - prodCompSearch.formatResult = this.resultListFormat; - prodCompSearch.minQueryLength = 3; - prodCompSearch.autoHighlight = false; - prodCompSearch.queryDelay = 0.05; - prodCompSearch.useIFrame = true; - prodCompSearch.maxResultsDisplayed = 25; - prodCompSearch.suppressInputUpdate = true; - prodCompSearch.textboxFocusEvent.subscribe(function () { + this.autoComplete = new YAHOO.widget.AutoComplete(field, container, this.dataSource); + this.autoComplete.generateRequest = this.generateRequest; + this.autoComplete.formatResult = this.resultListFormat; + this.autoComplete.minQueryLength = 3; + this.autoComplete.autoHighlight = false; + this.autoComplete.queryDelay = 0.05; + this.autoComplete.useIFrame = true; + this.autoComplete.maxResultsDisplayed = 25; + this.autoComplete.suppressInputUpdate = true; + this.autoComplete.textboxFocusEvent.subscribe(function () { var input = YAHOO.util.Dom.get(field); if (input.value && input.value.length > 3) { this.sendQuery(input.value); diff --git a/extensions/GuidedBugEntry/Config.pm b/extensions/GuidedBugEntry/Config.pm index 924fe568c..e4bc9c70b 100644 --- a/extensions/GuidedBugEntry/Config.pm +++ b/extensions/GuidedBugEntry/Config.pm @@ -1,23 +1,9 @@ -# -*- Mode: perl; indent-tabs-mode: nil -*- +# 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/. # -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the GuidedBugEntry Bugzilla Extension. -# -# The Initial Developer of the Original Code is the Mozilla Foundation -# Portions created by the Initial Developer are Copyright (C) 2011 the -# Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Byron Jones <glob@mozilla.com> +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::GuidedBugEntry; use strict; diff --git a/extensions/GuidedBugEntry/Extension.pm b/extensions/GuidedBugEntry/Extension.pm index 796c1ad3b..c88def6c3 100644 --- a/extensions/GuidedBugEntry/Extension.pm +++ b/extensions/GuidedBugEntry/Extension.pm @@ -1,23 +1,9 @@ -# -*- Mode: perl; indent-tabs-mode: nil -*- +# 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/. # -# The contents of this file are subject to the Mozilla Public -# License Version 1.1 (the "License"); you may not use this file -# except in compliance with the License. You may obtain a copy of -# the License at http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS -# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -# implied. See the License for the specific language governing -# rights and limitations under the License. -# -# The Original Code is the GuidedBugEntry Bugzilla Extension. -# -# The Initial Developer of the Original Code is the Mozilla Foundation -# Portions created by the Initial Developer are Copyright (C) 2011 the -# Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Byron Jones <glob@mozilla.com> +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::GuidedBugEntry; use strict; @@ -52,16 +38,18 @@ sub enter_bug_start { ) { # skip the first step if a product is provided if ($cgi->param('product')) { - print $cgi->redirect('enter_bug.cgi?format=guided#h=dupes|' . - url_quote($cgi->param('product'))); + print $cgi->redirect('enter_bug.cgi?format=guided#h=dupes' . + '|' . url_quote($cgi->param('product')) . + '|' . url_quote($cgi->param('component')) + ); exit; } $self->_init_vars($vars); print $cgi->header(); $template->process('guided/guided.html.tmpl', $vars) - || ThrowTemplateError($template->error()); - exit; + || ThrowTemplateError($template->error()); + exit; } # we use the __default__ format to bypass the guided entry @@ -71,7 +59,7 @@ sub enter_bug_start { ($cgi->param('format') && $cgi->param('format') eq "__default__") && ($cgi->param('product') && $cgi->param('product') ne '') ) { - $cgi->delete('format') + $cgi->delete('format'); } } @@ -104,6 +92,9 @@ sub _init_vars { $vars->{'platform'} = detect_platform(); $vars->{'op_sys'} = detect_op_sys(); + + eval 'use Bugzilla::Extension::BMO::Data'; + $vars->{'BMO'} = $@ ? 0 : 1; } sub page_before_template { diff --git a/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl b/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl index 6e511b4a6..ef00477cd 100644 --- a/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl +++ b/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl @@ -1,40 +1,26 @@ -[%# ***** BEGIN LICENSE BLOCK ***** - # Version: MPL 1.1 +[%# 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/. # - # The contents of this file are subject to the Mozilla Public License Version - # 1.1 (the "License"); you may not use this file except in compliance with - # the License. You may obtain a copy of the License at - # http://www.mozilla.org/MPL/ - # - # Software distributed under the License is distributed on an "AS IS" basis, - # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - # for the specific language governing rights and limitations under the - # License. - # - # The Original Code is the GuidedBugEntry Bugzilla Extension. - # - # The Initial Developer of the Original Code is - # the Mozilla Foundation. - # Portions created by the Initial Developer are Copyright (C) 2011 - # the Initial Developer. All Rights Reserved. - # - # Contributor(s): - # Byron Jones <glob@mozilla.com> - # - # ***** END LICENSE BLOCK ***** */ - #%] + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. [% PROCESS global/variables.none.tmpl %] +[% js_urls = [ 'extensions/GuidedBugEntry/web/js/products.js', + 'extensions/GuidedBugEntry/web/js/guided.js', + 'js/field.js', 'js/TUI.js', 'js/bug.js' ] %] +[% js_urls.push('extensions/BMO/web/js/choose_product.js') IF BMO %] + +[% yui_modules = [ 'history', 'datatable', 'container' ] %] +[% yui_modules.push('autocomplete') IF BMO %] + [% PROCESS global/header.html.tmpl - title = "Enter A $terms.Bug" - javascript_urls = [ - 'extensions/GuidedBugEntry/web/js/products.js', - 'extensions/GuidedBugEntry/web/js/guided.js', - 'js/field.js', 'js/TUI.js', 'js/bug.js' ] + title = "Enter A Bug" + javascript_urls = js_urls style_urls = [ 'extensions/GuidedBugEntry/web/style/guided.css', 'js/yui/assets/skins/sam/container.css' ] - yui = [ 'history', 'datatable', 'container' ] + yui = yui_modules %] <iframe id="yui-history-iframe" src="extensions/GuidedBugEntry/web/yui-history-iframe.txt"></iframe> @@ -270,6 +256,29 @@ dupes.setLabels( <h3> None of the above; my [% terms.bug %] is in: </h3> + +[% IF BMO %] + <div id="prod_comp_search_main"> + <div id="prod_comp_search_autocomplete"> + <div id="prod_comp_search_label"> + Type to find product and component by name or description: + <img id="prod_comp_throbber" src="extensions/GuidedBugEntry/web/images/throbber.gif" + class="hidden" width="16" height="11"> + </div> + <input id="prod_comp_search" type="text" size="60"> + <div id="prod_comp_search_autocomplete_container"></div> + </div> + </div> + <script type="text/javascript"> + if (typeof(YAHOO.bugzilla.prodCompSearch) !== 'undefined' && YAHOO.bugzilla.prodCompSearch != null) + YAHOO.bugzilla.prodCompSearch.init('prod_comp_search', 'prod_comp_search_autocomplete_container', 'guided'); + </script> + + <h3> + Or select a product: + </h3> +[% END %] + [% END %] [% BLOCK exit_block %] diff --git a/extensions/GuidedBugEntry/template/en/default/guided/products.html.tmpl b/extensions/GuidedBugEntry/template/en/default/guided/products.html.tmpl index c3991657f..f8a68e7c9 100644 --- a/extensions/GuidedBugEntry/template/en/default/guided/products.html.tmpl +++ b/extensions/GuidedBugEntry/template/en/default/guided/products.html.tmpl @@ -1,27 +1,9 @@ -[%# ***** BEGIN LICENSE BLOCK ***** - # Version: MPL 1.1 +[%# 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/. # - # The contents of this file are subject to the Mozilla Public License Version - # 1.1 (the "License"); you may not use this file except in compliance with - # the License. You may obtain a copy of the License at - # http://www.mozilla.org/MPL/ - # - # Software distributed under the License is distributed on an "AS IS" basis, - # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - # for the specific language governing rights and limitations under the - # License. - # - # The Original Code is the GuidedBugEntry Bugzilla Extension. - # - # The Initial Developer of the Original Code is - # the Mozilla Foundation. - # Portions created by the Initial Developer are Copyright (C) 2011 - # the Initial Developer. All Rights Reserved. - # - # Contributor(s): - # Byron Jones <glob@mozilla.com> - # - # ***** END LICENSE BLOCK ***** */ + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. #%] [% INCLUDE product_block diff --git a/extensions/GuidedBugEntry/template/en/default/pages/guided_products.js.tmpl b/extensions/GuidedBugEntry/template/en/default/pages/guided_products.js.tmpl index e8697a5a1..231681085 100644 --- a/extensions/GuidedBugEntry/template/en/default/pages/guided_products.js.tmpl +++ b/extensions/GuidedBugEntry/template/en/default/pages/guided_products.js.tmpl @@ -1,27 +1,9 @@ -[%# ***** BEGIN LICENSE BLOCK ***** - # Version: MPL 1.1 +[%# 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/. # - # The contents of this file are subject to the Mozilla Public License Version - # 1.1 (the "License"); you may not use this file except in compliance with - # the License. You may obtain a copy of the License at - # http://www.mozilla.org/MPL/ - # - # Software distributed under the License is distributed on an "AS IS" basis, - # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - # for the specific language governing rights and limitations under the - # License. - # - # The Original Code is the GuidedBugEntry Bugzilla Extension. - # - # The Initial Developer of the Original Code is - # the Mozilla Foundation. - # Portions created by the Initial Developer are Copyright (C) 2011 - # the Initial Developer. All Rights Reserved. - # - # Contributor(s): - # Byron Jones <glob@mozilla.com> - # - # ***** END LICENSE BLOCK ***** */ + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. #%] [%# this file allows us to pull in data defined in the BMO ext %] diff --git a/extensions/GuidedBugEntry/web/js/guided.js b/extensions/GuidedBugEntry/web/js/guided.js index 0812200ec..16f1d4952 100644 --- a/extensions/GuidedBugEntry/web/js/guided.js +++ b/extensions/GuidedBugEntry/web/js/guided.js @@ -1,27 +1,9 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1 +/* 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/. * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the GuidedBugEntry Bugzilla Extension. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Byron Jones <glob@mozilla.com> - * - * ***** END LICENSE BLOCK ***** */ + * This Source Code Form is "Incompatible With Secondary Licenses", as + * defined by the Mozilla Public License, v. 2.0. */ // global @@ -67,7 +49,9 @@ var guided = { // update history if (History && !noSetHistory) { - History.navigate('h', newStep + "|" + product.getName()); + History.navigate('h', newStep + '|' + product.getName() + + (product.getPreselectedComponent() ? '|' + product.getPreselectedComponent() : '') + ); } }, @@ -91,8 +75,9 @@ var guided = { }, _onStateChange: function(state, noSetHistory) { - state = state.split("|"); + state = state.split('|'); product.setName(state[1] || ''); + product.setPreselectedComponent(state[2] || ''); guided.setStep(state[0], noSetHistory); }, @@ -111,8 +96,24 @@ var product = { details: false, _counter: 0, _loaded: '', + _preselectedComponent: '', - onInit: function() { }, + onInit: function() { + // BMO only + if (YAHOO.bugzilla.prodCompSearch.autoComplete) { + // show a throbber while searching for products + var autoComplete = YAHOO.bugzilla.prodCompSearch.autoComplete; + var orig_generateRequest = autoComplete.generateRequest; + autoComplete.generateRequest = function(sQuery) { + Dom.removeClass('prod_comp_throbber', 'hidden'); + return orig_generateRequest(sQuery); + }; + autoComplete.doBeforeLoadData = function(sQuery, oResponse, oPayload) { + Dom.addClass('prod_comp_throbber', 'hidden'); + return true; + }; + } + }, onShow: function() { Dom.removeClass('advanced', 'hidden'); @@ -129,6 +130,14 @@ var product = { return Dom.get('product').value; }, + getPreselectedComponent: function() { + return this._preselectedComponent; + }, + + setPreselectedComponent: function(value) { + this._preselectedComponent = value; + }, + _getNameAndRelated: function() { var result = []; @@ -635,7 +644,7 @@ var bugForm = { var elComponent = Dom.get('component'); if (products[productName] && products[productName].noComponentSelection) { - elComponent.value = products[productName].defaultComponent; + elComponent.value = products[productName].defaultComponent; bugForm._mandatoryFields = [ 'short_desc', 'version_select' ]; } else { @@ -643,9 +652,15 @@ var bugForm = { bugForm._mandatoryFields = [ 'short_desc', 'component_select', 'version_select' ]; // check for the default component - var defaultRegex = products[productName] && products[productName].defaultComponent - ? new RegExp('^' + products[productName].defaultComponent + '$', 'i') - : new RegExp('General', 'i'); + var defaultRegex; + if (product.getPreselectedComponent()) { + defaultRegex = new RegExp('^' + quoteMeta(product.getPreselectedComponent()) + '$', 'i') + } else if(products[productName] && products[productName].defaultComponent) { + defaultRegex = new RegExp('^' + quoteMeta(products[productName].defaultComponent) + '$', 'i') + } else { + defaultRegex = new RegExp('General', 'i'); + } + var preselectedComponent = false; for (var i = 0, n = product.details.components.length; i < n; i++) { var component = product.details.components[i]; @@ -899,3 +914,6 @@ var bugForm = { } } +function quoteMeta(value) { + return value.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); +} diff --git a/extensions/GuidedBugEntry/web/js/products.js b/extensions/GuidedBugEntry/web/js/products.js index 35799b74f..de6dfa330 100644 --- a/extensions/GuidedBugEntry/web/js/products.js +++ b/extensions/GuidedBugEntry/web/js/products.js @@ -1,27 +1,9 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1 +/* 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/. * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the GuidedBugEntry Bugzilla Extension. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Byron Jones <glob@mozilla.com> - * - * ***** END LICENSE BLOCK ***** */ + * This Source Code Form is "Incompatible With Secondary Licenses", as + * defined by the Mozilla Public License, v. 2.0. */ /* Product-specifc configuration for guided bug entry * diff --git a/extensions/GuidedBugEntry/web/style/guided.css b/extensions/GuidedBugEntry/web/style/guided.css index b0c766d11..55550933f 100644 --- a/extensions/GuidedBugEntry/web/style/guided.css +++ b/extensions/GuidedBugEntry/web/style/guided.css @@ -1,27 +1,9 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1 +/* 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/. * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is the GuidedBugEntry Bugzilla Extension. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Byron Jones <glob@mozilla.com> - * - * ***** END LICENSE BLOCK ***** */ + * This Source Code Form is "Incompatible With Secondary Licenses", as + * defined by the Mozilla Public License, v. 2.0. */ /* global */ @@ -99,6 +81,20 @@ text-align: right; } +#prod_comp_search_main { + width: 400px; +} + +#prod_comp_search_label { + margin-bottom: 1px; +} + +#prod_comp_search_main li.yui-ac-highlight a { + text-decoration: none; + color: #FFFFFF; + display: block; +} + #products { width: 600px; } |