mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-04 02:45:53 +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('hide');
|
||||||
});
|
});
|
||||||
modal.modal();
|
modal.modal();
|
||||||
|
modal.find('a[disabled=disabled]').click(function(ev){
|
||||||
|
ev.preventDefault();
|
||||||
|
});
|
||||||
$('.modal-backdrop').last().css('z-index', modal.css('z-index') - 1);
|
$('.modal-backdrop').last().css('z-index', modal.css('z-index') - 1);
|
||||||
},
|
},
|
||||||
error: function(ev) {
|
error: function(ev) {
|
||||||
|
|
|
@ -78,9 +78,28 @@ class AssetsController < ApplicationController
|
||||||
elsif @assoc.class == RepositoryCell
|
elsif @assoc.class == RepositoryCell
|
||||||
can_manage_repository_rows?(@repository.team)
|
can_manage_repository_rows?(@repository.team)
|
||||||
end
|
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(
|
response_json['wopi-controls'] = render_to_string(
|
||||||
partial: 'shared/file_wopi_controlls.html.erb',
|
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
|
end
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
@ -7,11 +7,11 @@ module FileIconsHelper
|
||||||
# For showing next to file
|
# For showing next to file
|
||||||
def file_fa_icon_class(asset)
|
def file_fa_icon_class(asset)
|
||||||
file_ext = asset.file_file_name.split('.').last
|
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'
|
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'
|
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'
|
fa_class = 'fa-file-powerpoint'
|
||||||
elsif %w(pdf).include?(file_ext)
|
elsif %w(pdf).include?(file_ext)
|
||||||
fa_class = 'fa-file-pdf'
|
fa_class = 'fa-file-pdf'
|
||||||
|
@ -31,11 +31,11 @@ module FileIconsHelper
|
||||||
# For showing next to file
|
# For showing next to file
|
||||||
def file_extension_icon(asset)
|
def file_extension_icon(asset)
|
||||||
file_ext = asset.file_file_name.split('.').last
|
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'
|
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'
|
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'
|
image_link = 'office/PowerPoint-pptx_20x20x32.png'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -54,11 +54,11 @@ module FileIconsHelper
|
||||||
# For showing in view/edit buttons (WOPI)
|
# For showing in view/edit buttons (WOPI)
|
||||||
def file_application_icon(asset)
|
def file_application_icon(asset)
|
||||||
file_ext = asset.file_file_name.split('.').last
|
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'
|
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'
|
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'
|
image_link = 'office/PowerPoint-Color_16x16x32.png'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -72,11 +72,11 @@ module FileIconsHelper
|
||||||
# Shows correct WOPI application text (Word Online/Excel ..)
|
# Shows correct WOPI application text (Word Online/Excel ..)
|
||||||
def wopi_button_text(asset, action)
|
def wopi_button_text(asset, action)
|
||||||
file_ext = asset.file_file_name.split('.').last
|
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'
|
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'
|
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'
|
app = 'PowerPoint Online'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<%= file_application_icon(asset) %>
|
<%= file_application_icon(asset) %>
|
||||||
<%= wopi_button_text(asset, 'view') %>
|
<%= wopi_button_text(asset, 'view') %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if can_edit %>
|
<% if can_edit && edit_supported %>
|
||||||
<%= link_to edit_asset_url(id: asset),
|
<%= link_to edit_asset_url(id: asset),
|
||||||
class: 'btn btn-default btn-sm',
|
class: 'btn btn-default btn-sm',
|
||||||
target: '_blank',
|
target: '_blank',
|
||||||
|
@ -13,4 +13,14 @@
|
||||||
<%= file_application_icon(asset) %>
|
<%= file_application_icon(asset) %>
|
||||||
<%= wopi_button_text(asset, 'edit') %>
|
<%= wopi_button_text(asset, 'edit') %>
|
||||||
<% end %>
|
<% 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 %>
|
<% end %>
|
||||||
|
|
|
@ -187,6 +187,17 @@ class Constants
|
||||||
# Other
|
# 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 = [
|
TEXT_EXTRACT_FILE_TYPES = [
|
||||||
'application/msword',
|
'application/msword',
|
||||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
||||||
|
|
|
@ -1918,6 +1918,9 @@ en:
|
||||||
add_image: 'Add'
|
add_image: 'Add'
|
||||||
file_name: 'File name'
|
file_name: 'File name'
|
||||||
file_name_placeholder: 'Image'
|
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:
|
atwho:
|
||||||
no_results: "No results found"
|
no_results: "No results found"
|
||||||
users:
|
users:
|
||||||
|
|
Loading…
Add table
Reference in a new issue