Skip to content

Commit

Permalink
Merge branch 'seek-1.15' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
stuzart committed Jun 12, 2024
2 parents bddf151 + 805f00a commit 8b8178c
Show file tree
Hide file tree
Showing 21 changed files with 333 additions and 114 deletions.
11 changes: 7 additions & 4 deletions app/controllers/single_pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def dynamic_table_data
rescue Exception => e
render json: { status: :unprocessable_entity, error: e.message }
end

def download_samples_excel
sample_ids, sample_type_id, study_id, assay_id = Rails.cache.read(params[:uuid]).values_at(:sample_ids, :sample_type_id,
:study_id, :assay_id)
Expand Down Expand Up @@ -94,7 +94,10 @@ def download_samples_excel
rescue StandardError => e
flash[:error] = e.message
respond_to do |format|
format.html { redirect_to single_page_path(@project.id) }
format.html do
redirect_to single_page_path(id: @project.id, item_type: @assay.nil? ? 'study' : 'assay',
item_id: @assay.nil? ? @study.id : @assay.id)
end
format.json do
render json: { parameters: { sample_ids:, sample_type_id:, study_id: }, errors: e }, status: :bad_request
end
Expand Down Expand Up @@ -244,7 +247,7 @@ def get_spreadsheet_data(samples_sheet)
next if sample_cells.all? { |cell| (cell&.value == '' || cell&.value.nil?) }

sample_cells.map do |cell|
cell&.value
cell&.value unless cell&.value == ''
end.drop(1)
end.compact

Expand Down Expand Up @@ -334,7 +337,7 @@ def separate_unauthorized_samples(existing_excel_samples, db_samples, authorized
is_changed = false

db_sample.map do |k, v|
unless ees[k] == v
unless ees[k] == v || %w[id uuid].include?(k)
is_changed = true
break
end
Expand Down
11 changes: 9 additions & 2 deletions app/models/sample_attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class SampleAttribute < ApplicationRecord

auto_strip_attributes :pid
validates :sample_type, presence: true
validates :pid, format: { with: URI::regexp, allow_blank: true, allow_nil: true, message: 'not a valid URI' }
validates :pid, format: { with: URI::ABS_URI, allow_blank: true, allow_nil: true, message: 'not a valid URI' }
validate :validate_against_editing_constraints, if: -> { sample_type.present? }

before_save :store_accessor_name
Expand Down Expand Up @@ -64,7 +64,14 @@ def template_column_definition

def short_pid
return '' unless pid.present?
URI.parse(pid).fragment || pid.gsub(/.*\//,'') || pid
begin
URI.parse(pid).fragment || pid.gsub(/.*\//,'') || pid
rescue URI::InvalidURIError
# likely a space that managed to pass through earlier uri validation
fixed_pid = pid.gsub(' ','-')
URI.parse(fixed_pid).fragment || fixed_pid.gsub(/.*\//,'') || fixed_pid
end

end

def linked_extended_metadata_type
Expand Down
2 changes: 1 addition & 1 deletion app/views/assets/_asset_buttons.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<% if can_download_asset?(asset, params[:code]) -%>
<% if asset.is_a?(Workflow) %>
<% if display_asset.is_git_versioned? || asset.content_blob&.file_exists? %>
<%= button_link_to('Download RO Crate', 'ro_crate_file', ro_crate_workflow_path(asset, version: version, code: params[:code]),
<%= button_link_to('Download RO-Crate', 'ro_crate_file', ro_crate_workflow_path(asset, version: version, code: params[:code]),
'data-tooltip' => tooltip("The Workflow RO-Crate is a package containing the workflow definition, its metadata and supporting resources like test data")) %>
<% if asset.can_run? %>
<%= button_link_to("Run on Galaxy", 'run_galaxy', display_asset.run_url) %>
Expand Down
69 changes: 39 additions & 30 deletions app/views/single_pages/_duplicate_samples_panel.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<% unless @possible_duplicates.nil? or @possible_duplicates.compact.none? %>
<%= folding_panel("Possible Duplicates <span id='duplicate-samples-counter' class='label label-danger'>#{@possible_duplicates.size}</span>", true, :id => "duplicate-samples-panel", :body_options => {:id => "duplicate-samples-panel-content"},
:help_text => "These new samples have been matched to already existing samples.") do %>
<%= folding_panel("Possible Duplicates <span id='duplicate-samples-counter' class='label label-danger'>#{@possible_duplicates.size}</span>", true, :id => "duplicate-samples-panel", :body_options => { :id => "duplicate-samples-panel-content" },
:help_text => "These new samples have been matched to already existing samples.") do %>
<div class="table-responsive">
<table id="duplicate-samples-table" class="table">
<thead>
<tr>
<th></th>
<% for key in @possible_duplicates[0].keys %>
Expand All @@ -11,56 +12,64 @@
<% end %>
<% end %>
</tr>
</thead>
<tbody>
<% for dupl_sample in @possible_duplicates %>
<tr id='<%= "duplicate-sample-#{dupl_sample['duplicate']['id']}-1" %>' >
<td rowspan=2><button id=<%= "remove-#{dupl_sample['duplicate']['id']}" %> class="btn glyphicon glyphicon-trash danger" style="background-color:#d9534f;color:white;" onclick=<%= "removeSample('duplicate-sample-#{dupl_sample['duplicate']['id']}')" %>></button></td>
<% dupl_sample.map do |key, val| %>
<% val = '<new>' if key =='id' %>
<% unless %w[uuid duplicate].include?(key) %>
<% if @multiple_input_fields.include?(key)%>
<td>
<% val.each do |sub_sample| %>
<span class="badge", title='ID: <%= sub_sample['id'] %>' data-attr_type="seek-sample-multi"><%= sub_sample['title'] %></span>
<% end %>
</td>
<% elsif @cv_list_fields.include?(key) %>
<td>
<% val.each do |cv_term| %>
<span class="label label-default", title='<%= cv_term %>' data-attr_type="cv-list"><%= cv_term %></span>
<% end %>
</td>
<% elsif @registered_sample_fields.include?(key) %>
<td><span class="badge", title='<%= val['id'] %>' data-attr_type="seek-sample"><%= val['title'] %></span></td>
<% else %>
<td id='<%= "#{dupl_sample['duplicate']['id']}[#{key}]" %>' ><%= val %></td>
<tr id='<%= "duplicate-sample-#{dupl_sample['duplicate']['id']}-1" %>'>
<td rowspan=2>
<button id=<%= "remove-#{dupl_sample['duplicate']['id']}" %> class="btn glyphicon glyphicon-trash danger
" style="background-color:#d9534f;color:white;"
onclick=<%= "removeSample('duplicate-sample-#{dupl_sample['duplicate']['id']}')" %>></button></td>
<% dupl_sample.map do |key, val| %>
<% val = '<new>' if key == 'id' %>
<% unless %w[uuid duplicate].include?(key) %>
<% if @multiple_input_fields.include?(key) %>
<td>
<% val.each do |sub_sample| %>
<span class="badge" , title='ID: <%= sub_sample['id'] %>' data-attr_type="seek-sample-multi"><%= sub_sample['title'] %></span>
<% end %>
</td>
<% elsif @cv_list_fields.include?(key) %>
<td>
<% val.each do |cv_term| %>
<span class="label label-default" , title='<%= cv_term %>' data-attr_type="cv-list"><%= cv_term %></span>
<% end %>
</td>
<% elsif @registered_sample_fields.include?(key) %>
<td>
<span class="badge" , title='<%= val['id'] %>' data-attr_type="seek-sample"><%= val['title'] %></span>
</td>
<% else %>
<td id='<%= "#{dupl_sample['duplicate']['id']}[#{key}]" %>'><%= val %></td>
<% end %>
<% end %>
<% end %>
<% end %>
<tr id='<%= "duplicate-sample-#{dupl_sample['duplicate']['id']}-2" %>' class="danger">
<% dupl_sample['duplicate'].map do |key, val| %>
<% unless %w[uuid duplicate].include?(key) %>
<% if @multiple_input_fields.include?(key)%>
<% if @multiple_input_fields.include?(key) %>
<td>
<% val.each do |sub_sample| %>
<span class="badge", title='ID: <%= sub_sample['id'] %>'><%= sub_sample['title'] %></span>
<span class="badge" , title='ID: <%= sub_sample['id'] %>'><%= sub_sample['title'] %></span>
<% end %>
</td>
<% elsif @cv_list_fields.include?(key) %>
<td>
<% val.each do |cv_term| %>
<span class="label label-default", title='<%= cv_term %>'><%= cv_term %></span>
<span class="label label-default" , title='<%= cv_term %>'><%= cv_term %></span>
<% end %>
</td>
<% elsif @registered_sample_fields.include?(key) %>
<td><span class="badge", title='<%= val['id'] %>'><%= val['title'] %></span></td>
<td><span class="badge" , title='<%= val['id'] %>'><%= val['title'] %></span></td>
<% else %>
<td><%= val%></td>
<td><%= val %></td>
<% end %>
<% end %>
<% end %>
</tr>
</tr>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
Expand Down
33 changes: 20 additions & 13 deletions app/views/single_pages/_new_samples_panel.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<% unless @new_samples.nil? or @new_samples.compact.none? %>
<%= folding_panel("New Samples <span id='new-samples-counter' class='label label-primary'>#{@new_samples.size}</span>", true, :id => "new-samples-panel", :body_options => {:id => "new-samples-panel-content"},
:help_text => "These samples have been detected as new samples and will be created.") do %>
<%= folding_panel("New Samples <span id='new-samples-counter' class='label label-primary'>#{@new_samples.size}</span>", true, :id => "new-samples-panel", :body_options => { :id => "new-samples-panel-content" },
:help_text => "These samples have been detected as new samples and will be created.") do %>
<div class="table-responsive">
<table id="create-samples-table" class="table">
<thead>
<tr>
<th></th>
<% for key in @new_samples[0].keys %>
Expand All @@ -11,36 +12,42 @@
<% end %>
<% end %>
</tr>
</thead>
<tbody>
<% for new_sample in @new_samples %>
<% new_sample_id = UUID.generate %>
<tr id='<%= "new-sample-#{new_sample_id}" %>'>
<td><button id=<%= "remove-#{new_sample_id}" %> class="btn glyphicon glyphicon-trash danger" style="background-color:#d9534f;color:white;" onclick=<%= "removeSample('new-sample-#{new_sample_id}')" %>></button></td>
<% new_sample.map do |key, val| %>
<% val = '<new>' if key =='id' %>
<td>
<button id=<%= "remove-#{new_sample_id}" %> class="btn glyphicon glyphicon-trash danger
" style="background-color:#d9534f;color:white;"
onclick=<%= "removeSample('new-sample-#{new_sample_id}')" %>></button></td>
<% new_sample.map do |key, val| %>
<% val = '<new>' if key == 'id' %>
<% unless key == 'uuid' %>
<% if @multiple_input_fields.include?(key)%>
<td id='<%= "new-sample-#{new_sample_id}[#{key}]" %>' >
<% if @multiple_input_fields.include?(key) %>
<td id='<%= "new-sample-#{new_sample_id}[#{key}]" %>'>
<% val.each do |sub_sample| %>
<span class="badge", title='ID: <%= sub_sample['id'] %>' data-attr_type="seek-sample-multi"><%= sub_sample['title'] %></span>
<span class="badge" , title='ID: <%= sub_sample['id'] %>' data-attr_type="seek-sample-multi"><%= sub_sample['title'] %></span>
<% end %>
</td>
<% elsif @cv_list_fields.include?(key) %>
<td id='<%= "new-sample-#{new_sample_id}[#{key}]" %>' >
<td id='<%= "new-sample-#{new_sample_id}[#{key}]" %>'>
<% val.each do |cv_term| %>
<span class="label label-default", title='<%= cv_term %>' data-attr_type="cv-list"><%= cv_term %></span>
<span class="label label-default" , title='<%= cv_term %>' data-attr_type="cv-list"><%= cv_term %></span>
<% end %>
</td>
<% elsif @registered_sample_fields.include?(key) %>
<td id='<%= "new-sample-#{new_sample_id}[#{key}]" %>' >
<span class="badge", title='<%= val['id'] %>' data-attr_type="seek-sample"><%= val['title'] %></span>
<td id='<%= "new-sample-#{new_sample_id}[#{key}]" %>'>
<span class="badge" , title='<%= val['id'] %>' data-attr_type="seek-sample"><%= val['title'] %></span>
</td>
<% else %>
<td id='<%= "new-sample-#{new_sample_id}[#{key}]" %>' ><%= val %></td>
<td id='<%= "new-sample-#{new_sample_id}[#{key}]" %>'><%= val %></td>
<% end %>
<% end %>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
Expand Down
13 changes: 9 additions & 4 deletions app/views/single_pages/_unauthorized_samples_panel.html.erb
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
<% unless @unauthorized_samples.nil? or @unauthorized_samples.compact.none? %>
<% @can_upload = false %>
<% errors.append("There are unauthorized samples present in the spreadsheet.") %>
<%= folding_panel("Unauthorized Samples", false, :id => "unauthorized-samples-panel", :body_options => {:id => "unauthorized-samples-panel-content"},
:help_text => "Sample the current user does not have permission to edit them.") do %>
<%= folding_panel("Unauthorized Samples", false, :id => "unauthorized-samples-panel", :body_options => { :id => "unauthorized-samples-panel-content" },
:help_text => "Sample the current user does not have permission to edit them.") do %>
<div>
<p>
<b>You don't have permission to edit the samples listed below. Please contact the submitter of these samples or revert the changes in the spreadsheet to its original values.</b>
<b>You don't have permission to edit the samples listed below. Please contact the submitter of these samples or
revert the changes in the spreadsheet to its original values.</b>
</p>
</div>
<div class="table-responsive">
<table id="unauthorized-samples-table" class="table">
<thead>
<tr>
<% for key in @unauthorized_samples[0].keys %>
<% unless key == 'uuid' %>
<th><%= key %></th>
<% end %>
<% end %>
</tr>
</thead>
<tbody>
<% for unauthorized_sample in @unauthorized_samples %>
<tr id='<%= "unauthorized-sample-#{unauthorized_sample['id']}" %>' class="">
<% unauthorized_sample.map do |key, val| %>
<% unless key == 'uuid' %>
<% if @multiple_input_fields.include?(key) %>
<td>
<% val.each do |sub_sample| %>
<span class="badge", title='ID: <%= sub_sample['id'] %>'><%= sub_sample['title'] %></span>
<span class="badge" , title='ID: <%= sub_sample['id'] %>'><%= sub_sample['title'] %></span>
<% end %>
</td>
<% else %>
Expand All @@ -34,6 +38,7 @@
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
Expand Down
Loading

0 comments on commit 8b8178c

Please sign in to comment.