Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Case Contact Form Overhaul #6048

Merged
merged 41 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ba5069a
additional expenses and contact topic answer controllers
thejonroberts Sep 25, 2024
fd8caa5
view template formatting
thejonroberts Sep 2, 2024
7d34901
better expenses, specs, & fixes
thejonroberts Sep 6, 2024
7a2e77f
use casa_case_contact_topics if present
thejonroberts Sep 9, 2024
6211850
autosave and grouped contact_types
thejonroberts Sep 14, 2024
9c50147
model spec validation changes
thejonroberts Sep 15, 2024
d4a1743
form stimulus controller, nested form behavior
thejonroberts Sep 16, 2024
cf4a115
better contact type validation
thejonroberts Sep 16, 2024
4d1d1ef
dollar sign and css scoping
thejonroberts Sep 17, 2024
bbe3303
handle nested-form autosaves
thejonroberts Sep 20, 2024
f7289c9
handle autosave of additional expenses
thejonroberts Sep 21, 2024
e841dc2
put NestedForm import back
thejonroberts Sep 23, 2024
145304a
alias policy actions
thejonroberts Sep 23, 2024
ed80190
require contact type validation
thejonroberts Sep 23, 2024
78436a0
rebase fixes
thejonroberts Sep 26, 2024
afd0915
types column layout vs grid
thejonroberts Sep 29, 2024
f296ace
valid html
thejonroberts Oct 1, 2024
ee76e14
handle json actions in app controller
thejonroberts Oct 8, 2024
afaabca
use a fallback casa_org for draft contact relationships
thejonroberts Oct 9, 2024
3ade120
CaseContactPolicy specs & fixes
thejonroberts Oct 9, 2024
4a4ad66
required * form notation for expenses
thejonroberts Oct 9, 2024
f029a25
additional expense policy & scope for draft contacts
thejonroberts Oct 9, 2024
80d381b
draft case topic answer org relation and specs
thejonroberts Oct 9, 2024
06b6e5c
case contact policy scope & better specs
thejonroberts Oct 9, 2024
e3e6a8b
better policy specs
thejonroberts Oct 9, 2024
9119416
lint
thejonroberts Oct 9, 2024
bd75f2b
minor usage annoyances
thejonroberts Oct 9, 2024
570d7f3
remove env var
thejonroberts Oct 9, 2024
8c70ea0
reduce number of policy spec runs (same specs)
thejonroberts Oct 10, 2024
d4d6b3e
restrict new policy
thejonroberts Oct 10, 2024
735f22a
autosave on expense description changes
thejonroberts Oct 11, 2024
6b4f3a6
contact type last used and vertical medium
thejonroberts Oct 13, 2024
472c828
match design specs
thejonroberts Oct 15, 2024
e7c8574
remove unused function, pending policy specs
thejonroberts Oct 15, 2024
3f0b42b
fix specs
thejonroberts Oct 16, 2024
77a0179
remove topic id db null constraint
thejonroberts Oct 17, 2024
b4a3134
limit topic answers & disable current selected topics
thejonroberts Oct 18, 2024
1513c4e
lint
thejonroberts Oct 18, 2024
b6e73f9
fix flaky spec
thejonroberts Oct 18, 2024
eb35c9c
use helper, lint
thejonroberts Oct 18, 2024
027f3a6
use pluck, admin edit test tweak
thejonroberts Oct 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/assets/stylesheets/base/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ $sidebar-dark: #1A2142;
--dark: #262d3f;
--gray: #5d657b;
--silver: #D9D9D9;
--inactive: #9AA4CA;
}
15 changes: 3 additions & 12 deletions app/assets/stylesheets/pages/case_contacts.scss
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@

fieldset {
border: 1px double #CCC;
}

.slide-container {
padding: 0rem 1rem;
}

legend {
font-size: small;
}

.slider {
display: inline;
}
Expand Down Expand Up @@ -90,7 +81,7 @@ legend {
}
}
}

.other-expenses li {
margin-bottom: .2rem;
}
Expand Down Expand Up @@ -118,7 +109,7 @@ legend {
display: flex;
align-items: center;
}

.dollar-sign .other-expense-amount {
position: relative;
padding-left: 32px;
Expand All @@ -135,7 +126,7 @@ legend {
left: 28px;
z-index: 100;
}

.pr-7 {
padding-right: 1.5rem !important;
padding-left: 2.5rem !important;
Expand Down
65 changes: 47 additions & 18 deletions app/assets/stylesheets/pages/case_contacts_form.scss
thejonroberts marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,31 +1,60 @@
@use "../base/breakpoints.scss" as screen-sizes;

.case-contacts-form {
&-buttons {
display: flex;
justify-content: flex-end;
gap: 10px;
#case-contact-form {
& #contact-form-types {
--group-width: 250px;

@media only screen and (max-width: screen-sizes.$mobile) {
& > a, & > button {
flex-grow: 1;
columns: var(--group-width);

& fieldset {
display: inline-block;
width: var(--group-width);
padding: .25rem;

& legend {
color: var(--inactive);
}

& .form-check {
padding-left: .25rem;

& input {
float: none;
}

& label {
display: inline;
}
}
}
}

&-checkbox {
border-color: #757575;
& .input-group-text {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}

&-title {
@media only screen and (max-width: screen-sizes.$mobile) {
font-size: 28px;
}
& h2 {
font-size: 28px;
}

&-subtitle {
& h3 {
font-size: medium;
}

& legend {
font-size: medium;
}

& #contact-form-action-buttons {
display: flex;
justify-content: flex-end;
gap: 10px;

@media only screen and (max-width: screen-sizes.$mobile) {
font-size: 24px;
}
& > a, & > button {
flex-grow: 1;
}
}
}
}
}
6 changes: 0 additions & 6 deletions app/assets/stylesheets/shared/form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,3 @@ form {
display: initial;
}

.details__topics-label {
span {
display: initial;
}

}
2 changes: 0 additions & 2 deletions app/components/form/hour_minute_duration_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<%= @form.number_field :duration_hours,
min: 0,
class: "form-control",
size: "10",
style: "background:white",
value: @hour_value,
required: true %>
Expand All @@ -14,7 +13,6 @@
<%= @form.number_field :duration_minutes,
min: 0,
class: "form-control",
size: "10",
style: "background:white",
value: @minute_value,
required: true %>
Expand Down
3 changes: 0 additions & 3 deletions app/components/form/submit_button_component.html.erb

This file was deleted.

13 changes: 0 additions & 13 deletions app/components/form/submit_button_component.rb

This file was deleted.

30 changes: 0 additions & 30 deletions app/components/form/title_component.html.erb

This file was deleted.

15 changes: 0 additions & 15 deletions app/components/form/title_component.rb

This file was deleted.

30 changes: 30 additions & 0 deletions app/controllers/additional_expenses_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
class AdditionalExpensesController < ApplicationController
before_action :force_json_format

def create
@additional_expense = AdditionalExpense.new(additional_expense_params)
authorize @additional_expense

if @additional_expense.save
render json: @additional_expense.as_json, status: :created
else
render json: @additional_expense.errors.as_json, status: :unprocessable_entity
end
end

def destroy
@additional_expense = AdditionalExpense.find(params[:id])
authorize @additional_expense

@additional_expense.destroy!

head :no_content
end

private

def additional_expense_params
params.require(:additional_expense)
.permit(:case_contact_id, :other_expense_amount, :other_expenses_describe)
end
end
34 changes: 31 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ApplicationController < ActionController::Base
rescue_from StandardError, with: :log_and_reraise
rescue_from Pundit::NotAuthorizedError, with: :not_authorized
rescue_from Organizational::UnknownOrganization, with: :not_authorized
rescue_from ActionController::UnknownFormat, with: :unsupported_media_type

impersonates :user

Expand All @@ -34,6 +35,7 @@ def after_sign_out_path_for(resource_or_scope)
end

def set_active_banner
return nil unless request.format.html?
return nil unless current_organization

@active_banner = current_organization.banners.active.first
Expand Down Expand Up @@ -111,6 +113,12 @@ def redirect_back_to_referer(fallback_location:)

private

# Allows us to not specify respond_to formats in json-only controller or action.
# Same behavior as when a request format is not defined in a respond_to block.
def force_json_format
raise ActionController::UnknownFormat unless request.format.json?
end
thejonroberts marked this conversation as resolved.
Show resolved Hide resolved

def store_user_location!
# the current URL can be accessed from a session
store_location_for(:user, request.fullpath)
Expand All @@ -135,9 +143,29 @@ def set_current_organization
end

def not_authorized
session[:user_return_to] = nil
flash[:notice] = "Sorry, you are not authorized to perform this action."
redirect_to(root_url)
message = "Sorry, you are not authorized to perform this action."
respond_to do |format|
format.json do
render json: {error: message}, status: :unauthorized
end
format.any do
session[:user_return_to] = nil
flash[:notice] = message
redirect_to(root_url)
end
end
end

def unsupported_media_type
respond_to do |format|
format.json do
render json: {error: "json unsupported"}, status: :unsupported_media_type
end
format.any do
flash[:alert] = "Page not found"
redirect_back_or_to root_url
end
end
thejonroberts marked this conversation as resolved.
Show resolved Hide resolved
end

def log_and_reraise(error)
Expand Down
Loading
Loading