list.html.tmpl 6.87 KB
Newer Older
1
<!-- 1.0@bugzilla.org -->
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
[%# 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 Bug Tracking System.
  #
  # The Initial Developer of the Original Code is Netscape Communications
  # Corporation. Portions created by Netscape are
  # Copyright (C) 1998 Netscape Communications Corporation. All
  # Rights Reserved.
  #
  # Contributor(s): Myk Melez <myk@mozilla.org>
  #%]

22
<script type="text/javascript">
23
<!-- 
24 25 26
  // Enables or disables a requestee field depending on whether or not
  // the user is requesting the corresponding flag.
  function toggleRequesteeField(flagField)
27
  {
28 29 30 31
    // Convert the ID of the flag field into the ID of its corresponding
    // requestee field and then use the ID to get the field.
    var id = flagField.name.replace(/flag(_type)?-(\d+)/, "requestee$1-$2");
    var requesteeField = document.getElementById(id);
32
    if (!requesteeField) return;
33 34 35 36 37
    
    // Enable or disable the requestee field based on the value
    // of the flag field.
    if (flagField.value == "?") requesteeField.disabled = false;
    else                        requesteeField.disabled = true;
38 39
  }
  
40 41
  // Disables requestee fields when the window is loaded since they shouldn't
  // be enabled until the user requests that flag type.
42 43 44
  function disableRequesteeFields()
  {
    var inputElements = document.getElementsByTagName("input");
45
    var inputElement, id, flagField;
46 47 48
    for ( var i=0 ; i<inputElements.length ; i++ )
    {
      inputElement = inputElements.item(i);
49 50 51 52 53 54 55 56 57
      if (inputElement.name.search(/^requestee(_type)?-(\d+)$/) != -1)
      {
        // Convert the ID of the requestee field into the ID of its corresponding
        // flag field and then use the ID to get the field.
        id = inputElement.name.replace(/requestee(_type)?-(\d+)/, "flag$1-$2");
        flagField = document.getElementById(id);
        if (flagField && flagField.value != "?")
            inputElement.disabled = true;
      }
58 59 60
    }
  }
  window.onload = disableRequesteeFields;
61
// -->
62 63
</script>

64 65 66 67 68 69 70 71
[%# We list flags by looping twice over the flag types relevant for the bug.
  # In the first loop, we display existing flags and then, for active types,
  # we display UI for adding new flags.  In the second loop, we display UI 
  # for adding additional new flags for those types for which a flag already
  # exists but which are multiplicable (can have multiple flags of the type
  # on a single bug/attachment).
  #%]

72
<table id="flags">
73 74 75 76 77 78 79 80 81 82
  <tr>
    <th colspan="3">
      Flags:
    </th>
    [% IF any_flags_requesteeble %]
      <th>
        Requestee:
      </th>
    [% END %]
  </tr>
83

84
  [%# Step 1: Display every flag type (except inactive types with no flags). %]
85
  [% FOREACH type = flag_types %]
86 87
    
    [%# Step 1a: Display existing flag(s). %]
88 89 90 91 92 93 94 95 96
    [% FOREACH flag = type.flags %]
      <tr>
        <td>
          [% flag.setter.nick FILTER html %]:
        </td>
        <td>
          [% type.name FILTER html %]
        </td>
        <td>
97 98
          <select id="flag-[% flag.id %]" name="flag-[% flag.id %]" 
                  onchange="toggleRequesteeField(this);">
99
            <option value="X"></option>
100
            [% IF type.is_active %]
101 102
              <option value="+" [% "selected" IF flag.status == "+" %]>+</option>
              <option value="-" [% "selected" IF flag.status == "-" %]>-</option>
103 104 105
              [% IF type.is_requestable %]
                <option value="?" [% "selected" IF flag.status == "?" %]>?</option>
              [% END %]
106
            [% ELSE %]
107
              <option value="[% flag.status %]" selected="selected">[% flag.status %]</option>
108
            [% END %]
109 110
          </select>
        </td>
111 112 113 114 115 116 117 118
        [% IF any_flags_requesteeble %]
          <td>
            [% IF type.is_active && type.is_requesteeble %]
              <span style="white-space: nowrap;">
                (<input type="text" size="8" maxlength="255"
                        id="requestee-[% flag.id %]" 
                        name="requestee-[% flag.id %]"
                        [% IF flag.status == "?" && flag.requestee %]
119
                          value="[% flag.requestee.login FILTER html %]"
120 121 122 123 124 125
                        [% END %]
                 >)
              </span>
            [% END %]
          </td>
        [% END %]
126 127
      </tr>
    [% END %]
128 129
    
    [%# Step 1b: Display UI for setting flag. %]
130
    [% IF (!type.flags || type.flags.size == 0) && type.is_active %]
131 132
      <tr>
        <td>&nbsp;</td>
133
        <td>[% type.name FILTER html %]</td>
134
        <td>
135 136
          <select id="flag_type-[% type.id %]" name="flag_type-[% type.id %]" 
                  onchange="toggleRequesteeField(this);">
137 138 139 140 141 142 143 144
            <option value="X"></option>
            <option value="+">+</option>
            <option value="-">-</option>
            [% IF type.is_requestable %]
              <option value="?">?</option>
            [% END %]
          </select>
        </td>
145 146 147 148 149 150 151 152 153 154 155
        [% IF any_flags_requesteeble %]
          <td>
            [% IF type.is_requesteeble %]
              <span style="white-space: nowrap;">
                (<input type="text" size="8" maxlength="255"
                        id="requestee_type-[% type.id %]" 
                        name="requestee_type-[% type.id %]">)
              </span>
            [% END %]
          </td>
        [% END %]
156 157 158 159
      </tr>
    [% END %]
  [% END %]

160
  [%# Step 2: Display flag type again (if type is multiplicable). %]
161
  [% FOREACH type = flag_types %]
162
    [% NEXT UNLESS type.flags.size > 0 && type.is_multiplicable && type.is_active %]
163 164 165 166 167
    [% IF !separator_displayed %]
        <tr><td colspan="3"><hr></td></tr>
        [% separator_displayed = 1 %]
    [% END %]
    <tr>
168
      <td colspan="2">addl. [% type.name FILTER html %]</td>
169
      <td>
170 171
        <select id="flag_type-[% type.id %]" name="flag_type-[% type.id %]" 
                onchange="toggleRequesteeField(this);">
172 173 174 175 176 177 178 179
          <option value="X"></option>
          <option value="+">+</option>
          <option value="-">-</option>
          [% IF type.is_requestable %]
            <option value="?">?</option>
          [% END %]
        </select>
      </td>
180 181 182 183 184 185 186 187 188 189 190
      [% IF any_flags_requesteeble %]
        <td>
          [% IF type.is_requesteeble %]
              <span style="white-space: nowrap;">
                (<input type="text" size="8" maxlength="255"
                        id="requestee_type-[% type.id %]" 
                        name="requestee_type-[% type.id %]">)
              </span>
          [% END %]
        </td>
      [% END %]
191 192 193 194
    </tr>
  [% END %]

</table>