Edgewall Software

Ticket #454: ticket-edit-minor-fixes-r8561.diff

File ticket-edit-minor-fixes-r8561.diff, 7.6 KB (added by cboos, 2 years ago)

several minor enhancements on top of r8538, take 2

  • trac/htdocs/css/ticket.css

    #454: a few minor enhancements
     - cosmetic changes for the comment editor, which is now aligned with the preview and other comments
     - don't show the ''Add comment'' and regular field modification form when editing a comment
     - add a helper `comment_is_edited` variable in the template
    
    diff --git a/trac/htdocs/css/ticket.css b/trac/htdocs/css/ticket.css
    a b  
    7373 float: right; 
    7474 position: relative; 
    7575 bottom: 0.3em; 
     76 margin-left: 0.2em; 
    7677} 
    7778 
    7879#changelog { border: 1px outset #996; padding: 1em } 
    79 #trac-edited_comment { margin-left: -1px; margin-right: -1px; width: 100% } 
    80 #changelog .wikitoolbar { margin-left: -1px } 
     80#trac-comment-editor { margin-left: 2em; } 
    8181#preview { border: 1px solid #d7d7d7; padding: 1em } 
    8282#preview h3, #changelog h3 { 
    8383 border-bottom: 1px solid #d7d7d7; 
     
    8585 font-size: 100%; 
    8686 font-weight: normal; 
    8787} 
    88 .threading, #changelog .inlinebuttons { float: right; } 
     88.threading, #changelog .inlinebuttons {  
     89 float: right; 
     90 margin-left: 0.2em; 
     91} 
    8992.threading { font-size: 85%; } 
    9093 
    9194#preview .changes, #changelog .changes { list-style: square; margin-left: 2em; padding: 0 } 
  • trac/ticket/templates/ticket.html

    diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.html
    a b  
    4949    </py:def> 
    5050 
    5151    <py:def function="display_change(change)"> 
    52       <ul py:if="change.fields" class="changes"> 
    53         <li py:for="field_name, field in change.fields.items()"> 
    54           <strong>${field_labels[field_name]}</strong> 
    55           <py:choose> 
    56             <py:when test="field_name == 'attachment'"> 
    57               <a href="${href.attachment('ticket', ticket.id, field.new)}"><em>${field.new}</em></a>  
    58               <a href="${href('raw-attachment', 'ticket', ticket.id, field.new)}" 
    59                  title="${_('Download')}" class="trac-rawlink"><img src="${chrome.htdocs_location}download.png" alt="${_('Download')}"/></a>  
    60               added 
    61             </py:when> 
    62             <py:when test="'rendered' in field">${field.rendered}</py:when> 
    63             <py:when test="field.old and field.new"> 
    64               changed from <em>${field.old}</em> to <em>${field.new}</em> 
    65             </py:when> 
    66             <py:when test="not field.old and field.new"> 
    67               set to <em>${field.new}</em> 
    68             </py:when> 
    69             <py:otherwise> 
    70               <em>${field.old}</em> deleted 
    71             </py:otherwise> 
    72           </py:choose> 
    73         </li> 
    74       </ul> 
    75       <div py:if="'comment' in change and (str(change.cnum) != cnum_edit or edited_comment is not None)" 
    76            class="comment searchable ${str(change.cnum) == cnum_edit and 'ticketdraft' or None}" xml:space="preserve"> 
    77         ${wiki_to_html(context, [change.comment, edited_comment][str(change.cnum) == cnum_edit], escape_newlines=preserve_newlines)} 
    78       </div> 
     52      <py:with vars="comment_is_edited = str(change.cnum) == cnum_edit"> 
     53        <ul py:if="change.fields" class="changes"> 
     54          <li py:for="field_name, field in change.fields.items()"> 
     55            <strong>${field_labels[field_name]}</strong> 
     56            <py:choose> 
     57              <py:when test="field_name == 'attachment'"> 
     58                <a href="${href.attachment('ticket', ticket.id, field.new)}"><em>${field.new}</em></a>  
     59                <a href="${href('raw-attachment', 'ticket', ticket.id, field.new)}" 
     60                   title="${_('Download')}" class="trac-rawlink"><img src="${chrome.htdocs_location}download.png" alt="${_('Download')}"/></a>  
     61                added 
     62              </py:when> 
     63              <py:when test="'rendered' in field">${field.rendered}</py:when> 
     64              <py:when test="field.old and field.new"> 
     65                changed from <em>${field.old}</em> to <em>${field.new}</em> 
     66              </py:when> 
     67              <py:when test="not field.old and field.new"> 
     68                set to <em>${field.new}</em> 
     69              </py:when> 
     70              <py:otherwise> 
     71                <em>${field.old}</em> deleted 
     72              </py:otherwise> 
     73            </py:choose> 
     74          </li> 
     75        </ul> 
     76        <div py:if="'comment' in change and (not comment_is_edited or edited_comment is not None)" 
     77             class="comment searchable ${comment_is_edited and 'ticketdraft' or None}" xml:space="preserve"> 
     78          ${wiki_to_html(context, (change.comment, edited_comment)[comment_is_edited], escape_newlines=preserve_newlines)} 
     79        </div> 
     80      </py:with> 
    7981    </py:def> 
    8082 
    8183    <div id="content" class="ticket"  
     
    216218          <h2>Change History</h2> 
    217219          <div id="changelog"> 
    218220            <py:for each="change in changes"> 
    219               <div class="change"> 
     221              <div class="change" py:with="comment_is_edited = str(change.cnum) == cnum_edit"> 
    220222                <h3 class="change"> 
    221223                  <span class="threading" py:if="'cnum' in change" 
    222224                        py:with="change_replies = replies.get(str(change.cnum), [])"> 
     
    234236                  </span> 
    235237                  <i18n:msg params="date, author">Changed ${dateinfo(change.date)} ago by ${authorinfo(change.author)}</i18n:msg> 
    236238                </h3> 
    237                 <div py:if="not (can_edit_comment and str(change.cnum) == cnum_edit)" class="inlinebuttons"> 
     239                <div py:if="not (can_edit_comment and comment_is_edited)" class="inlinebuttons"> 
    238240                  <form py:if="'cnum' in change and can_append"  
    239241                        method="get" action="#comment" class="inlinebuttons"> 
    240242                    <div> 
     
    251253                  </form>               
    252254                </div> 
    253255                ${display_change(change)} 
    254                 <form py:if="can_edit_comment and str(change.cnum) == cnum_edit" method="post" action="#comment:${change.cnum}"> 
     256                <form id="trac-comment-editor" py:if="can_edit_comment and comment_is_edited" method="post" action="#comment:${change.cnum}"> 
    255257                  <div> 
    256                     <textarea id="trac-edited_comment" name="edited_comment" class="wikitext" rows="10" cols="78"> 
     258                    <textarea name="edited_comment" class="wikitext" rows="10" cols="78"> 
    257259${[edited_comment, change.comment][edited_comment is None]}</textarea> 
    258260                    <input type="hidden" name="cnum_edit" value="${change.cnum}"/> 
    259                     <input type="submit" name="preview_comment" value="${_('Preview')}" title='Preview changes to comment ${change.cnum}'/> 
     261                    <input type="submit" name="preview_comment" value="${_('Preview')}" title="Preview changes to comment ${change.cnum}"/> 
    260262                    <input type="submit" name="edit_comment" value="${_('Submit changes')}" title="Submit changes to comment ${change.cnum}"/> 
    261263                    <input type="submit" name="cancel_comment" value="${_('Cancel')}" title="Cancel comment edit"/> 
    262264                  </div> 
     
    268270      </py:if> 
    269271      <!--! End of the section we don't show on initial new tickets --> 
    270272 
    271       <form py:if="not version and version != 0 and (can_append or can_modify or can_edit or can_create)" 
     273      <form py:if="not version and version != 0 and not cnum_edit and (can_append or can_modify or can_edit or can_create)" 
    272274            action="${ticket.exists and href.ticket(ticket.id) or href.newticket()}" method="post" id="propertyform"> 
    273275        <h3 py:if="ticket.exists"><a id="edit" onfocus="$('#comment').get(0).focus()"> 
    274276            Add/Change #${ticket.id} ($ticket.summary)</a></h3>