Skip to content

Commit 7a8c1c5

Browse files
katiez667Katie Zhang
andauthored
feat: add queue history page (#445)
* feat(queues): add queue history page * feat(queues): add queue history page * fix: run prettier * fix: run prettier again * fix: rubocop and prettier conciliation --------- Co-authored-by: Katie Zhang <zhangmy667@gmail.com>
1 parent 816626c commit 7a8c1c5

5 files changed

Lines changed: 50 additions & 3 deletions

File tree

‎app/controllers/organization_timeline_entries_controller.rb‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ def queues
9292
@structural = OrganizationTimelineEntry.structural.current
9393
end
9494

95+
def history
96+
@entries =
97+
OrganizationTimelineEntry.where.not(ended_at: nil).order(ended_at: :desc)
98+
end
99+
95100
private
96101

97102
def set_organization_timeline_entry

‎app/models/ability.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,8 @@ def initialize(user)
478478
can %i[create update destroy], Membership
479479
can %i[hardhats read_basic_details read_all_details], Organization
480480
can %i[create update destroy], OrganizationBuildStatus
481-
can %i[create edit update end structural electrical downtime],
482-
OrganizationTimelineEntry
481+
can %i[create edit update end downtime], OrganizationTimelineEntry
482+
can %i[structural electrical queues history], OrganizationTimelineEntry
483483
can %i[create update read_phone_number], Participant
484484
can :read_coord, Shift
485485
can :create, ShiftParticipant
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<% update_document_title(add: 'Queue History') %>
2+
<% update_breadcrumbs(add: link_to('Queues', queues_path)) %>
3+
<% update_breadcrumbs(add: 'History') %>
4+
<% nav(active: 'queues') %>
5+
6+
<div class="content wide">
7+
<div>
8+
<h1>Queue History</h1>
9+
<% if @entries.empty? %>
10+
<p>No history yet.</p>
11+
<% else %>
12+
<table class="table table-striped">
13+
<thead>
14+
<th>Org</th>
15+
<th>Type</th>
16+
<th>Notes</th>
17+
<th>Entered</th>
18+
<th>Ended</th>
19+
</thead>
20+
<tbody>
21+
<% @entries.each do |entry| %>
22+
<tr>
23+
<td
24+
><%= link_to entry.organization.short_name, entry.organization %></td
25+
>
26+
<td><%= entry.entry_type.humanize %></td>
27+
<td><%= h entry.description %></td>
28+
<td><%= entry.started_at %></td>
29+
<td><%= entry.ended_at %></td>
30+
</tr>
31+
<% end %>
32+
</tbody>
33+
</table>
34+
<% end %>
35+
</div>
36+
</div>

‎app/views/organization_timeline_entries/queues.html.erb‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
<%= render partial: 'organization_timeline_entries',
1616
locals: {
1717
entries: @electrical
18-
} %> </div
18+
} %>
19+
<p class="alignright">
20+
<%= link_to 'See Queue History', queue_history_path, class: 'cta' %>
21+
<br />
22+
</p> </div
1923
><div class="sidebar"> <%= render partial: 'queue_sidebar' %> </div>
2024
</div>

‎config/routes.rb‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@
238238
get 'electrical' => 'organization_timeline_entries#electrical',
239239
:as => 'electrical'
240240
get 'queues' => 'organization_timeline_entries#queues', :as => 'queues'
241+
get 'queues/history' => 'organization_timeline_entries#history',
242+
:as => 'queue_history'
241243

242244
resources :users
243245

0 commit comments

Comments
 (0)