From 5cff02a403a608775b3d7d93c4d1276c4b33631e Mon Sep 17 00:00:00 2001 From: Sebastin Santy Date: Thu, 22 Jun 2017 01:31:16 +0530 Subject: Bug 1365344 - Extract the "status" and "null" modules (#101) * Added comp_desc, ajax loading, modified rest * Make summary field long * Fixed indentations --- extensions/BugModal/lib/WebService.pm | 7 +-- extensions/BugModal/web/common_bug_modal.js | 82 ----------------------------- extensions/BugModal/web/new_bug.js | 48 +++++++++++++++++ 3 files changed, 52 insertions(+), 85 deletions(-) create mode 100644 extensions/BugModal/web/new_bug.js (limited to 'extensions/BugModal') 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($(''); + }); + }, + function() {} + ); + }); + $('#component') + .change(function(event) { + $("#component option[value='Select Product']").remove(); + $('#comp_desc').text($('#component').find(":selected").attr('desc').split('_').join(' ')); + }); + +}); -- cgit v1.2.3-24-g4f1b