Edgewall Software

Ticket #9125: report_patch.diff

File report_patch.diff, 8.0 KB (added by Carsten Klein <carsten.klein@…>, 2 years ago)

patch to both report.py and templates/report_view.py

  • branches/ReportPatch/trac/ticket/report.py

     
    436436                header_groups.append([]) 
    437437            header_group.append(header) 
    438438 
     439        maxcols = 0  
     440        for header_group in header_groups: 
     441            numhidden = 0 
     442            numcols = 0 
     443            for header in header_group: 
     444                if header['hidden']: 
     445                    numhidden += 1 
     446                else: 
     447                    numcols += 1 
     448            maxcols = numcols > maxcols and numcols or maxcols 
     449            i = 1 
     450            for header in header_group: 
     451                header['numhidden'] = numhidden 
     452                header['grpindex'] = i 
     453                i += 1 
     454 
    439455        # Structure the rows and cells: 
    440456        #  - group rows according to __group__ value, if defined 
    441457        #  - group cells the same way headers are grouped 
  • branches/ReportPatch/trac/ticket/templates/report_view.html

    +
     
    9696        </h2> 
    9797        <table class="listing tickets"> 
    9898          <thead> 
    99             <tr py:for="header_group in header_groups"> 
    100               <th py:for="header in header_group" py:if="not header.hidden" py:with="fullrow = header is header_group[-1]" 
    101                 colspan="${fullrow and '100' or None}"> 
     99            <tr py:for="header_group in header_groups" py:if="not (header_group[0].hidden and len(header_group)==1)">  
     100              <th py:for="header in header_group" py:if="not header.hidden" 
     101                  py:with="fullrow = header is header_group[-1]; 
     102                           grpnumcols = len(header_group); 
     103                           curcol = header.grpindex; 
     104                           grpnumhidden = header.numhidden; 
     105                           colspan = (grpnumcols - grpnumhidden &lt; maxcols and curcol == grpnumcols) and (maxcols - curcol + grpnumhidden + 1) or 1;" 
     106                colspan="$colspan"> 
    102107                <a py:strip="not sorting_enabled" 
    103108                   py:with="filtered_args = dict([(k,v) for k,v in args.items() if k not in ('sort', 'asc')])" 
    104109                  href="${href.report(report.id, filtered_args, sort=header.col, asc=not header.asc and '1' or '0')}"> 
     
    108113            </tr> 
    109114          </thead> 
    110115 
    111           <tbody> 
    112             <py:for each="row in row_group"> 
     116          <tbody py:for="row in row_group"> 
    113117              <tr py:for="cell_group in row.cell_groups" 
     118                py:if="not (cell_group[0].header.hidden and len(cell_group) == 1)" 
    114119                py:with="fullrow = len(cell_group) == 1; 
    115                          td_attrs = fullrow and {'class': 'fullrow', 'colspan': 100} or {}" 
     120                         grpnumcols = len(cell_group); 
     121                         td_attrs = fullrow and {'class': 'fullrow', 'colspan': maxcols} or {}; 
     122                         td_attrs = fullrow and {'colspan': maxcols} or {}" 
    116123                class="${'__color__' in row and 'color'+row.__color__+'-' or ''}${row.__idx__ % 2 and 'odd' or 'even'}" 
    117124                style="${'__bgcolor__' in row and 'background: '+row.__bgcolor__+';' or None 
    118125                }${'__fgcolor__' in row and 'color: '+row.__fgcolor__+';' or None 
     
    120127                }${fullrow and 'border: none; padding: 0;' or None}"> 
    121128 
    122129                <py:for each="cell in cell_group"> 
    123                   <py:if test="not cell.header.hidden"> 
    124                     <py:with vars="col = cell.header.col.strip('_')"> 
     130                  <py:if test="not cell.header.hidden">  
     131                    <py:with vars="col = cell.header.col.strip('_'); 
     132                                   curcol = cell.header.grpindex; 
     133                                   grpnumhidden = cell.header.numhidden; 
     134                                   colspan_last = (grpnumcols - grpnumhidden &lt; maxcols) and (maxcols - curcol + grpnumhidden + 1) or 1; 
     135                                   td_attrs = (not fullrow and ( curcol == grpnumcols )) and {'colspan': colspan_last} or td_attrs;"> 
    125136                      <py:choose> 
    126137 
    127138                        <py:when test="col == 'report'"> 
    128139                          <td class="$col" py:attrs="td_attrs"> 
    129140                            <a title="View report" href="${href.report(cell.value)}">{$cell.value}</a> 
    130                             <hr py:if="fullrow"/> 
     141                            <!-- ! <hr py:if="fullrow"/> --> 
    131142                          </td> 
    132143                        </py:when> 
    133144 
    134145                        <py:when test="col in ('ticket', 'id')"> 
    135146                          <td class="ticket" py:attrs="td_attrs"> 
    136147                            <a title="View ${row.resource.realm}" href="${url_of(row.resource)}">#$cell.value</a> 
    137                             <hr py:if="fullrow"/> 
     148                            <!-- ! <hr py:if="fullrow"/> --> 
    138149                          </td> 
    139150                        </py:when> 
    140151 
    141152                        <py:when test="col == 'summary' and row.id"> 
    142153                          <td class="$col" py:attrs="td_attrs"> 
    143154                            <a title="View ${row.resource.realm}" href="${url_of(row.resource)}">$cell.value</a> 
    144                             <hr py:if="fullrow"/> 
     155                            <!-- ! <hr py:if="fullrow"/> --> 
    145156                          </td> 
    146157                        </py:when> 
    147158 
    148159                        <!--! generic fields --> 
    149160                        <py:when test="col == 'time'"> 
    150161                          <td class="date" py:attrs="td_attrs">${cell.value != '' and format_time(int(cell.value)) or '--'} 
    151                             <hr py:if="fullrow"/> 
     162                            <!-- ! <hr py:if="fullrow"/> --> 
    152163                          </td> 
    153164                        </py:when> 
    154165 
    155166                        <py:when test="col in ('date', 'created', 'modified')"> 
    156167                          <td class="date" py:attrs="td_attrs">${cell.value != '' and format_date(int(cell.value)) or '--'} 
    157                             <hr py:if="fullrow"/> 
     168                            <!-- ! <hr py:if="fullrow"/> --> 
    158169                          </td> 
    159170                        </py:when> 
    160171 
    161172                        <py:when test="col == 'datetime'"> 
    162173                          <td class="date" py:attrs="td_attrs">${cell.value != '' and format_datetime(int(cell.value)) or '--'} 
    163                             <hr py:if="fullrow"/> 
     174                            <!-- ! <hr py:if="fullrow"/> --> 
    164175                          </td> 
    165176                        </py:when> 
    166177 
    167178                        <py:when test="col == 'description'"> 
    168179                          <td class="$col" py:attrs="td_attrs" xml:space="preserve"> 
    169180                            ${wiki_to_html(context(row.resource), cell.value)} 
    170                             <hr py:if="fullrow"/> 
     181                            <!-- ! <hr py:if="fullrow"/> --> 
    171182                          </td> 
    172183                        </py:when> 
    173184 
    174185                        <py:when test="col == 'milestone'"> 
    175186                          <td class="$col" py:attrs="td_attrs"> 
    176187                            <a title="View milestone" href="${href.milestone(cell.value)}">$cell.value</a> 
    177                             <hr py:if="fullrow"/> 
     188                            <!-- ! <hr py:if="fullrow"/> --> 
    178189                          </td> 
    179190                        </py:when> 
    180191 
    181192                        <py:otherwise> 
    182193                          <td class="$col" py:attrs="td_attrs">$cell.value 
    183                             <hr py:if="fullrow"/> 
     194                            <!-- ! <hr py:if="fullrow"/> --> 
    184195                          </td> 
    185196                        </py:otherwise> 
    186197 
     
    189200                  </py:if> 
    190201                </py:for> 
    191202              </tr> 
    192             </py:for> 
    193203          </tbody> 
    194204        </table> 
    195205      </py:for>