Skip to content

Commit

Permalink
Add custom metadata functionality to Isa Studies
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin De Pelseneer committed Oct 6, 2023
1 parent 927a28c commit a24c4f7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/controllers/isa_studies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def study_params
[:title, :description, :experimentalists, :investigation_id, { sop_ids: [] },
*creator_related_params, :position, { scales: [] }, { publication_ids: [] },
{ discussion_links_attributes: %i[id url label _destroy] },
{ custom_metadata_attributes: determine_custom_metadata_keys }]
{ custom_metadata_attributes: determine_custom_metadata_keys(:study) }]
end

def sample_type_params(params, field)
Expand Down
26 changes: 13 additions & 13 deletions app/views/isa_studies/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<%= study_fields.text_area :description, :rows=>5, :class=>"form-control rich-text-edit" %>
</div>

<%= render partial: 'custom_metadata/custom_metadata_type_selection', locals:{f:f, resource:@isa_study.study} %>
<%= render partial: 'custom_metadata/custom_metadata_type_selection', locals:{f:study_fields, resource:@isa_study.study} %>
<%= render partial: 'custom_metadata/custom_metadata_attribute_input', locals:{f:study_fields,resource:@isa_study.study, parent_resource: "isa_study"} %>

<% unless @isa_study.study.experimentalists.blank? %>
<div class="form-group">
Expand All @@ -24,14 +25,13 @@

<div id="investigation_collection" class="hidden">
<%= render :partial=>"studies/investigation_list",:locals=>{study:@isa_study.study, :investigations=>Investigation.all.select {|i|current_user.person.member_of? i.projects}} -%>
</div>
</div>

<div class="form-group">
<%= study_fields.label "Study position" -%><br/>
<%= study_fields.number_field :position, :rows => 5, :class=>"form-control" -%>
</div>

<%= render partial: 'custom_metadata/custom_metadata_attribute_input', locals:{f:f,resource:@isa_study.study} %>

<%= render partial: 'assets/manage_specific_attributes', locals: { f: study_fields } if show_form_manage_specific_attributes? %>

Expand All @@ -42,27 +42,27 @@
<%= render partial: 'projects/implicit_project_selector', locals: { action: action,
select_id: '#study_investigation_id',
parents: Investigation.authorized_for('edit') } %>

<%= folding_panel("Define #{t(:sample_type)} for Source") do %>
<%= render partial: 'sample_types_form', locals: {f: f, sample_type: @isa_study.source, id_suffix: "_source_sample_type", action: action } if @isa_study.source %>
<% end %>

<%= folding_panel(t(:sop).pluralize) do %>
<p class="help-block">The following <%= t(:sop).pluralize %> are associated with this <%= t(:study) %>:</p>

<%= study_fields.fancy_multiselect :sops, { other_projects_checkbox: true, name: "isa_study[study][sop_ids]" } %>

<% end %>

<%= folding_panel("Define #{t(:sample_type)} for Sample") do %>
<%= render partial: 'sample_types_form', locals: {f: f, sample_type: @isa_study.sample_collection, id_suffix: "_sample_collection_sample_type", action: action } if @isa_study.sample_collection %>
<% end %>

<% end -%>
<% end -%>





<%= form_submit_buttons(@isa_study.study) %>

<script>
Expand All @@ -74,16 +74,16 @@
showTemplateModal()
}

$j(document).ready(function () {
$j(document).ready(function () {
const urlSearchParams = new URLSearchParams(window.location.search);
const params = Object.fromEntries(urlSearchParams.entries());
const investigation_id = params["investigation_id"]
// Prevent setting the hidden field on redirect (query string parameters are missing)
if(investigation_id) {
$j("#isa_study_study_investigation_id").val(investigation_id);
$j("#isa_study_study_investigation_id").val(investigation_id);
$j("#study_investigation_id").val(investigation_id).change();
}
}

Templates.init($j('#template-attributes'));
});
Templates.init($j('#template-attributes'));
});
</script>

0 comments on commit a24c4f7

Please sign in to comment.