diff options
author | Sebastin Santy <sebastinssanty@gmail.com> | 2017-07-06 02:01:45 +0200 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2017-07-07 00:19:21 +0200 |
commit | 6f06744ccc95232300ee53ead82166e60c84351c (patch) | |
tree | 5ebf4ea1962a2a2ccfc7378e70e8fe4af8a588e2 /extensions/BugModal/lib/WebService.pm | |
parent | 37722eca39874bb6abdcd120e3e458bd62dea62b (diff) | |
download | bugzilla-6f06744ccc95232300ee53ead82166e60c84351c.tar.gz bugzilla-6f06744ccc95232300ee53ead82166e60c84351c.tar.xz |
Bug 1365345 - Modal Bug Entry Prototype
Diffstat (limited to 'extensions/BugModal/lib/WebService.pm')
-rw-r--r-- | extensions/BugModal/lib/WebService.pm | 23 |
1 files changed, 14 insertions, 9 deletions
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 |