From 3ae73efc60d570fc3f0e918be3889f0ae5a9f263 Mon Sep 17 00:00:00 2001 From: Sebastin Santy Date: Tue, 4 Jul 2017 01:11:09 +0530 Subject: Bug 1365345 - Modal Bug Entry Prototype --- extensions/BugModal/web/new_bug.js | 105 ++++++++++++++++++++++++++----------- 1 file changed, 73 insertions(+), 32 deletions(-) (limited to 'extensions/BugModal/web') diff --git a/extensions/BugModal/web/new_bug.js b/extensions/BugModal/web/new_bug.js index cd1b16453..cd471fc2e 100644 --- a/extensions/BugModal/web/new_bug.js +++ b/extensions/BugModal/web/new_bug.js @@ -1,48 +1,89 @@ -$(document).ready(function() { +var comp_desc = {} + +function load_products(query, callback) { bugzilla_ajax( { url: 'rest/bug_modal/products' }, function(data) { - $('#product').empty() - $('#product').append($(''); - }); - }, - function() {} - ); + { + url: 'rest/bug_modal/product_info?product=' + encodeURIComponent($('#product').val()) + }, + function(data) { + product_info = data; + $('#product-throbber').hide(); + $('#component').attr('disabled', false); + $('#comp_desc').text('Select a component to read its description.'); + var selectize = $("#component")[0].selectize; + selectize.clear(); + selectize.clearOptions(); + selectize.load(function(callback) { + callback(data.components) + }); + + for (var i in data.components) + comp_desc[data.components[i]["name"]] = data.components[i]["description"]; + + selectize = $("#version")[0].selectize; + selectize.clear(); + selectize.clearOptions(); + selectize.load(function(callback) { + callback(data.versions); + }); + }, + function() { + alert("Network issues. Please refresh the page and try again"); + } + ); }); - $('#component') - .change(function(event) { - $("#component option[value='Select Product']").remove(); - $('#comp_desc').text($('#component').find(":selected").attr('desc').split('_').join(' ')); + + component_sel.on("change", function () { + var selectize = $("#component")[0].selectize; + $('#comp_desc').text(comp_desc[selectize.getValue()]); }); + + $('.create-btn') + .click(function(event) { + event.preventDefault(); + if (document.newbugform.checkValidity && !document.newbugform.checkValidity()) + return; + this.form.submit() + }); }); -- cgit v1.2.3-24-g4f1b