From cdc2b86c0a103bcfcebdda74e132a58f5174e68e Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Mon, 29 Dec 2008 00:05:06 +0000 Subject: [PATCH] =?utf8?q?Bug=20465589:=20Already=20selected=20user=20acco?= =?utf8?q?unts=20are=20no=20longer=20displayed=20when=20usemenuforusers=20?= =?utf8?q?is=20enabled=20and=20the=20account=20has=20been=20disabled=20-?= =?utf8?q?=20Patch=20by=20Fr=C3=83=C2=A9d=C3=83=C2=A9ric=20Buclin=20=20r=3Dwicked=20a=3DLpSolit?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Bugzilla/Template.pm | 7 ++++ t/008filter.t | 2 +- .../default/admin/components/create.html.tmpl | 3 -- .../en/default/bug/create/create.html.tmpl | 32 +++++++++++++++++++ template/en/default/bug/edit.html.tmpl | 1 - .../en/default/global/userselect.html.tmpl | 27 ++++++++++------ .../en/default/list/edit-multiple.html.tmpl | 2 -- 7 files changed, 57 insertions(+), 17 deletions(-) diff --git a/Bugzilla/Template.pm b/Bugzilla/Template.pm index 8a322fae58..68773d4e73 100644 --- a/Bugzilla/Template.pm +++ b/Bugzilla/Template.pm @@ -388,6 +388,13 @@ $Template::Stash::LIST_OPS->{ containsany } = return 0; }; +# Clone the array reference to leave the original one unaltered. +$Template::Stash::LIST_OPS->{ clone } = + sub { + my $list = shift; + return [@$list]; + }; + # Allow us to still get the scalar if we use the list operation ".0" on it, # as we often do for defaults in query.cgi and other places. $Template::Stash::SCALAR_OPS->{ 0 } = diff --git a/t/008filter.t b/t/008filter.t index d999e20085..9a53ced93a 100644 --- a/t/008filter.t +++ b/t/008filter.t @@ -211,7 +211,7 @@ sub directive_ok { return 1 if $directive =~ /^(time2str|url)\(/; # Safe Template Toolkit virtual methods - return 1 if $directive =~ /\.(length$|size$|push\()/; + return 1 if $directive =~ /\.(length$|size$|push\(|delete\()/; # Special Template Toolkit loop variable return 1 if $directive =~ /^loop\.(index|count)$/; diff --git a/template/en/default/admin/components/create.html.tmpl b/template/en/default/admin/components/create.html.tmpl index 86411adad9..0949837fc6 100644 --- a/template/en/default/admin/components/create.html.tmpl +++ b/template/en/default/admin/components/create.html.tmpl @@ -52,7 +52,6 @@ [% INCLUDE global/userselect.html.tmpl name => "initialowner" id => "initialowner" - value => "" size => 64 %] @@ -65,7 +64,6 @@ [% INCLUDE global/userselect.html.tmpl name => "initialqacontact" id => "initialqacontact" - value => "" size => 64 emptyok => 1 %] @@ -80,7 +78,6 @@ [% INCLUDE global/userselect.html.tmpl name => "initialcc" id => "initialcc" - value => "" size => 64 multiple => 5 %] diff --git a/template/en/default/bug/create/create.html.tmpl b/template/en/default/bug/create/create.html.tmpl index aaf2de5a6b..ee819a2aae 100644 --- a/template/en/default/bug/create/create.html.tmpl +++ b/template/en/default/bug/create/create.html.tmpl @@ -198,11 +198,23 @@ function handleWantsAttachment(wants_attachment) { @@ -342,6 +354,7 @@ function handleWantsAttachment(wants_attachment) { disabled => assigned_to_disabled size => 30 emptyok => 1 + custom_userlist => assignees_list %] @@ -357,6 +370,7 @@ function handleWantsAttachment(wants_attachment) { disabled => qa_contact_disabled size => 30 emptyok => 1 + custom_userlist => qa_contacts_list %] @@ -630,3 +644,21 @@ function handleWantsAttachment(wants_attachment) { [% END %] + +[% BLOCK build_userlist %] + [% user_found = 0 %] + [% default_login = default_user.login %] + [% RETURN UNLESS default_login %] + + [% FOREACH user = userlist %] + [% IF user.login == default_login %] + [% user_found = 1 %] + [% LAST %] + [% END %] + [% END %] + + [% userlist.push({login => default_login, + identity => default_user.identity, + visible => 1}) + UNLESS user_found %] +[% END %] diff --git a/template/en/default/bug/edit.html.tmpl b/template/en/default/bug/edit.html.tmpl index 3f519bfa9a..9923f00494 100644 --- a/template/en/default/bug/edit.html.tmpl +++ b/template/en/default/bug/edit.html.tmpl @@ -859,7 +859,6 @@ [% INCLUDE global/userselect.html.tmpl id => "newcc" name => "newcc" - value => "" size => 30 multiple => 5 %] diff --git a/template/en/default/global/userselect.html.tmpl b/template/en/default/global/userselect.html.tmpl index e27ca0d6ff..35075ef9de 100644 --- a/template/en/default/global/userselect.html.tmpl +++ b/template/en/default/global/userselect.html.tmpl @@ -11,6 +11,7 @@ # The Original Code is the Bugzilla Bug Tracking System. # # Contributor(s): Byron Jones + # Frédéric Buclin #%] [%# INTERFACE: @@ -23,7 +24,6 @@ # size: optional, input only; size attribute value # emptyok: optional, select only; if true, prepend menu option to start of select # multiple: optional, do multiselect box, value is size (height) of box - # do_not_change: optional, contains the string meaning "do not alter this role" # custom_userlist: optional, specify a limited list of users to use #%] @@ -39,27 +39,34 @@ [% END %] - [% IF do_not_change %] - - [% END %] - [% UNLESS custom_userlist %] [% custom_userlist = user.get_userlist %] [% END %] [% SET selected = {} %] - [% FOREACH selected_value IN value.split(', ') %] - [% SET selected.$selected_value = 1 %] + [% IF value.defined %] + [% FOREACH selected_value IN value.split(', ') %] + [% SET selected.$selected_value = 1 %] + [% END %] [% END %] + [% FOREACH tmpuser = custom_userlist %] [% IF tmpuser.visible OR selected.${tmpuser.login} == 1 %] [% END %] [% END %] + + [%# If the list is not empty, this means some accounts have not been mentioned yet. %] + [% FOREACH selected_user = selected.keys %] + + [% END %] [% ELSE %] "assigned_to" name => "assigned_to" value => dontchange - do_not_change => dontchange size => 32 %] @@ -189,7 +188,6 @@ id => "qa_contact" name => "qa_contact" value => dontchange - do_not_change => dontchange size => 32 %] -- 2.47.2