redmine_dmsf/app/views/dmsf/_file.html.erb
2017-04-26 12:08:53 +02:00

144 lines
5.6 KiB
Plaintext

<%
# encode: utf-8
#
# Redmine plugin for Document Management System "Features"
#
# Copyright (C) 2011-17 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.
%>
<% wf = DmsfWorkflow.find_by_id(file.last_revision.dmsf_workflow_id) if file.last_revision.dmsf_workflow_id %>
<td class="dmsf_checkbox"><%= check_box_tag(name, id, false,
:title => l(:title_check_for_zip_download_or_email), :id => "file_#{id}") %></td>
<% if DmsfFolder.is_column_on?('id') %>
<td class="id"><%= link_to(file.id, dmsf_file_path(:id => file)) %></td>
<% end %>
<% if DmsfFolder.is_column_on?('title') %>
<td class="dmsf_title">
<% if @tree_view %>
<span class='dmsf_expander'></span>
<% end %>
<% file_view_url = url_for({:controller => :dmsf_files, :action => 'view', :id => file}) %>
<%= link_to(h(title),
file_view_url,
:target => '_blank',
:class => "icon icon-file #{DmsfHelper.filetype_css(file.name)}",
:title => h(file.last_revision.try(:tooltip)),
'data-downloadurl' => "#{file.last_revision.detect_content_type}:#{h(file.name)}:#{file_view_url}") %>
<div class="dmsf_filename" title="<%= l(:title_filename_for_download)%>"><%= h(link ? link.path : file.display_name) %></div>
</td>
<% end %>
<% if DmsfFolder.is_column_on?('extension') %>
<td class="dmsf_extension">
<%= file.extension %>
</td>
<% end %>
<% if DmsfFolder.is_column_on?('size') %>
<td class="dmsf_size"><%= number_to_human_size(file.last_revision.size) %></td>
<% end %>
<% if DmsfFolder.is_column_on?('modified') %>
<td class="dmsf_modified">
<%= format_time(file.last_revision.updated_at) %>
</td>
<% end %>
<% if DmsfFolder.is_column_on?('version') %>
<td class="dmsf_version" title="<%= file.last_revision.comment %>"><%= file.last_revision.version %></td>
<% end %>
<% if DmsfFolder.is_column_on?('workflow') %>
<td class="dmsf_workflow">
<% if wf && @file_approval_allowed %>
<%= link_to(
file.last_revision.workflow_str(false),
log_dmsf_workflow_path(
:project_id => project.id,
:id => wf.id,
:dmsf_file_revision_id => file.last_revision.id),
:title => file.last_revision.workflow_tooltip,
:remote => true) %>
<% else %>
<%= file.last_revision.workflow_str(false) %>
<% end %>
</td>
<% end %>
<% if DmsfFolder.is_column_on?('author') %>
<td class="dmsf_author"><%= h(file.last_revision.user) %></td>
<% end %>
<% cfs = CustomField.where(:type => 'DmsfFileRevisionCustomField').order(:position) %>
<% cfs.each do |c| %>
<% if DmsfFolder.is_column_on?(c.name) %>
<td class="dmsf_cf">
<%= file.custom_value(c) %>
</td>
<% end %>
<% end %>
<td class="dmsf_buttons">
<% if @file_manipulation_allowed %>
<%= link_to('', dmsf_file_path(:id => file),
:title => l(:link_details, :title => h(file.last_revision.title)),
:class => 'icon icon-edit') %>
<% if !file.locked? %>
<%= link_to('', lock_dmsf_files_path(:id => file),
:title => l(:title_lock_file),
:class => 'icon icon-lock') %>
<% elsif file.unlockable? && (!file.locked_for_user? || @force_file_unlock_allowed) %>
<%= link_to('', unlock_dmsf_files_path(:id => file),
:title => file.get_locked_title,
:class => 'icon icon-unlock') %>
<% else %>
<span class="icon icon-unlock" title="<%= file.get_locked_title %>"></span>
<% end %>
<% unless file.locked? %>
<% if file.notification %>
<%= link_to('', notify_deactivate_dmsf_files_path(:id => file),
:title => l(:title_notifications_active_deactivate),
:class => 'icon icon-email') %>
<% else %>
<%= link_to('', notify_activate_dmsf_files_path(:id => file),
:title => l(:title_notifications_not_active_activate),
:class => 'icon icon-email-add') %>
<% end %>
<% if link %>
<%= link_to('', dmsf_link_path(link),
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:title_delete),
:method => :delete,
:class => 'icon icon-del') %>
<% else %>
<% if @file_delete_allowed %>
<%= link_to('', dmsf_file_path(:id => file),
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:title_delete),
:method => :delete,
:class => 'icon icon-del') %>
<% else %>
<span class="icon"></span>
<% end %>
<% end %>
<% else %>
<span class="icon"></span>
<span class="icon"></span>
<% end %>
<% end %>
<%= render(:partial => 'dmsf_files/approval_workflow_button',
:locals => {:file => file, :file_approval_allowed => @file_approval_allowed,
:workflows_available => @workflows_available, :project => project, :wf => wf }) %>
</td>
<td class="hol"><%= position %></td>
<td class="hol"><%= file.last_revision.size %></td>
<td class="hol"><%= file.last_revision.updated_at.to_i %></td>
<td class="hol"><%= file.last_revision.iversion %></td>