[%# 1.0@bugzilla.org %]
[%# The contents of this file are subject to the Mozilla Public
  # License Version 1.1 (the "License"); you may not use this file
  # except in compliance with the License. You may obtain a copy of
  # the License at http://www.mozilla.org/MPL/
  #
  # Software distributed under the License is distributed on an "AS
  # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  # implied. See the License for the specific language governing
  # rights and limitations under the License.
  #
  # The Original Code is the Bugzilla Test Runner System.
  #
  # The Initial Developer of the Original Code is Maciej Maczynski.
  # Portions created by Maciej Maczynski are Copyright (C) 2001
  # Maciej Maczynski. All Rights Reserved.
  #
  # Contributor(s): Ed Fuentetaja <efuentetaja@acm.org>
  #                 Greg Hendricks <ghendricks@novell.com>
  #%]

[%# INTERFACE:
  # ...
  #%]

[%############################################################################%]
[%# Template Initialization                                                  #%]
[%############################################################################%]

[% PROCESS global/variables.none.tmpl %]

[% title = "Test Cases" %]

[%############################################################################%]
[%# Page Header                                                              #%]
[%############################################################################%]

[% PROCESS global/header.html.tmpl
   style_urls = ['testopia.css'] %]

[% PROCESS testopia/style.none.tmpl %]
[% PROCESS testopia/blocks.html.tmpl %]
[% PROCESS testopia/messages.html.tmpl %]
<script type="text/javascript">
  djConfig = {
    parseWidgets: false,
    searchIds: ["tags", "addtags", "caserun_env"]
  };
</script>
<script src="testopia/js/util.js" type="text/javascript"></script>
<script src="testopia/dojo/dojo.js" type="text/javascript"></script>
<script type="text/javascript">
  dojo.require('dojo.io.*');
  dojo.require("dojo.widget.ComboBox");
  function getProdComps(product){
      document.getElementById("components").disabled = true;
      document.getElementById("action").disabled = true;
      dojo.io.bind({
          url:   "tr_quicksearch.cgi",
          content: {  product_id: product, action: "getcomps" },
          load:  function(type, data, evt){
                   var comps = document.getElementById("components");
                   comps.options.length = 0;
                   for (i in data){
                     var myOp = new Option(data[i].name, data[i].id);
                     addOption(comps, myOp);
                   }
                   document.getElementById("components").disabled = false;
                   document.getElementById("action").disabled = false;
                 },
          error: function(type, error){ alert(error.message);},
          mimetype: "text/json"
      });
  }   </script>
[% PROCESS testopia/case/filter.html.tmpl IF addrun %]

<form id="table" action="tr_list_cases.cgi" method="POST">

[% PROCESS testopia/case/table.html.tmpl %]

<p><b>
[% IF table.list_count == 0 %]
No test cases
[% ELSE %]
  [% IF table.list_count == 1 %]
    One test case
  [% ELSE %]
    [% table.list_count FILTER none %] total test cases
  [% END %]
[% END %]
found.</b>
[% IF candelete %]
<span style="float: right;"><input type="submit" name="action" value="Delete Selected"></span>
<br><br>
[% END %]
</p>
[% IF dotweak AND table.list_count %]
<h3>Update Selected Test Cases</h3>

<table border="0">

  <tr>
    <td align="right"><b>Requirement</b></td>
    <td><input name="requirement" value="--Do Not Change--" size="30"></td>
    <td align="right">
    <select name="tag_action">
      <option value="add">Add</option>
      <option value="rem">Remove</option>
    </select>
       <b>Tags</b></td>
    <td><input id="addtags" name="addtags"
                   dojoType="combobox" 
                   dataUrl="tr_quicksearch.cgi?action=gettag&search=${searchString}" 
                   mode="remote"
                   maxListLength="10"></td>
    <td rowspan="5">
      <table>
        <tr><th align="center">Add Components From</th></tr>
        <tr>
        <td>
        [% PROCESS select sel = { name      => 'prod_pick',
                                  list      => user.get_selectable_products,
                                  default   => case.get_product_ids.0,
                                  events    => 'onChange="getProdComps(this.value)"',
                                  accesskey => 'p' } %]
        </td>
      </tr>
      <tr>
          <td>
    
      [% PROCESS select sel = { name      => 'components',
                                accesskey => 'c', 
                                mult      => 1
                                elements  => 7 }%]
  
          </td>
        </tr>
      </table>
    </td>
  </tr>
  
  <tr>
    <td align="right"><b>Status</b></td>
    <td>
    [% PROCESS select sel = { name  => 'status',
                          accesskey => 's', 
                          list      => status_list
                          default   => "--Do Not Change--"  } %]
    </td>
    <td align="right"><b>Automatic</b></td>
    <td>
      <select name="isautomated" id="isautomated">
        <option value="-1">--Do Not Change--</option>
        <option value="0">Manual</option>
        <option value="1">Automatic</option>
       </select>
    </td>
  </tr>

  <tr>
    <td align="right"><b>Priority<b></td>
    <td>
    [% PROCESS select sel = { name  => 'priority',
                          accesskey => 'p', 
                          list      => priority_list
                          default   => "--Do Not Change--" } %]
    </td>
  
    <td align="right"><b>Script</b></td>
    <td><input name="script" id="script" size="30" value="--Do Not Change--" /></td>
  </tr>

  <tr>
  [% IF NOT multiprod AND NOT addrun %]
    <td align="right"><b>Category<b></td>
    <td>
    [% PROCESS select sel = { name  => 'category',
                          accesskey => 'c', 
                          list      => category_list
                          default   => "--Do Not Change--" } %]
    </td>
  [% ELSE %]
    <input type="hidden" name="category" value="-1" />
  [% END %]
    <td align="right"><b>Arguments:</b></td>
    <td><input name="arguments" id="arguments" size="30" value="--Do Not Change--" /></td>
  </tr>
  <tr>
    <td align="right"><b>Default Tester<b></td>
    <td><input name="tester" value="--Do Not Change--" /></td>
  </tr>
  <tr>
    <th colspan="3">Add selected cases to the following runs (only CONFIRMED cases will be added):</th>

    <td><input name="addruns" value="[% addrun FILTER html %]" />(comma-separated list of ids)</td>
[% IF plan %]
    <th align="right" valign="top">With build:
      [% PROCESS select sel = { name => "caserun_build", 
                                list => plan.product.builds(1), 
                              }
       %]
      and Envrionment:
      <input dojoType="select" 
             dataUrl="tr_quicksearch.cgi?action=getenv&prod_id=[% plan.product.id FILTER none %]&search=${searchString}" 
             mode="remote"
             autoComplete="false"
             name="caserun_env"
             id="caserun_env"
             maxListLength="10">
    </th>
[% END %]
  </tr>
  <tr>
    <th colspan="3" valign="top">Clone selected cases to the following plans 
                (comma-separated list of ids):</th>
    <td><input name="linkplans" />
        <input type="radio" style="border: none" name="copymethod" value="copy" checked="checked">Copy
        <input type="radio" style="border: none" name="copymethod" value="link">Link<br/>
        <input type="checkbox" style="border: none" name="newauthor">Make me the author of copied cases.</td>
  </tr>

</table>        

<p align="right">
  <input type="hidden" name="getlist" value="1"/>
  <input TYPE="SUBMIT" name="action" id="action" class="tr_button" VALUE="Commit">
</p>
<script type="text/javascript">
  getProdComps(document.getElementById('prod_pick').value);
</script>  

[% END %]
</form>

[% IF table.list_count >0 %]
<div id="buglist_actions">
    <div class="links">
        <span class="label">Export:</span>
        <a href="tr_list_cases.cgi?[% urlquerypart FILTER remove('&viewall=.') FILTER html %]&amp;ctype=csv&amp;viewall=1"><img src="testopia/img/csv.png" class="image"></a>
        |
        <a href="tr_list_cases.cgi?[% urlquerypart FILTER remove('&viewall=.') FILTER html %]&amp;ctype=xml&amp;viewall=1"><img src="testopia/img/xml.png" class="image"></a>
    </div>
</div>

[% END %]
[% PROCESS "testopia/saved-search.html.tmpl" %]
[%############################################################################%]
[%# Page Footer                                                              #%]
[%############################################################################%]

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