Skip to content

Commit

Permalink
new view and action to display the extracted samples in a table #2052
Browse files Browse the repository at this point in the history
  • Loading branch information
stuzart committed Nov 14, 2024
1 parent c167c37 commit bc899a8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
11 changes: 9 additions & 2 deletions app/controllers/data_files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,19 @@ def filter
end
end

def samples_table
def extracted_samples
@samples = @data_file.extracted_samples.includes(:sample_type)
respond_to do |format|
format.html
end
end

def extracted_samples_table
respond_to do |format|
format.html do
render(partial: 'samples/table_view', locals: {
samples: @data_file.extracted_samples.includes(:sample_type),
source_url: samples_table_data_file_path(@data_file)
source_url: extracted_samples_table_data_file_path(@data_file)
})
end
format.json { @samples = @data_file.extracted_samples.select([:id, :title, :json_metadata]) }
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 @@ -20,7 +20,7 @@
<% end %>
<% if asset.extracted_samples.any? %>
<%= button_link_to("View samples", 'view_samples', data_file_samples_path(asset)) %>
<%= button_link_to("View extracted samples", 'view_samples', extracted_samples_data_file_path(asset)) %>
<% end %>
<% if attempt_to_show_extract_samples_button?(asset, display_asset) %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/data_files/_sample_persistence_status.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<p>
You can view the new samples by clicking the button below.
</p>
<%= link_to('View Created Samples', data_file_samples_path(data_file),
<%= link_to('View Created Samples', extracted_samples_data_file_path(data_file),
class: 'btn btn-primary') %>
<% end %>
<% end %>
Expand Down
14 changes: 14 additions & 0 deletions app/views/data_files/extracted_samples.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<% if @samples.any? %>
<div id="samples-table">
<%= render partial: "samples/table_view", locals: { samples: @samples, link: true }%>
</div>
<script>
$j(document).ready(function () {
Samples.initTable($j('#samples-table'));
});
</script>
<% else %>
<div class='alert alert-warning'>
There are no Samples available to be displayed
</div>
<% end %>
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,8 @@
post :create_metadata
end
member do
get :samples_table
get :extracted_samples_table
get :extracted_samples
get :select_sample_type
get :confirm_extraction
get :extraction_status
Expand Down
2 changes: 1 addition & 1 deletion lib/seek/permissions/translator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Translator
view: Set.new(%i[
view show index search favourite favourite_delete comment comment_delete comments
comments_timeline rate tag items statistics tag_suggestions preview runs
new_object_based_on_existing_one samples_table current diagram
new_object_based_on_existing_one extracted_samples extracted_samples_table current diagram
]).freeze,

download: Set.new(%i[
Expand Down

0 comments on commit bc899a8

Please sign in to comment.