sanger/sequencescape

View on GitHub
app/views/shared/poly_metadata/edit/_study.html.erb

Summary

Maintainability
Test Coverage
<%# This partial contains poly_metadata form fields for a study. It is included 
in the form to edit a study, i.e. for creating or updating a study. 

The key assignment is used to avoid repetition of the key string. form_collection 
is a helper method that generates a form group with a label and an input field. 

The label is generated using label_tag and the input field is generated using 
text_field_tag. The name for label_tag includes poly_metadata_ to match id of 
the input field. 

The name for text_field_tag includes poly_metadata[] to create a grouping in the 
params hash available in the controller. The value of the input field is set to 
the value of the poly_metadatum record found by the key. 

The last argument of the form_collection method is a string that provides 
information about the field, which is displayed as a help text under the input 
field.
%>
<% key = 'scrna_core_pbmc_donor_pooling_required_number_of_cells' %>
<%= form_collection(
  label_tag("poly_metadata_#{key}", 
    'scRNA Core PBMC donor pooling required number of cells'),
  text_field_tag("poly_metadata[#{key}]", 
    @study.poly_metadatum_by_key(key)&.value,
    class: 'form-control'),
  "This option is used to generate the driver file for the scRNA Core " +
  "Pipeline's PBMC donor pooling. If this value is not set for each study " +
  "involved in the pooling process, Limber will issue a warning. However, " +
  "the process can still proceed using the default value configured in Limber."
) %>