mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-27 22:49:02 +08:00
Disable WOPI edit button in read only mode [SCI-3281]
This commit is contained in:
parent
ffa7c5ecb2
commit
c47d243b1f
3 changed files with 15 additions and 17 deletions
|
|
@ -353,8 +353,12 @@ var FilePreviewModal = (function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
modal.find('.file-edit-link').css('display', 'none');
|
||||||
modal.find('.file-preview-container').html(data['preview-icon']);
|
modal.find('.file-preview-container').html(data['preview-icon']);
|
||||||
}
|
}
|
||||||
|
if (readOnly) {
|
||||||
|
modal.find('#wopi_file_edit_button').remove();
|
||||||
|
}
|
||||||
if (data.processing) {
|
if (data.processing) {
|
||||||
checkFileReady(url, modal);
|
checkFileReady(url, modal);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,15 +52,15 @@ class AssetsController < ApplicationController
|
||||||
'download-url' => download_asset_path(@asset, timestamp: Time.now.to_i)
|
'download-url' => download_asset_path(@asset, timestamp: Time.now.to_i)
|
||||||
}
|
}
|
||||||
|
|
||||||
if @asset.is_image?
|
can_edit = if @assoc.class == Step
|
||||||
can_edit = if @assoc.class == Step
|
can_manage_protocol_in_module?(@protocol) || can_manage_protocol_in_repository?(@protocol)
|
||||||
can_manage_protocol_in_module?(@protocol) || can_manage_protocol_in_repository?(@protocol)
|
elsif @assoc.class == Result
|
||||||
elsif @assoc.class == Result
|
can_manage_module?(@my_module)
|
||||||
can_manage_module?(@my_module)
|
elsif @assoc.class == RepositoryCell
|
||||||
elsif @assoc.class == RepositoryCell
|
can_manage_repository_rows?(@repository.team)
|
||||||
can_manage_repository_rows?(@repository.team)
|
end
|
||||||
end
|
|
||||||
|
|
||||||
|
if @asset.is_image?
|
||||||
response_json.merge!(
|
response_json.merge!(
|
||||||
'editable' => @asset.editable_image? && can_edit,
|
'editable' => @asset.editable_image? && can_edit,
|
||||||
'processing' => @asset.file.processing?,
|
'processing' => @asset.file.processing?,
|
||||||
|
|
@ -78,15 +78,6 @@ class AssetsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if wopi_file?(@asset)
|
if wopi_file?(@asset)
|
||||||
can_edit =
|
|
||||||
if @assoc.class == Step
|
|
||||||
can_manage_protocol_in_module?(@protocol) ||
|
|
||||||
can_manage_protocol_in_repository?(@protocol)
|
|
||||||
elsif @assoc.class == Result
|
|
||||||
can_manage_module?(@my_module)
|
|
||||||
elsif @assoc.class == RepositoryCell
|
|
||||||
can_manage_repository_rows?(@repository.team)
|
|
||||||
end
|
|
||||||
edit_supported, title = wopi_file_edit_button_status
|
edit_supported, title = wopi_file_edit_button_status
|
||||||
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',
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<%= link_to view_asset_url(id: asset),
|
<%= link_to view_asset_url(id: asset),
|
||||||
|
id: 'wopi_file_view_button',
|
||||||
class: 'btn btn-default btn-sm',
|
class: 'btn btn-default btn-sm',
|
||||||
target: '_blank',
|
target: '_blank',
|
||||||
style: 'display: inline-block' do %>
|
style: 'display: inline-block' do %>
|
||||||
|
|
@ -7,6 +8,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if can_edit && edit_supported %>
|
<% if can_edit && edit_supported %>
|
||||||
<%= link_to edit_asset_url(id: asset),
|
<%= link_to edit_asset_url(id: asset),
|
||||||
|
id: 'wopi_file_edit_button',
|
||||||
class: 'btn btn-default btn-sm',
|
class: 'btn btn-default btn-sm',
|
||||||
target: '_blank',
|
target: '_blank',
|
||||||
style: 'display: inline-block' do %>
|
style: 'display: inline-block' do %>
|
||||||
|
|
@ -15,6 +17,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% elsif can_edit %>
|
<% elsif can_edit %>
|
||||||
<%= link_to edit_asset_url(id: asset),
|
<%= link_to edit_asset_url(id: asset),
|
||||||
|
id: 'wopi_file_edit_button',
|
||||||
class: 'btn btn-default btn-sm',
|
class: 'btn btn-default btn-sm',
|
||||||
target: '_blank',
|
target: '_blank',
|
||||||
title: title,
|
title: title,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue