Ticket #7025 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

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

Reported by: josh@oxideinteractive.com.au Assigned to: bobbysmith007
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

Change History

05/03/10 23:52:51 changed by bobbysmith007

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

07/12/10 23:47:12 changed by bobbysmith007

  • status changed from new to closed.
  • resolution set to fixed.

(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

07/12/10 23:48:00 changed by bobbysmith007

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!


Add/Change #7025 (Rewrite ticket properties table on-the-fly to remove whitespace left from stream filtering)




Change Properties
Action