mirror of
				https://github.com/scinote-eln/scinote-web.git
				synced 2025-11-01 00:56:05 +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 { | ||||
|           modal.find('.file-edit-link').css('display', 'none'); | ||||
|           modal.find('.file-preview-container').html(data['preview-icon']); | ||||
|         } | ||||
|         if (readOnly) { | ||||
|           modal.find('#wopi_file_edit_button').remove(); | ||||
|         } | ||||
|         if (data.processing) { | ||||
|           checkFileReady(url, modal); | ||||
|         } | ||||
|  |  | |||
|  | @ -52,15 +52,15 @@ class AssetsController < ApplicationController | |||
|       'download-url' => download_asset_path(@asset, timestamp: Time.now.to_i) | ||||
|     } | ||||
| 
 | ||||
|     if @asset.is_image? | ||||
|       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 | ||||
|     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 | ||||
| 
 | ||||
|     if @asset.is_image? | ||||
|       response_json.merge!( | ||||
|         'editable' =>  @asset.editable_image? && can_edit, | ||||
|         'processing' => @asset.file.processing?, | ||||
|  | @ -78,15 +78,6 @@ class AssetsController < ApplicationController | |||
|     end | ||||
| 
 | ||||
|     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 | ||||
|       response_json['wopi-controls'] = render_to_string( | ||||
|         partial: 'shared/file_wopi_controlls.html.erb', | ||||
|  |  | |||
|  | @ -1,4 +1,5 @@ | |||
| <%= link_to view_asset_url(id: asset), | ||||
|         id: 'wopi_file_view_button', | ||||
|         class: 'btn btn-default btn-sm', | ||||
|         target: '_blank', | ||||
|         style: 'display: inline-block' do %> | ||||
|  | @ -7,6 +8,7 @@ | |||
| <% end %> | ||||
| <% if can_edit && edit_supported %> | ||||
|   <%= link_to edit_asset_url(id: asset), | ||||
|           id: 'wopi_file_edit_button', | ||||
|           class: 'btn btn-default btn-sm', | ||||
|           target: '_blank', | ||||
|           style: 'display: inline-block' do %> | ||||
|  | @ -15,6 +17,7 @@ | |||
|   <% end %> | ||||
| <% elsif can_edit %> | ||||
|   <%= link_to edit_asset_url(id: asset), | ||||
|           id: 'wopi_file_edit_button', | ||||
|           class: 'btn btn-default btn-sm', | ||||
|           target: '_blank', | ||||
|           title: title, | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue