diff options
Diffstat (limited to 'extensions/BugModal')
-rw-r--r-- | extensions/BugModal/lib/WebService.pm | 7 | ||||
-rw-r--r-- | extensions/BugModal/web/common_bug_modal.js | 82 | ||||
-rw-r--r-- | extensions/BugModal/web/new_bug.js | 48 |
3 files changed, 52 insertions, 85 deletions
diff --git a/extensions/BugModal/lib/WebService.pm b/extensions/BugModal/lib/WebService.pm index a7026288c..556a2d7cc 100644 --- a/extensions/BugModal/lib/WebService.pm +++ b/extensions/BugModal/lib/WebService.pm @@ -96,9 +96,10 @@ sub components { ThrowCodeError( 'params_required', { function => 'BugModal.components', params => ['product'] } ); } - my $product = Bugzilla::Product->check( { name => $params->{product_name}, cache => 1 } ); - $product = Bugzilla->user->can_enter_product( $product, 1 ); - return { components => _name( $product->components ) }; + my $product = Bugzilla::Product->check({ name => $params->{product_name}, cache => 1 }); + $product = Bugzilla->user->can_enter_product($product, 1); + my @components = map { { name => $_->name, description => Bugzilla::Component->check({ product => $product, name => $_->name })->description} } @{ $product->components }; + return { components => \@components } } # everything we need for edit mode in a single call, returning just the fields diff --git a/extensions/BugModal/web/common_bug_modal.js b/extensions/BugModal/web/common_bug_modal.js index 3a5a149fb..1a2d309bb 100644 --- a/extensions/BugModal/web/common_bug_modal.js +++ b/extensions/BugModal/web/common_bug_modal.js @@ -1079,88 +1079,6 @@ $(function() { $('#component, #version, #target_milestone').each(function() { $(this).data('default', $(this).val()); }); - $('#product') - .change(function(event) { - $('#product-throbber').show(); - $('#component, #version, #target_milestone').attr('disabled', true); - - slide_module($('#module-tracking'), 'show'); - - $.each($('input[name=groups]'), function() { - if (this.checked) { - slide_module($('#module-security'), 'show'); - return false; - } - }); - - bugzilla_ajax( - { - url: 'rest/bug_modal/new_product/' + BUGZILLA.bug_id + '?product=' + encodeURIComponent($('#product').val()) - }, - function(data) { - $('#product-throbber').hide(); - $('#component, #version, #target_milestone').attr('disabled', false); - var is_default = $('#product').val() == $('#product').data('default'); - - // populate selects - $.each(data, function(key, value) { - if (key == 'groups') return; - var el = $('#' + key); - if (!el) return; - el.empty(); - var selected = el.data('preselect'); - $(value).each(function(i, v) { - el.append($('<option>', { value: v.name, text: v.name })); - if (typeof selected === 'undefined' && v.selected) - selected = v.name; - }); - el.val(selected); - el.prop('required', true); - if (is_default) { - el.removeClass('attention'); - el.val(el.data('default')); - } - else { - el.addClass('attention'); - } - }); - - // update groups - var dirtyGroups = []; - var any_groups_checked = 0; - $('#module-security').find('input[name=groups]').each(function() { - var that = $(this); - var defaultChecked = !!that.attr('checked'); - if (defaultChecked !== that.is(':checked')) { - dirtyGroups.push({ name: that.val(), value: that.is(':checked') }); - } - if (that.is(':checked')) { - any_groups_checked = 1; - } - }); - $('#module-security .module-content') - .html(data.groups) - .addClass('attention'); - $.each(dirtyGroups, function() { - $('#module-security').find('input[value=' + this.name + ']').prop('checked', this.value); - }); - // clear any default groups if user was making bug public - // unless the group is mandatory for the new product - if (!any_groups_checked) { - $('#module-security').find('input[name=groups]').each(function() { - var that = $(this); - if (!that.data('mandatory')) { - that.prop('checked', false); - } - }); - } - }, - function() { - $('#product-throbber').hide(); - $('#component, #version, #target_milestone').attr('disabled', false); - } - ); - }); // product/component search $('#product-search') diff --git a/extensions/BugModal/web/new_bug.js b/extensions/BugModal/web/new_bug.js new file mode 100644 index 000000000..cd1b16453 --- /dev/null +++ b/extensions/BugModal/web/new_bug.js @@ -0,0 +1,48 @@ +$(document).ready(function() { + 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 })); + }); + }, + function() {} + ); + + $('#component').empty() + $('#component').append($('<option>', { value: 'Select Component', text: 'Select Component' })); + + $('#product') + .change(function(event) { + $('#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() {} + ); + }); + $('#component') + .change(function(event) { + $("#component option[value='Select Product']").remove(); + $('#comp_desc').text($('#component').find(":selected").attr('desc').split('_').join(' ')); + }); + +}); |