bloodhound-trac / trac / ticket / templates / ticket.html

<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns=""
      py:with="preview_mode = 'preview' in req.args">
  <xi:include href="layout.html" />

    <title py:choose="">
      <py:when test="ticket.exists">#${} (${ticket.summary})</py:when>
      <py:otherwise>New Ticket</py:otherwise>
    <script py:if="ticket.exists" type="text/javascript" src="${chrome.htdocs_location}js/threaded_comments.js"></script>
    <script type="text/javascript" py:choose="">
      jQuery(document).ready(function($) {
        $("div.description").find("h1,h2,h3,h4,h5,h6").addAnchor(_("Link to this section"));
        $(".foldable").enableFolding(false, true);
      <py:when test="ticket.exists">/*<![CDATA[*/
        $("#trac-up-attachments").click(function () {
          return true;

        /* only enable control elements for the currently selected action */
        var actions = $("#action input[name='action']");

        function updateActionFields() {
          actions.each(function () {

        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) {
              } else if (input.filter("input[type=checkbox]").length > 0) {
                input.val(field_value == "1" ? [field_value] : []);
              } else {
            } else { // Special case for CC checkbox
              input = $("#propertyform input[name=cc_update]").val([]);
            return false;

        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
          // Unthread, unrevert and update changelog
          if (!$('#trac-comments-oldest').checked())
          if ($('#trac-comments-only-toggle').attr('checked'))
            $('#trac-comments-only-toggle').click().attr('checked', true);
          // Show warning
          var new_changes = $("#changelog .trac-new");
          $("#trac-edit-warning").toggle(new_changes.length != 0);
          if (new_changes.length != 0)
          // 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;
          // Collapse property form if comment editor has focus
          if (show_preview && comment_focused)
        }, "#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");
        <py:if test="preview_mode">
        $("#propertyform").autoSubmit({preview: '1'}, function(data, reply) {
        }, "#ticket .trac-loading");
        <py:if test="not preview_mode">

    <py:def function="commentref(prefix, cnum, cls=None)">
      <a href="#comment:$cnum" class="$cls">$prefix$cnum</a>

    <div id="content" class="ticket"
         py:with="can_append = 'TICKET_APPEND' in perm(ticket.resource);
                  can_create = 'TICKET_CREATE' in perm(ticket.resource) and not ticket.exists;
                  can_modify = 'TICKET_CHGPROP' in perm(ticket.resource);
                  can_edit = 'TICKET_EDIT_DESCRIPTION' in perm(ticket.resource);
                  only_for_admin = 'TICKET_ADMIN' in perm(ticket.resource);
                  has_edit_comment = 'TICKET_EDIT_COMMENT' in perm(ticket.resource);
                  has_property_editor = not version and version != 0 and not cnum_edit
                                        and (can_append or can_modify or can_edit or can_create)">

      <h1 py:if="not ticket.exists">
        Create New Ticket <span py:if="preview_mode and ticket.type" class="status">(${ticket.type})</span>

      <py:if test="ticket.exists">
        <xi:include href="ticket_box.html" py:with="preview_mode = change_preview.fields"/>

        <!--! do not show attachments for old versions of this ticket or for new tickets -->
        <py:if test="not version and version != 0 and ticket.exists">
          <xi:include href="list_of_attachments.html"
                      py:with="alist = attachments; foldable = True"/>

        <div style="${'display: none' if not changes else None}">
          <div 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>
                <input id="trac-comments-only-toggle" type="checkbox" />
                <label for="trac-comments-only-toggle">Comments only</label>

          <h3 class="foldable">Change History <span class="trac-count">(${len(changes)})</span></h3>

          <div id="changelog">
            <py:for each="change in changes">
              <div class="change${' trac-new' if > start_time and 'attachment' not in change.fields else None}"
                   id="${'trac-change-%d-%d' % (change.cnum, to_utimestamp( if 'cnum' in change else None}">
                <xi:include href="ticket_change.html"/>
      <!--! End of the section we don't show on initial new tickets -->

      <form py:if="has_property_editor" method="post" id="propertyform"
            action="${href.ticket( + '#trac-add-comment' if ticket.exists
                      else href.newticket() + '#ticket'}">
        <!--! Add comment -->
        <div py:if="ticket.exists and can_append" id="trac-add-comment" class="field">
          <h3 class="foldable" id="edit">Add Comment</h3>
            <div id="trac-edit-warning" class="warning system-message"
                 style="${'display: none' if start_time == ticket['changetime'] else None}"
              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.
            <!--! Comment field -->
              <label for="comment" i18n:msg="">You may use
                <a tabindex="42" href="${'WikiFormatting')}">WikiFormatting</a>
              <textarea id="comment" name="comment" class="wikitext trac-resizable" rows="10" cols="78">

          <h3 py:if="ticket.exists" class="foldable">Modify Ticket</h3>
          <div id="modify">
            <!--! Properties -->
            <fieldset id="properties" py:if="can_modify or can_edit or can_create"
                      py:with="fields = [f for f in fields if not f.skip]">
              <legend py:choose="">
                  <py:when test="ticket.exists">Change Properties</py:when>
                <tr py:if="can_modify or can_create">
                  <th><label for="field-summary">Summary:</label></th>
                  <td class="fullrow" colspan="3">
                    <input type="text" id="field-summary" name="field_summary"
                           value="$ticket.summary" size="70" />
                <py:if test="only_for_admin">
                    <th><label for="field-reporter">Reporter:</label></th>
                    <td class="fullrow" colspan="3">
                      <input type="text" id="field-reporter" name="field_reporter"
                             value="${ticket.reporter}" size="70" />
                <py:if test="can_edit or can_create">
                    <th><label for="field-description">Description:</label></th>
                    <td class="fullrow" colspan="3">
                        <label for="field-description" id="field-description-help" i18n:msg="">You may use
                          <a tabindex="42" href="${'WikiFormatting')}">WikiFormatting</a> here.
                        <textarea id="field-description" name="field_description"
                                  class="wikitext trac-resizable" rows="10" cols="68">
                <tr py:for="row in group(fields, 2, lambda f: f.type != 'textarea')"
                    py:if="can_modify or can_create"
                    py:with="fullrow = len(row) == 1">
                  <py:for each="idx, field in enumerate(row)"
                          py:with="value = ticket.get_value_or_default(">
                    <th class="col${idx + 1}" py:if="idx == 0 or not fullrow">
                      <label for="field-${}" py:if="field"
                             py:strip="field.type == 'radio'" i18n:msg="field">${
                        field.edit_label or field.label or}:</label>
                    <td class="col${idx + 1}" py:if="idx == 0 or not fullrow"
                        colspan="${3 if fullrow else None}">
                      <py:choose test="field.type" py:if="field">
                        <select py:when="'select'" id="field-${}" name="field_${}">
                          <option py:if="field.optional"></option>
                          <option py:for="option in field.options"
                                  selected="${value == option or None}"
                                  value="$option" py:content="option"></option>
                          <optgroup py:for="optgroup in field.optgroups"
                            <option py:for="option in optgroup.options"
                                    selected="${value == option or None}"
                                    value="$option" py:content="option"></option>
                        <textarea py:when="'textarea'" id="field-${}" name="field_${}"
                                  cols="${field.width}" rows="${field.height}"
                                  class="${'wikitext ' if field.format == 'wiki' else None}trac-resizable">
                        <span py:when="'checkbox'">
                          <input type="checkbox" id="field-${}" name="field_${}"
                                 checked="${value == '1' or None}" value="1" />
                          <input type="hidden" name="field_checkbox_${}" value="1" />
                        <label py:when="'radio'"
                               py:for="idx, option in enumerate(field.options)">
                          <input type="radio" name="field_${}" value="${option}"
                                 checked="${value == option or None}" />
                        <py:otherwise><!--! Text input fields -->
                            <span py:when="field.cc_entry"><!--! Special case for Cc: field -->
                              <input type="checkbox" id="field-cc" name="cc_update"
                                title="This checkbox allows you to add or remove yourself from the CC list."
                                checked="${field.cc_update}" />
                            <!--! Cc: when TICKET_EDIT_CC is allowed -->
                            <span py:when=" == 'cc'">
                              <input  type="text" id="field-${}"
                                title="Space or comma delimited email addresses and usernames are accepted."
                                name="field_${}" value="${value}" />
                            <!--! All the other text input fields -->
                            <input py:otherwise="" type="text" id="field-${}"
                              name="field_${}" value="${value}" />

            <!--! Workflow support -->
            <py:if test="ticket.exists"> <!--! do not display the actions for New tickets -->
                <fieldset py:when="can_append or can_modify" id="action">
                  <div py:for="key, label, controls, hints in action_controls">
                      <input type="radio" id="action_$key" name="action" value="$key"
                             checked="${key == action or None}" />
                      <label for="action_$key">$label</label>
                      <span class="hint" py:for="hint in hints">$hint</span>
                  <py:for each="key, label, controls, hints in action_controls">
                    <input py:if="key == action" type="hidden" name="action" value="$action" />

        <!--! Preview of ticket changes -->
        <div py:if="ticket.exists and can_append" id="ticketchange" class="ticketdraft"
             style="${'display: none' if not (change_preview.fields or change_preview.comment)
                                         or cnum_edit is not None else None}">
          <xi:include href="ticket_change.html" py:with="change = change_preview; preview = True"/>

        <!--! Author or Reporter -->
        <div py:if="authname == 'anonymous'" class="field">
          <fieldset py:choose="">
            <legend py:when="ticket.exists">Author</legend>
            <legend py:otherwise="">Reporter</legend>
                  <label for="author">Your email or username:</label><br />
                  <input type="text" id="author" name="author" size="40" value="$author_id" />
                  <br />
            <p py:if="author_id == 'anonymous'" class="hint">
              <i18n:msg>E-mail address and user name can be saved in the <a href="${href.prefs()}">Preferences</a>.</i18n:msg>

        <!--! Attachment on creation checkbox -->
        <p py:if="not ticket.exists and 'ATTACHMENT_CREATE' in perm(ticket.resource.child('attachment'))">
            <input type="checkbox" name="attachment" checked="${'attachment' in req.args or None}" />
            I have files to attach to this ticket

        <div py:if="ticket.exists" class="trac-nav">
          <a href="#attachments" id="trac-up-attachments" title="Go to the list of attachments">Attachments</a> &uarr;
        <div class="buttons">
          <py:if test="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}" />
          <input type="submit" name="preview" value="${_('Preview')}" accesskey="r" />&nbsp;
          <input type="submit" name="submit" value="${_('Submit changes') if ticket.exists else _('Create ticket')}" />


      <xi:include href="ticket_box.html" py:if="not ticket.exists"
                  py:with="hide = not preview_mode; preview_mode = True"/>

      <div id="help" i18n:msg="">
        <strong>Note:</strong> See
        <a href="${'TracTickets')}">TracTickets</a> for help on using