mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-31 12:09:17 +08:00
Fix the file preview modal so it supports WOPI_ENABLED == false
This commit is contained in:
parent
bbf54de9c7
commit
b78caef915
3 changed files with 16 additions and 9 deletions
|
@ -5,6 +5,7 @@ class AssetsController < ApplicationController
|
|||
include ActionView::Helpers::TextHelper
|
||||
include ActionView::Helpers::UrlHelper
|
||||
include ActionView::Context
|
||||
include ApplicationHelper
|
||||
include InputSanitizeHelper
|
||||
include FileIconsHelper
|
||||
|
||||
|
@ -81,7 +82,7 @@ class AssetsController < ApplicationController
|
|||
)
|
||||
end
|
||||
|
||||
if wopi_file?(@asset)
|
||||
if wopi_enabled? && wopi_file?(@asset)
|
||||
edit_supported, title = wopi_file_edit_button_status
|
||||
response_json['wopi-controls'] = render_to_string(
|
||||
partial: 'shared/file_wopi_controlls.html.erb',
|
||||
|
@ -293,6 +294,7 @@ class AssetsController < ApplicationController
|
|||
def asset_data_type(asset)
|
||||
return 'wopi' if wopi_file?(asset)
|
||||
return 'image' if asset.is_image?
|
||||
|
||||
'file'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -221,4 +221,8 @@ module ApplicationHelper
|
|||
user.avatar(style) == '/images/icon_small/missing.png' ||
|
||||
user.avatar(style) == '/images/thumb/missing.png'
|
||||
end
|
||||
|
||||
def wopi_enabled?
|
||||
ENV['WOPI_ENABLED'] == 'true'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<%= link_to create_wopi_file_path,
|
||||
class: 'btn btn-default create-wopi-file-btn',
|
||||
target: '_blank',
|
||||
<% if wopi_enabled? %>
|
||||
<%= link_to create_wopi_file_path,
|
||||
class: 'btn btn-default create-wopi-file-btn',
|
||||
target: '_blank',
|
||||
title: 'Create_new_file',
|
||||
data: { 'id': element_id, 'type': element_type, } do %>
|
||||
|
||||
<span class="btn btn-default new-asset-upload-button">
|
||||
<span class="fas fa-file-medical new-asset-upload-icon"></span>
|
||||
<%=t 'assets.create_wopi_file.button_text' %>
|
||||
</span>
|
||||
<span class="btn btn-default new-asset-upload-button">
|
||||
<span class="fas fa-file-medical new-asset-upload-icon"></span>
|
||||
<%=t 'assets.create_wopi_file.button_text' %>
|
||||
</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in a new issue