Fixed sorting on Vendor Details. The Linked Participants are now sorted by last name.
This commit is contained in:
parent
944824f443
commit
6933ca7635
|
@ -5,6 +5,7 @@ class VendorsController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@vendor = Vendor.find(params[:id])
|
@vendor = Vendor.find(params[:id])
|
||||||
|
@sorted_participants = @vendor.service_contracts.includes(:participant).map(&:participant).sort_by(&:last_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
<div class="row mt-4">
|
<div class="row mt-4">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h2 class="mt-4">Linked Participants</h2>
|
<h2 class="mt-4">Linked Participants</h2>
|
||||||
<% if @vendor.participants.any? %>
|
<% if @sorted_participants.any? %>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead class="table-light">
|
<thead class="table-light">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -66,21 +66,22 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @vendor.service_contracts.each do |contract| %>
|
<% @sorted_participants.each do |participant| %>
|
||||||
<tr>
|
<% participant.service_contracts.each do |contract| %>
|
||||||
<% participant = contract.participant %>
|
<tr>
|
||||||
<td><%= participant ? "#{participant.first_name} #{participant.last_name}" : 'No Participant Assigned' %></td>
|
<td><%= "#{participant.first_name} #{participant.last_name}" %></td>
|
||||||
<td><%= contract.start_date.strftime('%B %d, %Y') if contract.start_date.present? %></td>
|
<td><%= contract.start_date.strftime('%B %d, %Y') if contract.start_date %></td>
|
||||||
<td><%= contract.end_date.strftime('%B %d, %Y') if contract.end_date.present? %></td>
|
<td><%= contract.end_date.strftime('%B %d, %Y') if contract.end_date %></td>
|
||||||
<td>
|
<td>
|
||||||
<%= link_to participant_path(participant), class: 'btn btn-sm btn-secondary' do %>
|
<%= link_to participant_path(participant), class: 'btn btn-sm btn-secondary' do %>
|
||||||
<i class="bi bi-eye"></i> <!-- Eyeball icon for 'Show' -->
|
<i class="bi bi-eye"></i> <!-- Eyeball icon for 'Show' -->
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= link_to edit_service_contract_path(contract), class: 'btn btn-sm btn-info' do %>
|
<%= link_to edit_service_contract_path(contract), class: 'btn btn-sm btn-info' do %>
|
||||||
<i class="bi bi-pencil-fill" style="color: white;"></i> <!-- Pencil icon for 'Edit' with white color -->
|
<i class="bi bi-pencil-fill" style="color: white;"></i> <!-- Pencil icon for 'Edit' with white color -->
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
@ -89,3 +90,4 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue