diff options
-rw-r--r-- | extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl | 3 | ||||
-rw-r--r-- | extensions/GuidedBugEntry/web/js/guided.js | 100 | ||||
-rw-r--r-- | extensions/GuidedBugEntry/web/js/products.js | 7 |
3 files changed, 81 insertions, 29 deletions
diff --git a/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl b/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl index 37c4c5590..4cb28235e 100644 --- a/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl +++ b/extensions/GuidedBugEntry/template/en/default/guided/guided.html.tmpl @@ -398,7 +398,7 @@ explain how to write effective [% terms.bug %] reports.</li> </div> </tr> -<tr class="odd"> +<tr class="odd" id="componentTR"> <td valign="top"> <div class="label"> Component: @@ -514,6 +514,7 @@ explain how to write effective [% terms.bug %] reports.</li> <td colspan="2" id="submitTD"> <input type="submit" id="submit" value="Submit [% terms.Bug %]"> </td> + <td> </td> </tr> </table> diff --git a/extensions/GuidedBugEntry/web/js/guided.js b/extensions/GuidedBugEntry/web/js/guided.js index 4a12be49f..76d3ae799 100644 --- a/extensions/GuidedBugEntry/web/js/guided.js +++ b/extensions/GuidedBugEntry/web/js/guided.js @@ -168,6 +168,19 @@ var product = { Dom.addClass("product_support", "hidden"); } + // show/hide component selection row + if (products[productName].noComponentSelection) { + if (!Dom.hasClass('componentTR', 'hidden')) { + Dom.addClass('componentTR', 'hidden'); + bugForm.toggleOddEven(); + } + } else { + if (Dom.hasClass('componentTR', 'hidden')) { + Dom.removeClass('componentTR', 'hidden'); + bugForm.toggleOddEven(); + } + } + if (this._loaded == productName) return; @@ -548,7 +561,7 @@ var dupes = { var bugForm = { _visibleHelpPanel: null, - _mandatoryFields: [ 'short_desc', 'component_select', 'version_select' ], + _mandatoryFields: [], onInit: function() { Dom.get('user_agent').value = navigator.userAgent; @@ -602,38 +615,59 @@ var bugForm = { // build components - // check for a general component - var defaultComponent = false; - for (var i = 0, n = product.details.components.length; i < n; i++) { - var component = product.details.components[i]; - if (component.is_active == '1') { - if (component.name.match(/general/i)) { - defaultComponent = component.name; - break; + var elComponent = Dom.get('component'); + if (products[productName].noComponentSelection) { + + elComponent.value = products[productName].defaultComponent; + bugForm._mandatoryFields = [ 'short_desc', 'version_select' ]; + + } else { + + bugForm._mandatoryFields = [ 'short_desc', 'component_select', 'version_select' ]; + + // check for the default component + var defaultRegex = products[productName].defaultComponent + ? new RegExp('^' + products[productName].defaultComponent + '$', 'i') + : 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]; + if (component.is_active == '1') { + if (defaultRegex.test(component.name)) { + preselectedComponent = component.name; + break; + } } } - } - // if there isn't a default component, default to blank - if (!defaultComponent) { - elComponents.options[elComponents.options.length] = new Option('', ''); - } + // if there isn't a default component, default to blank + if (!preselectedComponent) { + elComponents.options[elComponents.options.length] = new Option('', ''); + } - // build component select - for (var i = 0, n = product.details.components.length; i < n; i++) { - var component = product.details.components[i]; - if (component.is_active == '1') { - elComponents.options[elComponents.options.length] = - new Option(component.name, component.name); + // build component select + for (var i = 0, n = product.details.components.length; i < n; i++) { + var component = product.details.components[i]; + if (component.is_active == '1') { + elComponents.options[elComponents.options.length] = + new Option(component.name, component.name); + } + } + + var validComponent = false; + for (var i = 0, n = elComponents.options.length; i < n && !validComponent; i++) { + if (elComponents.options[i].value == elComponent.value) + validComponent = true; + } + if (!validComponent) + elComponent.value = ''; + if (elComponent.value == '' && preselectedComponent) + elComponent.value = preselectedComponent; + if (elComponent.value != '') { + elComponents.value = elComponent.value; + this.onComponentChange(elComponent.value); } - } - var elComponent = Dom.get('component'); - if (elComponent.value == '' && defaultComponent) - elComponent.value = defaultComponent; - if (elComponent.value != '') { - elComponents.value = elComponent.value; - this.onComponentChange(elComponent.value); } // build versions @@ -741,6 +775,18 @@ var bugForm = { return false; }, + toggleOddEven: function() { + var rows = Dom.get('bugForm').getElementsByTagName('TR'); + var doToggle = false; + for (var i = 0, n = rows.length; i < n; i++) { + if (doToggle) { + rows[i].className = rows[i].className == 'odd' ? 'even' : 'odd'; + } else { + doToggle = rows[i].id == 'componentTR'; + } + } + }, + _getFilename: function() { var filename = Dom.get('data').value; if (!filename) diff --git a/extensions/GuidedBugEntry/web/js/products.js b/extensions/GuidedBugEntry/web/js/products.js index c6fc25e75..35799b74f 100644 --- a/extensions/GuidedBugEntry/web/js/products.js +++ b/extensions/GuidedBugEntry/web/js/products.js @@ -29,8 +29,11 @@ * version: function which returns a version (eg. detected from UserAgent) * support: string which is displayed at the top of the duplicates page * secgroup: the group to place confidential bugs into + * defaultComponent: the default compoent to select. Defaults to 'General' + * noComponentSelection: when true, the default component will always be + * used. Defaults to 'false'; * detectPlatform: when true the platform and op_sys will be set from the - * browser's user agent. when false, these will be set to All + * browser's user agent. when false, these will be set to All */ var products = { @@ -52,6 +55,8 @@ var products = { return false; } }, + defaultComponent: "Untriaged", + noComponentSelection: true, detectPlatform: true, support: 'If you are new to Firefox or Bugzilla, please consider checking ' + |