{# Copyright (C) 2010-2021 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 https://trac.edgewall.org/wiki/TracLicense.

  This software consists of voluntary contributions made by many
  individuals. For the exact contribution history, see the revision
  history and logs, available at https://trac.edgewall.org/.
#}

# extends 'layout.html'

<!DOCTYPE html>
<html>
  <head>
    <title>
      # block title
      #   if action == 'delete':
      #     trans id = ticket.id

      Delete Ticket #${id}

      #     endtrans
      #   else:
      #     trans num = cnum, id = ticket.id

      Delete comment ${num} on Ticket #${id}

      #     endtrans
      #   endif
      ${ super() }
      # endblock title
    </title>
  </head>

  <body>
    # block content
    <div id="content" class="ticket">
      # if action == 'delete':
      <h1>
        # set ticket_link
        <a href="${href.ticket(ticket.id)}">${
          _("Ticket #%(id)s", id=ticket.id)}</a>
        # endset
        # trans ticket = ticket_link

        Delete ${ticket}

        # endtrans
        <span class="status">(${ticket.status}{%
          if ticket.type %} ${ticket.type}{% endif %}{%
          if ticket.resolution %}: ${ticket.resolution}{% endif %})</span>
      </h1>

      #   with
      #     set can_append = false
      #     set preview_mode = false
      #     include 'ticket_box.html'
      #   endwith

      <form id="delete-confirm" action="" method="post">
        <div>
          ${jmacros.form_token_input()}
          <input type="hidden" name="action" value="delete"/>
          <p>
            <strong>
              ${_("Are you sure you want to delete this ticket?")}
            </strong>
            # with
            #   set comments = changes|selectattr('cnum')|list|count
            #   set attachments = changes|rejectattr('cnum')|list|count
            #   trans comments, attachments

              (comments: ${comments}, attachments: ${attachments})

            #   endtrans
            # endwith
            <br/>
          </p>
          # if attachments:
          <p>${_("The following attachments will also be deleted:")}</p>
          <ul>
            # for attachment in attachments:
            <li>
              <a href="${url_of(attachment.resource)}"
                 title="${_('View attachment')}">${attachment.filename}</a>
            </li>
            # endfor
          </ul>
          # endif
          <p><strong>${_("This is an irreversible operation.")}</strong></p>
        </div>
        <div class="buttons">
          <input type="submit" class="trac-disable-on-submit"
                 value="${_('Delete ticket')}"/>
          <input type="submit" name="cancel" value="${_('Cancel')}"/>
        </div>
      </form>

      # else:
      <h1>${_("Delete comment %(num)s on Ticket #%(id)s",
              num=cnum, id=ticket.id)}</h1>

        <div id="changelog">
          <div class="change">
            # with hide_buttons = true
            #   include 'ticket_change.html'
            # endwith
          </div>
        </div>

        <form id="edit" action="" method="post">
          <div>
            ${jmacros.form_token_input()}
            <input type="hidden" name="action" value="delete-comment"/>
            <input type="hidden" name="cnum" value="${cnum}"/>
            <input type="hidden" name="cdate" value="${cdate}"/>
            <p><strong>
                ${_("Are you sure you want to delete this ticket comment?")}
            </strong></p>
            <p><strong>${_("This is an irreversible operation.")}</strong></p>
          </div>
          <div class="buttons">
            <input type="submit" class="trac-disable-on-submit"
                   value="${_('Delete comment')}"/>
            <input type="submit" name="cancel" value="${_('Cancel')}"/>
          </div>
        </form>
        # endif
    </div>
    ${ super() }
    # endblock content
  </body>
</html>
