This commit is contained in:
Karel Picman 2018-02-13 15:10:15 +01:00
parent d07b83102e
commit a980eca47d
2 changed files with 19 additions and 2 deletions

View File

@ -34,6 +34,16 @@ class DmsfFileRevision < ActiveRecord::Base
STATUS_DELETED = 1
STATUS_ACTIVE = 0
PROTOCOLS = {
'application/msword' => 'ms-word',
'application/vnd.ms-excel' => 'ms-excel',
'application/vnd.ms-powerpoint' => 'ms-powerpoint',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'ms-word',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'ms-excel',
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'ms-powerpoint',
'application/vnd.openxmlformats-officedocument.presentationml.slideshow' => 'ms-powerpoint'
}.freeze
scope :visible, -> { where(:deleted => STATUS_ACTIVE) }
scope :deleted, -> { where(:deleted => STATUS_DELETED) }
@ -340,4 +350,11 @@ class DmsfFileRevision < ActiveRecord::Base
tooltip
end
def protocol
unless @protocol
@protocol = PROTOCOLS[self.mime_type]
end
@protocol
end
end

View File

@ -22,8 +22,8 @@
<ul>
<li>
<% if @file && @file.last_revision %>
<% url = "ms-word:ofe|u|#{Setting.protocol.strip}://#{Setting.host_name.strip}/#{Addressable::URI.escape(@file.project.identifier)}/" %>
<% if @file && @file.last_revision && @file.last_revision.protocol %>
<% url = "#{@file.last_revision.protocol}:ofe|u|#{Setting.protocol.strip}://#{Setting.host_name.strip}/dmsf/webdav/#{Addressable::URI.escape(@file.project.identifier)}/" %>
<% if @file.dmsf_folder %>
<% url << @file.dmsf_folder.dmsf_path_str %>
<% end %>