From 038e32c1753b1d7bfbf026ee99f6128e038cc70c Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Mon, 9 Apr 2012 22:49:29 +0800 Subject: Bug 738329: allow preseleting products and components in component-watch prefs --- extensions/ComponentWatching/Extension.pm | 7 +++++-- .../en/default/account/prefs/component_watch.html.tmpl | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'extensions/ComponentWatching') diff --git a/extensions/ComponentWatching/Extension.pm b/extensions/ComponentWatching/Extension.pm index c47fa4749..db191dfbe 100644 --- a/extensions/ComponentWatching/Extension.pm +++ b/extensions/ComponentWatching/Extension.pm @@ -178,6 +178,7 @@ sub user_preferences { my $save = $args->{'save_changes'}; my $handled = $args->{'handled'}; + my $vars = $args->{'vars'}; my $user = Bugzilla->user; my $input = Bugzilla->input_params; @@ -189,7 +190,7 @@ sub user_preferences { my $productName = $input->{'add_product'}; my $ra_componentNames = $input->{'add_component'}; - $ra_componentNames = [$ra_componentNames] unless ref($ra_componentNames); + $ra_componentNames = [$ra_componentNames || ''] unless ref($ra_componentNames); # load product and verify access my $product = Bugzilla::Product->new({ name => $productName }); @@ -227,7 +228,9 @@ sub user_preferences { } } - $args->{'vars'}->{'watches'} = _getWatches($user); + $vars->{'add_product'} = $input->{'product'}; + $vars->{'add_component'} = $input->{'component'}; + $vars->{'watches'} = _getWatches($user); $$handled = 1; } diff --git a/extensions/ComponentWatching/template/en/default/account/prefs/component_watch.html.tmpl b/extensions/ComponentWatching/template/en/default/account/prefs/component_watch.html.tmpl index 46acd386f..0eed6b3b3 100644 --- a/extensions/ComponentWatching/template/en/default/account/prefs/component_watch.html.tmpl +++ b/extensions/ComponentWatching/template/en/default/account/prefs/component_watch.html.tmpl @@ -46,6 +46,13 @@ function onSelectProduct() { // support IE component.add(new Option('__Any__', ''), 0); } + if ('[% add_component FILTER js %]' != '' + && bz_valueSelected(Dom.get('product'), '[% add_product FILTER js %]') + ) { + var index = bz_optionIndex(Dom.get('component'), '[% add_component FILTER js %]'); + if (index != -1) + Dom.get('component').options[index].selected = true; + } onSelectComponent(); } @@ -75,7 +82,8 @@ watch "__Any__". @@ -83,11 +91,12 @@ watch "__Any__". Component: - [% FOREACH product IN selectable_products %] [% FOREACH component IN product.components %] - + [% END %] [% END %] -- cgit v1.2.3-24-g4f1b