list.html.tmpl 6.22 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
[% RETURN UNLESS attachments.size || Param("maxattachmentsize") || Param("maxlocalattachment") %]
10

11
<script type="text/javascript">
12 13
<!--
function toggle_display(link) {
14
    var table = document.getElementById("attachment_table");
15 16
    var view_all = document.getElementById("view_all");
    var hide_obsolete_url_parameter = "&hide_obsolete=1";
17 18 19 20
    // Store current height for scrolling later
    var originalHeight = table.offsetHeight;
    var rows = YAHOO.util.Dom.getElementsByClassName(
        'bz_tr_obsolete', 'tr', table);
21

22 23
    for (var i = 0; i < rows.length; i++) {
        bz_toggleClass(rows[i], 'bz_default_hidden');
24 25
    }

26 27
    if (YAHOO.util.Dom.hasClass(rows[0], 'bz_default_hidden')) {
        link.innerHTML = "Show Obsolete";
28
        view_all.href = view_all.href + hide_obsolete_url_parameter 
29 30 31
    }
    else {
        link.innerHTML = "Hide Obsolete";
32
        view_all.href = view_all.href.replace(hide_obsolete_url_parameter,"");
33
    }
34 35

    var newHeight = table.offsetHeight;
36
    // This scrolling makes the window appear to not move at all.
37 38 39
    window.scrollBy(0, newHeight - originalHeight);

    return false;
40 41
}
//-->
42 43
</script>

44
<br>
45
<table id="attachment_table">
46
  <tr id="a0">
47
    <th colspan="[% show_attachment_flags ? 3 : 2 %]" class="left">
48
      Attachments
49
    </th>
50
  </tr>
51

52
  [% count = 0 %]
53
  [% obsolete_attachments = 0 %]
54
  [% user_cache = template_cache.users %]
55

56
  [% FOREACH attachment = attachments %]
57
    [% count = count + 1 %]
58
    [% IF !attachment.isprivate || user.is_insider || attachment.attacher.id == user.id %]
59 60 61
      [% IF attachment.isobsolete %]
        [% obsolete_attachments = obsolete_attachments + 1 %]
      [% END %]
62
      <tr id="a[% count %]" class="[% "bz_contenttype_" _ attachment.contenttype
63
                     FILTER css_class_quote %]
64 65
                 [% " bz_patch" IF attachment.ispatch %]
                 [% " bz_private" IF attachment.isprivate %]
66 67
                 [% " bz_tr_obsolete bz_default_hidden" 
                     IF attachment.isobsolete %]">
68
        <td>
69
          [% IF attachment.datasize %]
70
            <a href="attachment.cgi?id=[% attachment.id %]"
71
               title="View the content of the attachment">
72
          [% END %]
73
          <b>[% attachment.description FILTER html FILTER obsolete(attachment.isobsolete) %]</b>
74 75 76 77 78 79
          [% "</a>" IF attachment.datasize %]

          <span class="bz_attach_extra_info">
            [% IF attachment.datasize %]
              ([% attachment.datasize FILTER unitconvert %],
              [% IF attachment.ispatch %]
80
                patch)
81 82 83 84 85 86 87 88 89 90
              [% ELSE %]
                [%+ attachment.contenttype FILTER html %])
              [% END %]
            [% ELSE %]
              (<em>deleted</em>)
            [% END %]

            <br>
            <a href="#attach_[% attachment.id %]"
               title="Go to the comment associated with the attachment">
91
              [%- attachment.attached FILTER time("%Y-%m-%d %H:%M %Z") %]</a>,
92

93 94 95 96 97 98 99 100
            [%# No need to recreate the exact same template if we already have it. %]
            [% attacher_id = attachment.attacher.id %]
            [% UNLESS user_cache.$attacher_id %]
              [% user_cache.$attacher_id = BLOCK %]
                [% INCLUDE global/user.html.tmpl who = attachment.attacher %]
              [% END %]
            [% END %]
            [% user_cache.$attacher_id FILTER none %]
101
          </span>
102
        </td>
103 104

        [% IF show_attachment_flags %]
105
          <td class="bz_attach_flags">
106
            [% IF attachment.flags.size == 0 %]
107
              <i>no flags</i>
108 109
            [% ELSE %]
              [% FOREACH flag = attachment.flags %]
110 111 112 113 114 115 116
                [% IF user.id %]
                  <span title="[% flag.setter.identity FILTER html %]">[% flag.setter.nick FILTER html %]</span>:
                [% ELSIF flag.setter.name %]
                  <span title="[% flag.setter.name FILTER html %]">[% flag.setter.nick FILTER html %]</span>:
                [% ELSE %]
                  [% flag.setter.nick FILTER html %]:
                [% END %]
117
                [%+ flag.type.name FILTER html %][% flag.status %]
118
                [%+ IF flag.status == "?" && flag.requestee %]
119 120 121 122 123 124 125
                  [% IF user.id %]
                    (<span title="[% flag.requestee.identity FILTER html %]">[% flag.requestee.nick FILTER html %]</span>)
                  [% ELSIF flag.requestee.name %]
                    (<span title="[% flag.requestee.name FILTER html %]">[% flag.requestee.nick FILTER html %]</span>)
                  [% ELSE %]
                    ([% flag.requestee.nick FILTER html %])
                  [% END %]
126
                [% END %]<br>
127
              [% END %]
128
            [% END %]
129
          </td>
130
        [% END %]
131

132
        <td>
133
          <a href="attachment.cgi?id=[% attachment.id %]&amp;action=edit">Details</a>
134
          [% IF attachment.ispatch && feature_enabled('patch_viewer') %]
135
            | <a href="attachment.cgi?id=[% attachment.id %]&amp;action=diff">Diff</a>
136
          [% END %]
137
          [% Hook.process("action") %]
138 139 140
        </td>
      </tr>
    [% END %]
141 142
  [% END %]

143 144 145 146
  <tr class="bz_attach_footer">
    <td colspan="[% show_attachment_flags ? 3 : 2 %]">
      [% IF attachments.size %]
        <span class="bz_attach_view_hide">
147
          [% IF obsolete_attachments %]
148 149
            <a href="#a0" onclick="return toggle_display(this);">Show
              Obsolete</a> ([% obsolete_attachments %])
150 151
          [% END %]
          [% IF Param("allow_attachment_display") %]
152 153 154
            <a id="view_all" href="attachment.cgi?bugid=
                  [%- bugid %]&amp;action=viewall
                  [%- "&amp;hide_obsolete=1" IF obsolete_attachments %]">View All</a>
155 156 157
          [% END %]
        </span>
      [% END %]
158
      [% IF Param("maxattachmentsize") || Param("maxlocalattachment") %]
159 160 161
        <a href="attachment.cgi?bugid=[% bugid %]&amp;action=enter">Add an attachment</a>
        (proposed patch, testcase, etc.)
      [% END %]
162 163 164 165
    </td>
  </tr>
</table>
<br>