Add column with default sort to prioritize new Agents in the index view

This commit is contained in:
Andrew Cantino 2016-03-13 13:27:49 -07:00
parent a025923c3c
commit 7476d7dcf1
2 changed files with 5 additions and 1 deletions

View file

@ -4,7 +4,7 @@ class AgentsController < ApplicationController
include SortableTable
def index
set_table_sort sorts: %w[name last_check_at last_event_at last_receive_at], default: { name: :asc }
set_table_sort sorts: %w[name created_at last_check_at last_event_at last_receive_at], default: { created_at: :desc }
@agents = current_user.agents.preload(:scenarios, :controllers).reorder(table_sort).page(params[:page])

View file

@ -2,6 +2,7 @@
<table class='table table-striped'>
<tr>
<th><%= sortable_column 'name', 'asc' %></th>
<th><%= sortable_column 'created_at', 'desc', name: 'Age' %></th>
<th>Schedule</th>
<th><%= sortable_column 'last_check_at', name: 'Last Check' %></th>
<th><%= sortable_column 'last_event_at', name: 'Last Event Out' %></th>
@ -23,6 +24,9 @@
</span>
<% end %>
</td>
<td class='<%= "agent-unavailable" if agent.unavailable? %>'>
<%= time_ago_in_words agent.created_at %>
</td>
<td class='<%= "agent-unavailable" if agent.unavailable? %>'>
<% if agent.can_be_scheduled? %>
<%= agent_schedule(agent, ',<br/>') %>