Commit 223bd464 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 339437: Make flag requestee a select box and limit users to requestable only…

Bug 339437: Make flag requestee a select box and limit users to requestable only - Patch by Seth <laoseth@gmail.com> r/a=LpSolit
parent 09b34ef6
......@@ -186,6 +186,11 @@ sub sortkey { return $_[0]->{'sortkey'}; }
=over
=item C<grant_list>
Returns a reference to an array of users who have permission to grant this flag type.
The arrays are populated with hashrefs containing the login, identity and visibility of users.
=item C<grant_group>
Returns the group (as a Bugzilla::Group object) in which a user
......@@ -214,6 +219,17 @@ explicitly excluded from the flagtype.
=cut
sub grant_list {
my $self = shift;
my @custusers;
my @allusers = @{Bugzilla->user->get_userlist};
foreach my $user (@allusers) {
my $user_obj = new Bugzilla::User({name => $user->{login}});
push(@custusers, $user) if $user_obj->can_set_flag($self);
}
return \@custusers;
}
sub grant_group {
my $self = shift;
......
......@@ -259,7 +259,7 @@ span.quote {
table#flags th,
table#flags td {
vertical-align: baseline;
vertical-align: middle;
text-align: left;
}
......
......@@ -40,8 +40,6 @@
table.attachment_info th { text-align: right; vertical-align: top; }
table.attachment_info td { text-align: left; vertical-align: top; }
#noview { text-align: left; vertical-align: middle; }
table#flags th, table#flags td { font-size: small; vertical-align: baseline; text-align: left; }
"
%]
......
......@@ -45,10 +45,19 @@
function disableRequesteeFields()
{
var inputElements = document.getElementsByTagName("input");
var selectElements = document.getElementsByTagName("select");
//You cannot update Node lists, so you must create an array to combine the NodeLists
var allElements = [];
for( var i=0; i < inputElements.length; i++ ) {
allElements[allElements.length] = inputElements.item(i);
}
for( var i=0; i < selectElements.length; i++ ) { //Combine inputs with selects
allElements[allElements.length] = selectElements.item(i);
}
var inputElement, id, flagField;
for ( var i=0 ; i<inputElements.length ; i++ )
for ( var i=0 ; i<allElements.length ; i++ )
{
inputElement = inputElements.item(i);
inputElement = allElements[i];
if (inputElement.name.search(/^requestee(_type)?-(\d+)$/) != -1)
{
// Convert the ID of the requestee field into the ID of its corresponding
......@@ -130,13 +139,23 @@
<td>
[% IF type.is_active && type.is_requesteeble %]
<span style="white-space: nowrap;">
(<input type="text" size="30" maxlength="255"
id="requestee-[% flag.id %]"
name="requestee-[% flag.id %]"
[% IF flag.status == "?" && flag.requestee %]
value="[% flag.requestee.login FILTER html %]"
[% END %]
>)
[% IF Param('usemenuforusers') %]
[% INCLUDE global/userselect.html.tmpl
name => "requestee-$flag.id"
id => "requestee-$flag.id"
value => flag.requestee.login
multiple => 0
emptyok => 1
custom_userlist => flag.type.grant_list
%]
[% ELSE %]
(<input type="text" size="30" maxlength="255"
id="requestee-[% flag.id %]"
name="requestee-[% flag.id %]"
[% IF flag.status == "?" && flag.requestee %]
value="[% flag.requestee.login FILTER html %]"
[% END %]>)
[% END %]
</span>
[% END %]
</td>
......@@ -173,9 +192,19 @@
<td>
[% IF type.is_requesteeble %]
<span style="white-space: nowrap;">
(<input type="text" size="30" maxlength="255"
id="requestee_type-[% type.id %]"
name="requestee_type-[% type.id %]">)
[% IF Param('usemenuforusers') %]
[% INCLUDE global/userselect.html.tmpl
name => "requestee_type-$type.id"
id => "requestee_type-$type.id"
multiple => type.is_multiplicable * 3
emptyok => !type.is_multiplicable
custom_userlist => type.grant_list
%]
[% ELSE %]
(<input type="text" size="30" maxlength="255"
id="requestee_type-[% type.id %]"
name="requestee_type-[% type.id %]">)
[% END %]
</span>
[% END %]
</td>
......@@ -216,11 +245,21 @@
[% IF any_flags_requesteeble %]
<td>
[% IF type.is_requesteeble %]
<span style="white-space: nowrap;">
<span style="white-space: nowrap;">
[% IF Param('usemenuforusers') %]
[% INCLUDE global/userselect.html.tmpl
name => "requestee_type-$type.id"
id => "requestee_type-$type.id"
multiple => type.is_multiplicable * 3
emptyok => !type.is_multiplicable
custom_userlist => type.grant_list
%]
[% ELSE %]
(<input type="text" size="30" maxlength="255"
id="requestee_type-[% type.id %]"
name="requestee_type-[% type.id %]">)
</span>
[% END %]
</span>
[% END %]
</td>
[% END %]
......
......@@ -25,6 +25,7 @@
# 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
#%]
[% IF Param("usemenuforusers") %]
......@@ -45,7 +46,11 @@
</option>
[% END %]
[% FOREACH tmpuser = user.get_userlist %]
[% UNLESS custom_userlist %]
[% custom_userlist = user.get_userlist %]
[% END %]
[% FOREACH tmpuser = custom_userlist %]
[% IF tmpuser.visible OR value.match("\\b$tmpuser.login\\b") %]
<option value="[% tmpuser.login FILTER html %]"
[% " selected=\"selected\"" IF value.match("\\b$tmpuser.login\\b") %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment