Opened 10 years ago
Last modified 10 years ago
#11923 new enhancement
Support Trac 1.0.x
Reported by: | Chris Nelson | Owned by: | Takanori Suzuki |
---|---|---|---|
Priority: | normal | Component: | TicketExtPlugin |
Severity: | normal | Keywords: | adoption-request |
Cc: | Trac Release: | 1.0 |
Description
Numerous minor issues.
Attachments (0)
Change History (10)
comment:1 follow-up: 2 Changed 10 years ago by
comment:2 follow-up: 3 Changed 10 years ago by
Keywords: | adoption-request added |
---|
Replying to ChrisNelson:
Of note: once I got this working in 1.0.1, the fields I have unchecked for a ticket type are hidden on initial view of a ticket but reappear when the ticket preview kicks in. It seems there is a new hook that the processor needs to be tied to.
I encountered the same issue this week while working on CondFieldsPlugin, #11920. I didn't see an existing hook, but need to look closer. The only partially-relevant ticket I found on t.e.o is trac:#10852 (requesting a hook for a different event).
comment:3 Changed 10 years ago by
Replying to rjollos:
Replying to ChrisNelson:
Of note: once I got this working in 1.0.1, the fields I have unchecked for a ticket type are hidden on initial view of a ticket but reappear when the ticket preview kicks in. It seems there is a new hook that the processor needs to be tied to.
I encountered the same issue this week while working on CondFieldsPlugin, #11920. I didn't see an existing hook, but need to look closer. The only partially-relevant ticket I found on t.e.o is trac:#10852 (requesting a hook for a different event).
I wonder, though, if it isn't a bug rather than a missing feature. If I make an AJAX request to unhide and populate the preview area, why should the ticket header change? Is a display attribute being too-broadly applied?
comment:4 Changed 10 years ago by
The fields are revealed by
// Update ticket box $("#ticket").replaceWith(items.filter('#ticket'));
in trac/ticket/templates/ticket.html
. That function replaces the existing ticket header with entirely new elements, it does not just update the values. items
has not been filtered by any extension point. The effect is that display: none
added by TicketExt is lost and all elements are displayed.
I'm a jQuery newbie but I'm exploring this on StackOverflow.
Ultimately, this will require a change to Trac to either copy values only (leaving attributes in place) or allow request filters to process XHR requests for auto-preview. I lean toward the former as it is a narrow, local change that doesn't require new extension point behavior, etc.
comment:5 Changed 10 years ago by
I have a patch to Trac that lets the plugin do its job:
-
trac/ticket/templates/ticket.html
diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.ht ml index 186138e..e9a2e35 100644
a b 67 67 $("#comment").focus(function() { comment_focused = true; }) 68 68 .blur(function() { comment_focused = false; }); 69 69 $("#propertyform").autoSubmit({preview: '1'}, function(data, reply) { 70 function copyHeaderData(f, t) { 71 if (f.length != t.length) { 72 console.log('Shape mismatch'); 73 } 74 else { 75 var i; 76 for (i = 0; i < t.length; ++i) { 77 t[i].innerHTML = f[i].innerHTML; 78 } 79 } 80 } 70 81 var items = $(reply); 71 82 // Update ticket box 72 $("#ticket").replaceWith(items.filter('#ticket'));83 copyHeaderData(items.filter("#ticket").find("td"), $("#ticket td")); 73 84 // Unthread, unrevert and update changelog 74 85 if (!$('#trac-comments-oldest').checked()) 75 86 $('#trac-comments-oldest').click().change();
comment:6 follow-up: 7 Changed 10 years ago by
You'll also have to update the description, summary, status, resolution, timestamps in div.date
, add the ticketdraft
class to #ticket
and possibly more. A jQuery version of your code that also updates the description and adds the "draft" background is:
-
trac/ticket/templates/ticket.html
diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.ht index 353ef63..d0865c3 100644
a b 79 79 $("#propertyform").autoSubmit({preview: '1'}, function(data, reply) { 80 80 var items = $(reply); 81 81 // Update ticket box 82 $("#ticket").replaceWith(items.filter('#ticket')); 82 var newProps = $('table.properties td', items); 83 $('#ticket table.properties td').each(function(i) { 84 $(this).html(newProps.eq(i).html()); 85 }); 86 var newDescription = $('div.description div.searchable', items); 87 $('#ticket div.description div.searchable').html(newDescription.html( 88 if (items.hasClass('ticketdraft')) 89 $('#ticket').addClass('ticketdraft'); 83 90 // Unthread, unrevert and update changelog 84 91 if (!$('#trac-comments-oldest').checked()) 85 92 $('#trac-comments-oldest').click().change();
When I got to this far I realized this was going to be very brittle code, and we probably need to make the autopreview behave the same as an explicit preview. We should probably open a ticket in Trac and get some dev input.
comment:7 follow-up: 9 Changed 10 years ago by
Replying to rjollos:
You'll also have to update the description, summary, status, resolution, timestamps in
div.date
,
I see what you mean about description, summary, status, and resolution.
I don't see any changes in the timestamps. Would that happen if someone changed the ticket under me?
add the
ticketdraft
class to#ticket
I don't see that that has any effect. <shrug>
and possibly more. A jQuery version of your code that also updates the description and adds the "draft" background is:
The "draft" background is present in my test bed.<shrug>
trac/ticket/templates/ticket.html
diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.ht index 353ef63..d0865c3 100644
a b 79 79 $("#propertyform").autoSubmit({preview: '1'}, function(data, reply) { 80 80 var items = $(reply); 81 81 // Update ticket box 82 $("#ticket").replaceWith(items.filter('#ticket')); 82 var newProps = $('table.properties td', items); 83 $('#ticket table.properties td').each(function(i) { 84 $(this).html(newProps.eq(i).html()); 85 }); 86 var newDescription = $('div.description div.searchable', items); 87 $('#ticket div.description div.searchable').html(newDescription.html( 88 if (items.hasClass('ticketdraft')) 89 $('#ticket').addClass('ticketdraft'); 83 90 // Unthread, unrevert and update changelog 84 91 if (!$('#trac-comments-oldest').checked()) 85 92 $('#trac-comments-oldest').click().change();
Thanks for the jQueryification. :-)
When I got to this far I realized this was going to be very brittle code, and we probably need to make the autopreview behave the same as an explicit preview. We should probably open a ticket in Trac and get some dev input.
I'll do that.
comment:9 Changed 10 years ago by
Replying to ChrisNelson:
I don't see any changes in the timestamps. Would that happen if someone changed the ticket under me?
I didn't think of that possibility. The timestamps would definitely need to be updated though if the display is relative rather than absolute.
add the
ticketdraft
class to#ticket
I don't see that that has any effect. <shrug>
and possibly more. A jQuery version of your code that also updates the description and adds the "draft" background is:
The "draft" background is present in my test bed.<shrug>
Maybe your patch somehow accounts for that. When I briefly tried it I was getting the Shape mismatch in the console and didn't look any deeper.
comment:10 Changed 10 years ago by
I tried without success to iterate the elements and copy display
from the existing page to the new items.
Of note: once I got this working in 1.0.1, the fields I have unchecked for a ticket type are hidden on initial view of a ticket but reappear when the ticket preview kicks in. It seems there is a new hook that the processor needs to be tied to.