To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / app / views / files / index.html.erb @ 443:350acce374a2

History | View | Annotate | Download (2.8 KB)

1 22:40f7cfd4df19 chris
<div class="contextual">
2 37:94944d00e43c chris
<%= link_to(l(:label_attachment_new), new_project_file_path(@project), :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
3 22:40f7cfd4df19 chris
</div>
4
5
<h2><%=l(:label_attachment_plural)%></h2>
6
7
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
8 255:a7002a8f0eca chris
<% active_change_allowed = delete_allowed %>
9 22:40f7cfd4df19 chris
10
<table class="list files">
11
  <thead><tr>
12 256:e0dc03c8d745 chris
    <%= sort_header_tag('active', :caption => l(:field_active)) %>
13 22:40f7cfd4df19 chris
    <%= sort_header_tag('filename', :caption => l(:field_filename)) %>
14
    <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc') %>
15
    <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc') %>
16 255:a7002a8f0eca chris
    <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc') %>
17 22:40f7cfd4df19 chris
    <th>MD5</th>
18
    <th></th>
19
  </tr></thead>
20
  <tbody>
21 260:847add61573b chris
<% have_file = false %>
22 22:40f7cfd4df19 chris
<% @containers.each do |container| %>
23
  <% next if container.attachments.empty? -%>
24
        <% if container.is_a?(Version) -%>
25
  <tr>
26 255:a7002a8f0eca chris
          <th colspan="7" align="left">
27 22:40f7cfd4df19 chris
                  <%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package") %>
28
                </th>
29
        </tr>
30
        <% end -%>
31
  <% container.attachments.each do |file| %>
32 269:255fcd5f5a4e chris
  <tr class="file <%= cycle("odd", "even") %> <%= "active" if file.active? %>">
33 257:3ecf99348b9f chris
    <td class="active">
34 260:847add61573b chris
      <% have_file = true %>
35 257:3ecf99348b9f chris
      <% if active_change_allowed
36
           active_id = "active-" + file.id.to_s -%>
37
        <div id="<%= active_id %>">
38 258:ce817f379723 chris
        <%= link_to_remote image_tag(file.active? ? 'fav.png' : 'fav_off.png'),
39 257:3ecf99348b9f chris
              :url => {:controller => 'attachments', :action => 'toggle_active', :project_id => @project.id, :id => file},
40
              :update => active_id
41
        %>
42
        </div>
43
      <% else -%>
44
        <%= image_tag('fav.png') if file.active? %>
45
      <% end -%>
46
    </td>
47 269:255fcd5f5a4e chris
    <% if file.active? %>
48
      <td class="filename active"><%= link_to_attachment file, :download => true %><br><span class="description"><%= h(file.description) %></span></td>
49
    <% else %>
50
      <td class="filename"><%= link_to_attachment file, :download => true, :title => file.description %>
51
    <% end %>
52
    </td>
53 22:40f7cfd4df19 chris
    <td class="created_on"><%= format_time(file.created_on) %></td>
54
    <td class="filesize"><%= number_to_human_size(file.filesize) %></td>
55
    <td class="downloads"><%= file.downloads %></td>
56
    <td class="digest"><%= file.digest %></td>
57
    <td align="center">
58
    <%= link_to(image_tag('delete.png'), {:controller => 'attachments', :action => 'destroy', :id => file},
59
                                                                                                                                                                 :confirm => l(:text_are_you_sure), :method => :post) if delete_allowed %>
60
    </td>
61
  </tr>
62
  <% end
63
  reset_cycle %>
64
<% end %>
65
  </tbody>
66
</table>
67
68 260:847add61573b chris
<%= l(:text_files_active_change) if active_change_allowed and have_file %>
69 257:3ecf99348b9f chris
70 22:40f7cfd4df19 chris
<% html_title(l(:label_attachment_plural)) -%>