summaryrefslogtreecommitdiffstats
path: root/extensions/BugModal/web
diff options
context:
space:
mode:
authorSebastin Santy <sebastinssanty@gmail.com>2017-07-03 21:41:09 +0200
committerDylan William Hardison <dylan@hardison.net>2017-07-07 00:19:20 +0200
commit3ae73efc60d570fc3f0e918be3889f0ae5a9f263 (patch)
treed8cfb21d3e5a8d2d3bce51949835b8b6e7686549 /extensions/BugModal/web
parent6f68125893590fc9de60185f5535bae12adbcb54 (diff)
downloadbugzilla-3ae73efc60d570fc3f0e918be3889f0ae5a9f263.tar.gz
bugzilla-3ae73efc60d570fc3f0e918be3889f0ae5a9f263.tar.xz
Bug 1365345 - Modal Bug Entry Prototype
Diffstat (limited to 'extensions/BugModal/web')
-rw-r--r--extensions/BugModal/web/new_bug.js105
1 files changed, 73 insertions, 32 deletions
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($('<option>', { value: 'Select Product', text: 'Select Product' }));
- // populate select menus
- $.each(data.products, function(key, value) {
- $('#product').append($('<option>', { value: value.name, text: value.name }));
- });
+ callback(data.products);
},
- function() {}
+ function() {
+ callback();
+ }
);
+}
+
+$(document).ready(function() {
+ var product_sel = $("#product").selectize({
+ valueField: 'name',
+ labelField: 'name',
+ searchField: 'name',
+ options: [],
+ preload: true,
+ create: false,
+ load: load_products
+ });
+ var component_sel = $("#component").selectize({
+ valueField: 'name',
+ labelField: 'name',
+ searchField: 'name',
+ options: [],
+ });
- $('#component').empty()
- $('#component').append($('<option>', { value: 'Select Component', text: 'Select Component' }));
+ var version_sel = $("#version").selectize({
+ valueField: 'name',
+ labelField: 'name',
+ searchField: 'name',
+ options: [],
+ });
- $('#product')
- .change(function(event) {
+ product_sel.on("change", function () {
$('#product-throbber').show();
$('#component').attr('disabled', true);
- $("#product option[value='Select Product']").remove();
bugzilla_ajax(
- {
- url: 'rest/bug_modal/components?product=' + encodeURIComponent($('#product').val())
- },
- function(data) {
- $('#product-throbber').hide();
- $('#component').attr('disabled', false);
- $('#component').empty();
- $('#component').append($('<option>', { value: 'Select Component', text: 'Select Component' }));
- $('#comp_desc').text('Select a component to read its description.');
- $.each(data.components, function(key, value) {
- $('#component').append('<option value=' + value.name + ' desc=' + value.description.split(' ').join('_') + '>' + value.name + '</option>');
- });
- },
- 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()
+ });
});