mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-09 22:23:28 +08:00
Merge pull request #1705 from urbanrotnik/ur-sci-3387-office-files-icons
Show icons for office files [SCI-3387]
This commit is contained in:
commit
dba1ccfc34
2 changed files with 9 additions and 23 deletions
|
@ -4,34 +4,20 @@ module FileIconsHelper
|
|||
%w(csv ods xls xlsb xlsm xlsx odp pot potm potx pps ppsm ppsx ppt pptm pptx doc docm docx dot dotm dotx odt rtf).include?(file_ext)
|
||||
end
|
||||
|
||||
# For showing next to file
|
||||
def file_fa_icon_class(asset)
|
||||
file_ext = asset.file_file_name.split('.').last
|
||||
if Constants::FILE_TEXT_FORMATS.include?(file_ext)
|
||||
fa_class = 'fa-file-word'
|
||||
|
||||
if Extends::FILE_FA_ICON_MAPPINGS[file_ext] # Check for custom mappings or possible overrides
|
||||
return Extends::FILE_FA_ICON_MAPPINGS[file_ext]
|
||||
elsif Constants::FILE_TEXT_FORMATS.include?(file_ext)
|
||||
return 'fa-file-word'
|
||||
elsif Constants::FILE_TABLE_FORMATS.include?(file_ext)
|
||||
fa_class = 'fa-file-excel'
|
||||
return 'fa-file-excel'
|
||||
elsif Constants::FILE_PRESENTATION_FORMATS.include?(file_ext)
|
||||
fa_class = 'fa-file-powerpoint'
|
||||
return 'fa-file-powerpoint'
|
||||
elsif %w(pdf).include?(file_ext)
|
||||
fa_class = 'fa-file-pdf'
|
||||
return 'fa-file-pdf'
|
||||
elsif %w(txt csv tab tex).include?(file_ext)
|
||||
fa_class = 'fa-file-alt'
|
||||
end
|
||||
|
||||
# Now check for custom mappings or possible overrides
|
||||
if Extends::FILE_ICON_MAPPINGS[file_ext]
|
||||
fa_class = Extends::FILE_FA_ICON_MAPPINGS[file_ext]
|
||||
end
|
||||
|
||||
fa_class = 'fa-file' if fa_class.blank?
|
||||
fa_class
|
||||
end
|
||||
|
||||
def file_fa_icon_class_v2(asset)
|
||||
file_ext = asset.file_file_name.split('.').last
|
||||
|
||||
if Constants::FILE_TEXT_FORMATS.include?(file_ext)
|
||||
return 'fa-file-alt'
|
||||
elsif Constants::WHITELISTED_IMAGE_TYPES.include?(file_ext)
|
||||
return 'fa-image'
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<% if image_preview %>
|
||||
<%= image_tag image_preview %>
|
||||
<% else %>
|
||||
<i class="fas <%= file_fa_icon_class_v2(asset) if asset.file_file_name %>"></i>
|
||||
<i class="fas <%= file_fa_icon_class(asset) if asset.file_file_name %>"></i>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="attachment-label"><%= truncate(asset.file_file_name,
|
||||
|
|
Loading…
Reference in a new issue