Modify

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 Changed 10 years ago by Chris Nelson

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.

comment:2 in reply to:  1 ; Changed 10 years ago by Ryan J Ollos

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 in reply to:  2 Changed 10 years ago by Chris Nelson

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 Chris Nelson

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 Chris Nelson

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  
    6767        $("#comment").focus(function() { comment_focused = true; })
    6868                     .blur(function() { comment_focused = false; });
    6969        $("#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          }
    7081          var items = $(reply);
    7182          // Update ticket box
    72           $("#ticket").replaceWith(items.filter('#ticket'));
     83          copyHeaderData(items.filter("#ticket").find("td"), $("#ticket td"));
    7384          // Unthread, unrevert and update changelog
    7485          if (!$('#trac-comments-oldest').checked())
    7586            $('#trac-comments-oldest').click().change();

comment:6 Changed 10 years ago by Ryan J Ollos

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  
    7979        $("#propertyform").autoSubmit({preview: '1'}, function(data, reply) {
    8080          var items = $(reply);
    8181          // 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');
    8390          // Unthread, unrevert and update changelog
    8491          if (!$('#trac-comments-oldest').checked())
    8592            $('#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 in reply to:  6 ; Changed 10 years ago by Chris Nelson

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  
    7979        $("#propertyform").autoSubmit({preview: '1'}, function(data, reply) {
    8080          var items = $(reply);
    8181          // 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');
    8390          // Unthread, unrevert and update changelog
    8491          if (!$('#trac-comments-oldest').checked())
    8592            $('#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:8 Changed 10 years ago by Chris Nelson

Opened trac:#11719.

comment:9 in reply to:  7 Changed 10 years ago by Ryan J Ollos

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 Chris Nelson

I tried without success to iterate the elements and copy display from the existing page to the new items.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain Takanori Suzuki.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.