blob: 75c09faf80fb216353deb258a88a60ebc9b3766c [file] [log] [blame]
Copybara854996b2021-09-07 19:36:02 +00001[define title]Field [field_def.field_name][end]
2[define category_css]css/ph_detail.css[end]
3[include "../framework/header.ezt" "showtabs"]
4
5<a href="/p/[projectname]/adminLabels">&lsaquo; Back to field list</a><br><br>
6
7
8<h4>Custom field</h4>
9
10<form action="detail.do" method="POST">
11<input type="hidden" name="token" value="[form_token]">
12<input type="hidden" name="field" value="[field_def.field_name]">
13
14<table cellspacing="8" class="rowmajor vt">
15 <tr>
16 <th width="1%">Name:</th>
17 <td>
18 [if-any uneditable_name]
19 <input type="hidden" name="name" value="[field_def.field_name]">
20 [field_def.field_name]
21 [else][if-any allow_edit]
22 <input name="name" value="[field_def.field_name]" size="30" class="acob">
23 [else]
24 [field_def.field_name]
25 [end][end]
26 </td>
27 </tr>
28
29 <tr>
30 <th>Description:</th>
31 <td>
32 [if-any allow_edit]
33 <textarea name="docstring" rows="4" cols="75">[field_def.docstring]</textarea>
34 [else]
35 [field_def.docstring]
36 [end]
37 </td>
38 </tr>
39
40 <tr>
41 <th>Type:</th>
42 [# TODO(jrobbins): make field types editable someday.]
43 <td>[field_def.type_name]</td>
44 </tr>
45
46 [is field_def.type_name "APPROVAL_TYPE"]
47 <tr>
48 <th>Approvers:</th>
49 <td>
50 [if-any allow_edit]
51 <input id="member_approvers" name="approver_names" size="75" value="[initial_approvers]"
52 autocomplete="off">
53 <span class="fielderror" style="margin-left:1em">
54 [if-any errors.approvers][errors.approvers][end]
55 </span>
56 [else]
57 [for field_def.approvers]
58 <div>[include "../framework/user-link.ezt" field_def.approvers]</div>
59 [end]
60 [end]
61 </td>
62 </tr>
63 <tr>
64 <th>Survey:</th>
65 <td>
66 [if-any allow_edit]
67 <textarea name="survey" rows="4" cols="75">[field_def.survey]</textarea>
68 [else]
69 <table cellspacing="4" cellpadding="0" style="padding: 2px; border:2px solid #eee">
70 [for field_def.survey_questions]
71 <tr><td>[field_def.survey_questions]</td></tr>
72 [end]
73 </table>
74 [end]
75 </td>
76 </tr>
77
78 [if-any approval_subfields]
79 <tr>
80 <th>Subfields:</th>
81 <td>
82 [for approval_subfields]
83 <div><a href="/p/[projectname]/fields/detail?field=[approval_subfields.field_name]">
84 [approval_subfields.field_name]
85 </a></div>
86 [end]
87 </td>
88 </tr>
89 [end]
90 [else]
91
92 <tr>
93 <th>Issue Gate field:</th>
94 <td>
95 [if-any field_def.is_phase_field]Yes[else]No[end]
96 </td>
97 </tr>
98
99 [is field_def.field_name "Type"][else]
100 <tr>
101 <th>Applicable:</th>
102 <td>When issue type is:
103 [if-any allow_edit]
104 [define oddball_applicability]Yes[end]
105 <select id="applicable_type" name="applicable_type">
106 <option value=""
107 [is initial_applicable_type ""]
108 selected="selected"
109 [define oddball_applicability]No[end]
110 [end]
111 >Anything</option>
112 <option disabled="disabled">----</option>
113 [for well_known_issue_types]
114 <option value="[well_known_issue_types]"
115 [is initial_applicable_type well_known_issue_types]
116 selected="selected"
117 [define oddball_applicability]No[end]
118 [end]
119 >[well_known_issue_types]</option>
120 [end]
121 [# If an oddball type was used, keep it.]
122 [is oddball_applicability "Yes"]
123 <option value="[initial_applicable_type]" selected="selected"
124 >[initial_applicable_type]</option>
125 [end]
126 </select>
127 [else]
128 [initial_applicable_type]
129 [end]
130 [# TODO(jrobbins): editable applicable_predicate.]
131 </td>
132 </tr>
133 [end]
134
135 <tr>
136 <th>Importance:</th>
137 <td>
138 [if-any allow_edit]
139 <select id="importance" name="importance">
140 <option value="required" [is field_def.importance "required"]selected[end]>Required when applicable</option>
141 <option value="normal" [is field_def.importance "normal"]selected[end]>Offered when applicable</option>
142 <option value="niche" [is field_def.importance "niche"]selected[end]>Under "Show all fields" when applicable</option>
143 </select>
144 [else]
145 [is field_def.importance "required"]Required when applicable[end]
146 [is field_def.importance "normal"]Offered when applicable[end]
147 [is field_def.importance "niche"]Under "Show all fields" when applicable[end]
148 [end]
149 </td>
150 </tr>
151
152 <tr>
153 <th>Multivalued:</th>
154 <td>
155 [if-any allow_edit]
156 <input type="checkbox" name="is_multivalued" class="acob"
157 [if-any field_def.is_multivalued_bool]checked="checked"[end]>
158 [else]
159 [if-any field_def.is_multivalued_bool]Yes[else]No[end]
160 [end]
161 </td>
162 </tr>
163 [end]
164
165 [# TODO(jrobbins): dynamically display validation info as field type is edited.]
166 [is field_def.type_name "ENUM_TYPE"]
167 <tr>
168 <th>Choices:</th>
169 <td>
170 [if-any allow_edit]
171 <textarea name="choices" rows="10" cols="75" style="tab-size:18" [if-any allow_edit][else]disabled="disabled"[end]
172 >[initial_choices]</textarea>
173 [else]
174 <table cellspacing="4" cellpadding="0" style="padding: 2px; border:2px solid #eee">
175 [for field_def.choices]
176 <tr>
177 <td>[field_def.choices.name]</td>
178 <td>[if-any field_def.choices.docstring]= [end][field_def.choices.docstring]</td>
179 </tr>
180 [end]
181 </table>
182 [end]
183 </td>
184 </tr>
185 [end]
186
187 [is field_def.type_name "INT_TYPE"]
188 <tr id="int_row">
189 <th>Validation:</th>
190 <td>
191 Min value:
192 <input type="number" name="min_value" style="text-align:right; width: 4em"
193 value="[field_def.min_value]" class="acob"
194 [if-any allow_edit][else]disabled="disabled"[end]>
195
196 Max value:
197 <input type="number" name="max_value" style="text-align:right; width: 4em"
198 value="[field_def.max_value]" class="acob"
199 [if-any allow_edit][else]disabled="disabled"[end]>
200 <span class="fielderror" style="margin-left:1em">
201 [if-any errors.min_value][errors.min_value][end]</span><br>
202 </td>
203 </tr>
204 [end]
205
206 [is field_def.type_name "STR_TYPE"]
207 <tr id="str_row">
208 <th>Validation:</th>
209 <td>
210 Regex: <input type="text" name="regex" size="30" value="[field_def.regex]" class="acob"><br>
211 <span class="fielderror" style="margin-left:1em"
212 >[if-any errors.regex][errors.regex][end]</span>
213 </td>
214 </tr>
215 [end]
216
217 [is field_def.type_name "USER_TYPE"]
218 <tr id="user_row">
219 <th>Validation:</th>
220 <td>
221 <input type="checkbox" name="needs_member" id="needs_member" class="acob"
222 [if-any allow_edit][else]disabled="disabled"[end]
223 [if-any field_def.needs_member_bool]checked="checked"[end]>
224 <label for="needs_member">User must be a project member</label><br>
225 <span id="needs_perm_span" style="margin-left:1em">Required permission:
226 <input type="text" name="needs_perm" id="needs_perm" size="20"
227 value="[field_def.needs_perm]" autocomplete="off" class="acob"
228 [if-any allow_edit][else]disabled="disabled"[end]></span><br>
229 </td>
230 </tr>
231 <tr id="user_row2">
232 <th>Permissions:</th>
233 <td>
234 The users named in this field is granted this permission on this issue:<br>
235 [# TODO(jrobbins): one-click way to specify View vs. EditIssue vs. any custom perm.]
236 <input type="text" name="grants_perm" id="grants_perm" class="acob"
237 size="20" value="[field_def.grants_perm]" autocomplete="off"
238 [if-any allow_edit][else]disabled[end]>
239 </td>
240 </tr>
241 <tr id="user_row3">
242 <th>Notification:</th>
243 <td>
244 The users named in this field will be notified via email whenever:<br>
245 <select name="notify_on" [if-any allow_edit][else]disabled[end]
246 class="acrob">
247 <option value="never" [is field_def.notify_on "0"]selected="selected"[end]
248 >No notifications</option>
249 <option value="any_comment" [is field_def.notify_on "1"]selected="selected"[end]
250 >Any change or comment is added</option>
251 </select>
252 </td>
253 </tr>
254 [end]
255
256 [is field_def.type_name "DATE_TYPE"]
257 <tr id="date_row">
258 <th>Action:</th>
259 <td>
260 [if-any allow_edit]
261 <select name="date_action">
262 <option value="no_action" [is field_def.date_action_str "no_action"]selected="selected"[end]
263 >No action</option>
264 [# TODO(jrobbins): owner-only option.]
265 <option value="ping_participants" [is field_def.date_action_str "ping_participants"]selected="selected"[end]
266 >Post a comment and notify all issue participants</option>
267 </select>
268 [else]
269 [is field_def.date_action_str "no_action"]No action[end]
270 [# TODO(jrobbins): owner-only option.]
271 [is field_def.date_action_str "ping_participants"]Post a comment and notify all issue participants[end]
272 [end]
273 </td>
274 </tr>
275 [end]
276
277 [if-any field_def.is_approval_subfield]
278 <tr>
279 <th>Parent Approval:</th>
280 <td>
281 <a href="/p/[projectname]/fields/detail?field=[field_def.parent_approval_name]">
282 [field_def.parent_approval_name]
283 </a>
284 </td>
285 </tr>
286 [end]
287
288 <th>Admins:</th>
289 <td>
290 [if-any allow_edit]
291 <input id="member_admins" name="admin_names" size="75" value="[initial_admins]"
292 autocomplete="off" class="acob">
293 <span class="fielderror" style="margin-left:1em">
294 [if-any errors.field_admins][errors.field_admins][end]
295 </span>
296 [else]
297 [for field_def.admins]
298 <div>[include "../framework/user-link.ezt" field_def.admins]</div>
299 [end]
300 [end]
301 </td>
302 </tr>
303
304 [is field_def.type_name "APPROVAL_TYPE"][else]
305
306 <tr id="editors_restriction">
307 <th>Restriction
308 <i id="editors_tooltip" class="material-icons inline-icon" style="font-size:14px; vertical-align: text-bottom"
309 title="Project owners and field admins can always edit the values of a custom field.">
310 info_outline</i> :
311 </th>
312 <td style="display:flex; align-items:center">
313 [if-any allow_edit]
314 <input id="editors_checkbox" type="checkbox" name="is_restricted_field" class="acob"
315 [if-any field_def.is_restricted_field]checked="checked"[end]>
316 Restrict users that can edit values of this custom field.
317 [else]
318 [if-any field_def.is_restricted_field]Yes[else]No[end]
319 [end]
320 </td>
321 </tr>
322 <tr id="editors_input"
323 [if-any field_def.is_restricted_field][else]style="display:none"[end]>
324 <th>Editors:</th>
325 <td>
326 [if-any allow_edit]
327 <input id="member_editors" name="editor_names" size="75" value="[initial_editors]"
328 autocomplete="off" class="acob"
329 [if-any field_def.is_restricted_field][else]disabled[end]>
330 <span class="fielderror" style="margin-left:1em">
331 [if-any errors.field_editors][errors.field_editors][end]
332 </span>
333 [else]
334 [for field_def.editors]
335 <div>[include "../framework/user-link.ezt" field_def.editors]</div>
336 [end]
337 [end]
338 </td>
339 </tr>
340
341 [end]
342
343 <tr>
344 <td></td>
345 <td>
346 [if-any allow_edit]
347 <input type="submit" name="submit" value="Save changes">
348 <input type="submit" class="secondary" name="deletefield" value="Delete Field"
349 id="deletefield">
350 [end]
351 </td>
352 </tr>
353
354</table>
355</form>
356
357
358<script type="text/javascript" nonce="[nonce]">
359runOnLoad(function() {
360 var needs_perm_span = document.getElementById('needs_perm_span');
361 var needs_perm = document.getElementById('needs_perm');
362 var needs_member = document.getElementById('needs_member');
363 function enableNeedsPerm(enable) {
364 needs_perm_span.style.color = enable ? 'inherit' : '#999';
365 needs_perm.disabled = enable ? '' : 'disabled';
366 if (!enable) needs_perm.value = '';
367 }
368 [if-any allow_edit]
369 if (needs_perm)
370 enableNeedsPerm(needs_member.checked);
371 [end]
372
373 if ($("deletefield")) {
374 $("deletefield").addEventListener("click", function(event) {
375 var msg = ("Are you sure you want to delete [field_def.field_name]?\n" +
376 "This operation cannot be undone. " +
377 "[if-any approval_subfields]\nAll subfields will also be deleted.[end]" +
378 "[is field_def.type_name "ENUM_TYPE"]\nEnum values will be retained on issues as labels.[end]");
379 if (!confirm(msg))
380 event.preventDefault();
381 });
382 }
383
384 [is field_def.type_name "APPROVAL_TYPE"][else]
385 //Enable editors input only when restricting the field.
386 document.getElementById('editors_checkbox').onchange = function() {
387 var member_editors = document.getElementById('member_editors');
388 var editors_input = document.getElementById('editors_input');
389 if (this.checked) {
390 editors_input.style.display = '';
391 } else {
392 editors_input.style.display = 'none';
393 }
394 member_editors.disabled = !this.checked;
395 };
396 [end]
397
398 var acobElements = document.getElementsByClassName("acob");
399 for (var i = 0; i < acobElements.length; ++i) {
400 var el = acobElements[[]i];
401 el.addEventListener("focus", function(event) {
402 _acrob(null);
403 _acof(event);
404 });
405 }
406
407 [is field_def.type_name "APPROVAL_TYPE"]
408 $('member_approvers').addEventListener("focus", function(event) {
409 _acof(event);
410 });
411 [end]
412
413 if ($("needs_member")) {
414 $("needs_member").addEventListener("change", function(event) {
415 enableNeedsPerm($("needs_member").checked);
416 });
417 }
418});
419</script>
420
421[include "../framework/footer.ezt"]