summaryrefslogtreecommitdiffstats
path: root/template/en/default/reports/report-table.html.tmpl
blob: 9027efa73a7d4e276f452359d40fb0e36826f0c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
[%# This Source Code Form is subject to the terms of the Mozilla Public
  # License, v. 2.0. If a copy of the MPL was not distributed with this
  # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  #
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
  #%]

[%# INTERFACE:
  # buglistbase: The base query for this table, in URL form
  # col_field: string. Name of the field being plotted as columns.
  # row_field: string. Name of the field being plotted as rows.
  # tbl_field: string. Name of the field being plotted as tables.
  # col_names: array. List of values for the field being plotted as columns.
  # row_names: array. List of values for the field being plotted as rows.
  # data: <depends on format>. Data to plot. Only data.$tbl is accessed. 
  # tbl: Name of a hash in data which is the table to be plotted.
  # table_id: the incremented number of the table being displayed.
  #%]

[% col_field_disp = field_descs.$col_field || col_field %]
[% row_field_disp = field_descs.$row_field || row_field %]

[% urlbase = BLOCK %]buglist.cgi?[% buglistbase FILTER html %][% END %]
[% IF tbl == "-total-" %]
  [% IF tbl_vals %]
    [% urlbase = urlbase _ "&amp;" _ tbl_vals %]
  [% END %]
[% ELSIF tbl_field %]
  [% urlbase = BLOCK %][% urlbase %]&amp;[% tbl_field FILTER uri %]=[% tbl FILTER uri %][% END %]
[% END %]

[% IF tbl_field %]
  <h2>[% tbl_disp FILTER email FILTER html %]</h2>
[% END %]

[% total_key = '-total-' %]
[%# Most of these classes are defined in the DataTables plugin itself. %]
<table id="tabular_report_[% table_id FILTER html %]" class="tabular_report display cell-border compact">
  <thead>
    <tr>
      <th>
        [% IF col_field %]
          &darr;&nbsp;[% row_field_disp FILTER html %] \ [% col_field_disp FILTER html %]&nbsp;&rarr;
        [% ELSE %]
          [% row_field_disp FILTER html %]
        [% END %]
      </th>
      [% FOREACH col = col_names %]
        <th>[% PROCESS value_display value = col field = col_field %]</th>
      [% END %]
      <th class="ttotal">Total</th>
    </tr>
  </thead>
  <tbody>
  [% FOREACH row = row_names %]
    <tr>
      <td class="right">
        [% PROCESS value_display value = row field = row_field %]
      </td>
      [% FOREACH col = col_names %]
        [% NEXT IF col == "" %]
        <td>
          [% IF data.$tbl.$col.$row AND data.$tbl.$col.$row > 0 %]
            <a href="[% urlbase %]&amp;
              [% row_field FILTER uri %]=[% row FILTER uri %]&amp;
              [% col_field FILTER uri %]=[% col FILTER uri %]">
              [% data.$tbl.$col.$row %]</a>
          [% ELSE %]
            <span class="bz_default_hidden">0</span>
          [% END %]
        </td>
      [% END %]
      <td class="ttotal right">
        <a href="[% urlbase %]&amp;
          [% row_field FILTER uri %]=[% row FILTER uri %]
          [% "&amp;$col_vals" IF col_vals %]">
        [% data.$tbl.$total_key.$row OR 0 FILTER html %]</a>
      </td>
    </tr>
  [% END %]
  </tbody>
  <tfoot>
    <tr>
      <td class="ttotal">Total</td>
      [% FOREACH col = col_names %]
        [% NEXT IF col == "" %]
        <td class="ttotal">
          <a href="[% urlbase %]&amp;
            [% col_field FILTER uri %]=[% col FILTER uri %]
            [% "&amp;$row_vals" IF row_vals %]">
          [% data.$tbl.$col.$total_key OR 0 FILTER html %]</a>
        </td>
      [% END %]
      <td class="ttotal right">
        <strong>
          <a href="[% urlbase %]
            [% "&amp;$row_vals" IF row_vals %]
            [% "&amp;$col_vals" IF col_vals %]">[% data.$tbl.$total_key.$total_key OR 0 FILTER html %]</a>
        </strong>
      </td>
    </tr>
  </tfoot>
</table>

<script type="text/javascript">
  $(document).ready(function() {
    $("#tabular_report_[% table_id FILTER html %]").DataTable({
      order: [],
      paging: false,
      scrollY: 600,
      scrollCollapse: true
    });
  });
</script>

[% IF note_multi_select %]
  <p class="extra_info">
    NOTE: Axes contain multi-value fields, so the total numbers might not add up,
    as a single [% terms.bug %] can match several rows or columns.
  </p>
[% END %]

[% BLOCK value_display %]
  [% SET disp_value = display_value(field, value) %]
  [% IF field == 'assigned_to' OR field == 'reporter'
           OR field == 'qa_contact'
  %]
    [% disp_value = value FILTER email %]
  [% END %]
  [% disp_value FILTER html FILTER replace('^ $','&nbsp;') %]
[% END %]