<%
# encoding: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2011-16 Karel Pičman <karel.picman@kontron.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
%>

<table class="display list dmsf_list" id="browser">
  <thead>
    <tr>
      <th class="dmsf_checkbox dmsf_th">
        <input id="check_all_entries" title="<%= l(:title_check_uncheck_all_for_zip_download_or_email) %>" type="checkbox" />
      </th>
      <th class ="dmsf_th"><%= l(:link_title) %></th>
      <th class ="dmsf_th"><%= l(:link_size) %></th>
      <th class ="dmsf_th"><%= l(:link_modified) %></th>
      <th title="<%= l(:label_dmsf_version) %>" class ="dmsf_th"><%= l(:link_ver) %></th>
      <th class ="dmsf_th"><%= l(:link_workflow) %></th>
      <th class ="dmsf_th"><%= l(:link_author) %></th>
      <th class ="dmsf_th"></th>
      <th class="dmsf_invisible"></th>
      <th class="dmsf_invisible"></th>
      <th class="dmsf_invisible"></th>
      <th class="dmsf_invisible"></th>
    </tr>
  </thead>
  <tbody>
  <% @subfolders.each do |subfolder| %>
    <tr class="dir">
      <%= render(:partial => 'dir',
        :locals => {
          :project => @project,
          :subfolder => subfolder,
          :link => nil,
          :id => subfolder.id,
          :name => 'subfolders[]',
          :title => subfolder.title,
          :position => 0 }) %>
    </tr>
  <% end %>
  <% @dir_links.each do |link| %>
    <% unless link.target_project %>
      <% Rails.logger.error "Error: dmsf_link id #{link.id} has no target!" %>
      <% next %>
    <% end %>
    <tr class="dmsf_gray">
      <%= render(:partial => 'dir',
        :locals => {
          :project => link.target_project,
          :subfolder => link.target_folder,
          :link => link,
          :id => link.id,
          :name => 'dir_links[]',
          :title => link.name,
          :position => 0}) %>
    </tr>
  <% end %>
  <% @files.each do |file| %>
    <% unless file.last_revision %>
      <% Rails.logger.error "Error: dmsf_file id #{file.id} has no revision!" %>
      <% next %>
    <% end %>
    <tr class="file">
      <%= render(:partial => 'file', :locals => {
          :project => @project,
          :file => file,
          :link => nil,
          :id => file.id,
          :name => 'files[]',
          :title => file.title,
          :position => 1 }) %>
    </tr>
  <% end %>
  <% @file_links.each do |link| %>
    <% unless link.target_file.last_revision %>
      <% Rails.logger.error "Error: dmsf_file id #{link.target_id} has no revision!" %>
      <% next %>
      <% end %>
      <tr class="dmsf_gray">
        <%= render(:partial => 'file', :locals => {
            :project => link.target_project,
            :file => link.target_file,
            :link => link,
            :id => link.id,
            :name => 'file_links[]',
            :title => link.name,
            :position => 1}) %>
      </tr>
    <% end %>
    <% @url_links.each do |link| %>
      <tr class="dmsf_gray">
        <%= render(:partial => 'url', :locals => {
            :project => link.target_project,
            :file => link.target_file,
            :link => link,
            :id => link.id,
            :name => 'file_links[]',
            :title => link.name,
            :position => 1}) %>
      </tr>
    <% end %>
  </tbody>
</table>
