saved-searches.html.tmpl 5.96 KB
Newer Older
1 2 3
[%# 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/.
4
  #
5 6
  # This Source Code Form is "Incompatible With Secondary Licenses", as
  # defined by the Mozilla Public License, v. 2.0.
7 8
  #%]

9 10 11
[%# INTERFACE:
  # queryshare_groups: list of groups the user may share queries with
  #                    (id, name).
12
  # bless_group_ids: list of group ids the user may bless.
13 14
  #%]

15 16 17 18 19 20 21
[% IF user.can_bless %]
  <script type="text/javascript"><!--
    function update_checkbox(group) {
      var bless_groups = [[% bless_group_ids.join(",") FILTER js %]];
      var checkbox = document.getElementById(group.name.replace(/share_(\d+)/, "force_$1"));

      if (bz_isValueInArray(bless_groups, group.value)) {
22
        YAHOO.util.Dom.removeClass(checkbox.parentNode, "bz_default_hidden");
23
      } else {
24
        YAHOO.util.Dom.addClass(checkbox.parentNode, "bz_default_hidden");
25 26 27 28 29 30
        checkbox.checked = false;
      }
    } //-->
  </script>
[% END %]

31 32
<p>Your saved searches are as follows:</p>

33 34 35 36 37 38 39
  <table id="saved_search_prefs">
    <tr class="column_header">
      <th>Search</th>
      <th>Run</th>
      <th>Edit</th>
      <th>Forget</th>
      <th>Show in Footer</th>
40
      [% may_share = user.in_group(Param('querysharegroup')) && queryshare_groups.size %]
41
      [% IF may_share %]
42
        <th>Share With a Group</th>
43
      [% END %]
44
      [% Hook.process('saved-header') %]
45
    </tr>
46

47
    <tr>
48
      <td>My [% terms.Bugs %]</td>
49
      <td>
50
        [% filtered_username = user.login FILTER uri %]
51 52
        <a href="[% Param('mybugstemplate').replace('%userid%', filtered_username) %]">Run</a>
      </td>
53 54
      <td></td>
      <td></td>
55
      <td class="center">
56 57
        <input type="checkbox" name="showmybugslink" value="1"
               [%+ 'checked="checked"' IF user.showmybugslink %]>
58
      </td>
59
      [% IF may_share %]
60
        <td>&mdash;</td>
61
      [% END %]
62
      [% Hook.process('saved-row') %]
63
    </tr>
64

65
    [% FOREACH q = user.queries %]
66
      <tr [% 'class="shared_search"' IF q.shared_with_group.id %]>
67 68
        <td>[% q.name FILTER html %]</td>
        <td>
69 70
          <a href="buglist.cgi?cmdtype=dorem&amp;remaction=run&amp;namedcmd=[% q.name FILTER uri %]
                   [% IF q.shared_with_group.id %]&amp;sharer_id=[% user.id FILTER uri %][% END %]">Run</a>
71 72
        </td>
        <td>
73
          <a href="query.cgi?[% q.edit_link FILTER html %]&amp;known_name=
74
                   [% q.name FILTER uri %]">Edit</a>
75 76
        </td>
        <td>
77
          [% IF q.used_in_whine %]
78 79 80
            Remove from <a href="editwhines.cgi">whining</a> first
          [% ELSE %]
            <a href="buglist.cgi?cmdtype=dorem&amp;remaction=forget&amp;namedcmd=
81 82
                     [% q.name FILTER uri %]&amp;token=
                     [% issue_hash_token([q.id, q.name]) FILTER uri %]">Forget</a>
83
          [% END %]
84
        </td>
85
        <td class="center">
86
          <input type="checkbox" 
87 88
                 name="link_in_footer_[% q.id FILTER html %]"
                 value="1"
89
                 alt="[% q.name FILTER html %]"
90 91
                 [% " checked" IF q.link_in_footer %]>
        </td>
92 93
        [% IF may_share %]
          <td>
94 95
            <select name="share_[% q.id FILTER html %]"
              [% IF user.can_bless %] onchange="update_checkbox(this);"[% END %]>
96 97 98
              <option value="">Don't share</option>
              [% FOREACH group = queryshare_groups %]
                <option value="[% group.id %]"
99 100 101
                        [% ' selected="selected"' 
                           IF q.shared_with_group.id == group.id %]
                >[% group.name FILTER html %]</option>
102 103
              [% END %]
            </select>
104
            [% IF user.can_bless %]
105 106 107 108 109 110
              <span [% IF !bless_group_ids.grep("^$q.shared_with_group.id\$").0
                     %]class="bz_default_hidden"[% END %]>
                <input type="checkbox" id="force_[% q.id FILTER html %]"
                       name="force_[% q.id FILTER html %]" value="1">
                <label for="force_[% q.id FILTER html %]">Add to footer</label>
              </span>
111
            [% END %]
112 113 114 115
            [% IF q.shared_with_users %]
              (shared with [% q.shared_with_users FILTER html %]
              [%+ q.shared_with_users > 1 ? "users" : "user" %])
            [% END %]
116 117
          </td>
        [% END %]
118
        [% Hook.process('saved-row') %]
119 120 121
      </tr>
    [% END %]
  </table>
122

123 124 125 126 127
[% IF user.can_bless %]
  <p>Note that for every search that has the "Add to footer" selected, a
     link to the shared search is added to the footer of every user that is
     a direct member of the group at the time you click Submit Changes.</p>
[% END %]
128

129 130
[% IF user.queries_available.size %]
  <p>You may use these searches saved and shared by others:</p>
131

132 133 134 135 136 137 138 139
  <table id="shared_search_prefs">
    <tr class="column_header">
      <th>Search</th>
      <th>Shared By</th>
      <th>Shared To</th>
      <th>Run</th>
      <th>Edit</th>
      <th>Show in Footer</th>
140
    </tr>
141

142
    [% FOREACH q = user.queries_available %]
143 144 145
      <tr>
        <td>[% q.name FILTER html %]</td>
        <td>[% q.user.identity FILTER html %]</td>
146
        <td>[% q.shared_with_group.name FILTER html %]</td>
147 148
        <td>
          <a href="buglist.cgi?cmdtype=dorem&amp;remaction=run&amp;namedcmd=
149 150
                   [% q.name FILTER uri %]&amp;sharer_id=
                   [% q.user.id FILTER uri %]">Run</a>
151
        </td>
152 153
        <td>
          <a href="query.cgi?[% q.edit_link FILTER html %]&amp;known_name=
154
                   [% q.name FILTER uri %]">Edit</a>
155
        </td>
156
        <td class="center">
157 158
          <input type="checkbox" 
                 name="link_in_footer_[% q.id FILTER html %]"
159
                 value="1"
160
                 alt="[% q.name FILTER html %]"
161 162 163 164
                 [% " checked" IF q.link_in_footer %]>
        </td>
      </tr>
    [% END %]
165
  </table>
166 167 168
[% ELSE %]
  <p>No searches are shared with you by other users.</p>
[% END %]