forked from rubyforgood/homeward-tails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
926 Staff Dashboard - make overdue tasks the default shown table (rub…
…yforgood#943) * Added table name and set Overdue table as default in Dashboard * Linted the code * Added PetAvatarComponent for displaying Pet's image * Move common query logic to PetTaskable concern Rename table name Update tests to reflect new table name Lint the code * Cleaned up unnecessary code * Rename method for improved context clarity
- Loading branch information
Showing
10 changed files
with
103 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module PetTaskable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
scope :with_overdue_tasks, -> { | ||
left_joins(:tasks) | ||
.select("pets.*, COUNT(tasks.id) AS incomplete_tasks_count") | ||
.where(tasks: {completed: false}) | ||
.where("tasks.due_date < ?", Time.current) | ||
.group("pets.id") | ||
} | ||
|
||
scope :with_incomplete_tasks, -> { | ||
left_joins(:tasks) | ||
.select("pets.*, COUNT(tasks.id) AS incomplete_tasks_count") | ||
.where(tasks: {completed: false}) | ||
.where("tasks.due_date IS NULL OR tasks.due_date >= ?", Time.current) | ||
.group("pets.id") | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
app/views/organizations/staff/dashboard/_pets_with_incomplete_or_overdue_tasks.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<turbo-frame id="tasks-frame"> | ||
<h3 class = "text-capitalize"><%= @header_title%></h3> | ||
<div class="card"> | ||
<table class="table mb-0 text-nowrap table-hover table-centered"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Name</th> | ||
<th class="text-center" scope="col">Sex</th> | ||
<th class="text-center" scope="col"><%= @column_name %></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @pets.each do |pet| %> | ||
<tr> | ||
<td> | ||
<div class="d-flex align-items-center"> | ||
<%= render PetAvatarComponent.new(pet)%> | ||
<div class="ms-3"> | ||
<h4 class="mb-0"> | ||
<%= link_to pet.name, staff_pet_path(pet), class: 'text-inherit', data: { turbo: false } %> | ||
</h4> | ||
</div> | ||
</div> | ||
</td> | ||
<td> | ||
<div class="d-flex justify-content-center"> | ||
<%= pet.sex %> | ||
</div> | ||
</td> | ||
<td> | ||
<div class="d-flex justify-content-center"> | ||
<%= link_to pet.incomplete_tasks_count, staff_pet_path(pet, active_tab: 'tasks'), class: 'text-inherit', data: { turbo: false } %> | ||
</div> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
<div class="d-flex justify-content-center align-items-center mt-2"> | ||
<%== pagy_bootstrap_nav(@pagy) if @pagy.pages > 1 %> | ||
</div> | ||
</turbo-frame> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1 @@ | ||
<turbo-frame id="tasks-frame"> | ||
<div class="card"> | ||
<table class="table mb-0 text-nowrap table-hover table-centered"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Name</th> | ||
<th class="text-center" scope="col">Sex</th> | ||
<th class="text-center" scope="col"><%= column_name %></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @pets.each do |pet| %> | ||
<tr> | ||
<td> | ||
<div class="d-flex align-items-center"> | ||
<div class="icon-shape icon-lg rounded-3 border"> | ||
<% if pet.images.attached? %> | ||
<%= image_tag pet.images.first, class: 'card-img' %> | ||
<% else %> | ||
<%= image_tag('coming_soon.jpg', class: 'card-img') %> | ||
<% end %> | ||
</div> | ||
<div class="ms-3"> | ||
<h4 class="mb-0"> | ||
<%= link_to pet.name, staff_pet_path(pet), class: 'text-inherit', data: { turbo: false } %> | ||
</h4> | ||
</div> | ||
</div> | ||
</td> | ||
<td> | ||
<div class="d-flex justify-content-center"> | ||
<%= pet.sex %> | ||
</div> | ||
</td> | ||
<td> | ||
<div class="d-flex justify-content-center"> | ||
<%= link_to pet.incomplete_tasks_count, staff_pet_path(pet, active_tab: 'tasks'), class: 'text-inherit', data: { turbo: false } %> | ||
</div> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
<div class="d-flex justify-content-center align-items-center mt-2"> | ||
<%== pagy_bootstrap_nav(@pagy) if @pagy.pages > 1 %> | ||
</div> | ||
</turbo-frame> | ||
<%= render 'pets_with_incomplete_or_overdue_tasks'%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters