Commits

Olemis Lang  committed 028b6c4

BH Dashboard #166: Custom pagination template in grid widget template

  • Participants
  • Parent commits bb5f80b
  • Branches t166_report_pagination

Comments (0)

Files changed (2)

 hgsvn/rm_files.diff
+t166/t166_r1371737_flexible_pagination_grid.diff

File t166/t166_r1371737_flexible_pagination_grid.diff

+# HG changeset patch
+# Parent f0f1df1c310a15dab259066b98b805b0afa3784b
+BH Theme #166: Flexible pagination in grid template
+
+diff -r f0f1df1c310a bhdashboard/widgets/templates/widget_grid.html
+--- a/bhdashboard/widgets/templates/widget_grid.html	Fri Aug 10 17:23:42 2012 +0200
++++ b/bhdashboard/widgets/templates/widget_grid.html	Fri Aug 24 20:35:04 2012 -0400
+@@ -27,123 +27,128 @@
+   </div -->
+   <py:choose test="">
+     <div py:when="paginator.has_more_pages">
+-      <div class="report-result" style="float: left; margin-right: 1.6em;">
++      <div class="report-result">
+         Results <span class="numresults">(${paginator.displayed_items()})</span>
+       </div>
+-      <xi:include href="page_index.html" />
+     </div>
+     <div py:when="numrows" class="numrows">($numrows total rows)</div>
+   </py:choose>
+ 
+   <py:choose test="">
+-    <table class="table table-condensed tickets" py:when="numrows"
+-        py:with="use_groups = len(row_groups) &gt; 1 or row_groups[0][0] is not None">
+-      <thead>
+-        <tr py:for="header_group in header_groups"
+-            py:if="not all(header.hidden for header in header_group)">
+-          <th py:if="use_groups"></th>
+-          <th py:for="header in header_group" py:if="not header.hidden" py:with="fullrow = header is header_group[-1]"
+-              colspan="${fullrow and '100' or None}">
+-            ${header.title}
+-          </th>
+-        </tr>
+-      </thead>
+-      <tbody>
+-        <py:for each="(value_for_group, row_group) in row_groups">
+-          <py:for each="idx, row in enumerate(row_group)">
+-            <tr py:for="cell_group in row.cell_groups"
+-                py:if="not all(cell.header.hidden for cell in cell_group)"
+-                py:with="fullrow = len(cell_group) == 1;
+-                       td_attrs = fullrow and {'class': 'fullrow', 'colspan': 100} or {}"
+-                class="${'__color__' in row and 'color'+row.__color__+'-' or ''}${row.__idx__ % 2 and 'odd' or 'even'}"
+-                style="${'__bgcolor__' in row and 'background: '+row.__bgcolor__+';' or None
+-                }${'__fgcolor__' in row and 'color: '+row.__fgcolor__+';' or None
+-                }${'__style__' in row and row.__style__+';' or None
+-                }${fullrow and 'border: none; padding: 0;' or None}">
+-
+-              <td py:if="use_groups" py:choose="" 
+-                  style="background: none repeat scroll 0 0 #FFFFFF; color: #333333;">
+-                <py:when test="idx == 0 and value_for_group and not fullrow">
+-                  $value_for_group
+-                </py:when>
+-                <py:when test="idx == 0 and not value_for_group and not fullrow">
+-                  <span class="label">empty</span>
+-                </py:when>
+-                <py:otherwise>&nbsp;</py:otherwise>
+-              </td>
+-              <py:for each="cell in cell_group">
+-                <py:if test="not cell.header.hidden">
+-                  <py:with vars="col = cell.header.col.strip('_')">
+-                    <py:choose>
++    <py:when test="numrows">
++      <table class="table table-condensed tickets" 
++          py:with="use_groups = len(row_groups) &gt; 1 or row_groups[0][0] is not None">
++        <thead>
++          <tr py:for="header_group in header_groups"
++              py:if="not all(header.hidden for header in header_group)">
++            <th py:if="use_groups"></th>
++            <th py:for="header in header_group" py:if="not header.hidden" py:with="fullrow = header is header_group[-1]"
++                colspan="${fullrow and '100' or None}">
++              ${header.title}
++            </th>
++          </tr>
++        </thead>
++        <tbody>
++          <py:for each="(value_for_group, row_group) in row_groups">
++            <py:for each="idx, row in enumerate(row_group)">
++              <tr py:for="cell_group in row.cell_groups"
++                  py:if="not all(cell.header.hidden for cell in cell_group)"
++                  py:with="fullrow = len(cell_group) == 1;
++                         td_attrs = fullrow and {'class': 'fullrow', 'colspan': 100} or {}"
++                  class="${'__color__' in row and 'color'+row.__color__+'-' or ''}${row.__idx__ % 2 and 'odd' or 'even'}"
++                  style="${'__bgcolor__' in row and 'background: '+row.__bgcolor__+';' or None
++                  }${'__fgcolor__' in row and 'color: '+row.__fgcolor__+';' or None
++                  }${'__style__' in row and row.__style__+';' or None
++                  }${fullrow and 'border: none; padding: 0;' or None}">
+   
+-                      <!--! for the report listing -->
+-                      <py:when test="col == 'report'">
+-                        <td class="$col" py:attrs="td_attrs">
+-                          <a title="View report" href="${href.report(cell.value)}">{$cell.value}</a>
+-                        </td>
+-                      </py:when>
+-  
+-                      <py:when test="col == 'title'">
+-                        <td class="$col" py:attrs="td_attrs">
+-                          <a title="View report" href="${href.report(row.id)}">$cell.value</a>
+-                        </td>
+-                      </py:when>
+-  
+-                      <!--! for the ticket listing -->
+-                      <py:when test="col in ('ticket', 'id')">
+-                        <td class="ticket" py:attrs="td_attrs">
+-                          <a title="View ${row.resource.realm}" href="${url_of(row.resource)}">#$cell.value</a>
+-                        </td>
+-                      </py:when>
+-  
+-                      <py:when test="col == 'summary' and row.id">
+-                        <td class="$col" py:attrs="td_attrs">
+-                          <a title="View ${row.resource.realm}" href="${url_of(row.resource)}">$cell.value</a>
+-                        </td>
+-                      </py:when>
+-  
+-                      <!--! generic fields -->
+-                      <py:when test="col == 'time'">
+-                        <td class="date" py:attrs="td_attrs">${cell.value != '' and format_time(int(cell.value)) or '--'}
+-                        </td>
+-                      </py:when>
+-  
+-                      <py:when test="col in ('date', 'created', 'modified')">
+-                        <td class="date" py:attrs="td_attrs">${cell.value != '' and format_date(int(cell.value)) or '--'}
+-                        </td>
+-                      </py:when>
+-  
+-                      <py:when test="col == 'datetime'">
+-                        <td class="date" py:attrs="td_attrs">${cell.value != '' and format_datetime(int(cell.value)) or '--'}
+-                        </td>
+-                      </py:when>
+-  
+-                      <py:when test="col == 'description'">
+-                        <td class="$col" py:attrs="td_attrs" xml:space="preserve">
+-                          ${wiki_to_html(context(row.resource), cell.value)}
+-                        </td>
+-                      </py:when>
+-  
+-                      <py:when test="col == 'milestone'">
+-                        <td class="$col" py:attrs="td_attrs">
+-                          <a title="View milestone" href="${href.milestone(cell.value)}">$cell.value</a>
+-                        </td>
+-                      </py:when>
+-  
+-                      <py:otherwise>
+-                        <td class="$col" py:attrs="td_attrs">$cell.value
+-                        </td>
+-                      </py:otherwise>
+-  
+-                    </py:choose>
+-                  </py:with>
+-                </py:if>
+-              </py:for>
+-            </tr>
++                <td py:if="use_groups" py:choose="" 
++                    style="background: none repeat scroll 0 0 #FFFFFF; color: #333333;">
++                  <py:when test="idx == 0 and value_for_group and not fullrow">
++                    $value_for_group
++                  </py:when>
++                  <py:when test="idx == 0 and not value_for_group and not fullrow">
++                    <span class="label">empty</span>
++                  </py:when>
++                  <py:otherwise>&nbsp;</py:otherwise>
++                </td>
++                <py:for each="cell in cell_group">
++                  <py:if test="not cell.header.hidden">
++                    <py:with vars="col = cell.header.col.strip('_')">
++                      <py:choose>
++    
++                        <!--! for the report listing -->
++                        <py:when test="col == 'report'">
++                          <td class="$col" py:attrs="td_attrs">
++                            <a title="View report" href="${href.report(cell.value)}">{$cell.value}</a>
++                          </td>
++                        </py:when>
++    
++                        <py:when test="col == 'title'">
++                          <td class="$col" py:attrs="td_attrs">
++                            <a title="View report" href="${href.report(row.id)}">$cell.value</a>
++                          </td>
++                        </py:when>
++    
++                        <!--! for the ticket listing -->
++                        <py:when test="col in ('ticket', 'id')">
++                          <td class="ticket" py:attrs="td_attrs">
++                            <a title="View ${row.resource.realm}" href="${url_of(row.resource)}">#$cell.value</a>
++                          </td>
++                        </py:when>
++    
++                        <py:when test="col == 'summary' and row.id">
++                          <td class="$col" py:attrs="td_attrs">
++                            <a title="View ${row.resource.realm}" href="${url_of(row.resource)}">$cell.value</a>
++                          </td>
++                        </py:when>
++    
++                        <!--! generic fields -->
++                        <py:when test="col == 'time'">
++                          <td class="date" py:attrs="td_attrs">${cell.value != '' and format_time(int(cell.value)) or '--'}
++                          </td>
++                        </py:when>
++    
++                        <py:when test="col in ('date', 'created', 'modified')">
++                          <td class="date" py:attrs="td_attrs">${cell.value != '' and format_date(int(cell.value)) or '--'}
++                          </td>
++                        </py:when>
++    
++                        <py:when test="col == 'datetime'">
++                          <td class="date" py:attrs="td_attrs">${cell.value != '' and format_datetime(int(cell.value)) or '--'}
++                          </td>
++                        </py:when>
++    
++                        <py:when test="col == 'description'">
++                          <td class="$col" py:attrs="td_attrs" xml:space="preserve">
++                            ${wiki_to_html(context(row.resource), cell.value)}
++                          </td>
++                        </py:when>
++    
++                        <py:when test="col == 'milestone'">
++                          <td class="$col" py:attrs="td_attrs">
++                            <a title="View milestone" href="${href.milestone(cell.value)}">$cell.value</a>
++                          </td>
++                        </py:when>
++    
++                        <py:otherwise>
++                          <td class="$col" py:attrs="td_attrs">$cell.value
++                          </td>
++                        </py:otherwise>
++    
++                      </py:choose>
++                    </py:with>
++                  </py:if>
++                </py:for>
++              </tr>
++            </py:for>
+           </py:for>
+-        </py:for>
+-      </tbody>
+-    </table>
++        </tbody>
++      </table>
++      <div py:if="paginator.has_more_pages" class="row" 
++          style="margin-top: -12px; margin-bottom: 12px; text-align: center">
++        <xi:include href="${pagination_template or 'page_index.html'}" />
++      </div>
++    </py:when>
+     <div class="alert alert-info" py:otherwise="" style="margin-top: 2em;">
+       <span class="label label-info">Info</span> Items list is empty
+     </div>