forked from edgewall/trac
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jticket.html
627 lines (569 loc) · 24.6 KB
/
jticket.html
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
{# Copyright (C) 2007-2014 Edgewall Software
This software is licensed as described in the file COPYING, which
you should have received as part of this distribution. The terms
are also available at http://trac.edgewall.com/license.html.
This software consists of voluntary contributions made by many
individuals. For the exact contribution history, see the revision
history and logs, available at http://trac.edgewall.org/.
#}
# extends "jlayout.html"
<!DOCTYPE html>
<html>
<head>
<title>
# block title
# if ticket.exists:
${'#'}${ticket.id} (${ticket.summary})
# else:
${_("New Ticket")}
# endif
${ super() }
# endblock title
</title>
# block head
${ super() }
# if ticket.exists:
<script type="text/javascript"
src="${chrome.htdocs_location}js/threaded_comments.js"></script>
# endif
<script type="text/javascript">
jQuery(document).ready(function($) {
$("div.description").find("h1,h2,h3,h4,h5,h6")
.addAnchor(j_("Link to this section"));
$(".foldable").enableFolding(false, true);
# if ticket.exists:
/*<![CDATA[*/
$("#attachments").toggleClass("collapsed");
$("#trac-up-attachments").click(function () {
$("#attachments").removeClass("collapsed");
return true;
});
$("#modify").parent().toggleClass("collapsed");
$(".trac-topnav a").click(function() {
$("#modify").parent().removeClass("collapsed");
});
function setRevertHandler() {
$("button.trac-revert").click(function() {
var div = $("div", this);
var field_name = div[0].id.substr(7);
var field_value = div.text();
var input = $("#propertyform *[name=field_" + field_name + "]");
if (input.length > 0) {
if (input.filter("input[type=radio]").length > 0) {
input.val([field_value]);
} else if (input.filter("input[type=checkbox]").length > 0) {
input.val(field_value == "1" ? [field_value] : []);
} else {
input.val(field_value);
}
} else { // Special case for CC checkbox
input = $("#propertyform input[name=cc_update]").val([]);
}
input.change();
// Remove the revert button
if ($(this).closest("tbody").children("tr").length === 1)
$(this).closest(".trac-change-panel").remove();
else
$(this).closest("tr").remove();
return false;
});
}
setRevertHandler();
var comment_focused = false;
$("#comment").focus(function() { comment_focused = true; })
.blur(function() { comment_focused = false; });
$("#propertyform").autoSubmit({preview: '1'}, function(data, reply) {
var items = $(reply);
// Update ticket box
$("#ticket").replaceWith(items.filter('#ticket'));
// Replaces content of #changelog, without recreating it
$("#changelog").empty().append(items.filter("#changelog").contents());
// Apply comments order and "Show" preferences
applyCommentsOrder(
$('#prefs input[name="trac-comments-order"]:checked').val());
// Show warning
var new_changes = $("#changelog .trac-new");
$("#trac-edit-warning").toggle(new_changes.length != 0);
if (new_changes.length != 0)
$("#changelog").parent().show().removeClass("collapsed");
// Update view time
$("#propertyform input[name='view_time']")
.replaceWith(items.filter("input[name='view_time']"));
// Update preview
var preview = $("#ticketchange")
.html(items.filter('#preview').children());
var show_preview = preview.children().length != 0;
$("#ticketchange").toggle(show_preview);
setRevertHandler();
// Execute scripts to load stylesheets
items.filter("script").appendTo("head");
}, "#ticketchange .trac-loading");
$("#trac-comment-editor")
.autoSubmit({preview_comment: '1'}, function(data, reply) {
var comment = $("#trac-comment-editor")
.next("div.comment").html(reply);
comment.toggle(comment.children().length != 0);
}, "#changelog .trac-loading");
/*]]>*/
# else:
$("#propertyform").autoSubmit({preview: '1'}, function(data, reply) {
$('#ticket').replaceWith(reply);
}, "#ticket .trac-loading");
# endif
});
</script>
# endblock head
</head>
<body>
<p>
# macro commentref(prefix, cnum, cls=none)
<a href="#comment:${cnum}" class="${cls}">${prefix}${cnum}</a>
# endmacro
</p>
# block content
<div id="content" class="ticket">
# set preview_mode = 'preview' in req.args
# set can_append = 'TICKET_APPEND' in perm(ticket.resource)
# set can_create = ('TICKET_CREATE' in perm(ticket.resource) and
not ticket.exists)
# set can_modify = 'TICKET_CHGPROP' in perm(ticket.resource)
# set can_edit = 'TICKET_EDIT_DESCRIPTION' in perm(ticket.resource)
# set only_for_admin = 'TICKET_ADMIN' in perm(ticket.resource)
# set has_edit_comment = 'TICKET_EDIT_COMMENT' in perm(ticket.resource)
# set has_property_editor = (
not version and version != 0 and not cnum_edit and
(can_append or can_modify or can_edit or can_create))
# if (ticket.exists or preview_mode) and has_property_editor:
<div class="trac-topnav">
<a href="#modify" title="${_("Go to the ticket editor")}">${
_("Modify")}</a> ↓
</div>
# endif
# if not ticket.exists:
<h1>${_("Create New Ticket")}
# if preview_mode and ticket.type:
<span class="status">(${ticket.type})</span>
# endif
</h1>
# endif
# if ticket.exists:
# with preview_mode = change_preview.fields
# include "jticket_box.html"
# endwith
## # Do not show attachments for old versions of this ticket
## # or for new tickets.
# if not version and version != 0 and ticket.exists:
# with alist = attachments, foldable = True
# include "jlist_of_attachments.html"
# endwith
# endif
<div${{'style': 'display: none' if not changes}|htmlattr}>
<div class="trac-noscript" style="position: relative">
<form id="prefs" method="get" action="${href.prefs()}"
style="position: absolute; right: 0">
<div id="trac-comments-order">
<input type="radio" id="trac-comments-oldest"
name="trac-comments-order" value="oldest"
checked="checked" />
<label for="trac-comments-oldest">${_("Oldest first")}</label>
<input type="radio" id="trac-comments-newest"
name="trac-comments-order" value="newest" />
<label for="trac-comments-newest">${_("Newest first")}</label>
<span id="trac-threaded-toggle" style="display: none">
<input type="radio" id="trac-comments-threaded"
name="trac-comments-order" value="threaded" />
<label for="trac-comments-threaded">${_("Threaded")}</label>
</span>
</div>
<div>
<input id="trac-show-comments-toggle" type="checkbox"
checked="checked" />
<label for="trac-show-comments-toggle">${
_("Show comments")}</label>
<input id="trac-show-property-changes-toggle" type="checkbox" />
<label for="trac-show-property-changes-toggle">
${_("Show property changes")}</label>
</div>
</form>
</div>
<h3 class="foldable">
${_("Change History")}
<span class="trac-count">(${len(changes)})</span></h3>
<div id="changelog">
# for change in changes:
<div class="${classes('change',
'trac-new' if change.date is greaterthan(start_time) and
'attachment' not in change.fields)}"
id="${'trac-change-%d-%d' % (
change.cnum,
to_utimestamp(change.date)) if 'cnum' in change}">
# include "jticket_change.html"
</div>
# endfor
</div>
</div>
# endif
## end of the section we don't show for initial new tickets
# if has_property_editor:
<form method="post" id="propertyform"
action="${href.ticket(ticket.id) + '#trac-add-comment' if
ticket.exists else href.newticket() + '#ticket'}">
${jmacros.form_token_input()}
<div>
# if ticket.exists:
<h3 class="foldable">Modify Ticket</h3>
# endif
<div id="modify">
## Properties
# if can_modify or can_edit or can_create:
<fieldset id="properties">
# with fields = fields|rejectattr('skip')|selectattr('editable')
<legend>
# if ticket.exists:
${_("Change Properties")}
# else:
${_("Properties")}
# endif
</legend>
<table class="trac-properties">
<col class="th" /><col class="td" />
<col class="th" /><col class="td" />
# if can_modify or can_create:
<tr>
<th><label for="field-summary">${_("Summary:")}</label></th>
<td class="fullrow" colspan="3">
<input type="text" id="field-summary" name="field_summary"${
{'class': 'trac-autofocus' if not ticket.exists and
not preview_mode,
'value': ticket.summary or ''
}|htmlattr}/>
</td>
</tr>
# endif
## Reporter field
# if only_for_admin or (not ticket.exists and authname == 'anonymous'):
<tr>
<th>
<label for="field-reporter">
# if only_for_admin:
${_("Reporter:")}
# else:
${_("Your email or username:")}
# endif
</label>
</th>
<td class="fullrow" colspan="3">
<input type="text" id="field-reporter" name="field_reporter"
value="${ticket.reporter}" />
# if not only_for_admin and ticket.reporter == 'anonymous':
<p class="hint">
# set preferences
<a href="${href.prefs()}" class="trac-target-new">${
_("Preferences")}</a>
# endset
# trans prefs = preferences
E-mail address and name can be saved in the ${prefs}
# endtrans
</p>
# endif
</td>
</tr>
# endif
# if can_edit or can_create:
<tr>
<th class="trac-textarea"><label for="field-description">${
_("Description:")}</label></th>
<td class="fullrow" colspan="3">
<fieldset>
<label for="field-description"
id="field-description-help">
# trans href = href.wiki('WikiFormatting')
You may use <a tabindex="42"
href="${href}">WikiFormatting</a> here.
# endtrans
</label>
<textarea id="field-description"
name="field_description"
class="wikitext trac-fullwidth trac-resizable"
rows="10" cols="68">${
ticket.description}</textarea>
</fieldset>
</td>
</tr>
# endif
# if can_modify or can_create:
# for row in fields|groupattr(2, 'type', 'not_equalto', 'textarea'):
<tr>
# set fullrow = len(row) == 1
# for field in row:
# set value = (ticket[field.name] if ticket.exists else
ticket.get_value_or_default(field.name))
# if loop.first or not fullrow:
<th class="${classes('col%d' % loop.index,
'trac-textarea' if field.type == 'textarea')}">
# if field:
# set label = (field.edit_label or field.label or
field.name)
# if field.type == 'radio':
${_("%(label)s:", label=label)}
# else:
<label for="field-${field.name}">${
_("%(label)s:", label=label)}</label>
# endif
# endif
</th>
# endif
# if loop.first or not fullrow:
<td class="${classes('col%d' % loop.index,
fullrow=fullrow)}"${
{'colspan': 3 if fullrow}|htmlattr}>
# if field:
# if field.type == 'select':
<select id="field-${field.name}"
name="field_${field.name}">
# if field.optional:
<option></option>
# endif
# for option in field.options:
<option${{'selected': value == option,
'value': option
}|htmlattr}>${option}</option>
# endfor
# for optgroup in field.optgroups:
# if optgroup.options:
<optgroup label="${optgroup.label}">
# for option in optgroup.options:
<option${{'selected': value == option,
'value': option
}|htmlattr}>${option}</option>
# endfor
</optgroup>
# endif
# endfor
</select>
# elif field.type == 'textarea':
<textarea id="field-${field.name}"
name="field_${field.name}"
class="${classes('trac-resizable',
wikitext=field.format == 'wiki')}"
cols="60" rows="${field.height}"
>{# jinjacheck: "ID field- already defined" OK #}${
value}</textarea>
# elif field.type == 'checkbox':
<span>
<input type="checkbox" id="field-${field.name}"
name="field_${field.name}" value="1"${
{'checked': value == '1'}|htmlattr}/>
## jinjacheck: "ID field- already defined" OK
<input type="hidden" name="field_checkbox_${field.name}"
value="1" />
</span>
# elif field.type == 'radio':
# for option in field.options:
<label>
<input type="radio" name="field_${field.name}"${
{'checked': value == option,
'value': option
}|htmlattr}/>
${option}
</label>
# endfor
# elif field.type == 'time':
<input type="text" id="field-${field.name}"
title="${field.format_hint}"
name="field_${field.name}" value="${field.edit}"
class="trac-${'date' if field.format == 'date' else
'datetime'}picker"/>
## jinjacheck: "ID field- already defined" OK
# else:
## # Special case for Cc: field
# if field.name == 'cc':
<span>
## # Unauthenticated user without TICKET_EDIT_CC
## # and with email set in prefs
# if 'cc_entry' in field:
# if field.cc_action is none:
<em>
# set preferences_link
<a href="${href.prefs()}" class="trac-target-new">${
_("Preferences")}</a>
# endset
${tag_("Set your email in %(preferences_link)s",
preferences_link=preferences_link|safe)}
</em>
# else:
<label for="field-cc"><em>${field.cc_entry}</em></label>
<input type="checkbox" id="field-cc" name="cc_update"${
{'title': _("This checkbox allows you to add or
remove yourself from the CC list."),
'disabled': field.cc_action is none,
'checked': field.cc_update
}|htmlattr} />
# endif
# elif field.cc_action is none:
## # Unauthenticated user without TICKET_EDIT_CC
## # and no email set in prefs
# else:
## # TICKET_EDIT_CC is allowed
<input type="text" id="field-${field.name}"
title="${_("Space or comma delimited email
addresses and usernames are
accepted.")}"
name="field_${field.name}"
value="${value}"/>
## jinjacheck: "ID field- already defined" OK
# endif
</span>
# else:
## # All the other text input fields
<input type="text" id="field-${field.name}"
name="field_${field.name}"${
{'value': value}|htmlattr}/>
## jinjacheck: "ID field- already defined" OK
# endif
# endif
# endif
</td>
# endif
# endfor
</tr> {# jinjacheck: "CDATA" OK #}
# endfor
# endif
</table>
# endwith
</fieldset>
# endif
## Workflow support
# with hidden = not can_append
# include "jticket_workflow.html"
# endwith
</div>
</div>
## Add comment
# if ticket.exists and can_append:
<div id="trac-add-comment"
class="${classes('field', 'trac-scroll' if preview_mode)}">
<h3 class="foldable" id="edit">${_("Add Comment")}</h3>
<div>
<div id="trac-edit-warning" class="warning system-message" ${
{'style': 'display: none;' if start_time == ticket['changetime']
}|htmlattr}>
# trans
This ticket has been modified since you started
editing. You should review the
<em class="trac-new">other modifications</em> which have
been appended above, and
any <em class="trac-conflict">conflicts</em> shown in
the preview below. You can nevertheless proceed and
submit your changes if you wish so.
# endtrans
</div>
## Comment field
<fieldset>
# if authname == 'anonymous':
<div class="author">
<table class="trac-properties">
<tr>
<th>
<label for="author">${
_("Your email or username:")}</label><br />
</th>
<td>
<input type="text" id="author" name="author"
value="${author_id}" />
</td>
</tr>
</table>
# if author_id == 'anonymous':
<p class="hint">
# trans href = href.prefs()
E-mail address and name can be saved in the
<a href="${href}" class="trac-target-new">Preferences</a>.
# endtrans
</p>
# endif
</div>
# endif
<label for="comment">
# trans href = href.wiki('WikiFormatting')
You may use <a tabindex="42" href="${href}">WikiFormatting</a>
here.
# endtrans
</label>
<textarea id="comment" name="comment"
class="${classes('wikitext', 'trac-fullwidth',
'trac-resizable',
'trac-autofocus' if replyto)}"
rows="10" cols="78">${
comment}</textarea>
</fieldset>
</div>
</div>
# endif
## Attachment on creation checkbox
# if not ticket.exists and ('ATTACHMENT_CREATE' in perm(ticket.resource.child('attachment'))):
<p>
<label>
<input type="checkbox" name="attachment"${
{'checked': 'attachment' in req.args}|htmlattr}/>
# trans
I have files to attach to this ticket
# endtrans
</label>
</p>
# endif
# if ticket.exists:
<div class="trac-nav">
<a href="#attachments" id="trac-up-attachments"
title="${_("Go to the list of attachments")}">${
_("Attachments")}</a> ↑
<a href="#content" id="trac-up-view"
title="${_("View the ticket description")}">${
_("Description")}</a> ↑
</div>
# endif
<div class="buttons">
# if ticket.exists:
<input type="hidden" name="start_time"
value="${to_utimestamp(start_time)}" />
<input type="hidden" name="view_time"
value="${to_utimestamp(ticket['changetime'])}" />
<input type="hidden" name="replyto"${{'value': replyto}|htmlattr}/>
# endif
<input type="submit" name="preview" value="${_('Preview')}"
${accesskey("r")}/>
<input type="submit" name="submit"
value="${_('Submit changes') if ticket.exists else
_('Create ticket')}"
class="trac-disable-on-submit" />
</div>
## Preview of ticket changes
# if ticket.exists and can_append:
<div id="ticketchange" class="ticketdraft"${
{'style': 'display: none' if not
(change_preview.fields or change_preview.comment) or
cnum_edit is not none
}|htmlattr}>
# with change = change_preview, preview = True
# include "jticket_change.html"
# endwith
</div>
# endif
</form>
# endif
# if not ticket.exists:
# with hide = not preview_mode, preview_mode = true
# include "jticket_box.html"
# endwith
# endif
<div id="help">
# trans href = href.wiki('TracTickets')
<strong>Note:</strong> See
<a href="${href}">TracTickets</a> for help on using tickets.
# endtrans
</div>
</div>
${ super() }
# endblock content
</body>
</html>