# HG changeset patch
# Parent 9ce137a90d5f972acba25d56cbb7e65b1132e3c8
#7145: a few follow-ups to attachment:7145-concurrent-editing-2-r10647.patch

 - correctly handle conflict reporting for the first comment
 - simplify switching off threaded mode
 - change the wording and the presentation of the //other modifications// notification
 - move the //Author or Reporter// block below the preview

diff -r 9ce137a90d5f trac/htdocs/css/ticket.css
--- a/trac/htdocs/css/ticket.css	Wed Mar 23 12:01:41 2011 +0100
+++ b/trac/htdocs/css/ticket.css	Wed Mar 23 17:01:14 2011 +0100
@@ -110,7 +110,7 @@ div.comment ol { list-style: decimal }
 }
 #trac-comment-editor .wikitoolbar { margin-left: -1px }
 #trac-add-comment :link, #trac-add-comment :visited { color: #b00 }
-#changelog .trac-new { border-left: 0.3em solid #c0f0c0; padding-left: 0.3em; }
+.trac-new { border-left: 0.31em solid #c0f0c0; padding-left: 0.31em; }
 #changelog h3, #ticketchange h3 {
  border-bottom: 1px solid #d7d7d7;
  color: #999;
@@ -138,7 +138,6 @@ form .field .wikitoolbar { margin-left: 
 form .field div.trac-resizable { width: 100% }
 
 #propertyform { margin-bottom: 2em; }
-#trac-edit-warning .trac-new { background-color: #c0f0c0; }
 #properties { white-space: nowrap; line-height: 160%; padding: .5em }
 #properties table { border-spacing: 0; width: 100%; padding: 0 .5em }
 #properties table th {
diff -r 9ce137a90d5f trac/htdocs/js/threaded_comments.js
--- a/trac/htdocs/js/threaded_comments.js	Wed Mar 23 12:01:41 2011 +0100
+++ b/trac/htdocs/js/threaded_comments.js	Wed Mar 23 17:01:14 2011 +0100
@@ -2,7 +2,8 @@ jQuery(document).ready(function($){
   var comments = null;
   var toggle = $('#trac-threaded-toggle');
   toggle.click(function() {
-    if ($(this).checked()) {
+    $(this).toggleClass('checked');
+    if ($(this).hasClass('checked')) {
       comments = $("div.change");
       comments.each(function() {
         var children = $("a.follow-up", this).map(function() {
diff -r 9ce137a90d5f trac/ticket/templates/ticket.html
--- a/trac/ticket/templates/ticket.html	Wed Mar 23 12:01:41 2011 +0100
+++ b/trac/ticket/templates/ticket.html	Wed Mar 23 17:01:14 2011 +0100
@@ -44,12 +44,14 @@
           // Unthread and update changelog
           var threaded_toggle = $('#trac-threaded-toggle');
           if (threaded_toggle.checked())
-            threaded_toggle.attr('checked', false).click().attr('checked', false);
+            threaded_toggle.click();
           $("#changelog .trac-new").remove();
           var new_changes = items.filter("#new-changes").children();
           $("#changelog").append(new_changes);
           // Show warning
           $("#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
@@ -130,7 +132,7 @@
                       py:with="alist = attachments; foldable = True"/>
         </py:if>
 
-        <div py:if="ticket.exists and changes">
+        <div style="${None if ticket.exists and changes else 'display: none'}">
           <form id="trac-threaded-form" method="get" action="" style="display: none">
             <div>
               <input id="trac-threaded-toggle" type="checkbox" />
@@ -151,17 +153,18 @@
             action="${href.ticket(ticket.id) + '#trac-add-comment' if ticket.exists
                       else href.newticket() + '#ticket'}">
         <!--! Add comment -->
-        <div py:if="ticket.exists and can_append" class="field">
+        <div py:if="ticket.exists and can_append" id="trac-add-comment" class="field">
           <div class="trac-nav">
             <a href="#content" title="View ticket fields and description">View</a> &uarr;
           </div>
-          <h2 id="trac-add-comment">
+          <h2>
             <a id="edit" onfocus="$('#comment').get(0).focus()">Add a comment</a>
           </h2>
           <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. The
-            <span class="trac-new">other modifications</span> are highlighted.
+            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.
+            You can nevertheless proceed and submit your changes if you wish so.
           </div>
           <!--! Comment field -->
           <fieldset class="iefix">
@@ -306,6 +309,19 @@
           </div>
         </div>
 
+        <!--! 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}">
+          <h3 class="change" id="${'comment:%d' % change_preview.cnum if 'cnum' in change_preview else None}">
+            <span class="threading" py:if="'replyto' in change_preview">
+              in reply to: ${commentref('&uarr;&nbsp;', change_preview.replyto)}
+            </span>
+            <i18n:msg params="author">Changed by ${authorinfo(change_preview.author)}</i18n:msg>
+          </h3>
+          <div id="ticketchange-content"><xi:include href="ticket_change.html" py:with="change = change_preview"/></div>
+        </div>
+
         <!--! Author or Reporter -->
         <div py:if="authname == 'anonymous'" class="field">
           <fieldset py:choose="">
@@ -328,19 +344,6 @@
           </fieldset>
         </div>
 
-        <!--! 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}">
-          <h3 class="change" id="${'comment:%d' % change_preview.cnum if 'cnum' in change_preview else None}">
-            <span class="threading" py:if="'replyto' in change_preview">
-              in reply to: ${commentref('&uarr;&nbsp;', change_preview.replyto)}
-            </span>
-            <i18n:msg params="author">Changed by ${authorinfo(change_preview.author)}</i18n:msg>
-          </h3>
-          <div id="ticketchange-content"><xi:include href="ticket_change.html" py:with="change = change_preview"/></div>
-        </div>
-
         <!--! Attachment on creation checkbox -->
         <p py:if="not ticket.exists and 'ATTACHMENT_CREATE' in perm(ticket.resource.child('attachment'))">
           <label>

