Made code more aesthetic

This commit is contained in:
Zanz2 2017-11-09 15:38:06 +01:00
parent 096ee00e07
commit a40a63ae50
2 changed files with 76 additions and 86 deletions

View file

@ -12,78 +12,73 @@
</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 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) {

View file

@ -108,21 +108,16 @@
<% end #step component loop %>
<% tables, garbage = protocolsio_string_to_table_element(step_info_string) %>
<% if tables.present? %>
<br><hr><br>
<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 %>
<% 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>