-
-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add crud methods for case-specific placements * add placement destroy action * final functionalities added: use Modal Components, create & new actions * cleanup unused things * write unit tests for added placement views * run linter * ensure placement_types are not hardcoded but still org-specific * add back placement show action and placement decorators * undo placement_types factory change * fix-5780: add placement_policy_spec.rb * undo config change * fix failing tests for casa_case.show * clean up placements, remove most added error handling and _placements partial table * fix placement policy on certain actions * add system specs for CRUD actions on placements * fix failing tests * update placement policies * update spec/system/placements/index_spec.rb test * flaky test fixes * add policy scope for placements index action * update placement policy scope * please linter * Update config/environments/test.rb Co-authored-by: Jon Roberts <[email protected]> * Update config/environments/test.rb Co-authored-by: Jon Roberts <[email protected]> * dont display placement info on casa case when org has no placement types yet * run linter --------- Co-authored-by: Jon Roberts <[email protected]>
- Loading branch information
1 parent
ac35c95
commit b682c08
Showing
27 changed files
with
575 additions
and
28 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 |
---|---|---|
|
@@ -169,4 +169,4 @@ body.casa_cases-show { | |
flex-direction: column; | ||
gap: .2rem; | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class PlacementPolicy < ApplicationPolicy | ||
class Scope < ApplicationPolicy::Scope | ||
def resolve | ||
return scope.none unless @user&.casa_org | ||
|
||
scope.joins(:casa_case).where(casa_cases: {casa_org: @user.casa_org}) | ||
end | ||
end | ||
|
||
def allowed_to_edit_casa_case? | ||
casa_case_policy.edit? | ||
end | ||
|
||
alias_method :show?, :allowed_to_edit_casa_case? | ||
alias_method :edit?, :allowed_to_edit_casa_case? | ||
alias_method :update?, :allowed_to_edit_casa_case? | ||
alias_method :new?, :allowed_to_edit_casa_case? | ||
alias_method :create?, :allowed_to_edit_casa_case? | ||
alias_method :destroy?, :admin_or_supervisor? | ||
|
||
private | ||
|
||
def casa_case_policy | ||
CasaCasePolicy.new(user, record.casa_case) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
<% placements = casa_case.placements %> | ||
<label>Placements:</label> | ||
<% if placements.empty? %> | ||
No Placements | ||
<% else %> | ||
<ul> | ||
<% placements.each do |pcd| %> | ||
<p> | ||
<%= link_to(pcd.decorate.placement_info, casa_case_placement_path(casa_case, pcd)) %> | ||
</p> | ||
<% end %> | ||
</ul> | ||
<% current_placement = casa_case.placements.order(placement_started_at: :desc).first %> | ||
|
||
<% if current_placement %> | ||
<h6> | ||
<strong>Current Placement:</strong> | ||
<%= current_placement.placement_type.name %> | ||
</h6> | ||
|
||
<p>Placed since: <%= current_placement.decorate.formatted_date %></p> | ||
<p><%= link_to "See All Placements", casa_case_placements_path(casa_case), class: 'text-primary hover-underline' %></p> | ||
<% elsif casa_case.casa_org.placement_types.present? %> | ||
<h6> | ||
<strong>Current Placement:</strong> | ||
Unknown | ||
</h6> | ||
|
||
<p><%= link_to "See All Placements", casa_case_placements_path(casa_case), class: 'text-primary hover-underline' %></p> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div class="input-style-1"> | ||
<%= form.label :placement_started_at, "Placement Started At" %> | ||
<%= form.date_field :placement_started_at, | ||
value: placement.placement_started_at&.to_date || Time.zone.now, | ||
class: "form-control" %> | ||
</div> | ||
<div class="select-style-1"> | ||
<%= form.label :placement_type_id, "Placement Type" %> | ||
<div class="select-position"> | ||
<%= form.collection_select( | ||
:placement_type_id, | ||
PlacementType.for_organization(current_organization).order_alphabetically, | ||
:id, :name, | ||
{include_hidden: false, include_blank: "-Select Placement Type-"}, | ||
{class: "form-control"} | ||
) %> | ||
</div> | ||
</div> |
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,29 @@ | ||
<div class="card-style mb-30"> | ||
<div class="alert-box danger-alert"> | ||
<%= render "/shared/error_messages", resource: placement %> | ||
</div> | ||
<%= form_with(model: placement, url: [casa_case, placement], local: true, | ||
data: { controller: "placement-form", nested_form_wrapper_selector_value: ".nested-form-wrapper" }) do |form| %> | ||
<div class="row align-items-center"> | ||
<div class="col-md-6"> | ||
<h6><strong>Case Number:</strong> <%= link_to casa_case.case_number, casa_case %></h6> | ||
</div> | ||
<div class="col-md-6"> | ||
<div class="breadcrumb-wrapper"> | ||
<span class="top-page-actions ml-5"> | ||
<%= button_tag(type: "submit", class: "btn-sm main-btn primary-btn btn-hover") do %> | ||
<% if placement.persisted? %> | ||
<i class="lni lni-pencil-alt"></i> Update | ||
<% else %> | ||
<i class="lni lni-plus"></i> Create | ||
<% end %> | ||
<% end %> | ||
</span> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="row align-items-center"> | ||
<%= render 'placements/fields', placement: placement, form: form, casa_case: casa_case %> | ||
</div> | ||
<% end %> | ||
</div> |
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,11 @@ | ||
<div class="title-wrapper pt-30"> | ||
<div class="row align-items-center"> | ||
<div class="col-md-6"> | ||
<div class="title mb-30"> | ||
<h1>Editing Placement</h1> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<%= render 'form', casa_case: @casa_case, placement: @placement %> |
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,69 @@ | ||
<div class="title-wrapper pt-30"> | ||
<div class="row align-items-center"> | ||
<div class="col-md-6"> | ||
<div class="title mb-30"> | ||
<h1>Placement History for | ||
<%= link_to "#{@casa_case.case_number}", casa_case_path(@casa_case) %> | ||
</h1> | ||
</div> | ||
</div> | ||
<div class="col-md-6"> | ||
<div class="breadcrumb-wrapper mb-30"> | ||
<%= link_to new_casa_case_placement_path(@casa_case), class: "main-btn btn-sm primary-btn btn-hover ml-3" do %> | ||
<i class="lni lni-plus"></i> | ||
New Placement | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="col-lg-12"> | ||
<div class="card-style mb-30"> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Placement Type</th> | ||
<th>Date</th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @placements.each_with_index do |placement, idx| %> | ||
<tr> | ||
<td><%= placement.placement_type.name %></td> | ||
<td> | ||
<%= placement.decorate.formatted_date %> | ||
- | ||
<% if idx.zero? %> | ||
Present | ||
<% elsif @placements[idx - 1].placement_started_at %> | ||
<%= @placements[idx - 1].decorate.formatted_date %> | ||
<% end %> | ||
</td> | ||
<td><%= link_to edit_casa_case_placement_path(@casa_case, placement), class: "btn-sm main-btn primary-btn-outline btn-hover ms-auto" do %> | ||
<i class="lni lni-pencil-alt"></i> | ||
Edit | ||
<% end %> | ||
</td> | ||
<td> | ||
<%= render(Modal::OpenLinkComponent.new(target: placement.id, klass: "btn-sm main-btn danger-btn-outline btn-hover ms-auto")) do %> | ||
<i class="lni lni-trash-can"></i> | ||
Delete | ||
<% end %> | ||
</td> | ||
</tr> | ||
<%= render(Modal::GroupComponent.new(id: placement.id)) do |component| %> | ||
<% component.with_header(text: "Delete Placement?", id: placement.id) %> | ||
<% component.with_footer do %> | ||
<%= link_to casa_case_placement_path(@casa_case, placement), method: :delete, class: "btn-sm main-btn danger-btn btn-hover ms-auto" do %> | ||
<i class="lni lni-trash-can"></i> | ||
Confirm | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> |
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,11 @@ | ||
<div class="title-wrapper pt-30"> | ||
<div class="row align-items-center"> | ||
<div class="col-md-6"> | ||
<div class="title mb-30"> | ||
<h1>New Placement</h1> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<%= render 'form', casa_case: @casa_case, placement: @placement %> |
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
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,8 +1,8 @@ | ||
FactoryBot.define do | ||
factory :placement do | ||
association :creator, factory: :user | ||
casa_case | ||
placement_type | ||
placement_started_at { DateTime.now } | ||
creator { association :user } | ||
end | ||
end |
Oops, something went wrong.