Skip to content

Commit

Permalink
Staff can view checklist on pets show and interact (#265)
Browse files Browse the repository at this point in the history
* Update with partial

* Update with attempt with nice_partials gem

* Syntax cleanup

* Added new nice_partails folder

* Syntax cleanup

* Update with path params value changed

* Update Front-end spacing clean up

* Added new partials and Table to DB

* Update Changed the task list to now be a modal

* Post merge commit

* Add Applications list to Pet show (#288)

* Update sidebar styling to avoid spilling to tab links

Co-authored-by: FionaDL fionadlapham@gmail.com

* Fix applicant name on applications page

Co-authored-by: FionaDL fionadlapham@gmail.com

* add applications partial and test

Co-authored-by: FionaDL fionadlapham@gmail.com

* add tests for application tab

Co-authored-by: FionaDL fionadlapham@gmail.com

* Clear default_url_options[:script_name] after each test (#287)

* Added edit partial

* 281: Pets Show Overview Tab make Edit and Delete buttons more visible (#286)

* Replace dropdown button with edit button, add delete button beneath summary card

* Modify delete button styling

* docs: add jadekstewart3 as a contributor for code (#291)

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>

* docs: add edwinthinks as a contributor for code (#292)

* docs: update README.md [skip ci]

* docs: update README.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Ben <95949082+kasugaijin@users.noreply.github.com>

* Org dashboard (#290)

* Add instance variables that will be used in the dashboard view

* Add template html and begin inital formatting to utilize instance variables scoped to organization

* remove img tag for non existant avatar

* Merge conflict updated

* Merge conflict updated

* Add column 2 org profiles (#289)

* Create migration file to add about us to organization profiles table, and add column to seed files

* add about us field for organization_profiles

* add validation for about us

* add validation for about us

* standard

* Remove validation that we didnt need

* remove null false from migration file and migrate

* standard rb

* add validation for about us

* Add back in accidentially removed validation

* Migrate updated migration file

* Add null false back into correct place and migrate

* remove not null comment

* standard rb

* merge main

* Remove default values from foreign keys (#298)

* Improve UI of Accept Invitation Form (#300)

* Improve tests stability (#296)

* Fix global tests setup

* Ensure organization slugs are uniq in tests

* Fix factories so they use the same organization for associations

* Ensure user emails are uniq in tests

* Use current_tenant in factories

* Use ActsAsTenant.test_tenant in tests

* run standard:fix

* fix all contributors table (#293)

* 268 part 1: staff can upload profile pic (#276)

* Add model changes and tests

* Add form field, and changes into the controller

* change naming from Picture to Avatar

* Run standard fix

* Move avatarable tests to shared module

* Add uniq index to organization slug (#302)

* Merge conflict updated

* Update with working but ugly crud features

* Syntax error cleanup

* Removed binding

* Added partial files and corrected before acgtion

* Remove 'overview' from the default active tab options

* Update Frontend form still nested

* Linter error cleanup

* Merge conflict resolved

* Pet controller refactor

* Update with code clean up

* Pet controller syntax cleanup

* Removed partials

* Cleanup Syntax

* Test file merge conflict solution

* Syntax cleanup

* Code refactor

* Update spacing in file clean up

* Updated frontend with turbo delete button

* Update with Features rendering correctly but code is sloppy

* Standard error fix

* Update spacing and code clean up

* Removed unneeded CSS file

* Removed more unneeded css

* Removed hardcoded org

* Added turbo_stream file and last commit before migration that moves away from Tasks

* Update with skipped unit tests

* Syntax cleanup

* Update to spacing

* Update spacing cleanup

* Update spacing cleanup part 2

* Update spacing and syntax cleanup part 3

* Update styling changes to tasks

* Added model tests

* Update with passing tests

* Update syntax cleanup

* Update syntax spacing

* Update syntax spacing

* Update syntax spacing

* Update with Frontend cleanup

* Testing all passing

* Spacing cleanup

* Update cleanup

* Update spacing cleanup

* Added null:false to tasks name

* Added migration file

* Added updated test

---------

Co-authored-by: aisayo <aysan@ombulabs.com>
Co-authored-by: Piotr Borowiec <p.borowiec01@gmail.com>
Co-authored-by: MooseCowBear <82609260+MooseCowBear@users.noreply.github.com>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Ben <95949082+kasugaijin@users.noreply.github.com>
Co-authored-by: Jade Stewart <114014697+jadekstewart3@users.noreply.github.com>
Co-authored-by: Marlena Borowiec <96994176+marlena-b@users.noreply.github.com>
Co-authored-by: Yuri Pains <yuricarvalhop@gmail.com>
  • Loading branch information
9 people committed Nov 29, 2023
1 parent 39466d4 commit 836f51d
Show file tree
Hide file tree
Showing 22 changed files with 647 additions and 198 deletions.
72 changes: 72 additions & 0 deletions app/controllers/organizations/tasks_controller.rb
@@ -0,0 +1,72 @@
class Organizations::TasksController < Organizations::BaseController
before_action :set_pet, only: [:new, :create, :edit, :update, :destroy]
before_action :set_task, only: [:edit, :update]

def new
@task = @pet.tasks.build
render partial: "form", locals: {task: @task}
end

def create
@task = @pet.tasks.build(task_params)

if @task.save
respond_to do |format|
format.html { redirect_to pet_path(@pet, active_tab: "tasks") }
format.turbo_stream
end
else
render :new
end
end

def edit
end

def update
if @task.update(task_params)
respond_to do |format|
format.html { redirect_to @task, notice: "Task was successfully updated." }
format.turbo_stream { render turbo_stream: turbo_stream.replace("tasks_list", partial: "organizations/tasks/tasks", locals: {task: @task}) }
end
else
respond_to do |format|
format.html { render :edit }
end
end
end

def destroy
@task = Task.find(params[:id])
@task.destroy

respond_to do |format|
format.html { redirect_to pet_path(@pet), notice: "Task was successfully deleted." }
format.turbo_stream
end
rescue ActiveRecord::RecordNotFound
redirect_to pets_path
end

private

def set_pet
@organization = current_user.organization
raise ActiveRecord::RecordNotFound if @organization.nil?

pet_id = params[:pet_id] || params[:id]
@pet = @organization.pets.find(pet_id)
rescue ActiveRecord::RecordNotFound
redirect_to pets_path unless @pet
end

def set_task
@task = @pet.tasks.find(params[:id])
rescue ActiveRecord::RecordNotFound
redirect_to pets_path
end

def task_params
params.require(:task).permit(:name, :description, :completed)
end
end
4 changes: 4 additions & 0 deletions app/helpers/application_helper.rb
Expand Up @@ -7,6 +7,10 @@ def organization_home_path(organization)
home_index_path(script_name: "/#{organization.slug}")
end

def path_to_partial(active_tab)
"pets/#{active_tab}"
end

def current_organization_name
if Current.organization.present?
Current.organization.name
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/tasks_helper.rb
@@ -0,0 +1,2 @@
module TasksHelper
end
1 change: 1 addition & 0 deletions app/models/pet.rb
Expand Up @@ -31,6 +31,7 @@ class Pet < ApplicationRecord
acts_as_tenant(:organization)

has_many :adopter_applications, dependent: :destroy
has_many :tasks, dependent: :destroy
has_one :match, dependent: :destroy
has_many_attached :images
enum species: ["Dog", "Cat"]
Expand Down
23 changes: 23 additions & 0 deletions app/models/task.rb
@@ -0,0 +1,23 @@
# == Schema Information
#
# Table name: tasks
#
# id :bigint not null, primary key
# completed :boolean default(FALSE)
# description :text
# name :string not null
# created_at :datetime not null
# updated_at :datetime not null
# pet_id :bigint not null
#
# Indexes
#
# index_tasks_on_pet_id (pet_id)
#
# Foreign Keys
#
# fk_rails_... (pet_id => pets.id)
#
class Task < ApplicationRecord
belongs_to :pet
end
207 changes: 104 additions & 103 deletions app/views/organizations/pets/show.html.erb
@@ -1,112 +1,113 @@
<% breadcrumb :dashboard_pet, @pet %>

<%= render "components/dashboard/page" do |p| %>
<% p.header_title @pet.name %>
<% p.nav_tabs do %>
<%= render "components/dashboard/nav_tab", url: pet_path(@pet, active_tab: "overview"), text: "Summary", options: { active: /overview/ } %>
<%= render "components/dashboard/nav_tab", url: pet_path(@pet, active_tab: "applications"), text: "Tasks", options: { active: /applications/ } %>
<% end %>
<% p.content do %>
<div class="row">
<!-- from 265 -->
<div class="col-md-12 col-xl-8 col-12">
<%= render partial: "organizations/tasks/#{@active_tab}", locals: { pet: @pet } %>
</div>

<div class="col-md-12 col-xl-4 col-12">

<div class="mb-4">
<div>
<% if @pet.images.attached? %>
<%= image_tag @pet.images.first, class: 'rounded card-img-top' %>
<% else %>
<%= image_tag('coming_soon.jpg', class: 'rounded card-img-top') %>
<% end %>
</div>
<div class="row">
<!-- from 265 -->
<div class="col-12 mb-4">
<!-- nav -->
<ul class="nav nav-lb-tab">
<li class="nav-item ms-0 me-3">
<%= link_to 'Overview', pet_path(@pet, active_tab: 'overview'), class: 'nav-link' + (@active_tab == 'overview' ? ' active' : '') %>
</li>
<li class="nav-item mx-3">
<%= link_to 'Task', pet_path(@pet, active_tab: 'tasks'), class: 'nav-link' + (@active_tab == 'tasks' ? ' active' : '') %>
</li>
<li class="nav-item mx-3">
<%= link_to 'Applications', pet_path(@pet, active_tab: 'applications'), class: 'nav-link' + (@active_tab == 'applications' ? ' active' : '') %>
</li>
<li class="nav-item mx-3">
<%= link_to 'Files', pet_path(@pet, active_tab: 'files'), class: 'nav-link' + (@active_tab == 'files' ? ' active' : '') %>
</li>
</ul>
</div>
</div>
<div class="row">
<%= render partial: "organizations/tasks/#{@active_tab}", locals: { pet: @pet } %>
<div class="col-md-12 col-xl-4 col-12">
<!-- card -->
<div class="card mb-4 bg-primary border-primary">
<!-- card body -->
<div class="card-body">
<% if @pet.images.attached? %>
<%= image_tag @pet.images.first, class: 'rounded card-img-top' %>
<% else %>
<%= image_tag('coming_soon.jpg', class: 'rounded card-img-top') %>
<% end %>
</div>
</div>
<div class="card">
<!-- Card header -->
<div class="card-header card-header-height d-flex justify-content-between align-items-center">
<div>
<h4 class="mb-0">Recent Activity</h4>
</div>

<div class="card">
<!-- Card header -->
<div class="card-header card-header-height d-flex justify-content-between align-items-center">
<div>
<h4 class="mb-0">Recent Activity
</h4>
</div>
<div><a href="#">View All</a></div>
</div>
<!-- Card body -->
<div class="card-body">
<!-- List group -->
<ul class="list-group list-group-flush list-timeline-activity">
<li class="list-group-item px-0 pt-0 border-0 pb-6">
<div class="row position-relative">
<div class="col-auto">
<div class="icon-shape icon-md bg-light-primary text-primary rounded-circle">
<i class="fe fe-check"></i>
<div><a href="#">View All</a></div>
</div>
<!-- Card body -->
<div class="card-body">
<!-- List group -->
<ul class="list-group list-group-flush list-timeline-activity">
<li class="list-group-item px-0 pt-0 border-0 pb-6">
<div class="row position-relative">
<div class="col-auto">
<div class="icon-shape icon-md bg-light-primary text-primary rounded-circle">
<i class="fe fe-check"></i>
</div>
</div>
<div class="col ms-n3">
<h4 class="mb-0 h5">Task Finished</h4>
<p class="mb-0 text-body">Paula finished figma task</p>
<li class="list-group-item px-0 pt-0 border-0 pb-6">
<div class="row position-relative">
<div class="col-auto">
<div class="icon-shape icon-md bg-light-primary text-primary rounded-circle">
<i class="fe fe-message-square"></i>
</div>
</div>
<div class="col ms-n3">
<h4 class="mb-0 h5">New Comment</h4>
<p class="mb-0 text-body">Georg commented on task.</p>
</div>
<div class="col-auto">
<span class="text-muted fs-6">1 hour ago</span>
</div>
</div>
<div class="col ms-n3">
<h4 class="mb-0 h5">Task Finished</h4>
<p class="mb-0 text-body">Paula finished figma task</p>
<li class="list-group-item px-0 pt-0 border-0 pb-6">
<div class="row position-relative">
<div class="col-auto">
<div class="icon-shape icon-md bg-light-primary text-primary rounded-circle">
<i class="fe fe-message-square"></i>
</div>
</div>
<div class="col ms-n3">
<h4 class="mb-0 h5">New Comment</h4>
<p class="mb-0 text-body">Georg commented on task.</p>

</div>
<div class="col-auto">
<span class="text-muted fs-6">1 hour ago</span>

</div>
</li>
<li class="list-group-item px-0 pt-0 border-0 pb-6">
<div class="row position-relative">
<div class="col-auto">
<div class="icon-shape icon-md bg-light-primary text-primary rounded-circle">
<i class="fe fe-alert-triangle"></i>
</div>
</li>
<li class="list-group-item px-0 pt-0 border-0 pb-6">
<div class="row position-relative">
<div class="col-auto">
<div class="icon-shape icon-md bg-light-primary text-primary rounded-circle">
<i class="fe fe-alert-triangle"></i>
</div>
</div>
<div class="col ms-n3">
<h4 class="mb-0 h5">Task Overdue</h4>
<p class="mb-0 text-body">Task <a href="#"><u>status updatd for board</u></a>
is overdue.</p>

</div>
<div class="col-auto">
<span class="text-muted fs-6">1 day</span>

</div>
</div>
</li>
<li class="list-group-item px-0 pt-0 border-0">
<div class="row position-relative">
<div class="col-auto">
<div class="icon-shape icon-md bg-light-primary text-primary rounded-circle">
<i class="fe fe-mail"></i>
</div>
</div>
<div class="col ms-n3">
<h4 class="mb-0 h5">Update Send to Client</h4>
<p class="mb-0 text-body">Jitu send email to update design
for client Geeks UI.</p>

</div>
<div class="col-auto">
<span class="text-muted fs-6">1 day</span>
</div>
</div>
<div class="col ms-n3">
<h4 class="mb-0 h5">Task Overdue</h4>
<p class="mb-0 text-body">Task <a href="#"><u>status updatd for board</u></a> is overdue.</p>
</div>
<div class="col-auto">
<span class="text-muted fs-6">1 day</span>
</div>
</div>
</li>
<li class="list-group-item px-0 pt-0 border-0">
<div class="row position-relative">
<div class="col-auto">
<div class="icon-shape icon-md bg-light-primary text-primary rounded-circle">
<i class="fe fe-mail"></i>
</div>
</li>
</ul>
</div>
<div class="col ms-n3">
<h4 class="mb-0 h5">Update Send to Client</h4>
<p class="mb-0 text-body">Jitu send email to update design for client Geeks UI.</p>
</div>
<div class="col-auto">
<span class="text-muted fs-6">1 day</span>
</div>
</div>
</div>
</div>
</li>
</div>
</li>
</ul>
</div>
<% end %>
<% end %>
</div>
</div>
</div>
36 changes: 33 additions & 3 deletions app/views/organizations/tasks/_applications.html.erb
@@ -1,3 +1,33 @@
<div class="mb-4">
<%= render "partials/pet_applications", applications: pet.adopter_applications, pet: nil %>
</div>
<turbo-frame id="tasks_list" class="col-md-12 col-xl-8 col-12">
<div class="row">
<div class="col-12 mb-4">
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between align-items-center">
<div>
<h4 class="mb-0">Summary</h4>
</div>
<!-- dropdown -->
<div>
<span class="dropdown dropstart">
<a class="btn-icon btn btn-ghost btn-sm rounded-circle" href="#" role="button" id="DropdownTen" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fe fe-more-vertical"></i>
</a>
<span class="dropdown-menu" aria-labelledby="DropdownTen">
<span class="dropdown-header">Settings</span>
<%= link_to t('general.edit'), edit_pet_path(@pet), class: 'dropdown-item' %>
<%= link_to t('general.delete'), pet_path(@pet), class: 'dropdown-item',
data:
{
turbo_method: :delete,
turbo_confirm: t('organization_pets.show.are_you_sure_delete')
} %>
</span>
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</turbo-frame>

0 comments on commit 836f51d

Please sign in to comment.