1 [%# The contents of this file are subject to the Mozilla Public
2 # License Version 1.1 (the "License"); you may not use this file
3 # except in compliance with the License. You may obtain a copy of
4 # the License at http://www.mozilla.org/MPL/
6 # Software distributed under the License is distributed on an "AS
7 # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
8 # implied. See the License for the specific language governing
9 # rights and limitations under the License.
11 # The Original Code is the Bugzilla Bug Tracking System.
13 # The Initial Developer of the Original Code is Netscape Communications
14 # Corporation. Portions created by Netscape are
15 # Copyright (C) 1998 Netscape Communications Corporation. All
18 # Contributor(s): Myk Melez <myk@mozilla.org>
21 <script type="text/javascript">
23 // Enables or disables a requestee field depending on whether or not
24 // the user is requesting the corresponding flag.
25 function toggleRequesteeField(flagField, no_focus)
27 // Convert the ID of the flag field into the ID of its corresponding
28 // requestee field and then use the ID to get the field.
29 var id = flagField.name.replace(/flag(_type)?-(\d+)/, "requestee$1-$2");
30 var requesteeField = document.getElementById(id);
31 if (!requesteeField) return;
33 // Enable or disable the requestee field based on the value
35 if (flagField.value == "?") {
36 requesteeField.disabled = false;
37 if (!no_focus) requesteeField.focus();
39 requesteeField.disabled = true;
42 // Disables requestee fields when the window is loaded since they shouldn't
43 // be enabled until the user requests that flag type.
44 function disableRequesteeFields()
46 var inputElements = document.getElementsByTagName("input");
47 var selectElements = document.getElementsByTagName("select");
48 //You cannot update Node lists, so you must create an array to combine the NodeLists
50 for( var i=0; i < inputElements.length; i++ ) {
51 allElements[allElements.length] = inputElements.item(i);
53 for( var i=0; i < selectElements.length; i++ ) { //Combine inputs with selects
54 allElements[allElements.length] = selectElements.item(i);
56 var inputElement, id, flagField;
57 for ( var i=0 ; i<allElements.length ; i++ )
59 inputElement = allElements[i];
60 if (inputElement.name.search(/^requestee(_type)?-(\d+)$/) != -1)
62 // Convert the ID of the requestee field into the ID of its corresponding
63 // flag field and then use the ID to get the field.
64 id = inputElement.name.replace(/requestee(_type)?-(\d+)/, "flag$1-$2");
65 flagField = document.getElementById(id);
66 if (flagField && flagField.value != "?")
67 inputElement.disabled = true;
71 window.onload = disableRequesteeFields;
75 [%# We list flags by looping twice over the flag types relevant for the bug.
76 # In the first loop, we display existing flags and then, for active types,
77 # we display UI for adding new flags. In the second loop, we display UI
78 # for adding additional new flags for those types for which a flag already
79 # exists but which are multiplicable (can have multiple flags of the type
80 # on a single bug/attachment).
83 [% DEFAULT flag_table_id = "flags" %]
85 <table id="[% flag_table_id FILTER html %]">
86 [% UNLESS flag_no_header %]
91 [% IF any_flags_requesteeble %]
99 [%# Step 1: Display every flag type (except inactive types with no flags). %]
100 [% FOREACH type = flag_types %]
102 [%# Step 1a: Display existing flag(s). %]
103 [% FOREACH flag = type.flags %]
104 [%# if WEBKIT_CHANGES %]
105 [% IF type.name == 'in-rietveld' %]
106 <tr style='display:none'>
110 [%# endif // WEBKIT_CHANGES %]
112 [% flag.setter.nick FILTER html %]:
115 <label title="[% type.description FILTER html %]"
116 for="flag-[% flag.id %]">
117 [%- type.name FILTER html FILTER no_break -%]</label>
120 <select id="flag-[% flag.id %]" name="flag-[% flag.id %]"
121 title="[% type.description FILTER html %]"
122 onchange="toggleRequesteeField(this);"
124 [%# Only display statuses the user is allowed to set. %]
125 [% IF user.can_request_flag(type) %]
126 <option value="X"></option>
128 [% IF type.is_active %]
129 [% IF (type.is_requestable && user.can_request_flag(type)) || flag.status == "?" %]
130 <option value="?" [% "selected" IF flag.status == "?" %]>?</option>
132 [% IF user.can_set_flag(type) || flag.status == "+" %]
133 <option value="+" [% "selected" IF flag.status == "+" %]>+</option>
135 [% IF user.can_set_flag(type) || flag.status == "-" %]
136 <option value="-" [% "selected" IF flag.status == "-" %]>-</option>
139 <option value="[% flag.status %]" selected="selected">[% flag.status %]</option>
143 [% IF any_flags_requesteeble %]
145 [% IF (type.is_active && type.is_requestable && type.is_requesteeble) || flag.requestee %]
146 <span style="white-space: nowrap;">
147 [% IF Param('usemenuforusers') %]
148 [% flag_custom_list = flag.type.grant_list %]
149 [% IF !(type.is_active && type.is_requestable && type.is_requesteeble) %]
150 [%# We are here only because there was already a requestee. In this case,
151 the only valid action is to remove the requestee or leave it alone;
153 [% flag_custom_list = [flag.requestee] %]
155 [% INCLUDE global/userselect.html.tmpl
156 name => "requestee-$flag.id"
157 id => "requestee-$flag.id"
158 value => flag.requestee.login
161 custom_userlist => flag_custom_list
164 (<input type="text" size="30" maxlength="255"
165 id="requestee-[% flag.id %]"
166 name="requestee-[% flag.id %]"
167 [% IF flag.status == "?" && flag.requestee %]
168 value="[% flag.requestee.login FILTER html %]"
178 [%# Step 1b: Display UI for setting flag. %]
179 [% IF (!type.flags || type.flags.size == 0) && type.is_active %]
180 [%# if WEBKIT_CHANGES %]
181 [% IF type.name == 'in-rietveld' %]
182 <tr style='display:none'>
186 [%# endif // WEBKIT_CHANGES %]
189 <label title="[% type.description FILTER html %]"
190 for="flag_type-[% type.id %]">
191 [%- type.name FILTER html FILTER no_break %]</label>
194 <select id="flag_type-[% type.id %]" name="flag_type-[% type.id %]"
195 title="[% type.description FILTER html %]"
196 [% " disabled=\"disabled\"" UNLESS (type.is_requestable && user.can_request_flag(type)) || user.can_set_flag(type) %]
197 onchange="toggleRequesteeField(this);"
199 <option value="X"></option>
200 [% IF type.is_requestable && user.can_request_flag(type) %]
201 <option value="?">?</option>
203 [% IF user.can_set_flag(type) %]
204 <option value="+">+</option>
205 <option value="-">-</option>
209 [% IF any_flags_requesteeble %]
211 [% IF type.is_requestable && type.is_requesteeble %]
212 <span style="white-space: nowrap;">
213 [% IF Param('usemenuforusers') %]
214 [% INCLUDE global/userselect.html.tmpl
215 name => "requestee_type-$type.id"
216 id => "requestee_type-$type.id"
217 multiple => type.is_multiplicable * 3
218 emptyok => !type.is_multiplicable
220 custom_userlist => type.grant_list
223 (<input type="text" size="30" maxlength="255"
224 id="requestee_type-[% type.id %]"
225 name="requestee_type-[% type.id %]">)
235 [%# Step 2: Display flag type again (if type is multiplicable). %]
236 [% FOREACH type = flag_types %]
237 [% NEXT UNLESS type.flags && type.flags.size > 0 && type.is_multiplicable && type.is_active %]
238 [% IF !separator_displayed %]
239 <tr><td colspan="3"><hr></td></tr>
240 [% separator_displayed = 1 %]
244 addl. <label title="[% type.description FILTER html %]"
245 for="flag_type-[% type.id %]">
246 [%- type.name FILTER html FILTER no_break %]</label>
249 <select id="flag_type-[% type.id %]" name="flag_type-[% type.id %]"
250 title="[% type.description FILTER html %]"
251 [% " disabled=\"disabled\"" UNLESS (type.is_requestable && user.can_request_flag(type)) || user.can_set_flag(type) %]
252 onchange="toggleRequesteeField(this);"
254 <option value="X"></option>
255 [% IF type.is_requestable && user.can_request_flag(type) %]
256 <option value="?">?</option>
258 [% IF user.can_set_flag(type) %]
259 <option value="+">+</option>
260 <option value="-">-</option>
264 [% IF any_flags_requesteeble %]
266 [% IF type.is_requestable && type.is_requesteeble %]
267 <span style="white-space: nowrap;">
268 [% IF Param('usemenuforusers') %]
269 [% INCLUDE global/userselect.html.tmpl
270 name => "requestee_type-$type.id"
271 id => "requestee_type-$type.id"
272 multiple => type.is_multiplicable * 3
273 emptyok => !type.is_multiplicable
275 custom_userlist => type.grant_list
278 (<input type="text" size="30" maxlength="255"
279 id="requestee_type-[% type.id %]"
280 name="requestee_type-[% type.id %]">)