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 all 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
15 changes: 14 additions & 1 deletion app/assets/stylesheets/base/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@ $sidebar-active: #365CF5;
$sidebar-dark: #1A2142;

:root {
--dark: #262d3f;
--casa-red: #D50100;
--casa-primary-blue: #4A6CF7;

--gunmetal: #262D3F;
--dark-gunmetal: #212529;
--dark: #262d3f;
--dark-electric-blue: #5D657B;
--gray: #5d657b;
--dark-gray: #AAAAAA;
--gray-80: #CCCCCC;
--silver: #D9D9D9;

--inactive: #9AA4CA;

--input-placeholder-text: var(--gray);
--input-border-color: var(--gray-80);
}
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
156 changes: 138 additions & 18 deletions app/assets/stylesheets/pages/case_contacts_form.scss
Original file line number Diff line number Diff line change
@@ -1,31 +1,151 @@
@use "../base/breakpoints.scss" as screen-sizes;

.case-contacts-form {
&-buttons {
display: flex;
justify-content: flex-end;
gap: 10px;
#case-contact-form {
color: var(--gunmetal);

@media only screen and (max-width: screen-sizes.$mobile) {
& > a, & > button {
flex-grow: 1;
& section {
background: var(--white, #FFFFFF);
border: 1px solid var(--form-element-stroke, #E5E5E5);
border-radius: 10px;
box-shadow: 0px 0px 5px 0px #1A252F0D;
margin-bottom: 30px;
padding: 30px 20px;
}

& h2 {
font-size: 28px;
margin-bottom: 24px;
}

& h3 {
font-size: 16px;
}

& legend {
font-size: 16px;
font-weight: 400;
line-height: 19px;
color: var(--dark-electric-blue);
}

& label {
font-size: 16px;
font-weight: 500;
line-height: 19px;
}

& input,
textarea,
select {
border: 1px solid var(--input-border-color);

&::placeholder {
color: var(--input-placeholder-text);
opacity: 1;
}
}

& input[type="text"],
input[type="date"],
input[type="number"],
textarea,
select {
padding: 16px;
}

& .form-check {
margin-left: 0px;
padding-left: 0px;

& input {
width: 20px;
height: 20px;
margin-left: 0px;
margin-right: 3px;
float: none;

&:checked {
background-color: var(--casa-primary-blue);
border-color: var(--casa-primary-blue);
}

&[type="checkbox"] + label {
padding-top: 5px;
font-weight: 300;
}

&[type="radio"] + label {
padding-top: 1px;
font-size: 16px;
font-weight: 300;
line-height: 25px;
color: var(--dark-electric-blue)
}
}

label {
font-size: 16px;
font-weight: 600;
}
}

&-checkbox {
border-color: #757575;
& button {
--bs-link-color: var(--casa-primary-blue);

&.btn-link {
text-decoration: none;
padding: 0px;
}
}

&-title {
@media only screen and (max-width: screen-sizes.$mobile) {
font-size: 28px;
}
& .row {
--bs-gutter-x: .5rem;
}

& #contact-form-types {
--group-width: 250px;

columns: var(--group-width);

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

& .form-check {
& label {
display: inline;
color: var(--dark);
font-weight: 400;
color: var(--dark-gunmetal);
}

& small {
display: block;
margin-left: 28px;
font-style: italic;
font-weight: 300;
color: var(--dark-electric-blue);
}
}
}
}

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

&-subtitle {
& #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;
}

}
8 changes: 3 additions & 5 deletions app/components/form/hour_minute_duration_component.html.erb
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
<div class="d-flex flex-column flex-lg-row gap-2">
<div class="col input-style-1">
<div class="row input-style-1">
<div class="col-12 col-md">
<%= @form.label :duration_hours, "Hour(s)" %>
<%= @form.number_field :duration_hours,
min: 0,
class: "form-control",
size: "10",
style: "background:white",
value: @hour_value,
required: true %>
</div>
<div class="col input-style-1">
<div class="col-12 col-md">
<%= @form.label :duration_minutes, "Minute(s)" %>
<%= @form.number_field :duration_minutes,
min: 0,
class: "form-control",
size: "10",
style: "background:white",
value: @minute_value,
required: true %>
Expand Down
1 change: 1 addition & 0 deletions app/components/form/multiple_select_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
data-controller="multiple-select"
data-multiple-select-options-value="<%= @options %>"
data-multiple-select-selected-items-value="<%= @selected_items %>"
data-multiple-select-placeholder-term-value="<%= @placeholder_term %>"
data-multiple-select-with-options-value="true">

<template data-multiple-select-target="option">
Expand Down
3 changes: 2 additions & 1 deletion app/components/form/multiple_select_component.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# frozen_string_literal: true

class Form::MultipleSelectComponent < ViewComponent::Base
def initialize(form:, name:, options:, selected_items:, render_option_subtext: false)
def initialize(form:, name:, options:, selected_items:, render_option_subtext: false, placeholder_term: nil)
@form = form
@name = name
@options = options.to_json
@selected_items = selected_items
@render_option_subtext = render_option_subtext
@placeholder_term = placeholder_term
end
end
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
Loading
Loading