1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
[%# The contents of this file are subject to the Mozilla Public
# License Version 1.1 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
# implied. See the License for the specific language governing
# rights and limitations under the License.
#
# The Original Code is the Bugzilla Bug Tracking System.
#
# The Initial Developer of the Original Code is Netscape Communications
# Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All
# Rights Reserved.
#
# Contributor(s): Myk Melez <myk@mozilla.org>
#%]
<script type="text/javascript">
<!--
// Enables or disables a requestee field depending on whether or not
// the user is requesting the corresponding flag.
function toggleRequesteeField(flagField, no_focus)
{
// Convert the ID of the flag field into the ID of its corresponding
// requestee field and then use the ID to get the field.
var id = flagField.name.replace(/flag(_type)?-(\d+)/, "requestee$1-$2");
var requesteeField = document.getElementById(id);
if (!requesteeField) return;
// Enable or disable the requestee field based on the value
// of the flag field.
if (flagField.value == "?") {
requesteeField.disabled = false;
if (!no_focus) requesteeField.focus();
} else
requesteeField.disabled = true;
}
// Disables requestee fields when the window is loaded since they shouldn't
// be enabled until the user requests that flag type.
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<allElements.length ; 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
// flag field and then use the ID to get the field.
id = inputElement.name.replace(/requestee(_type)?-(\d+)/, "flag$1-$2");
flagField = document.getElementById(id);
if (flagField && flagField.value != "?")
inputElement.disabled = true;
}
}
}
YAHOO.util.Event.addListener(window, "load", disableRequesteeFields);
// -->
</script>
[% IF user.id %]
[%# We list flags by looping twice over the flag types relevant for the bug.
# In the first loop, we display existing flags and then, for active types,
# we display UI for adding new flags. In the second loop, we display UI
# for adding additional new flags for those types for which a flag already
# exists but which are multiplicable (can have multiple flags of the type
# on a single bug/attachment).
#%]
[% DEFAULT flag_table_id = "flags" %]
<table id="[% flag_table_id FILTER html %]">
[% UNLESS flag_no_header %]
<tr>
<th colspan="3">
Flags:
</th>
[% IF any_flags_requesteeble %]
<th>
Requestee:
</th>
[% END %]
</tr>
[% END %]
[%# Step 1: Display every flag type (except inactive types with no flags). %]
[% FOREACH type = flag_types %]
[%# Step 1a: Display existing flag(s). %]
[% FOREACH flag = type.flags %]
<tr>
<td>
[% flag.setter.nick FILTER html %]:
</td>
<td>
<label title="[% type.description FILTER html %]"
for="flag-[% flag.id %]">
[%- type.name FILTER html FILTER no_break -%]</label>
</td>
<td>
<select id="flag-[% flag.id %]" name="flag-[% flag.id %]"
title="[% type.description FILTER html %]"
onchange="toggleRequesteeField(this);"
class="flag_select">
[%# Only display statuses the user is allowed to set. %]
[% IF user.can_request_flag(type) %]
<option value="X"></option>
[% END %]
[% IF type.is_active %]
[% IF (type.is_requestable && user.can_request_flag(type)) || flag.status == "?" %]
<option value="?" [% "selected" IF flag.status == "?" %]>?</option>
[% END %]
[% IF user.can_set_flag(type) || flag.status == "+" %]
<option value="+" [% "selected" IF flag.status == "+" %]>+</option>
[% END %]
[% IF user.can_set_flag(type) || flag.status == "-" %]
<option value="-" [% "selected" IF flag.status == "-" %]>-</option>
[% END %]
[% ELSE %]
<option value="[% flag.status %]" selected="selected">[% flag.status %]</option>
[% END %]
</select>
</td>
[% IF any_flags_requesteeble %]
<td>
[% IF (type.is_active && type.is_requestable && type.is_requesteeble) || flag.requestee %]
<span style="white-space: nowrap;">
[% IF Param('usemenuforusers') %]
[% flag_custom_list = flag.type.grant_list %]
[% IF !(type.is_active && type.is_requestable && type.is_requesteeble) %]
[%# We are here only because there was already a requestee. In this case,
the only valid action is to remove the requestee or leave it alone;
nothing else. %]
[% flag_custom_list = [flag.requestee] %]
[% END %]
[% INCLUDE global/userselect.html.tmpl
name => "requestee-$flag.id"
id => "requestee-$flag.id"
value => flag.requestee.login
multiple => 0
emptyok => 1
custom_userlist => flag_custom_list
%]
[% ELSE %]
(<input type="text" class="requestee" 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>
[% END %]
</tr>
[% END %]
[%# Step 1b: Display UI for setting flag. %]
[% IF (!type.flags || type.flags.size == 0) && type.is_active %]
[% PROCESS flag_row first_cell_empty = 1 addl_text = "" %]
[% END %]
[% END %]
[%# Step 2: Display flag type again (if type is multiplicable). %]
[% FOREACH type = flag_types %]
[% NEXT UNLESS type.flags && type.flags.size > 0 && type.is_multiplicable && type.is_active %]
[% IF !separator_displayed %]
<tr><td colspan="3"><hr></td></tr>
[% separator_displayed = 1 %]
[% END %]
[% PROCESS flag_row first_cell_empty = 0 addl_text = "addl." %]
[% END %]
</table>
[% ELSE %]
[%# The user is logged out. Display flags as read-only. %]
[% FOREACH type = flag_types %]
[% FOREACH flag = type.flags %]
[% flag.setter.nick FILTER html %]:
[%+ type.name FILTER html FILTER no_break %][% flag.status %]
[% IF flag.requestee %]
([% flag.requestee.nick FILTER html %])
[% END %]<br>
[% END %]
[% END %]
[% END %]
[%# Display a table row for unset flags %]
[% BLOCK flag_row %]
<tr>
[% IF first_cell_empty %]
<td> </td>
<td>
[% ELSE %]
<td colspan="2">
[% END %]
[% addl_text FILTER html %]
<label title="[% type.description FILTER html %]" for="flag_type-[% type.id %]">
[%- type.name FILTER html FILTER no_break %]</label>
</td>
<td>
<select id="flag_type-[% type.id %]" name="flag_type-[% type.id %]"
title="[% type.description FILTER html %]"
[% " disabled=\"disabled\"" UNLESS (type.is_requestable && user.can_request_flag(type)) || user.can_set_flag(type) %]
onchange="toggleRequesteeField(this);"
class="flag_select">
<option value="X"></option>
[% IF type.is_requestable && user.can_request_flag(type) %]
<option value="?">?</option>
[% END %]
[% IF user.can_set_flag(type) %]
<option value="+">+</option>
<option value="-">-</option>
[% END %]
</select>
</td>
[% IF any_flags_requesteeble %]
<td>
[% IF type.is_requestable && type.is_requesteeble %]
<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
value => ""
custom_userlist => type.grant_list
%]
[% ELSE %]
(<input type="text" class="requestee" maxlength="255"
id="requestee_type-[% type.id %]"
name="requestee_type-[% type.id %]">)
[% END %]
</span>
[% END %]
</td>
[% END %]
</tr>
[% END %]
|