From 6f06744ccc95232300ee53ead82166e60c84351c Mon Sep 17 00:00:00 2001 From: Sebastin Santy Date: Thu, 6 Jul 2017 05:31:45 +0530 Subject: Bug 1365345 - Modal Bug Entry Prototype --- extensions/BugModal/lib/WebService.pm | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'extensions/BugModal/lib/WebService.pm') diff --git a/extensions/BugModal/lib/WebService.pm b/extensions/BugModal/lib/WebService.pm index 556a2d7cc..99d0383cc 100644 --- a/extensions/BugModal/lib/WebService.pm +++ b/extensions/BugModal/lib/WebService.pm @@ -38,9 +38,9 @@ sub rest_resources { # return all the components pertaining to the product. # required by new-bug - qr{^/bug_modal/components}, { + qr{^/bug_modal/product_info}, { GET => { - method => 'components', + method => 'product_info', params => sub { return { product_name => Bugzilla->input_params->{product} } }, @@ -87,19 +87,24 @@ sub products { return { products => _name($user->get_enterable_products) }; } -sub components { +sub product_info { my ( $self, $params ) = @_; if ( !ref $params->{product_name} ) { untaint( $params->{product_name} ); } else { - ThrowCodeError( 'params_required', - { function => 'BugModal.components', params => ['product'] } ); + 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); - my @components = map { { name => $_->name, description => Bugzilla::Component->check({ product => $product, name => $_->name })->description} } @{ $product->components }; - return { components => \@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 => $_->description, + } + } @{ $product->components }; + my @versions = map { { name => $_->name } } grep { $_->is_active } @{ $product->versions }; + return { components => \@components, versions => \@versions }; } # everything we need for edit mode in a single call, returning just the fields -- cgit v1.2.3-24-g4f1b