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
|
||||
@vendor = Vendor.find(params[:id])
|
||||
@sorted_participants = @vendor.service_contracts.includes(:participant).map(&:participant).sort_by(&:last_name)
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
<div class="row mt-4">
|
||||
<div class="col-12">
|
||||
<h2 class="mt-4">Linked Participants</h2>
|
||||
<% if @vendor.participants.any? %>
|
||||
<% if @sorted_participants.any? %>
|
||||
<table class="table table-striped">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
|
@ -66,21 +66,22 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @vendor.service_contracts.each do |contract| %>
|
||||
<tr>
|
||||
<% participant = contract.participant %>
|
||||
<td><%= participant ? "#{participant.first_name} #{participant.last_name}" : 'No Participant Assigned' %></td>
|
||||
<td><%= contract.start_date.strftime('%B %d, %Y') if contract.start_date.present? %></td>
|
||||
<td><%= contract.end_date.strftime('%B %d, %Y') if contract.end_date.present? %></td>
|
||||
<td>
|
||||
<%= link_to participant_path(participant), class: 'btn btn-sm btn-secondary' do %>
|
||||
<i class="bi bi-eye"></i> <!-- Eyeball icon for 'Show' -->
|
||||
<% end %>
|
||||
<%= 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 -->
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% @sorted_participants.each do |participant| %>
|
||||
<% participant.service_contracts.each do |contract| %>
|
||||
<tr>
|
||||
<td><%= "#{participant.first_name} #{participant.last_name}" %></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 %></td>
|
||||
<td>
|
||||
<%= link_to participant_path(participant), class: 'btn btn-sm btn-secondary' do %>
|
||||
<i class="bi bi-eye"></i> <!-- Eyeball icon for 'Show' -->
|
||||
<% end %>
|
||||
<%= 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 -->
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -89,3 +90,4 @@
|
|||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue