create-chart.html.tmpl 8.29 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
[%# 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:
  # chart: Chart object representing the currently assembled chart.
  # category: hash (keyed by category) of hashes (keyed by subcategory) of
  #           hashes (keyed by name), with value being the series_id of the
  #           series. Contains details of all series the user can see.
  #%]

[% PROCESS global/header.html.tmpl 
17 18
  title = "Create Chart"
  style_urls = ['skins/standard/buglist.css']
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
%]

[% PROCESS "reports/series-common.html.tmpl" 
  donames = 1 
%]

<script type="text/javascript">
[%# This function takes necessary action on selection of a subcategory %]
function subcatSelected() {
  var cat = document.chartform.category.value;
  var subcat = document.chartform.subcategory.value;
  var names = series[cat][subcat];
  
  var namewidget = document.chartform.name;

  namewidget.options.length = 0;
  var i = 0;

  for (x in names) {
    namewidget.options[i] = new Option(x, names[x]);
    i++;
  }

  namewidget.disabled = false;
  namewidget.options[0].selected = true;
  
  checkNewState();
}
</script>
  
49
[% gttext = "Grand Total" %]
50

51 52 53
<form method="get" action="chart.cgi" name="chartform">

  <table id="create_chart">
54 55 56
    [% IF NOT category OR category.size == 0 %]
      <tr>
        <td>
57
          <i>No data sets exist, or none are visible to you.</i>
58 59 60 61
        </td>
      </tr>
    [% ELSE %]
      <tr>
62 63 64
        <th><label for="category">Category</label></th>
        <th></th>
        <th><label for="subcategory">Sub-category</label></th>
65
        <th></th>
66
        <th><label for="name" accesskey="N">Name</label></th>
67 68 69
        <th></th>
      </tr>
      <tr>
70

71 72 73 74
        [% PROCESS series_select sel = { name => 'category', 
                                         size => 5,
                                         onchange = "catSelected();
                                                     subcatSelected();" } %]
75

76 77
        <td>
          <noscript>
78
            <input type="submit" name="action-assemble" value="Update --&gt;"
79 80 81
                   id="action-assemble">
          </noscript>
        </td>
82

83 84 85
        [% PROCESS series_select sel = { name => 'subcategory', 
                                         size => 5,
                                         onchange = "subcatSelected()" } %]
86

87 88
        <td>
          <noscript>
89
            <input type="submit" name="action-assemble" value="Update --&gt;"
90 91 92
                   id="action-assemble2">
          </noscript>
        </td>
93

94 95 96 97 98 99 100
        [% PROCESS series_select sel = { name => 'name',
                                         size => 5,
                                         multiple => 1,
                                         # We want to use the series ID as value,
                                         # not its name.
                                         value_in_hash => 1 } %]

101 102
        <td>
          <input type="submit" name="action-add" value="Add To List"
103 104 105 106 107 108
                 id="action-add"><br>
        </td>
      </tr>
    [% END %]
  </table>

109
  <h3>List Of Data Sets To Plot</h3>
110 111

  [% IF chart.lines.size %]
112
    <table id="edit_charts">
113
      <tr>
114 115
        <th>Select</th>
        <th>Label</th>
116
        <th></th>
117
        <th>Data Set</th>
118 119
        <th></th>
      </tr>
120

121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
      [%# The external loop has two counters; one which keeps track of where we
        #  are in the old labels array, and one which keeps track of the new
        #  indexes for the form elements. They are different if chart.lines has
        #  empty slots in it. 
        #%]
      [% labelidx = 0 %]
      [% newidx = 0 %]
      
      [% FOREACH line = chart.lines %]
        [% IF NOT line %]
          [%# chart.lines has an empty slot, so chart.labels will too. We
            # increment labelidx only to keep the labels in sync with the data.
            #%]
          [% labelidx = labelidx + 1 %]
          [% NEXT %]
        [% END %]
137

138 139 140
        [% FOREACH series = line %]
          <tr>
            [% IF loop.first %]
141
              <td class="center" rowspan="[% line.size %]">
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
                <input type="checkbox" value="1" name="select[% newidx %]">
              </td>
              <td rowspan="[% line.size %]">
                <input type="text" size="20" name="label[% newidx %]"
                       value="[% (chart.labels.$labelidx OR series.name) 
                                                               FILTER html %]">
              </td>
            [% END %]

            <td>
              [% "{" IF line.size > 1 %]
            </td>

            <td>
              [% series.category FILTER html %] / 
              [%+ series.subcategory FILTER html %] /
              [%+ series.name FILTER html %]
              <input type="hidden" name="line[% newidx %]" 
                     value="[% series.series_id %]">
            </td>

163
            <td>
164 165
              [% IF user.id == series.creator_id OR user.in_group("admin") %]
               <a href="chart.cgi?action=edit&amp;series_id=
166
                       [% series.series_id %]">Edit</a> |
167
               <a href="chart.cgi?action=confirm-delete&amp;series_id=
168
                       [%- series.series_id %]">Delete</a> |
169 170 171 172 173
              [% END %]
              <a href="buglist.cgi?cmdtype=dorem&amp;namedcmd=
                [% series.category FILTER uri %]%20/%20
                [% series.subcategory FILTER uri %]%20/%20
                [% series.name FILTER uri -%]&amp;series_id=
174 175
                [% series.series_id %]&amp;remaction=runseries">Run Search</a>
            </td>
176 177 178 179 180 181 182 183
          </tr>
        [% END %]
        [% labelidx = labelidx + 1 %]
        [% newidx = newidx + 1 %]
      [% END %]

      [% IF chart.gt %]
        <tr>
184
          <td class="center">
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
            <input type="checkbox" value="1" name="select65536">
            <input type="hidden" value="1" name="gt">
          </td>
          <td>
            <input type="text" size="20" name="labelgt"
                   value="[% (chart.labelgt OR gttext) FILTER html %]">
          </td>
          <td></td>
          <td>
            <i>[% gttext FILTER html %]</i>
          </td>
          <td></td>
        </tr>
      [% END %]
      <tr>
        <td colspan="6">&nbsp;</td>
      </tr>

      <tr>
204 205 206
        <td>
          <input type="submit" id="action-sum" name="action-sum" value="Sum"><br>
          <input type="submit" id="action-remove" name="action-remove" value="Remove">
207 208
        </td>

209 210
        <td class="right">
          <label for="cumulate"><b>Cumulate</b></label>:
211 212 213 214 215
          <input type="checkbox" name="cumulate" id="cumulate" value="1"
          [% " checked" IF chart.cumulate %]>
        </td>

        <td></td>
216 217
        <td>
          <label for="datefrom"><b>Date Range</b></label>:
218
          <input type="text" size="12" name="datefrom" id="datefrom"
219
            placeholder="YYYY-MM-DD"
220
            value="[% time2str("%Y-%m-%d", chart.datefrom) IF chart.datefrom%]">
221
          <label for="dateto"><b>to</b></label>
222
          <input type="text" size="12" name="dateto" id="dateto"
223
            placeholder="YYYY-MM-DD"
224 225 226
            value="[% time2str("%Y-%m-%d", chart.dateto) IF chart.dateto %]">
        </td>

227 228
        <td>
          <input type="submit" name="action-wrap" value="Chart This List"
229 230 231 232 233
                 id="action-wrap">
        </td>
      </tr>
    </table>
  [% ELSE %]
234
  <p><i>None</i></p>
235 236 237 238
  [% END %]  
</form>

[% IF user.in_group('editbugs') %]
239
  <h3>Create New Data Set</h3>
240
  <p>
241 242
    You can either create a new data set based on one of your saved searches
    or start with a clean slate.
243 244 245 246
  </p>

  <form action="chart.cgi" id="create_series" name="create_series" method="GET">
    <input type="hidden" name="action" value="convert_search">
247
    <label for="series_from_search">Based on:</label>
248
    <select id="series_from_search" name="series_from_search">
249
      <option value="">(Clean slate)</option>
250 251 252 253
      [% FOREACH q = user.queries %]
        <option value="[% q.name FILTER html %]">[% q.name FILTER html %]</option>
      [% END %]
    </select>
254
    <input id="submit_create" type="submit" value="Create a new data set">
255 256 257 258
  </form>
[% END %]                 

[% PROCESS global/footer.html.tmpl %]