Skip to content

Commit

Permalink
Merge pull request #1965 from sanger/y24-352-only-only-show-relatives…
Browse files Browse the repository at this point in the history
…-with-purpose

Y24-352: Filter for any relatives that might not have a purpose
  • Loading branch information
StephenHulme authored Sep 27, 2024
2 parents 1be6586 + a1a3f9b commit e5636b4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions app/views/labware/_relatives_list.html.erb
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
<%# locals: (presenter:) %>
<%
valid_parents = presenter.labware.parents&.filter{ |parent| parent.purpose.present? } || []
valid_children = presenter.labware.children&.filter{ |child| child.purpose.present? } || []
%>
<div id="relatives-information" class="list-group list-group-flush">

<div class="list-group-item">
<strong>Parents</strong>
<%= content_tag :span, presenter.labware.parents.size, class: "badge badge-pill badge-secondary" if presenter.labware.parents&.any? %>
<%= content_tag :span, valid_parents.size, class: "badge badge-pill badge-secondary" %>
</div>

<div id="parents-list" class="border-bottom">
<% if presenter.labware.parents&.any? { |parent| parent.purpose.present? } %>
<%= render partial: 'labware/parent_labware_item', collection: presenter.labware.parents, as: :labware %>
<% if valid_parents %>
<%= render partial: 'labware/parent_labware_item', collection: valid_parents, as: :labware %>
<% else %>
<div class="list-group-item text-muted">No parents found</div>
<% end %>
</div>

<div class="list-group-item">
<strong>Children</strong>
<%= content_tag :span, presenter.labware.children.size, class: "badge badge-pill badge-secondary" if presenter.labware.children&.any? %>
<%= content_tag :span, valid_children.size, class: "badge badge-pill badge-secondary" %>
</div>

<div id="children-list" class="rounded-bottom">
<% if presenter.labware.children&.any? { |child| child.purpose.present? } %>
<%= render partial: 'labware/child_labware_item', collection: presenter.labware.children, as: :labware, locals: { presenter: presenter, open_in_new_window: true } %>
<% if valid_children %>
<%= render partial: 'labware/child_labware_item', collection: valid_children, as: :labware, locals: { presenter: presenter, open_in_new_window: true } %>
<% else %>
<div class="list-group-item text-muted">No children found</div>
<% end %>
Expand Down

0 comments on commit e5636b4

Please sign in to comment.