Skip to content

Commit

Permalink
Add thead and tbody elements
Browse files Browse the repository at this point in the history
  • Loading branch information
kdp-cloud committed Jun 3, 2024
1 parent ace380f commit 04a82a4
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 58 deletions.
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
29 changes: 18 additions & 11 deletions app/views/single_pages/_update_samples_panel.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<% unless @update_samples.nil? or @update_samples.compact.none? %>
<%= folding_panel("Samples to Update <span id='update-samples-counter' class='label label-warning'>#{@update_samples.size}</span>", true, :id => "existing-samples-panel", :body_options => {:id => "existing-samples-panel-content"},
:help_text => "These samples were detected existing samples and will be updated.") do %>
<%= folding_panel("Samples to Update <span id='update-samples-counter' class='label label-warning'>#{@update_samples.size}</span>", true, :id => "existing-samples-panel", :body_options => { :id => "existing-samples-panel-content" },
:help_text => "These samples were detected existing samples and will be updated.") do %>
<div class="table-responsive">
<table id="update-samples-table" class="table">
<thead>
<tr>
<th></th>
<% for key in @update_samples[0].keys %>
Expand All @@ -11,38 +12,43 @@
<% end %>
<% end %>
</tr>
</thead>
<tbody>
<% for update_sample in @update_samples %>
<tr id='<%= "update-sample-#{update_sample['id']}-updated" %>' >
<tr id='<%= "update-sample-#{update_sample['id']}-updated" %>'>
<% db_sample = @authorized_db_samples.select { |s| s['id'] == update_sample['id'] }.first %>
<td rowspan=2><button id=<%= "remove-#{update_sample['id']}" %> class="btn glyphicon glyphicon-trash danger" style="background-color:#d9534f;color:white;" onclick=<%= "removeSample('update-sample-#{update_sample['id']}')" %>></button></td>
<td rowspan=2>
<button id=<%= "remove-#{update_sample['id']}" %> class="btn glyphicon glyphicon-trash danger
" style="background-color:#d9534f;color:white;"
onclick=<%= "removeSample('update-sample-#{update_sample['id']}')" %>></button></td>
<% update_sample.map do |key, val| %>
<% unless key == 'uuid' %>
<% if @multiple_input_fields.include?(key)%>
<td class='<%= (val != db_sample[key]) ? "warning" : "default" %>' id='<%= "update-sample-#{update_sample['id']}[#{key}]"%>' >
<% if @multiple_input_fields.include?(key) %>
<td class='<%= (val != db_sample[key]) ? "warning" : "default" %>' id='<%= "update-sample-#{update_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>
<% end %>
</td>
<% elsif @cv_list_fields.include?(key) %>
<td class='<%= (val != db_sample[key]) ? "warning" : "default" %>' id='<%= "update-sample-#{update_sample['id']}[#{key}]"%>' >
<td class='<%= (val != db_sample[key]) ? "warning" : "default" %>' id='<%= "update-sample-#{update_sample['id']}[#{key}]" %>'>
<% 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 class='<%= (val != db_sample[key]) ? "warning" : "default" %>' id='<%= "update-sample-#{update_sample['id']}[#{key}]"%>'>
<td class='<%= (val != db_sample[key]) ? "warning" : "default" %>' id='<%= "update-sample-#{update_sample['id']}[#{key}]" %>'>
<span class="badge" title='<%= val['id'] %>' data-attr_type="seek-sample"><%= val['title'] %></span>
</td>
<% else %>
<td class='<%= (val != db_sample[key]) ? "warning" : "default" %>' id='<%= "update-sample-#{update_sample['id']}[#{key}]"%>' ><%= val %></td>
<td class='<%= (val != db_sample[key]) ? "warning" : "default" %>' id='<%= "update-sample-#{update_sample['id']}[#{key}]" %>'><%= val %></td>
<% end %>
<% end %>
<% end %>
</tr>
<tr id='<%= "update-sample-#{update_sample['id']}-original" %>' >
<tr id='<%= "update-sample-#{update_sample['id']}-original" %>'>
<% db_sample.map do |key, val| %>
<% unless key == 'uuid' %>
<% 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>
Expand All @@ -63,6 +69,7 @@
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
Expand Down

0 comments on commit 04a82a4

Please sign in to comment.