mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-06 12:43:06 +08:00
Merge pull request #1436 from okriuchykhin/ok_SCI_2904
Disable edit button for unsupported WOPI formats [SCI-2904]
This commit is contained in:
commit
8ea37c541b
6 changed files with 60 additions and 14 deletions
|
@ -56,6 +56,9 @@
|
|||
modal.modal('hide');
|
||||
});
|
||||
modal.modal();
|
||||
modal.find('a[disabled=disabled]').click(function(ev){
|
||||
ev.preventDefault();
|
||||
});
|
||||
$('.modal-backdrop').last().css('z-index', modal.css('z-index') - 1);
|
||||
},
|
||||
error: function(ev) {
|
||||
|
|
|
@ -78,9 +78,28 @@ class AssetsController < ApplicationController
|
|||
elsif @assoc.class == RepositoryCell
|
||||
can_manage_repository_rows?(@repository.team)
|
||||
end
|
||||
file_ext = @asset.file_file_name.split('.').last
|
||||
if Constants::WOPI_EDITABLE_FORMATS.include?(file_ext)
|
||||
edit_supported = true
|
||||
title = ''
|
||||
else
|
||||
edit_supported = false
|
||||
title = if Constants::FILE_TEXT_FORMATS.include?(file_ext)
|
||||
I18n.t('assets.wopi_supported_text_formats_title')
|
||||
elsif Constants::FILE_TABLE_FORMATS.include?(file_ext)
|
||||
I18n.t('assets.wopi_supported_table_formats_title')
|
||||
else
|
||||
I18n.t('assets.wopi_supported_presentation_formats_title')
|
||||
end
|
||||
end
|
||||
response_json['wopi-controls'] = render_to_string(
|
||||
partial: 'shared/file_wopi_controlls.html.erb',
|
||||
locals: { asset: @asset, can_edit: can_edit }
|
||||
locals: {
|
||||
asset: @asset,
|
||||
can_edit: can_edit,
|
||||
edit_supported: edit_supported,
|
||||
title: title
|
||||
}
|
||||
)
|
||||
end
|
||||
respond_to do |format|
|
||||
|
|
|
@ -7,11 +7,11 @@ module FileIconsHelper
|
|||
# For showing next to file
|
||||
def file_fa_icon_class(asset)
|
||||
file_ext = asset.file_file_name.split('.').last
|
||||
if %w(doc docm docx dot dotm dotx odt rtf).include?(file_ext)
|
||||
if Constants::FILE_TEXT_FORMATS.include?(file_ext)
|
||||
fa_class = 'fa-file-word'
|
||||
elsif %w(ods xls xlsb xlsm xlsx).include?(file_ext)
|
||||
elsif Constants::FILE_TABLE_FORMATS.include?(file_ext)
|
||||
fa_class = 'fa-file-excel'
|
||||
elsif %w(odp pot potm potx pps ppsm ppsx ppt pptm pptx).include?(file_ext)
|
||||
elsif Constants::FILE_PRESENTATION_FORMATS.include?(file_ext)
|
||||
fa_class = 'fa-file-powerpoint'
|
||||
elsif %w(pdf).include?(file_ext)
|
||||
fa_class = 'fa-file-pdf'
|
||||
|
@ -31,11 +31,11 @@ module FileIconsHelper
|
|||
# For showing next to file
|
||||
def file_extension_icon(asset)
|
||||
file_ext = asset.file_file_name.split('.').last
|
||||
if %w(doc docm docx dot dotm dotx odt rtf).include?(file_ext)
|
||||
if Constants::FILE_TEXT_FORMATS.include?(file_ext)
|
||||
image_link = 'office/Word-docx_20x20x32.png'
|
||||
elsif %w(csv ods xls xlsb xlsm xlsx).include?(file_ext)
|
||||
elsif Constants::FILE_TABLE_FORMATS.include?(file_ext)
|
||||
image_link = 'office/Excel-xlsx_20x20x32.png'
|
||||
elsif %w(odp pot potm potx pps ppsm ppsx ppt pptm pptx).include?(file_ext)
|
||||
elsif Constants::FILE_PRESENTATION_FORMATS.include?(file_ext)
|
||||
image_link = 'office/PowerPoint-pptx_20x20x32.png'
|
||||
end
|
||||
|
||||
|
@ -54,11 +54,11 @@ module FileIconsHelper
|
|||
# For showing in view/edit buttons (WOPI)
|
||||
def file_application_icon(asset)
|
||||
file_ext = asset.file_file_name.split('.').last
|
||||
if %w(doc docm docx dot dotm dotx odt rtf).include?(file_ext)
|
||||
if Constants::FILE_TEXT_FORMATS.include?(file_ext)
|
||||
image_link = 'office/Word-color_16x16x32.png'
|
||||
elsif %w(csv ods xls xlsb xlsm xlsx).include?(file_ext)
|
||||
elsif Constants::FILE_TABLE_FORMATS.include?(file_ext)
|
||||
image_link = 'office/Excel-color_16x16x32.png'
|
||||
elsif %w(odp pot potm potx pps ppsm ppsx ppt pptm pptx).include?(file_ext)
|
||||
elsif Constants::FILE_PRESENTATION_FORMATS.include?(file_ext)
|
||||
image_link = 'office/PowerPoint-Color_16x16x32.png'
|
||||
end
|
||||
|
||||
|
@ -72,11 +72,11 @@ module FileIconsHelper
|
|||
# Shows correct WOPI application text (Word Online/Excel ..)
|
||||
def wopi_button_text(asset, action)
|
||||
file_ext = asset.file_file_name.split('.').last
|
||||
if %w(doc docm docx dot dotm dotx odt rtf).include?(file_ext)
|
||||
if Constants::FILE_TEXT_FORMATS.include?(file_ext)
|
||||
app = 'Word Online'
|
||||
elsif %w(csv ods xls xlsb xlsm xlsx).include?(file_ext)
|
||||
elsif Constants::FILE_TABLE_FORMATS.include?(file_ext)
|
||||
app = 'Excel Online'
|
||||
elsif %w(odp pot potm potx pps ppsm ppsx ppt pptm pptx).include?(file_ext)
|
||||
elsif Constants::FILE_PRESENTATION_FORMATS.include?(file_ext)
|
||||
app = 'PowerPoint Online'
|
||||
end
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<%= file_application_icon(asset) %>
|
||||
<%= wopi_button_text(asset, 'view') %>
|
||||
<% end %>
|
||||
<% if can_edit %>
|
||||
<% if can_edit && edit_supported %>
|
||||
<%= link_to edit_asset_url(id: asset),
|
||||
class: 'btn btn-default btn-sm',
|
||||
target: '_blank',
|
||||
|
@ -13,4 +13,14 @@
|
|||
<%= file_application_icon(asset) %>
|
||||
<%= wopi_button_text(asset, 'edit') %>
|
||||
<% end %>
|
||||
<% elsif can_edit %>
|
||||
<%= link_to edit_asset_url(id: asset),
|
||||
class: 'btn btn-default btn-sm',
|
||||
target: '_blank',
|
||||
title: title,
|
||||
disabled: true,
|
||||
style: 'display: inline-block' do %>
|
||||
<%= file_application_icon(asset) %>
|
||||
<%= wopi_button_text(asset, 'edit') %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -187,6 +187,17 @@ class Constants
|
|||
# Other
|
||||
#=============================================================================
|
||||
|
||||
FILE_TEXT_FORMATS = %w(doc docm docx dot dotm dotx odt rtf).freeze
|
||||
|
||||
FILE_TABLE_FORMATS = %w(csv ods xls xlsb xlsm xlsx).freeze
|
||||
|
||||
FILE_PRESENTATION_FORMATS =
|
||||
%w(odp pot potm potx pps ppsm ppsx ppt pptm pptx).freeze
|
||||
|
||||
WOPI_EDITABLE_FORMATS = %w(
|
||||
docx docm odt xlsx xlsm xlsb ods pptx ppsx odp
|
||||
).freeze
|
||||
|
||||
TEXT_EXTRACT_FILE_TYPES = [
|
||||
'application/msword',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||
|
|
|
@ -1918,6 +1918,9 @@ en:
|
|||
add_image: 'Add'
|
||||
file_name: 'File name'
|
||||
file_name_placeholder: 'Image'
|
||||
wopi_supported_text_formats_title: 'Only .docx, .docm, .odt file formats are supported for editing in Word Online.'
|
||||
wopi_supported_table_formats_title: 'Only .xlsx, .xlsm, .xlsb, .ods file formats are supported for editing in Excel Online.'
|
||||
wopi_supported_presentation_formats_title: 'Only .pptx, ppsx, .odp file formats are supported for editing in Powerpoint Online.'
|
||||
atwho:
|
||||
no_results: "No results found"
|
||||
users:
|
||||
|
|
Loading…
Reference in a new issue