Modify

Opened 15 years ago

Closed 14 years ago

Last modified 14 years ago

#7025 closed enhancement (fixed)

Rewrite ticket properties table on-the-fly to remove whitespace left from stream filtering

Reported by: josh@… Owned by: Russ Tyndall
Priority: normal Component: TimingAndEstimationPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

Currently, when you remove fields using stream-filters and permissions, the empty table-cell gets left behind, leaving a lot of ugly white-space.

You could use jQuery (or possibly more stream-filters?) to rewrite the table on the fly, in order to remove the extra white-space.

The current way I'm doing this is:

blackmagic.py

def remove_field(stream , field):
    """ Removes a field from the form area"""
    stream = stream | Transformer('//label[@for="field-%s"]' % field).replace(tag.span(class_='empty'))
    stream = stream | Transformer('//*[@id="field-%s"]' % field).replace(tag.span(class_='empty'))
    return remove_changelog(remove_header(stream , field), field)

jquery

/*  
*   Function attempts to rewrite a table to remove fields that have
*   been removed during stream filtering.
*   Only works for <table>, <thead>, <tbody> and <tfoot> tags.
*   Code by Josh Godsiff, for www.oxideinteractive.com.au
*   Email: josh@oxideinteractive.com.au
*/
$.prototype.cleanupTable = function() {
    if($(this).is('table')) {
        var body = $(this).children('thead, tbody, tfoot');
    } else if($(this).is('thead, tbody, tfoot')) {
        var body = $(this);
    } else {
        return 0;
    }
    
    var full = $(body).children('tr').filter(function() {
        return $(this).children('td.fullrow').length > 0;
    });
    $(full).detach();
    
    var data = $(body).find('tr').children().filter(function() {
        return ($(this).find('span.empty').length == 0 && $(this).is(':not(:empty)'));
    });
    
    $(body).children('tr').detach();
    $(body).append($(full));

    $(data).each(function(ind, val) {
        if(ind % 4 == 0) {
            $(body).append('<tr class="current"></tr>');
        }
        
        var col = (ind % 4 <= 1 ? 1 : 2);
        if($(this).children('span.empty').length <= 0) {
            $(this).attr('class', 'col' + col);
            $(body).find('tr.current').append($(this));
        }

        if(ind % 4 == 3) {
            $(body).find('tr.current').removeClass('current');
        }
    });
}

$(document).ready(function() {
    $('#properties table').cleanupTable();
    $('table.properties').cleanupTable();
});

Attachments (0)

Change History (3)

comment:1 Changed 15 years ago by Russ Tyndall

I will try to incorporate this into the plugin soon, thanks for your input

comment:2 Changed 14 years ago by Russ Tyndall

Resolution: fixed
Status: newclosed

(In [8262]) Added a whitespace cleaner (from Josh Godsiff - thanks!) to the ticket page to remove extra whitespace, and fixed csv exports in permissions branch. ver 1.0.5 - fix #7354 and #7025

comment:3 Changed 14 years ago by Russ Tyndall

Sorry it took me a while to get to this. I added you to the authors list in setup.py. Thanks much for the patch!

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Russ Tyndall.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.