mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-06 20:05:55 +08:00
Make docx parser feature togglable [SCI-9094] (#6055)
This commit is contained in:
parent
207b302a03
commit
3c0389adc8
4 changed files with 10 additions and 3 deletions
|
@ -824,6 +824,8 @@ class ProtocolsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_docx
|
def import_docx
|
||||||
|
return render_403 unless Protocol.docx_parser_enabled?
|
||||||
|
|
||||||
temp_files_ids = []
|
temp_files_ids = []
|
||||||
params[:files].each do |file|
|
params[:files].each do |file|
|
||||||
temp_file = TempFile.new(session_id: request.session_options[:id], file: file)
|
temp_file = TempFile.new(session_id: request.session_options[:id], file: file)
|
||||||
|
|
|
@ -232,6 +232,10 @@ class Protocol < ApplicationRecord
|
||||||
teams.blank? ? self : where(team: teams)
|
teams.blank? ? self : where(team: teams)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.docx_parser_enabled?
|
||||||
|
ENV.fetch('PROTOCOLS_PARSER_URL', nil).present?
|
||||||
|
end
|
||||||
|
|
||||||
def original_code
|
def original_code
|
||||||
# returns linked protocol code, or code of the original version of the linked protocol
|
# returns linked protocol code, or code of the original version of the linked protocol
|
||||||
parent&.parent&.code || parent&.code || code
|
parent&.parent&.code || parent&.code || code
|
||||||
|
|
|
@ -21,8 +21,8 @@
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li>
|
<li>
|
||||||
<a class="btn-link-alt btn-secondary-link btn-open-file" <%= can_create_protocols_in_repository?(@current_team) ? 'data-action="import"' : 'disabled="disabled"' %>>
|
<a class="btn-link-alt btn-secondary-link btn-open-file" <%= can_create_protocols_in_repository?(@current_team) ? 'data-action="import"' : 'disabled="disabled"' %>>
|
||||||
<span><%= t("protocols.index.import_alt") %></span>
|
<span><%= Protocol.docx_parser_enabled? ? t('protocols.index.import_eln_docx') : t('protocols.index.import_eln') %></span>
|
||||||
<input type="file" value="" accept=".eln,.docx" data-role="import-file-input"
|
<input type="file" value="" accept="<%= Protocol.docx_parser_enabled? ? '.eln,.docx' : '.eln' %>" data-role="import-file-input"
|
||||||
data-team-id="<%= @current_team.id %>" data-import-url="<%= import_protocols_path %>">
|
data-team-id="<%= @current_team.id %>" data-import-url="<%= import_protocols_path %>">
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -2881,7 +2881,8 @@ en:
|
||||||
edit: "Edit"
|
edit: "Edit"
|
||||||
clone_btn: "Copy"
|
clone_btn: "Copy"
|
||||||
import: "Import"
|
import: "Import"
|
||||||
import_alt: "From file (.docx, .eln)"
|
import_eln: "From file (.eln)"
|
||||||
|
import_eln_docx: "From file (.docx, .eln)"
|
||||||
import_protocols_io: "From Protocols.io"
|
import_protocols_io: "From Protocols.io"
|
||||||
modal_import_json_upload: "Upload"
|
modal_import_json_upload: "Upload"
|
||||||
modal_import_json_title: "Import protocols.io file"
|
modal_import_json_title: "Import protocols.io file"
|
||||||
|
|
Loading…
Add table
Reference in a new issue