mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-28 19:24:10 +08:00
Merge pull request #866 from biosistemika/protocols-io-import
Protocols io import
This commit is contained in:
commit
cd6799d571
14 changed files with 1067 additions and 221 deletions
|
@ -337,6 +337,19 @@ a {
|
|||
border-color: darken($color-theme-secondary, 10%);
|
||||
}
|
||||
}
|
||||
.btn-link-alt {
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin-right: 5px;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.btn-invis-file {
|
||||
display: none;
|
||||
opacity: 0;
|
||||
position: absolute;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.btn-open-file {
|
||||
position: relative;
|
||||
|
@ -1259,8 +1272,35 @@ ul.content-module-activities {
|
|||
position: relative;
|
||||
top: -10px;
|
||||
}
|
||||
|
||||
}
|
||||
// Import json protocols.io protocol modal
|
||||
#modal-import-json-protocol-preview .modal-dialog {
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
.import-protocols-modal-preview-container-json {
|
||||
height: 300px;
|
||||
overflow-x: scroll;
|
||||
overflow-y: scroll;
|
||||
width: 100%;
|
||||
|
||||
.eln-table {
|
||||
height: 21px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.badge-preview {
|
||||
background-color: $color-silver;
|
||||
border-radius: 2em;
|
||||
float: left;
|
||||
font-size: 20px;
|
||||
padding: 5px 14px;
|
||||
position: relative;
|
||||
top: -10px;
|
||||
}
|
||||
|
||||
}
|
||||
/* Steps and Results */
|
||||
#steps {
|
||||
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAABCAYAAACsXeyTAAAAIUlEQVQImWNgoD5gZGBgMILSjKRo/P//vwiSGQwMDAwMAEnaA0jgHoquAAAAAElFTkSuQmCC");
|
||||
|
@ -1796,6 +1836,15 @@ textarea.textarea-sm {
|
|||
-webkit-padding-before: 0;
|
||||
-webkit-padding-after: 0;
|
||||
}
|
||||
.btn.btn-default-link {
|
||||
border: 0;
|
||||
height: 100%;
|
||||
min-height: 34px;
|
||||
padding: 0;
|
||||
-webkit-padding-after: 0;
|
||||
-webkit-padding-before: 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2002,6 +2051,7 @@ th.custom-field .modal-tooltiptext {
|
|||
padding: 3px;
|
||||
}
|
||||
|
||||
|
||||
.btn:last-child {
|
||||
margin-right: 20px;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
44
app/helpers/protocols_io_table_helper.rb
Normal file
44
app/helpers/protocols_io_table_helper.rb
Normal file
|
@ -0,0 +1,44 @@
|
|||
module ProtocolsIoTableHelper
|
||||
def protocolsio_string_to_table_element(description_string)
|
||||
string_without_tables = string_html_table_remove(description_string)
|
||||
table_regex = %r{<table\b[^>]*>(.*?)<\/table>}m
|
||||
tr_regex = %r{<tr\b[^>]*>(.*?)<\/tr>}m
|
||||
td_regex = %r{<td\b[^>]*>(.*?)<\/td>}m
|
||||
tables = {}
|
||||
table_strings = description_string.scan(table_regex)
|
||||
table_strings.each_with_index do |table, table_counter|
|
||||
tables[table_counter.to_s] = {}
|
||||
tr_strings = table[0].scan(tr_regex)
|
||||
contents = {}
|
||||
contents['data'] = []
|
||||
tr_strings.each_with_index do |tr, tr_counter|
|
||||
td_strings = tr[0].scan(td_regex)
|
||||
contents['data'][tr_counter] = []
|
||||
td_strings.each do |td|
|
||||
td_stripped = ActionController::Base.helpers.strip_tags(td[0])
|
||||
contents['data'][tr_counter].push(td_stripped)
|
||||
end
|
||||
end
|
||||
tables[table_counter.to_s]['contents'] = Base64.encode64(
|
||||
contents.to_s.sub('=>', ':')
|
||||
)
|
||||
tables[table_counter.to_s]['name'] = nil
|
||||
end
|
||||
# return string_without_tables, tables
|
||||
return tables, string_without_tables
|
||||
end
|
||||
|
||||
def string_html_table_remove(description_string)
|
||||
description_string.remove!("\n", "\t", "\r", "\f")
|
||||
table_whole_regex = %r{(<table\b[^>]*>.*?<\/table>)}m
|
||||
table_pattern_array = description_string.scan(table_whole_regex)
|
||||
string_without_tables = description_string
|
||||
table_pattern_array.each do |table_pattern|
|
||||
string_without_tables = string_without_tables.gsub(
|
||||
table_pattern[0],
|
||||
t('protocols.protocols_io_import.comp_append.table_moved').html_safe
|
||||
)
|
||||
end
|
||||
string_without_tables
|
||||
end
|
||||
end
|
|
@ -45,7 +45,6 @@ module ProtocolsImporter
|
|||
|
||||
def populate_protocol(protocol, protocol_json, user, team)
|
||||
protocol.reload
|
||||
|
||||
asset_ids = []
|
||||
step_pos = 0
|
||||
# Check if protocol has steps
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<div
|
||||
class="modal fade"
|
||||
id="modal-import-json-protocol"
|
||||
tabindex="-1"
|
||||
role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<h4 class="modal-title"><%= t('protocols.index.modal_import_json_title') %></h4>
|
||||
<%= t("protocols.index.modal_import_json_notice") %>
|
||||
</div>
|
||||
<%= form_tag({ action: "protocolsio_import_create"}, id:"protocols_io_form",
|
||||
format: :json, multipart: true,remote: true,:method => "post") do %>
|
||||
|
||||
<div class="modal-body">
|
||||
|
||||
<%= file_field_tag 'json_file', accept: '.txt' %>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><%= t('general.cancel')%></button>
|
||||
<%= submit_tag t('protocols.index.modal_import_json_upload'), class: "btn
|
||||
btn-default" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,103 @@
|
|||
<div style="display: block;">
|
||||
<hr>
|
||||
<td>
|
||||
<div class="badge-num">
|
||||
<span class="badge-preview bg-primary size-digit-1">
|
||||
<b data-val="position"><%= 1 %></b>
|
||||
</span>
|
||||
|
||||
<span class="step-panel-collapse-link" data-toggle="collapse">
|
||||
<span class="glyphicon collapse-step-icon glyphicon-collapse-up"></span>
|
||||
<strong data-val="name"><%= 'Protocol info' %></strong>
|
||||
</span>
|
||||
</div>
|
||||
<br>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" role="tabpanel">
|
||||
<div data-val="description" class="ql-editor">
|
||||
<br>
|
||||
<% prot_info_string = '' %>
|
||||
<% protocol_table_elements_array = [] %>
|
||||
<% if json_object['before_start'].present? %>
|
||||
<% prot_info_string += (json_object['before_start']) %>
|
||||
<strong><%= t('protocols.protocols_io_import.preview.b_s_p') %></strong>
|
||||
<%= sanitize_input(string_html_table_remove(json_object['before_start']).html_safe) %><br>
|
||||
<% end %>
|
||||
<% if json_object['warning'].present? %>
|
||||
<% prot_info_string += (json_object['warning']) %>
|
||||
<strong><%= t('protocols.protocols_io_import.preview.warn') %></strong>
|
||||
<%= sanitize_input(string_html_table_remove(json_object['warning']).html_safe) %><br>
|
||||
<% end %>
|
||||
<% if json_object['guidelines'].present? %>
|
||||
<% prot_info_string += (json_object['guidelines']) %>
|
||||
<strong><%= t('protocols.protocols_io_import.preview.guideln') %></strong>
|
||||
<%= sanitize_input(string_html_table_remove(json_object['guidelines']).html_safe) %><br>
|
||||
<% end %>
|
||||
<% if json_object['manuscript_citation'].present? %>
|
||||
<% prot_info_string += (json_object['manuscript_citation']) %>
|
||||
<strong><%= t('protocols.protocols_io_import.preview.manu_cit') %></strong>
|
||||
<%= sanitize_input(string_html_table_remove(json_object['manuscript_citation']).html_safe) %><br>
|
||||
<% end %>
|
||||
<% if json_object['publish_date'].present? %>
|
||||
<strong><%= t('protocols.protocols_io_import.preview.pbl_date') %></strong>
|
||||
<%= sanitize_input(json_object['publish_date']) %><br>
|
||||
<% end %>
|
||||
<% if json_object['vendor_name'].present? %>
|
||||
<strong><%= t('protocols.protocols_io_import.preview.vnd_name') %></strong>
|
||||
<%= sanitize_input(json_object['vendor_name']) %><br>
|
||||
<% end %>
|
||||
<% if json_object['vendor_link'].present? %>
|
||||
<strong><%= t('protocols.protocols_io_import.preview.vnd_link') %></strong>
|
||||
<%= sanitize_input(json_object['vendor_link'].html_safe) %><br>
|
||||
<% end %>
|
||||
<% if json_object['keywords'].present? %>
|
||||
<strong><%= t('protocols.protocols_io_import.preview.key_wrd') %></strong>
|
||||
<%= sanitize_input(json_object['keywords']) %><br>
|
||||
<% end %>
|
||||
<% if json_object['tags'].present? %>
|
||||
<strong><%= t('protocols.protocols_io_import.preview.tags') %></strong>
|
||||
<% json_object['tags'].each do |tag| %>
|
||||
<%= sanitize_input(tag['tag_name'])+' , ' %><br>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if json_object['link'].present? %>
|
||||
<strong><%= t('protocols.protocols_io_import.preview.p_link') %></strong>
|
||||
<%= sanitize_input(json_object['link'].html_safe) %><br>
|
||||
<% end %>
|
||||
<% tables, garbage = protocolsio_string_to_table_element(prot_info_string) %>
|
||||
<% if tables.present? %>
|
||||
<br><hr><br>
|
||||
<% end %>
|
||||
<% table_count = 0 %>
|
||||
<% tables.each do |index, table| %>
|
||||
<% table_hash = JSON.parse((Base64.decode64(table['contents']))) %>
|
||||
<% pio_table_id = "pio_table_prot_info_"+table_count.to_s %>
|
||||
<% protocol_table_elements_array.push([pio_table_id,table_hash['data']]) %>
|
||||
<div id="<%=pio_table_id%>" ></div>
|
||||
<% table_count += 1 %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$('#modal-import-json-protocol-preview').on('shown.bs.modal', function (e) {
|
||||
var javascript_table_elements_p = <%=raw sanitize_input(protocol_table_elements_array.to_json) %>
|
||||
for(var j=0;j<javascript_table_elements_p.length;j++)
|
||||
{
|
||||
|
||||
var target = document.getElementById(javascript_table_elements_p[j][0]);
|
||||
var hot = new Handsontable(target, {
|
||||
data: javascript_table_elements_p[j][1],
|
||||
startRows: <%= Constants::HANDSONTABLE_INIT_ROWS_CNT %>,
|
||||
startCols: <%= Constants::HANDSONTABLE_INIT_COLS_CNT %>,
|
||||
rowHeaders: true,
|
||||
colHeaders: true,
|
||||
fillHandle: false,
|
||||
formulas: true,
|
||||
readOnly: true
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
|
@ -0,0 +1,96 @@
|
|||
<%= form_for(@protocol, :url => url_for(:controller => 'protocols',
|
||||
:action=>'protocolsio_import_save'),method: :post,format: :javascript,
|
||||
remote: true, :html=> { :id => "protocolsio-import-form" }) do |f| %>
|
||||
|
||||
<%= hidden_field_tag :json_object, JSON.generate(@json_object) %>
|
||||
|
||||
<% if URI.parse(request.referrer).query %>
|
||||
<%= hidden_field_tag :type,CGI.parse(URI.parse(request.referrer).query).fetch('type') %>
|
||||
<% else %>
|
||||
<%= hidden_field_tag :type,'public' %>
|
||||
<% end %>
|
||||
<!--Get the type of protocol to import (private, public) from the url -->
|
||||
<div
|
||||
id="modal-import-json-protocol-preview"
|
||||
class="modal fade"
|
||||
role="dialog"
|
||||
tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||
<h4 class="modal-title" data-role="header-import-into-protocol_protocols_io"><%=
|
||||
t('protocols.import_export.import_modal.title_import_into_protocol_protocols_io')
|
||||
%></h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<!-- General protocol info -->
|
||||
<div class="form-group">
|
||||
|
||||
<label><%= t('protocols.import_export.import_modal.name_label') %></label>
|
||||
|
||||
<%= f.text_field :name, :value => @json_object['protocol_name'], class:
|
||||
"form-control" %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>
|
||||
<span class="glyphicon glyphicon-user">
|
||||
</span> <%= t('protocols.import_export.import_modal.authors_label') %>
|
||||
</label>
|
||||
<%= f.text_field :authors, :value => @json_object['full_name'], class:
|
||||
"form-control" %>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label><%= t('protocols.import_export.import_modal.description_label') %></label>
|
||||
<%= f.text_area :description_notice, :value => t('protocols.protocols_io_import.import_description_notice'), class:
|
||||
"form-control",readonly: true %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
<div class="col-xs-4">
|
||||
<label><%= t('protocols.import_export.import_modal.created_at_label') %></label>
|
||||
|
||||
<% display_created_at=Time.at(@json_object['created_on'].to_i) %>
|
||||
<%= f.text_field :created_at, :value => display_created_at.to_s,
|
||||
readonly: true, class: "form-control" %>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<label><%= t('protocols.import_export.import_modal.updated_at_label') %></label>
|
||||
|
||||
<% display_last_modified=Time.at(@json_object['last_modified'].to_i) %>
|
||||
<%= f.text_field :last_modified, :value =>
|
||||
display_last_modified.to_s,readonly: true, class:
|
||||
"form-control" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Preview title -->
|
||||
<div>
|
||||
<h2 style="display: inline;"><%= t('protocols.import_export.import_modal.preview_title') %></h2>
|
||||
<h3 style="display: none;" data-role="title-position"></h3>
|
||||
</div>
|
||||
|
||||
<!-- Preview scroller -->
|
||||
<div
|
||||
class="import-protocols-modal-preview-container-json"
|
||||
data-role="preview-container">
|
||||
|
||||
<!-- Partial -->
|
||||
<%= render partial: "protocols/import_export/import_json_protocol_p_desc.html.erb", locals: {json_object: @json_object} %>
|
||||
<%= render partial: "protocols/import_export/import_json_protocol_s_desc.html.erb", locals: {json_object: @json_object} %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal"><%= t('general.cancel') %></button>
|
||||
|
||||
<%= f.submit t('protocols.import_export.import_modal.import'),class: "btn
|
||||
btn-primary" %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,148 @@
|
|||
<% whitelist_simple=['1','6','17'] %>
|
||||
<% whitelist_complex=['8','9','15','18','19','20']%>
|
||||
<% step_table_elements_array = [] %>
|
||||
<% json_object['steps'].each_with_index do |step,counter_orig| %>
|
||||
<% counter = counter_orig + 2 %>
|
||||
<div style="display: block;">
|
||||
<hr>
|
||||
<td>
|
||||
<div class="badge-num">
|
||||
<span class="badge-preview bg-primary size-digit-1">
|
||||
<b data-val="position"><%= (counter) %></b>
|
||||
</span>
|
||||
|
||||
<span class="step-panel-collapse-link" data-toggle="collapse">
|
||||
<span class="glyphicon collapse-step-icon glyphicon-collapse-up"></span>
|
||||
|
||||
<% title = nil %>
|
||||
<% step['components'].each do |key1,value1| #finding section (title of step) %>
|
||||
<% key1 = value1 if value1.class == Hash %>
|
||||
<% if(key1['component_type_id']=='6') %>
|
||||
<% title = sanitize_input(key1['data']) if key1['data'].present? %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% title ||=t('protocols.protocols_io_import.comp_append.missing_step') %>
|
||||
<strong data-val="name"><%= title %></strong>
|
||||
</span>
|
||||
</div>
|
||||
<br>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" role="tabpanel">
|
||||
<div data-val="description" class="ql-editor">
|
||||
<% step_info_string = '' %>
|
||||
<% step['components'].each do |key,value| %>
|
||||
<%#here i made an if to distinguish the first step from the
|
||||
others, because the first step #sometimes has index values as keys instead of
|
||||
hashes, you might see this elsewhere %>
|
||||
<% key = value if value.class == Hash %>
|
||||
<% if whitelist_simple.include?(key['component_type_id']) &&
|
||||
key['data'].present? %>
|
||||
<br>
|
||||
<% case key['component_type_id']
|
||||
when '1' %>
|
||||
<% step_info_string += (key['data']) %>
|
||||
<br><strong><%= t('protocols.protocols_io_import.preview.strng_s_desc') %></strong>
|
||||
<%=sanitize_input(string_html_table_remove(key['data']).html_safe)%><br>
|
||||
<% when '17' %>
|
||||
<% step_info_string += (key['data']) %>
|
||||
<br><strong><%= t('protocols.protocols_io_import.preview.s_exp_res') %></strong>
|
||||
<%=sanitize_input(string_html_table_remove(key['data']).html_safe)%>
|
||||
<br>
|
||||
<% end %>
|
||||
<% elsif key && whitelist_complex.include?(key['component_type_id']) %>
|
||||
<% case key['component_type_id']
|
||||
when '8'%>
|
||||
<% step_info_string += key['source_data']['name'] %>
|
||||
<br>
|
||||
<strong><%= key['name']+': ' %></strong>
|
||||
<%= sanitize_input(string_html_table_remove(key['source_data']['name']).html_safe) %>
|
||||
<br><%= t('protocols.protocols_io_import.preview.dev') %>
|
||||
<%= sanitize_input(key['source_data']['developer'].html_safe) %>
|
||||
<br><%= t('protocols.protocols_io_import.preview.vers') %>
|
||||
<%= sanitize_input(key['source_data']['version'].html_safe) %>
|
||||
<br><%= t('protocols.protocols_io_import.preview.s_link') %>
|
||||
<%= sanitize_input(key['source_data']['link'].html_safe) %>
|
||||
<br><%= t('protocols.protocols_io_import.preview.repo') %>
|
||||
<%= sanitize_input(key['source_data']['repository'].html_safe) %>
|
||||
<br><%= t('protocols.protocols_io_import.preview.os') %>
|
||||
<%= sanitize_input(key['source_data']['os_name'].html_safe)+
|
||||
' , '+sanitize_input(key['source_data']['os_version'].html_safe) %>
|
||||
<% when '9'%>
|
||||
<% step_info_string += key['source_data']['name'] %>
|
||||
<br>
|
||||
<strong><%= key['name']+': ' %></strong>
|
||||
<%= sanitize_input(string_html_table_remove(key['source_data']['name']).html_safe) %>
|
||||
<br><%= t('protocols.protocols_io_import.preview.s_link') %>
|
||||
<%= sanitize_input(key['source_data']['link'].html_safe) %>
|
||||
<% when '15'%>
|
||||
<% step_info_string += key['source_data']['description'] %>
|
||||
<br>
|
||||
<strong><%= key['name']+': ' %></strong>
|
||||
<%= sanitize_input(key['source_data']['name'].html_safe) %>
|
||||
<br><%= t('protocols.protocols_io_import.preview.s_desc') %>
|
||||
<%= sanitize_input(string_html_table_remove(key['source_data']['description']).html_safe) %>
|
||||
<br><%= t('protocols.protocols_io_import.preview.os') %>
|
||||
<%= sanitize_input(key['source_data']['os_name'].html_safe)+
|
||||
' , '+sanitize_input(key['source_data']['os_version'].html_safe) %>
|
||||
<% when '18'%>
|
||||
<br><strong><%= t('protocols.protocols_io_import.preview.sub_prot') %></strong>
|
||||
<%= sanitize_input(key['source_data']['protocol_name'].html_safe) %>
|
||||
<br><%= t('protocols.protocols_io_import.preview.auth') %>
|
||||
<%= sanitize_input(key['source_data']['full_name'].html_safe) %>
|
||||
<br>
|
||||
<% if key['source_data']['link'].present? %>
|
||||
<%= t('protocols.protocols_io_import.preview.s_nobr_link') %>
|
||||
<%= sanitize_input(key['source_data']['link'].html_safe) %>
|
||||
<% end %>
|
||||
<% when '19'%>
|
||||
<% step_info_string += key['source_data']['body'] %>
|
||||
<br>
|
||||
<strong><%= key['name']+': ' %></strong>
|
||||
<%= sanitize_input(string_html_table_remove(key['source_data']['body']).html_safe) %>
|
||||
<br><%= t('protocols.protocols_io_import.preview.s_link') %>
|
||||
<%= sanitize_input(key['source_data']['link'].html_safe) %>
|
||||
<% when '20'%>
|
||||
<% else %>
|
||||
<% end #case if%>
|
||||
<% end #inner if%>
|
||||
<% end #step component loop %>
|
||||
<% tables, garbage = protocolsio_string_to_table_element(step_info_string) %>
|
||||
<% if tables.present? %>
|
||||
<br><hr><br>
|
||||
<% end %>
|
||||
<% table_count = 0 %>
|
||||
<% tables.each do |index, table| %>
|
||||
<% table_hash = JSON.parse((Base64.decode64(table['contents']))) %>
|
||||
<% pio_table_id = "pio_table_step_"+counter.to_s+"_info_"+table_count.to_s %>
|
||||
<% step_table_elements_array.push([pio_table_id,table_hash['data']]) %>
|
||||
<div id="<%=pio_table_id%>" ></div>
|
||||
<% table_count += 1 %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end #step loop%>
|
||||
<br>
|
||||
<script type="text/javascript">
|
||||
$('#modal-import-json-protocol-preview').on('shown.bs.modal', function (e) {
|
||||
var javascript_table_elements_s = <%=raw sanitize_input(step_table_elements_array.to_json) %>
|
||||
|
||||
for(var j=0;j<javascript_table_elements_s.length;j++)
|
||||
{
|
||||
|
||||
var target = document.getElementById(javascript_table_elements_s[j][0]);
|
||||
var hot = new Handsontable(target, {
|
||||
data: javascript_table_elements_s[j][1],
|
||||
startRows: <%= Constants::HANDSONTABLE_INIT_ROWS_CNT %>,
|
||||
startCols: <%= Constants::HANDSONTABLE_INIT_COLS_CNT %>,
|
||||
rowHeaders: true,
|
||||
colHeaders: true,
|
||||
fillHandle: false,
|
||||
formulas: true,
|
||||
readOnly: true
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
<% provide(:head_title, t("protocols.index.head_title")) %>
|
||||
|
||||
<% if current_team %>
|
||||
<%= render partial: "protocols/breadcrumbs.html.erb", locals: { teams: @teams, current_team: @current_team, type: @type } %>
|
||||
|
||||
<ul class="nav nav-tabs nav-settings">
|
||||
<li role="presentation" class="<%= "active" if @type == :public %>">
|
||||
<%= link_to t("protocols.index.navigation.public"), protocols_path(team: @current_team, type: :public) %>
|
||||
|
@ -48,16 +48,30 @@
|
|||
</a>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="import-export-protocols" class="btn-group" role="group">
|
||||
<a class="btn btn-default btn-open-file" <%= can_import_protocols(@current_team) ? 'data-action="import"' : 'disabled="disabled"' %>>
|
||||
<span class="glyphicon glyphicon-import"></span>
|
||||
<span class="hidden-xs"> <%= t("protocols.index.import") %></span>
|
||||
<input type="file" value="" accept=".eln" data-role="import-file-input"
|
||||
data-team-id="<%= @current_team.id %>"
|
||||
data-type="<%= @type %>" data-import-url="<%= import_protocols_path %>"
|
||||
<%= 'disabled="disabled"' unless can_import_protocols(@current_team) %>>
|
||||
</a>
|
||||
<a class="btn btn-default btn-open-file" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" href="#">
|
||||
<span class="glyphicon glyphicon-import"></span><span class="hidden-xs"> <%= "Import protocol" %></span></a>
|
||||
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="btn-link-alt btn-default-link btn-open-file"
|
||||
<%= can_import_protocols(@current_team) ? 'data-action="import"' : 'disabled="disabled"' %>>
|
||||
<span class="glyphicon glyphicon-file"></span>
|
||||
<span class="hidden-xs"><%= t("protocols.index.import_alt") %></span>
|
||||
<input type="file" value="" accept=".eln" data-role="import-file-input"
|
||||
data-team-id="<%= @current_team.id %>"
|
||||
data-type="<%= @type %>" data-import-url="<%= import_protocols_path %>"
|
||||
<%= 'disabled="disabled"' unless can_import_protocols(@current_team) %>>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to "#modal-import-json-protocol", "data-toggle" => "modal" do %>
|
||||
<span class="glyphicon glyphicon-file"></span>
|
||||
<span class="hidden-xs"><%= t("protocols.index.import_json") %></span>
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<a class="btn btn-default" data-action="export" data-export-url="<%= export_protocols_path() %>">
|
||||
<span class="glyphicon glyphicon-export"></span>
|
||||
<span class="hidden-xs"> <%= t("protocols.index.export") %></span>
|
||||
|
@ -121,6 +135,8 @@
|
|||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
<div id="protocolsio-preview-modal-target"></div>
|
||||
<%= render partial: "protocols/import_export/import_json_protocol_modal.html.erb" %>
|
||||
|
||||
<%= render partial: "protocols/index/create_new_modal.html.erb" %>
|
||||
<%= render partial: "protocols/index/make_private_results_modal.html.erb" %>
|
||||
|
|
19
app/views/protocols/protocolsio_import_create.js.erb
Normal file
19
app/views/protocols/protocolsio_import_create.js.erb
Normal file
|
@ -0,0 +1,19 @@
|
|||
|
||||
<% if @protocolsio_too_big %>
|
||||
$('#modal-import-json-protocol').modal('hide');
|
||||
HelperModule.flashAlertMsg(' <%= t('my_modules.protocols.load_from_file_size_error',
|
||||
size: Constants::FILE_MAX_SIZE_MB ) %>','danger');
|
||||
<% else %>
|
||||
$('#modal-import-json-protocol').modal('hide');
|
||||
<% if remotipart_submitted? %> <%# a workaround to a bug with remotipart, that caused alot of headache, courtesy of github.com/dhampik %>
|
||||
$('#protocolsio-preview-modal-target').html(
|
||||
"<%= j "#{render(:partial => 'protocols/import_export/import_json_protocol_preview_modal')}" %>"
|
||||
);
|
||||
<% else %>
|
||||
$('#protocolsio-preview-modal-target').html(
|
||||
"<%= j render(:partial => 'protocols/import_export/import_json_protocol_preview_modal') %>"
|
||||
);
|
||||
<% end %>
|
||||
$('#modal-import-json-protocol-preview').modal('show');
|
||||
|
||||
<% end %>
|
10
app/views/protocols/protocolsio_import_save.js.erb
Normal file
10
app/views/protocols/protocolsio_import_save.js.erb
Normal file
|
@ -0,0 +1,10 @@
|
|||
<% if @protocolsio_general_error %>
|
||||
$('#modal-import-json-protocol-preview').modal('hide');
|
||||
alert(' <%= t('my_modules.protocols.load_from_file_protocol_general_error',
|
||||
max: Constants::NAME_MAX_LENGTH, min: Constants::NAME_MIN_LENGTH) %>');
|
||||
<% else %>
|
||||
$('#modal-import-json-protocol-preview').modal('hide');
|
||||
$('#protocols_io_form').trigger("reset");
|
||||
protocolsDatatable.ajax.reload();
|
||||
HelperModule.flashAlertMsg(' <%= t('protocols.index.import_results.message_ok_pio')%>', 'success');
|
||||
<% end %>
|
|
@ -603,6 +603,7 @@ en:
|
|||
load_from_file_error: "Failed to load the protocol from file."
|
||||
load_from_file_error_locked: "Failed to load the protocol from file. One or more files are currently being edited."
|
||||
load_from_file_size_error: "Failed to load the protocol from file. Limit is %{size}Mb."
|
||||
load_from_file_protocol_general_error: "Failed to load the protocol from file. It is likely that certain fields (protocol and individual step titles and names) contain too many or too few characters.(max is %{max} and min is %{min})"
|
||||
results:
|
||||
head_title: "%{project} | %{module} | Results"
|
||||
add_label: "Add new result:"
|
||||
|
@ -1380,11 +1381,60 @@ en:
|
|||
breadcrumbs:
|
||||
manager: "Protocol management"
|
||||
edit: "Edit protocol"
|
||||
protocols_io_import:
|
||||
import_description_notice: "The protocols description is listed below under \"Protocol info\"."
|
||||
preview:
|
||||
prot_desc: "Protocol Description: "
|
||||
b_s_p: "Before starting protocol information:"
|
||||
warn: "Protocol warning:"
|
||||
guideln: "Guidelines:"
|
||||
p_link: "Link:"
|
||||
s_nobr_link: "Link:"
|
||||
s_link: "Link:"
|
||||
s_desc: "Description:"
|
||||
strng_s_desc: "Description:"
|
||||
s_exp_res: "Expected result:"
|
||||
dev: "Developer:"
|
||||
vers: "Version:"
|
||||
repo: "Repository:"
|
||||
os: "OS name , OS version:"
|
||||
sub_prot: "This protocol also contains an attached sub-protocol:"
|
||||
auth: "Author:"
|
||||
manu_cit: "Manuscript citation:"
|
||||
pbl_date: "Publish date:"
|
||||
vnd_name: "Vendor name:"
|
||||
vnd_link: "Vendor link:"
|
||||
key_wrd: "Keywords:"
|
||||
tags: "Tags:"
|
||||
comp_append:
|
||||
table_moved: "<br><strong><i>There was a table here, it was moved to the end of this step. </i></strong>"
|
||||
missing_step: "Step"
|
||||
missing_desc: "Description missing"
|
||||
general_link: "<br>Link: "
|
||||
expected_result: "<br><strong>Expected result: </strong>"
|
||||
soft_packg:
|
||||
title: "<br><strong>Software package: </strong>"
|
||||
dev: "<br>Developer: "
|
||||
vers: "<br>Version: "
|
||||
repo: "<br>Repository: "
|
||||
os: "<br>OS name , OS version: "
|
||||
dataset:
|
||||
title: "<br><strong>Dataset: </strong>"
|
||||
command:
|
||||
title: "<br><strong>Command: </strong>"
|
||||
desc: "<br>Description: "
|
||||
os: "<br>OS name , OS version: "
|
||||
sub_protocol:
|
||||
title: "<br><strong>This step also contains an attached sub-protocol: </strong>"
|
||||
author: "<br>Author: "
|
||||
safety_infor:
|
||||
title: "<br><strong>Safety information: </strong>"
|
||||
import_export:
|
||||
load_file_error: "Failed to load the protocol file."
|
||||
import_modal:
|
||||
title_import: "Import protocol/s"
|
||||
title_import_into_protocol: "Load protocol from file"
|
||||
title_import_into_protocol_protocols_io: "Load protocol from protocols.io file"
|
||||
import_into_protocol_message: "This will overwrite the current protocol!"
|
||||
import_into_protocol_confirm: "Are you sure you wish to load protocol from file? This action will overwrite the current protocol."
|
||||
import_to_linked_task_file: "Are you sure you wish to load protocol from file? This action will overwrite the current protocol in the task and unlink it from repository. The current protocol will remain unchanged in repository."
|
||||
|
@ -1440,6 +1490,11 @@ en:
|
|||
edit: "Edit"
|
||||
clone_btn: "Copy"
|
||||
import: "Import"
|
||||
import_alt: "from SciNote protocol file(.eln)"
|
||||
import_json: "from protocols.io file(.txt)"
|
||||
modal_import_json_upload: "Upload file"
|
||||
modal_import_json_title: "Import protocols.io file"
|
||||
modal_import_json_notice: "Upload your protocols.io .txt json protocol file"
|
||||
export: "Export"
|
||||
make_private: "Make private"
|
||||
publish: "Publish"
|
||||
|
@ -1505,6 +1560,7 @@ en:
|
|||
title: "Import results"
|
||||
message_failed: "Failed to import %{nr} protocol/s."
|
||||
message_ok: "Successfully imported %{nr} protocol/s."
|
||||
message_ok_pio: "Successfully imported protocol from protocols.io file."
|
||||
row_success: "Imported"
|
||||
row_renamed: "Imported & renamed"
|
||||
row_failed: "Failed"
|
||||
|
|
|
@ -401,6 +401,7 @@ Rails.application.routes.draw do
|
|||
to: 'protocols#load_from_repository_modal'
|
||||
post 'load_from_repository', to: 'protocols#load_from_repository'
|
||||
post 'load_from_file', to: 'protocols#load_from_file'
|
||||
|
||||
get 'copy_to_repository_modal', to: 'protocols#copy_to_repository_modal'
|
||||
post 'copy_to_repository', to: 'protocols#copy_to_repository'
|
||||
get 'protocol_status_bar', to: 'protocols#protocol_status_bar'
|
||||
|
@ -418,6 +419,8 @@ Rails.application.routes.draw do
|
|||
post 'archive', to: 'protocols#archive'
|
||||
post 'restore', to: 'protocols#restore'
|
||||
post 'import', to: 'protocols#import'
|
||||
post 'protocolsio_import_create', to: 'protocols#protocolsio_import_create'
|
||||
post 'protocolsio_import_save', to: 'protocols#protocolsio_import_save'
|
||||
get 'export', to: 'protocols#export'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170515141252) do
|
||||
ActiveRecord::Schema.define(version: 20170619125051) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
|
Loading…
Reference in a new issue