summaryrefslogtreecommitdiffstats
path: root/extensions/ComponentWatching/template/en/default/account/prefs/component_watch.html.tmpl
blob: 05c1453dbb36e2f92b539dec2fac6d37aeaacb98 (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
[%# 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.
  #%]

[%# initialise product to component mapping #%]

[% SET selectable_products = user.get_selectable_products %]
[% SET dont_show_button = 1 %]

<script>
var Dom = YAHOO.util.Dom;
var useclassification = false;
var first_load = true;
var last_sel = [];
var cpts = new Array();
var watch_users = new Array();
[% n = 0 %]
[% FOREACH prod = selectable_products %]
  cpts['[% n %]'] = [
    [%- FOREACH comp = prod.components %]'[% comp.name FILTER js %]'[% ", " UNLESS loop.last %] [%- END -%] ];
  [% n = n + 1 %]
  [% FOREACH comp = prod.components %]
    [% IF comp.watch_user %]
      if (!watch_users['[% prod.name FILTER js %]'])
        watch_users['[% prod.name FILTER js %]'] = new Array();
      watch_users['[% prod.name FILTER js %]']['[% comp.name FILTER js %]'] = '[% comp.watch_user.login FILTER js %]';
    [% END %]
  [% END %]
[% END %]
</script>
<script type="text/javascript" src="[% 'js/productform.js' FILTER mtime FILTER html %]">
</script>

<script>
function onSelectProduct() {
  var component = Dom.get('component');
  selectProduct(Dom.get('product'), component);
  // selectProduct only supports __Any__ on both elements
  // we only want it on component, so add it back in
  try {
    component.add(new Option('__Any__', ''), component.options[0]);
  } catch(e) {
    // support IE
    component.add(new Option('__Any__', ''), 0);
  }
  if ('[% add_component FILTER js %]' != ''
      && bz_valueSelected(Dom.get('product'), '[% add_product FILTER js %]')
  ) {
    var index = bz_optionIndex(Dom.get('component'), '[% add_component FILTER js %]');
    if (index != -1)
      Dom.get('component').options[index].selected = true;
  }
  onSelectComponent();
}

function onSelectComponent() {
  var product_select = Dom.get('product');
  var product = product_select.options[product_select.selectedIndex].value;
  var component = Dom.get('component').value;
  if (component && watch_users[product] && watch_users[product][component]) {
    Dom.get('watch-user-email').innerHTML = watch_users[product][component];
    Dom.get('watch-user-div').style.display = '';
  } else {
    Dom.get('watch-user-div').style.display = 'none';
  }
  Dom.get('add').disabled = Dom.get('component').selectedIndex == -1;
}

YAHOO.util.Event.onDOMReady(onSelectProduct);

function onRemoveChange() {
  var cbs = Dom.get('remove_table').getElementsByTagName('input');
  for (var i = 0, l = cbs.length; i < l; i++) {
    if (cbs[i].checked) {
      Dom.get('remove').disabled = false;
      return;
    }
  }
  Dom.get('remove').disabled = true;
}

YAHOO.util.Event.onDOMReady(onRemoveChange);

</script>

<p>
  Select the components you want to watch.
  To watch all components in a product, watch "__Any__".<br>
  Use <a href="userprefs.cgi?tab=email">Email Preferences</a> to filter which
  notification emails you receive.
</p>

<table border="0" cellpadding="3" cellspacing="0">
<tr>
  <td align="right">Product:</td>
  <td colspan="2">
    <select name="add_product" id="product" onChange="onSelectProduct()">
    [% FOREACH product IN selectable_products %]
      <option [% 'selected' IF add_product == product.name %]>
        [%~ product.name FILTER html %]</option>
    [% END %]
    </select>
  </td>
</tr>
<tr>
  <td align="right" valign="top">Component:</td>
  <td>
    <select name="add_component" id="component" multiple size="10" onChange="onSelectComponent()">
      <option value="">__Any__</option>
    [% FOREACH product IN selectable_products %]
      [% FOREACH component IN product.components %]
        <option [% 'selected' IF add_component == component.name %]>
          [%~ component.name FILTER html %]</option>
      [% END %]
    [% END %]
    </select>
  </td>
  <td valign="top">
    <div id="watch-user-div"
         title="You can also watch a component by following this user. [% ~%]
                CC'ing this user on a [% terms.bug %] will trigger notifications to all watchers of this component."
         style="cursor:help">
      Watch User: <span id="watch-user-email"></span>
    </div>
  </td>
</tr>
<tr>
  <td>&nbsp;</td>
  <td><input type="submit" id="add" name="add" value="Add"></td>
</tr>
</table>

<hr>
<p>
  You are currently watching:
</p>

[% IF watches.size %]

  <table border="0" cellpadding="3" cellspacing="0" id="remove_table">
  <tr>
    <td>&nbsp;</td>
    <td><b>Product</b></td>
    <td>&nbsp;<b>Component</b></td>
  </tr>
  [% FOREACH watch IN watches %]
    <tr>
    [% IF (watch.component) %]
      <td>
        <input type="checkbox" onChange="onRemoveChange()" id="cwdel_[% loop.count %]" value="1"
               name="del_[% watch.product.id FILTER html %]_[% watch.component.id FILTER html %]">
      </td>
      <td>
        <label for="cwdel_[% loop.count %]">
          [% watch.component.product.name FILTER html %]
        </label>
      </td>
      <td>&nbsp;
        <a href="buglist.cgi?product=[% watch.product.name FILTER url_quote ~%]
                &component=[% watch.component.name FILTER url_quote %]&resolution=---">
        [% watch.component.name FILTER html %]
        </a>
      </td>
    [% ELSE %]
      <td>
        <input type="checkbox" onChange="onRemoveChange()" id="cwdel_[% loop.count %]" value="1"
               name="del_[% watch.product.id FILTER html %]" value="1">
      </td>
      <td>
        <label for="cwdel_[% loop.count %]">
          [% watch.product.name FILTER html %]
        </label>
      </td>
      <td>&nbsp;
        <a href="describecomponents.cgi?product=[% watch.product.name FILTER url_quote %]">
        __Any__
        </a>
      </td>
    [% END %]
    </tr>
  [% END %]
  </table>

  <input id="remove" type="submit" value="Remove Selected">

[% ELSE %]

  <p>
    <i>You are not watching any components directly.</i>
  </p>

[% END %]

[% IF user_watches.size %]

  <hr>
  <p>
    [% watches.size ? "In addition," : "However," %]
    you are watching the following components by watching users:
  </p>

  <table border="0" cellpadding="3" cellspacing="0">
  <tr>
    <td><b>User</b></td>
    <td>&nbsp;<b>Product</b></td>
    <td>&nbsp;<b>Component</b></td>
  </tr>
  [% FOREACH watch IN user_watches %]
    <tr>
      <td>[% watch.user.login FILTER html %]</td>
      <td>&nbsp;[% watch.component.product.name FILTER html %]</td>
      <td>&nbsp;
        <a href="buglist.cgi?product=[% watch.product.name FILTER url_quote ~%]
                &component=[% watch.component.name FILTER url_quote %]&resolution=---">
        [% watch.component.name FILTER html %]
        </a>
      </td>
    </tr>
  [% END %]
  </table>

  <p>
    Use <a href="userprefs.cgi?tab=email#new_watched_by_you">Email Preferences</a>
    to manage this list.
  </p>

[% END %]