<% @directories.each do |dir| %>
<%
if @directory.full_path.include?(dir.full_path)
dir = @directory
active = n
end
n = n + 1
%>
<% if !dir.parent_root? %>
<%= directory_links @directory %>
<% end %>
<% if !dir.subdirs.ordered.empty? %>
<% if dir.parent_root? %>
Sub-directories
<% end %>
<% dir.subdirs.ordered.each do |subdir| %>
- <%= link_to subdir.name, subdir %>
<% end %>
<% end %>
Files
<% dir.files.unrelated.each do |file| %>
<% if file.can_update? cuser %>
<%= link_to icon('pencil'), edit_data_file_path(file) %>
<% end %>
<% if file.can_destroy? cuser %>
<%= link_to icon('times'), file, confirm: 'Are you sure?', method: :delete %>
<% end %>
<%= namelink file %>
Size: <%= file.size_s %>MB
<%= link_to 'Download', file.url, class: 'button tiny' %>
<% end %>
<% if dir.files.empty? %>
Empty directory.
<% end %>
<% if cuser and cuser.admin? %>
<%= link_to "Edit Directory", edit_directory_path(dir), class: 'button' %>
<%= link_to "Delete Directory", dir, data: { confirm: "Are you sure?" }, method: 'delete', class: 'button' %>
<%= link_to "New Directory", { controller: "directories", action: "new", id: dir }, { class: 'button' } %>
<%= link_to "New File", { controller: "data_files", action: "new", id: dir }, { class: 'button' } %>
<% end %>
<% end %>