From 293b657da11e7197e90f260dc3e0c118cba126dd Mon Sep 17 00:00:00 2001 From: Sebastin Santy Date: Mon, 21 Aug 2017 22:19:26 +0530 Subject: Bug 1390225 - Make general/untriaged component as default, if available --- extensions/BugModal/web/new_bug.css | 9 +++++++++ extensions/BugModal/web/new_bug.js | 30 +++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) (limited to 'extensions') diff --git a/extensions/BugModal/web/new_bug.css b/extensions/BugModal/web/new_bug.css index 8a161bb9a..9264d9b38 100644 --- a/extensions/BugModal/web/new_bug.css +++ b/extensions/BugModal/web/new_bug.css @@ -49,3 +49,12 @@ .file-container { padding: 8px; } + +#comp_change { + float: right; + display: none; +} + +#component_wrap { + display: inline-block; +} diff --git a/extensions/BugModal/web/new_bug.js b/extensions/BugModal/web/new_bug.js index 7298b1d20..f3551f5c8 100644 --- a/extensions/BugModal/web/new_bug.js +++ b/extensions/BugModal/web/new_bug.js @@ -13,22 +13,32 @@ var component_load = function(product) { $('#product-throbber').hide(); $('#component').attr('disabled', false); $('#comp_desc').text('Select a component to read its description.'); - var selectize = $("#component")[0].selectize; + var selectize = $("#version")[0].selectize; selectize.clear(); selectize.clearOptions(); selectize.load(function(callback) { - callback(data.components) + callback(data.versions); }); - for (var i in data.components) - comp_desc[data.components[i]["name"]] = data.components[i]["description"]; - - selectize = $("#version")[0].selectize; + selectize = $("#component")[0].selectize; selectize.clear(); selectize.clearOptions(); selectize.load(function(callback) { - callback(data.versions); + callback(data.components) }); + selectize.enable(); + $('#comp_change').css('display', 'none'); + + for (component in data.components) { + if (data.components[component].name.toLowerCase() === "untriaged" || data.components[component].name.toLowerCase() === "general") { + selectize.setValue(data.components[component].name, false); + selectize.disable(); + $('#comp_change').css('display', 'inline-block'); + } + } + + for (var i in data.components) + comp_desc[data.components[i]["name"]] = data.components[i]["description"]; }, function() { alert("Network issues. Please refresh the page and try again"); @@ -106,6 +116,12 @@ $(document).ready(function() { component_load($("#product").val()); }); + $('#comp_change').on("click", function () { + selectize = $("#component")[0].selectize; + selectize.enable(); + $('#comp_change').css('display', 'none'); + }) + component_sel.on("change", function () { var selectize = $("#component")[0].selectize; $('#comp_desc').text(comp_desc[selectize.getValue()]); -- cgit v1.2.3-24-g4f1b