diff --git a/app/javascript/css/colors.scss b/app/javascript/css/colors.scss index 8a47695dc32..f4281a65f16 100644 --- a/app/javascript/css/colors.scss +++ b/app/javascript/css/colors.scss @@ -34,38 +34,37 @@ // May be unique colors, but used by all clients --bright-green: hsl(65, 100%, 42%); --orange: hsl(359, 80%, 54%); - } -[data-theme="me"] { +[data-theme='me'] { --default-font-color: #323130; --text-secondary: hsla(30, 2%, 37%, 1); //palette - --primary-color: #3D5D6F; - --primary-color-dark: #314A59; + --primary-color: #3d5d6f; + --primary-color-dark: #314a59; --primary-color-darker: #253843; --default-font-color: #323130; --placeholder-color: #676767; --placeholder-font-weight: 400; --floatlabel-color: #767676; - --floatlabel-onclick-color:#676767; + --floatlabel-onclick-color: #676767; --input-text-color: #454545; --form-element-text-color: #454545; --default-font-color: #323130; --placeholder-color: #676767; --floatlabel-color: #767676; - --floatlabel-onclick-color:#676767; + --floatlabel-onclick-color: #676767; --input-text-color: #454545; --form-element-text-color: #454545; - --secondary-color: #3B6B90; - --secondary-color-dark: #2E5470; - --secondary-color-darker: #213C50; + --secondary-color: #3b6b90; + --secondary-color-dark: #2e5470; + --secondary-color-darker: #213c50; - --tertiary-color: #5A7334; + --tertiary-color: #5a7334; --tertiary-color-dark: #465929; - --tertiary-color-darker: #32401D; + --tertiary-color-darker: #32401d; //fundamentals --primary-hover-color: var(--primary-color-dark); @@ -85,7 +84,7 @@ --placeholder-color: #676767; --placeholder-font-weight: 400; --floatlabel-color: #767676; - --floatlabel-onclick-color:#676767; + --floatlabel-onclick-color: #676767; --input-text-color: #454545; --form-element-text-color: #454545; @@ -93,126 +92,125 @@ --button-default-hover-color: var(--primary-hover-color); --button-default-active-color: var(--primary-color-darker); - --enrollment-status-red: #A21E1F; + --enrollment-status-red: #a21e1f; --enrollment-status-green: #027314; - --enrollment-status-yellow: #E5A900; + --enrollment-status-yellow: #e5a900; --enrollment-status-blue: #003260; - --enrollment-status-grey: #3B3A39; + --enrollment-status-grey: #3b3a39; - --button-primary-color: #3D5D6F; - --button-primary-hover-color: #314A59; + --button-primary-color: #3d5d6f; + --button-primary-hover-color: #314a59; --button-primary-active-color: #253843; - --button-secondary-color: #3B6B90; - --button-secondary-hover-color: #345F80; + --button-secondary-color: #3b6b90; + --button-secondary-hover-color: #345f80; --button-secondary-active-color: #274760; - --button-tertiary-color: #647F3A; - --button-tertiary-hover-color: #50662E; - --button-tertiary-active-color: #3C4C23; + --button-tertiary-color: #647f3a; + --button-tertiary-hover-color: #50662e; + --button-tertiary-active-color: #3c4c23; --button-error-color: var(--status-red); --button-error-hover-color: var(--status-red-hover); --button-error-active-color: var(--status-red-active); } -[data-theme="dc"] { +[data-theme='dc'] { --default-font-color: #323130; - --body-color: #FAFAFA; + --body-color: #fafafa; --placeholder-color: #676767; --floatlabel-color: #767676; - --floatlabel-onclick-color:#676767; + --floatlabel-onclick-color: #676767; --input-text-color: #454545; --form-element-text-color: #454545; - --button-default-color: #4A7EA6; - --button-default-hover-color: #345F80; + --button-default-color: #4a7ea6; + --button-default-hover-color: #345f80; --button-default-active-color: #274760; - --enrollment-status-red: #A21E1F; + --enrollment-status-red: #a21e1f; --enrollment-status-green: #027314; - --enrollment-status-yellow: #E5A900; + --enrollment-status-yellow: #e5a900; --enrollment-status-blue: #003260; - --enrollment-status-grey: #3B3A39; + --enrollment-status-grey: #3b3a39; //buttons - --button-primary-color: #007BC4; - --button-primary-hover-color: #00629D; - --button-primary-active-color: #004A76; + --button-primary-color: #007bc4; + --button-primary-hover-color: #00629d; + --button-primary-active-color: #004a76; --button-secondary-color: #003260; - --button-secondary-hover-color: #00284D; - --button-secondary-active-color: #001E3A; + --button-secondary-hover-color: #00284d; + --button-secondary-active-color: #001e3a; - --button-tertiary-color: #9D6E00; - --button-tertiary-hover-color: #7E5800; - --button-tertiary-active-color: #5E4200; + --button-tertiary-color: #9d6e00; + --button-tertiary-hover-color: #7e5800; + --button-tertiary-active-color: #5e4200; - --button-error-color: #A21E1F; - --button-error-hover-color: #85191A; + --button-error-color: #a21e1f; + --button-error-hover-color: #85191a; --button-error-active-color: #671314; } - -[data-contrast="true"] { - --secondary-font-color: #676C72; //secondary text gray +[data-contrast='true'] { + --secondary-font-color: #676c72; //secondary text gray --bold-font-color: #323130; //bold text - --theme-primary-blue: #3B6B90; //primary blue - --theme-secondary: #425C6E; //secondary dark blue - --primary-red: #D42537; //primary red - --background-light-red: #F9F1F1; //error notice background color - --primary-green: #5A7334; //green continue buttons - --secondary-green: #738C4A; //green for continue button hover - --success-green-background: #E3F9E6; //green for success pill - - --primary-yellow: #FFD600; - --soft-yellow: #FFFADF; + --theme-primary-blue: #3b6b90; //primary blue + --theme-secondary: #425c6e; //secondary dark blue + --primary-red: #d42537; //primary red + --background-light-red: #f9f1f1; //error notice background color + --primary-green: #5a7334; //green continue buttons + --secondary-green: #738c4a; //green for continue button hover + --success-green-background: #e3f9e6; //green for success pill + + --primary-yellow: #ffd600; + --soft-yellow: #fffadf; --primary-white: #ffffff; --primary-black: #000000; - --alert-notice-green: #62703E; //success notice green - --soft-blue: #D6EBFF; //home page right nav text color + --alert-notice-green: #62703e; //success notice green + --soft-blue: #d6ebff; //home page right nav text color - --status-red: #A21E1F; //status danger - --status-red-hover: #85191A; //status danger + --status-red: #a21e1f; //status danger + --status-red-hover: #85191a; //status danger --status-red-active: #671314; //status danger --status-blue: #003260; //status pending - --status-yellow: #E5A900; //status needs info + --status-yellow: #e5a900; //status needs info --status-green: #027314; //status complete - --light-gray: #A19F9D; + --light-gray: #a19f9d; --default-font-color: #323130; --placeholder-color: #676767; --floatlabel-color: #767676; - --floatlabel-onclick-color:#676767; + --floatlabel-onclick-color: #676767; --input-text-color: #454545; --form-element-text-color: #454545; - --button-default-color: #3D5D6F; - --button-default-hover-color: #314A59; + --button-default-color: #3d5d6f; + --button-default-hover-color: #314a59; --button-default-active-color: #253843; - --button-primary-color: #3D5D6F; - --button-primary-hover-color: #314A59; + --button-primary-color: #3d5d6f; + --button-primary-hover-color: #314a59; --button-primary-active-color: #253843; - --button-secondary-color: #3B6B90; - --button-secondary-hover-color: #345F80; + --button-secondary-color: #3b6b90; + --button-secondary-hover-color: #345f80; --button-secondary-active-color: #274760; - --button-tertiary-color: #647F3A; - --button-tertiary-hover-color: #50662E; - --button-tertiary-active-color: #3C4C23; + --button-tertiary-color: #647f3a; + --button-tertiary-hover-color: #50662e; + --button-tertiary-active-color: #3c4c23; --button-error-color: var(--status-red); --button-error-hover-color: var(--status-red-hover); --button-error-active-color: var(--status-red-active); - --enrollment-status-red: #A21E1F; + --enrollment-status-red: #a21e1f; --enrollment-status-green: #027314; - --enrollment-status-yellow: #E5A900; + --enrollment-status-yellow: #e5a900; --enrollment-status-blue: #003260; - --enrollment-status-grey: #3B3A39; + --enrollment-status-grey: #3b3a39; } diff --git a/app/javascript/css/contrast_level_aa.scss b/app/javascript/css/contrast_level_aa.scss index 01f4df1d9c0..90c8d7fa872 100644 --- a/app/javascript/css/contrast_level_aa.scss +++ b/app/javascript/css/contrast_level_aa.scss @@ -1,6 +1,6 @@ // all contents of this file must be nested within the data-contrast="true" selector to make sure they don't leak to other themes. // These will only be applied if the contrast level is set to true in the layout. -[data-contrast="true"] { +[data-contrast='true'] { --font: Barlow, sans-serif; --placeholder-font-weight: 400; @@ -9,59 +9,59 @@ border-radius: 18px; border: 1px; background-color: var(--status-yellow); - } + } - .success-notice { + .success-notice { padding: 8px 14px 8px 14px; border-radius: 18px; - border: 1px solid ; + border: 1px solid; background-color: var(--success-green-background); - } + } - .warning-status-hide { + .warning-status-hide { display: none !important; - } + } - .success-status-hide { + .success-status-hide { display: none !important; - } + } - .icon { + .icon { width: 1em; - } + } - // use these in case we want to improve the icons used for "info needed" statuses on the FAA application workflow - .warning-icon-small { + // use these in case we want to improve the icons used for "info needed" statuses on the FAA application workflow + .warning-icon-small { background-image: url('../../assets/images/warning-icon-small.svg'); background-repeat: no-repeat; background-position: center; color: transparent !important; padding: 1px; margin-right: 5px !important; - } - .warning-icon { + } + .warning-icon { background-image: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M9.49845 2.29672C10.5292 0.234426 13.4708 0.234426 14.5016 2.29672L22.9501 19.2003C23.8802 21.0612 22.5273 23.25 20.4485 23.25H3.55146C1.47273 23.25 0.11977 21.0612 1.0499 19.2003L9.49845 2.29672Z' fill='%23FFD600' stroke='%233B3A39' stroke-width='1.5'/%3E%3Cpath d='M13.0089 15.8215H11.0074L10.589 7.80707H13.4273L13.0089 15.8215ZM10.5562 18.627C10.5562 18.1676 10.6793 17.8203 10.9254 17.5852C11.1714 17.35 11.5297 17.2325 12 17.2325C12.4539 17.2325 12.8039 17.3528 13.05 17.5934C13.3015 17.834 13.4273 18.1786 13.4273 18.627C13.4273 19.059 13.3015 19.4008 13.05 19.6524C12.7984 19.8985 12.4484 20.0215 12 20.0215C11.5406 20.0215 11.1851 19.9012 10.9336 19.6606C10.682 19.4145 10.5562 19.07 10.5562 18.627Z' fill='%233B3A39'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: center; color: transparent !important; font-size: 27px !important; - } + } - .ready-4-review .note.purple::before { + .ready-4-review .note.purple::before { display: none; - } + } - .note.purple { + .note.purple { display: none; - } + } - .complete-icon-text{ + .complete-icon-text { font-weight: normal !important; - } + } - #account-detail .popover { + #account-detail .popover { .arrow:after { border-right-color: transparent; } - } + } } diff --git a/app/javascript/css/dc.scss b/app/javascript/css/dc.scss index 79a9925e6e0..e2e2b97135f 100644 --- a/app/javascript/css/dc.scss +++ b/app/javascript/css/dc.scss @@ -1,5 +1,5 @@ // all contents of this file must be nested within the data-theme="dc" selector to make sure they don't leak to other clients. -[data-theme="dc"] { +[data-theme='dc'] { --font: 'Open Sans', sans-serif; --placeholder-font-weight: 400; } diff --git a/app/views/insured/consumer_roles/docs_shared/_card_number.html.erb b/app/views/insured/consumer_roles/docs_shared/_card_number.html.erb index c263984d76f..7b2880c04b2 100644 --- a/app/views/insured/consumer_roles/docs_shared/_card_number.html.erb +++ b/app/views/insured/consumer_roles/docs_shared/_card_number.html.erb @@ -5,7 +5,8 @@ <%= v.text_field :card_number, :placeholder => l10n("insured.consumer_roles.docs_shared.card_number"), :pattern => "[a-zA-Z0-9]{13}", :class => "#{FinancialAssistanceRegistry.feature_enabled?(:optional_document_fields) ? "" : "required" } doc_fields", - :title => description.gsub("-li-", "") %> + :title => description.gsub("-li-", ""), + :id => "card_number" %> <%= render :partial => "insured/consumer_roles/docs_shared/vlp_doc_requirements", locals: {req: description} %> <% else %> diff --git a/app/views/insured/consumer_roles/docs_shared/_citizenship_number.html.erb b/app/views/insured/consumer_roles/docs_shared/_citizenship_number.html.erb index a5cd54820e2..751b77495a9 100644 --- a/app/views/insured/consumer_roles/docs_shared/_citizenship_number.html.erb +++ b/app/views/insured/consumer_roles/docs_shared/_citizenship_number.html.erb @@ -4,7 +4,8 @@ <%= v.text_field :citizenship_number, :placeholder => l10n("insured.consumer_roles.docs_shared.citizenship_number"), :pattern => "[a-zA-Z0-9]{6,12}", :class => "doc_fields", - :title => l10n("insured.consumer_roles.docs_shared.citizenship_number_req").gsub("-li-", "") %> + :title => l10n("insured.consumer_roles.docs_shared.citizenship_number_req").gsub("-li-", ""), + :id => "citizenship_number" %> <%= render :partial => "insured/consumer_roles/docs_shared/vlp_doc_requirements", locals: {req: l10n("insured.consumer_roles.docs_shared.citizenship_number_req")} %> <% else %> diff --git a/app/views/insured/consumer_roles/docs_shared/_country_of_citizenship.html.erb b/app/views/insured/consumer_roles/docs_shared/_country_of_citizenship.html.erb index 34b0853ceee..83a0f58b2cb 100644 --- a/app/views/insured/consumer_roles/docs_shared/_country_of_citizenship.html.erb +++ b/app/views/insured/consumer_roles/docs_shared/_country_of_citizenship.html.erb @@ -1,8 +1,12 @@ <% if @bs4 %> -
- <%= label_tag :country_of_citizenship, l10n("insured.consumer_roles.docs_shared.country_of_citizenship"), class: "weight-n" %> - <%= v.select :country_of_citizenship, options_for_select(::VlpDocument::COUNTRIES_LIST, @country||=l10n("insured.consumer_roles.docs_shared.country_of_citizenship")), prompt: l10n("insured.consumer_roles.docs_shared.country_of_citizenship"), class: "select_tag" %> -
+
+ <%= label_tag :country_of_citizenship, l10n("insured.consumer_roles.docs_shared.country_of_citizenship"), class: "weight-n" %> + <%= v.select :country_of_citizenship, + options_for_select(::VlpDocument::COUNTRIES_LIST, @country ||= l10n("insured.consumer_roles.docs_shared.country_of_citizenship")), + { prompt: l10n("insured.consumer_roles.docs_shared.country_of_citizenship") }, + { class: "select_tag", id: "country_of_citizenship" } %> +
+ <% else %>
<%= v.select :country_of_citizenship, options_for_select(::VlpDocument::COUNTRIES_LIST, @country||=l10n("insured.consumer_roles.docs_shared.country_of_citizenship")), prompt: l10n("insured.consumer_roles.docs_shared.country_of_citizenship"), class: "select_tag" %>
diff --git a/app/views/insured/consumer_roles/docs_shared/_i_94_number.html.erb b/app/views/insured/consumer_roles/docs_shared/_i_94_number.html.erb index 6f85f0c8b90..7b2d3e33f6b 100644 --- a/app/views/insured/consumer_roles/docs_shared/_i_94_number.html.erb +++ b/app/views/insured/consumer_roles/docs_shared/_i_94_number.html.erb @@ -4,7 +4,8 @@ <%= v.text_field :i94_number, :placeholder => l10n("insured.consumer_roles.docs_shared.i94_number"), :pattern => "[A-Za-z0-9]{11}", :class => "doc_fields", - :title => l10n("insured.consumer_roles.docs_shared.i94_number_req").gsub("-li-", "") %> + :title => l10n("insured.consumer_roles.docs_shared.i94_number_req").gsub("-li-", ""), + :id => "i94_number" %> <%= render :partial => "insured/consumer_roles/docs_shared/vlp_doc_requirements", locals: {req: l10n("insured.consumer_roles.docs_shared.i94_number_req")} %>
<% else %> diff --git a/app/views/insured/consumer_roles/docs_shared/_naturalization_number.html.erb b/app/views/insured/consumer_roles/docs_shared/_naturalization_number.html.erb index f068d6ac208..abda8465fe1 100644 --- a/app/views/insured/consumer_roles/docs_shared/_naturalization_number.html.erb +++ b/app/views/insured/consumer_roles/docs_shared/_naturalization_number.html.erb @@ -4,7 +4,8 @@ <%= v.text_field :naturalization_number, :placeholder => l10n("insured.consumer_roles.docs_shared.naturalization_number"), :pattern => "[a-zA-Z0-9]{6,12}", :class => "doc_fields", - :title => l10n("insured.consumer_roles.docs_shared.naturalization_number_req").gsub("-li-", "") %> + :title => l10n("insured.consumer_roles.docs_shared.naturalization_number_req").gsub("-li-", ""), + :id => "naturalization_number" %> <%= render :partial => "insured/consumer_roles/docs_shared/vlp_doc_requirements", locals: {req: l10n("insured.consumer_roles.docs_shared.naturalization_number_req")} %> <% else %> diff --git a/app/views/insured/consumer_roles/docs_shared/_passport_number.html.erb b/app/views/insured/consumer_roles/docs_shared/_passport_number.html.erb index d9ab1f92d90..b54360bc2db 100644 --- a/app/views/insured/consumer_roles/docs_shared/_passport_number.html.erb +++ b/app/views/insured/consumer_roles/docs_shared/_passport_number.html.erb @@ -4,7 +4,8 @@ <%= v.text_field :passport_number, :placeholder => l10n("insured.passport_number"), :pattern => "[a-zA-Z0-9]{6,12}", :class => "doc_fields", - :title => l10n("insured.passport_number_req").gsub("-li-", "") %> + :title => l10n("insured.passport_number_req").gsub("-li-", ""), + :id => "passport_number" %> <%= render :partial => "insured/consumer_roles/docs_shared/vlp_doc_requirements", locals: {req: l10n("insured.passport_number_req")} %> <% else %> diff --git a/app/views/insured/consumer_roles/docs_shared/_servis_id.html.erb b/app/views/insured/consumer_roles/docs_shared/_servis_id.html.erb index 335d19290f1..6b59e55870a 100644 --- a/app/views/insured/consumer_roles/docs_shared/_servis_id.html.erb +++ b/app/views/insured/consumer_roles/docs_shared/_servis_id.html.erb @@ -4,7 +4,8 @@ <%= v.text_field :sevis_id, :placeholder => l10n("insured.consumer_roles.docs_shared.sevis_id"), :pattern => "\\d{10}", :class => "doc_fields", - :title => l10n("insured.consumer_roles.docs_shared.sevis_id_req").gsub("-li-", "") %> + :title => l10n("insured.consumer_roles.docs_shared.sevis_id_req").gsub("-li-", ""), + :id => "sevis_id" %> <%= render :partial => "insured/consumer_roles/docs_shared/vlp_doc_requirements", locals: {req: l10n("insured.consumer_roles.docs_shared.sevis_id_req")} %> <% else %> diff --git a/app/views/insured/consumer_roles/docs_shared/_visa_number.html.erb b/app/views/insured/consumer_roles/docs_shared/_visa_number.html.erb index 233a8130221..2c68ff7680f 100644 --- a/app/views/insured/consumer_roles/docs_shared/_visa_number.html.erb +++ b/app/views/insured/consumer_roles/docs_shared/_visa_number.html.erb @@ -4,7 +4,8 @@ <%= v.text_field :visa_number, :placeholder => l10n("insured.consumer_roles.docs_shared.visa_number"), :pattern => "[a-zA-Z0-9]{8,12}", :class => "doc_fields", - :title => l10n("insured.consumer_roles.docs_shared.visa_number_req").gsub("-li-", "") %> + :title => l10n("insured.consumer_roles.docs_shared.visa_number_req").gsub("-li-", ""), + :id => "visa_number" %> <%= render :partial => "insured/consumer_roles/docs_shared/vlp_doc_requirements", locals: {req: l10n("insured.consumer_roles.docs_shared.visa_number_req")} %> <% else %> diff --git a/app/views/insured/families/personal.js.erb b/app/views/insured/families/personal.js.erb index 0cebc66704d..4b69be62469 100644 --- a/app/views/insured/families/personal.js.erb +++ b/app/views/insured/families/personal.js.erb @@ -27,4 +27,4 @@ // Had to extensively call this function because this is being called only on Document load. // FAA specific case For Primary Demographic fields conditional edit. demographicValidations(); -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/insured/family_members/_dependent.html.erb b/app/views/insured/family_members/_dependent.html.erb index d360f711075..436537fe198 100644 --- a/app/views/insured/family_members/_dependent.html.erb +++ b/app/views/insured/family_members/_dependent.html.erb @@ -75,4 +75,4 @@ Freebies.floatlabels(); -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/insured/family_members/_dependent_form.html.erb b/app/views/insured/family_members/_dependent_form.html.erb index d2135e37e70..9e9c169d411 100644 --- a/app/views/insured/family_members/_dependent_form.html.erb +++ b/app/views/insured/family_members/_dependent_form.html.erb @@ -500,4 +500,4 @@ } -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/insured/family_members/show.js.erb b/app/views/insured/family_members/show.js.erb index f5d414da23c..500546e2d86 100644 --- a/app/views/insured/family_members/show.js.erb +++ b/app/views/insured/family_members/show.js.erb @@ -16,4 +16,4 @@ if (!$(".my-household-page")) { } else { //manage family/ my household page location.reload(); -} \ No newline at end of file +} diff --git a/app/views/insured/fdsh_ridp_verifications/_outstanding_ridp_documents.html.erb b/app/views/insured/fdsh_ridp_verifications/_outstanding_ridp_documents.html.erb index 49cf470c3b6..aac6c2c0420 100644 --- a/app/views/insured/fdsh_ridp_verifications/_outstanding_ridp_documents.html.erb +++ b/app/views/insured/fdsh_ridp_verifications/_outstanding_ridp_documents.html.erb @@ -77,7 +77,7 @@ <%= link_to(insured_ridp_document_path(ridp_doc, :person_id => @person.id), method: :delete, remote: true, class: "btn-error outline text-nowrap") do %> <%= l10n("insured.consumer_roles.upload_ridp_documents.remove") %> - <% end %> + <% end)%> <% end %> @@ -182,6 +182,7 @@ +
<%= h(link_to 'Documents FAQ', ::EnrollRegistry[:enroll_app].setting(:submit_docs_url).item, class: "btn btn-default btn-small pull-right", target: '_blank', rel: "noopener noreferrer") %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index f555f27b09c..5c98ff4820f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -15,6 +15,10 @@ <%= csrf_meta_tags %> + <%= javascript_pack_tag 'application' %> + <%= javascript_include_tag "application" %> + <%= stylesheet_pack_tag 'application', media: "all" %> + <%= javascript_pack_tag ENV['CLIENT'] %> <%= stylesheet_pack_tag ENV['CLIENT'] %> diff --git a/app/views/shared/_age_off_excluded.html.erb b/app/views/shared/_age_off_excluded.html.erb index 084b959eecb..da95abb4ee2 100644 --- a/app/views/shared/_age_off_excluded.html.erb +++ b/app/views/shared/_age_off_excluded.html.erb @@ -12,4 +12,4 @@ Ageoff Exclusion
-<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/shared/_sep_progress.html.erb b/app/views/shared/_sep_progress.html.erb index 58fcdba1c72..3637333f6b9 100644 --- a/app/views/shared/_sep_progress.html.erb +++ b/app/views/shared/_sep_progress.html.erb @@ -80,4 +80,4 @@ show_previous_button: ![1, 7].include?(step), show_account_button: step > 2 && EnrollRegistry.feature_enabled?(:back_to_account_all_shop), show_help_button: step < 7, - is_complete: step == 7 } %> \ No newline at end of file + is_complete: step == 7 } %> diff --git a/components/financial_assistance/app/assets/javascripts/financial_assistance/income.js b/components/financial_assistance/app/assets/javascripts/financial_assistance/income.js index f19471b5eb5..793697b9909 100644 --- a/components/financial_assistance/app/assets/javascripts/financial_assistance/income.js +++ b/components/financial_assistance/app/assets/javascripts/financial_assistance/income.js @@ -1,30 +1,55 @@ function stopEditingIncome() { shouldShowEndDateWarningModal = false; // remove disabled style from drivers, instructions, and other income kinds - $('.driver-question, .driver-question a, .instruction-row, .income, .other-income-kind, .unemployment-income').removeClass('disabled'); + $( + '.driver-question, .driver-question a, .instruction-row, .income, .other-income-kind, .unemployment-income' + ).removeClass('disabled'); // enable inputs on drivers, instructions, and income kinds - except for submit (save) buttons as this would enable the submit button in the dummy forms, and fake-disabled-inputs as they should never be enabled - $('.driver-question input, .instruction-row input, .income input:not(":input[type=submit], .fake-disabled-input"), .other-income-kind input:not(":input[type=submit], .fake-disabled-input"), .unemployment-income input:not(":input[type=submit], .fake-disabled-input")').removeAttr('disabled'); + $( + '.driver-question input, .instruction-row input, .income input:not(":input[type=submit], .fake-disabled-input"), .other-income-kind input:not(":input[type=submit], .fake-disabled-input"), .unemployment-income input:not(":input[type=submit], .fake-disabled-input")' + ).removeAttr('disabled'); // enable "Add New" income buttons - $('#new-unemployment-income, #new-ai-an-income, .new-income, .add_new_other_income_kind').removeAttr('disabled'); - $("a.interaction-click-control-add-more").removeClass('hide'); - $("a[class*='income-edit'], a[class*='income-delete']").removeClass('disabled'); // legacy + $( + '#new-unemployment-income, #new-ai-an-income, .new-income, .add_new_other_income_kind' + ).removeAttr('disabled'); + $('a.interaction-click-control-add-more').removeClass('hide'); + $("a[class*='income-edit'], a[class*='income-delete']").removeClass( + 'disabled' + ); // legacy // enable nav $('#nav-buttons a').removeClass('disabled'); $('.col-md-3 > .interaction-click-control-continue').removeClass('disabled'); // legacy - -}; +} function startEditingIncome(income_kind) { shouldShowEndDateWarningModal = true; // apply disabled style to drivers, instructions, and other income kinds not being edited - $('.driver-question, .driver-question a, .instruction-row, .income:not(#' + income_kind + '), .other-income-kind:not(#' + income_kind + '), .unemployment-income:not(#' + income_kind + ')').addClass('disabled'); + $( + '.driver-question, .driver-question a, .instruction-row, .income:not(#' + + income_kind + + '), .other-income-kind:not(#' + + income_kind + + '), .unemployment-income:not(#' + + income_kind + + ')' + ).addClass('disabled'); // disable inputs on drivers, instructions, and other income kinds not being edited - except for submit (save) buttons as some form types require them to be enabled on edit/create - $('.driver-question input, .instruction-row input, .income:not(#' + income_kind + ') input:not(":input[type=submit]"), .other-income-kind:not(#' + income_kind + ') input:not(":input[type=submit]"), .unemployment-income:not(#' + income_kind + ') input:not(":input[type=submit]")').attr('disabled', true); + $( + '.driver-question input, .instruction-row input, .income:not(#' + + income_kind + + ') input:not(":input[type=submit]"), .other-income-kind:not(#' + + income_kind + + ') input:not(":input[type=submit]"), .unemployment-income:not(#' + + income_kind + + ') input:not(":input[type=submit]")' + ).attr('disabled', true); // disable "Add New" income buttons - $('#new-unemployment-income, #new-ai-an-income, .new-income, .add_new_other_income_kind').attr('disabled', true); - $("a.interaction-click-control-add-more").addClass('hide'); // legacy + $( + '#new-unemployment-income, #new-ai-an-income, .new-income, .add_new_other_income_kind' + ).attr('disabled', true); + $('a.interaction-click-control-add-more').addClass('hide'); // legacy // disable all income edit and edit buttons on created incomes $("a[class*='income-edit'], a[class*='income-delete']").addClass('disabled'); @@ -32,46 +57,57 @@ function startEditingIncome(income_kind) { // disable nav $('#nav-buttons a').addClass('disabled'); $('.col-md-3 > .interaction-click-control-continue').addClass('disabled'); // legacy -}; +} function checkDate(income_id) { - var startDate = $("#start_on_" + income_id).datepicker('getDate'); - var endDate = $("#end_on_" + income_id).datepicker('getDate'); + var startDate = $('#start_on_' + income_id).datepicker('getDate'); + var endDate = $('#end_on_' + income_id).datepicker('getDate'); - if ((endDate != "" && endDate != null) && (endDate < startDate)) { - alert('The end date must be after the start date.') - $("#end_on_" + income_id)[0].value = "" - window.event.preventDefault() + if (endDate != '' && endDate != null && endDate < startDate) { + alert('The end date must be after the start date.'); + $('#end_on_' + income_id)[0].value = ''; + window.event.preventDefault(); } -}; +} function currentlyEditing() { - return $('.interaction-click-control-continue').hasClass('disabled') || $('#nav-buttons a').hasClass('disabled'); -}; + return ( + $('.interaction-click-control-continue').hasClass('disabled') || + $('#nav-buttons a').hasClass('disabled') + ); +} function deleteIncomes(kind) { - const requests = $(kind).find('.other-incomes-list > .other-income').map(function(_, income) { - return $.ajax({ - type: 'DELETE', - url: $(income).attr('id').replace('other_income_', ''), - success: function() { - $(income).remove(); - } + const requests = $(kind) + .find('.other-incomes-list > .other-income') + .map(function (_, income) { + return $.ajax({ + type: 'DELETE', + url: $(income).attr('id').replace('other_income_', ''), + success: function () { + $(income).remove(); + }, + }); }); - }); - $.when.apply($, requests).done(function() { + $.when.apply($, requests).done(function () { const args = [].slice.apply(arguments); const responses = requests.length == 1 ? [args] : args; - if (responses.every(function(response) { return response[1] == 'success'; })) { + if ( + responses.every(function (response) { + return response[1] == 'success'; + }) + ) { $(kind).find('input[type="checkbox"]').prop('checked', false); - $(kind).find('[class^="interaction-click-control-add-more"]').addClass('hidden'); + $(kind) + .find('[class^="interaction-click-control-add-more"]') + .addClass('hidden'); $(kind).find('.new-other-income-form').addClass('hidden'); $(kind).find('.add-more-link').addClass('hidden'); } }); -}; +} /** * Clone, strip of dummy attributes, unhide, and append a new income form to the income list. @@ -85,53 +121,58 @@ function deleteIncomes(kind) { function generateNewForm(newIncomeFormEl, incomeListEl) { const clonedForm = newIncomeFormEl.clone(true, true); const attrs = ['id', 'class', 'for']; - attrs.forEach(function(attr) { + attrs.forEach(function (attr) { const els = clonedForm.find('[' + attr + '*="dummy"]'); - $(els).each(function() { + $(els).each(function () { const dummyAttr = $(this).attr(attr); $(this).attr(attr, dummyAttr.replace('dummy', '')); }); }); - clonedForm - .removeClass('hidden') - .appendTo(incomeListEl); + clonedForm.removeClass('hidden').appendTo(incomeListEl); return clonedForm; -}; +} -document.addEventListener("turbolinks:load", function () { +document.addEventListener('turbolinks:load', function () { var faWindow = $('.incomes'); - if ($('.incomes-list, .other-incomes-list, .unemployment-incomes .ai-an-incomes').length) { + if ( + $( + '.incomes-list, .other-incomes-list, .unemployment-incomes .ai-an-incomes' + ).length + ) { $(faWindow).bind('beforeunload', function (e) { - if (!currentlyEditing() || $('#unsavedIncomeChangesWarning:visible').length) + if ( + !currentlyEditing() || + $('#unsavedIncomeChangesWarning:visible').length + ) return undefined; - (e || faWindow.event).returnValue = 'You have an unsaved income, are you sure you want to proceed?'; //Gecko + IE + (e || faWindow.event).returnValue = + 'You have an unsaved income, are you sure you want to proceed?'; //Gecko + IE return 'You have an unsaved income, are you sure you want to proceed?'; }); $('a[href]:not(.disabled)').off('click'); - $('a[href]:not(.disabled)').on('click', function(e) { + $('a[href]:not(.disabled)').on('click', function (e) { if (currentlyEditing()) { e.preventDefault(); var self = this; $('#unsavedIncomeChangesWarning').modal('show'); - $('button#leave').click(function() { + $('button#leave').click(function () { window.location.href = $(self).attr('href'); }); return false; - } else - return true; + } else return true; }); var typingTimer; const doneTypingInterval = 500; - $(".end-on-field").on("change", function(){ + $('.end-on-field').on('change', function () { clearTimeout(typingTimer); - var endDateWarning = $("#end_date_warning_modal"); - typingTimer = setTimeout(function() { + var endDateWarning = $('#end_date_warning_modal'); + typingTimer = setTimeout(function () { if (shouldShowEndDateWarningModal) { endDateWarning.addClass('show'); endDateWarning.removeClass('hidden'); @@ -142,29 +183,33 @@ document.addEventListener("turbolinks:load", function () { }); /* Saving Responses to Job Income & Self Employment Driver Questions */ - $('#has_job_income_true, #has_job_income_false, #has_self_employment_income_true, #has_self_employment_income_false').on('change', function (e) { + $( + '#has_job_income_true, #has_job_income_false, #has_self_employment_income_true, #has_self_employment_income_false' + ).on('change', function (e) { var attributes = {}; attributes[$(this).attr('name')] = $(this).val(); $.ajax({ type: 'POST', url: window.location.pathname.replace('/incomes', ''), data: { financial_assistance_applicant: attributes }, - success: function (response) { - } - }) + success: function (response) {}, + }); }); /* Saving Responses to Other Income Driver Questions */ - $('#has_other_income_true, #has_other_income_false, #has_unemployment_income_true, #has_unemployment_income_false, #has_american_indian_alaskan_native_income_true, #has_american_indian_alaskan_native_income_false').on('change', function (e) { + $( + '#has_other_income_true, #has_other_income_false, #has_unemployment_income_true, #has_unemployment_income_false, #has_american_indian_alaskan_native_income_true, #has_american_indian_alaskan_native_income_false' + ).on('change', function (e) { var attributes = {}; attributes[$(this).attr('name')] = $(this).val(); $.ajax({ type: 'POST', - url: window.location.pathname.replace('/incomes', '').replace('/other', ''), + url: window.location.pathname + .replace('/incomes', '') + .replace('/other', ''), data: { financial_assistance_applicant: attributes }, - success: function (response) { - } - }) + success: function (response) {}, + }); }); /* DELETING all Job Incomes on selcting 'no' on Driver Question */ @@ -174,101 +219,146 @@ document.addEventListener("turbolinks:load", function () { if ($('.incomes-list:not(.self-employed-incomes-list) .income').length) { e.preventDefault(); // prompt to delete all these dedcutions - $("#destroyAllJobIncomes").modal(); + $('#destroyAllJobIncomes').modal(); $('#destroyAllJobIncomes .modal-cancel-button').off('click'); - $('#destroyAllJobIncomes .modal-cancel-button').on('click', function(e) { - $("#destroyAllJobIncomes").modal('hide'); - $('#has_job_income_true').prop('checked', true).trigger('change'); - }); + $('#destroyAllJobIncomes .modal-cancel-button').on( + 'click', + function (e) { + $('#destroyAllJobIncomes').modal('hide'); + $('#has_job_income_true').prop('checked', true).trigger('change'); + } + ); $('#destroyAllJobIncomes .modal-continue-button').off('click'); - $('#destroyAllJobIncomes .modal-continue-button').on('click', function(e) { - $("#destroyAllJobIncomes").modal('hide'); - //$(self).prop('checked', false); - $('#self-employed-income').addClass('hidden'); - $('#job_income').find('.incomes-list > .income').each(function (i, job_income) { - var url = $(job_income).attr('id').replace('income_', 'incomes/'); - $(job_income).remove(); - $.ajax({ - type: 'DELETE', - url: url - }); - }); - }); + $('#destroyAllJobIncomes .modal-continue-button').on( + 'click', + function (e) { + $('#destroyAllJobIncomes').modal('hide'); + //$(self).prop('checked', false); + $('#self-employed-income').addClass('hidden'); + $('#job_income') + .find('.incomes-list > .income') + .each(function (i, job_income) { + var url = $(job_income) + .attr('id') + .replace('income_', 'incomes/'); + $(job_income).remove(); + $.ajax({ + type: 'DELETE', + url: url, + }); + }); + } + ); } }); /* DELETING all American Indian/Alaskan Native Incomes on selcting 'no' on Driver Question */ - $('#has_american_indian_alaskan_native_income_false').on('change', function (e) { - var self = this; - //$('#DestroyExistingJobIncomesWarning').modal('show'); - if ($('.ai-an-incomes-list:not(.other-incomes-list) .ai-an-income').length) { - e.preventDefault(); - // prompt to delete all these dedcutions - $("#destroyAllAIANIncomes").modal(); - - $('#destroyAllAIANIncomes .modal-cancel-button').off('click'); - $('#destroyAllAIANIncomes .modal-cancel-button').on('click', function(e) { - $("#destroyAllAIAN").modal('hide'); - $('#has_american_indian_alaskan_native_income_true').prop('checked', true).trigger('change'); - }); - - $('#destroyAllAIANIncomes .modal-continue-button').off('click'); - $('#destroyAllAIANIncomes .modal-continue-button').on('click', function(e) { - $("#destroyAllAIANIncomes").modal('hide'); - //$(self).prop('checked', false); - - $('#ai_an_income').find('.ai-an-incomes-list > .ai-an-income').each(function (i, ai_an_income) { - var url = $(ai_an_income).attr('id').replace('financial_assistance_income_', ''); - $(ai_an_income).remove(); - $.ajax({ - type: 'DELETE', - url: url, - success: function() { - $(ai_an_income).remove(); - $("#add-more-link-ai").addClass('hidden'); - $("a.interaction-click-control-add-more").addClass('hide'); - } - }); - }); - }); + $('#has_american_indian_alaskan_native_income_false').on( + 'change', + function (e) { + var self = this; + //$('#DestroyExistingJobIncomesWarning').modal('show'); + if ( + $('.ai-an-incomes-list:not(.other-incomes-list) .ai-an-income').length + ) { + e.preventDefault(); + // prompt to delete all these dedcutions + $('#destroyAllAIANIncomes').modal(); + + $('#destroyAllAIANIncomes .modal-cancel-button').off('click'); + $('#destroyAllAIANIncomes .modal-cancel-button').on( + 'click', + function (e) { + $('#destroyAllAIAN').modal('hide'); + $('#has_american_indian_alaskan_native_income_true') + .prop('checked', true) + .trigger('change'); + } + ); + + $('#destroyAllAIANIncomes .modal-continue-button').off('click'); + $('#destroyAllAIANIncomes .modal-continue-button').on( + 'click', + function (e) { + $('#destroyAllAIANIncomes').modal('hide'); + //$(self).prop('checked', false); + + $('#ai_an_income') + .find('.ai-an-incomes-list > .ai-an-income') + .each(function (i, ai_an_income) { + var url = $(ai_an_income) + .attr('id') + .replace('financial_assistance_income_', ''); + $(ai_an_income).remove(); + $.ajax({ + type: 'DELETE', + url: url, + success: function () { + $(ai_an_income).remove(); + $('#add-more-link-ai').addClass('hidden'); + $('a.interaction-click-control-add-more').addClass( + 'hide' + ); + }, + }); + }); + } + ); + } } - }); + ); /* DELETING all Job Incomes on selcting 'no' on Driver Question */ $('#has_unemployment_income_false').on('change', function (e) { var self = this; stopEditingIncome(); //$('#DestroyExistingJobIncomesWarning').modal('show'); - if ($('.unemployment-incomes-list:not(.other-incomes-list) .unemployment-income').length) { + if ( + $( + '.unemployment-incomes-list:not(.other-incomes-list) .unemployment-income' + ).length + ) { e.preventDefault(); // prompt to delete all these dedcutions - $("#destroyAllUnemploymentIncomes").modal('show'); - - $("#destroyAllUnemploymentIncomes .modal-cancel-button").off('click'); - $('#destroyAllUnemploymentIncomes .modal-cancel-button').on('click', function(e) { - $("#destroyAllUnemploymentIncomes").modal('hide'); - $('#has_unemployment_income_true').prop('checked', true).trigger('change'); - }); - - $("#destroyAllUnemploymentIncomes .modal-continue-button").off('click'); - $('#destroyAllUnemploymentIncomes .modal-continue-button').on('click', function(e) { - $("#destroyAllUnemploymentIncomes").modal('hide'); - //$(self).prop('checked', false); - - $('#unemployment_income').find('.unemployment-incomes-list > .unemployment-income').each(function (i, unemployment_income) { - var url = $(unemployment_income).attr('id').replace('income_', ''); - $.ajax({ - type: 'DELETE', - url: url, - success: function() { - $(unemployment_income).remove(); - $("#add-more-link-unemployment").addClass('hidden'); - $("a.interaction-click-control-add-more").addClass('hide'); - } - }); - }); - }); + $('#destroyAllUnemploymentIncomes').modal('show'); + + $('#destroyAllUnemploymentIncomes .modal-cancel-button').off('click'); + $('#destroyAllUnemploymentIncomes .modal-cancel-button').on( + 'click', + function (e) { + $('#destroyAllUnemploymentIncomes').modal('hide'); + $('#has_unemployment_income_true') + .prop('checked', true) + .trigger('change'); + } + ); + + $('#destroyAllUnemploymentIncomes .modal-continue-button').off('click'); + $('#destroyAllUnemploymentIncomes .modal-continue-button').on( + 'click', + function (e) { + $('#destroyAllUnemploymentIncomes').modal('hide'); + //$(self).prop('checked', false); + + $('#unemployment_income') + .find('.unemployment-incomes-list > .unemployment-income') + .each(function (i, unemployment_income) { + var url = $(unemployment_income) + .attr('id') + .replace('income_', ''); + $.ajax({ + type: 'DELETE', + url: url, + success: function () { + $(unemployment_income).remove(); + $('#add-more-link-unemployment').addClass('hidden'); + $('a.interaction-click-control-add-more').addClass('hide'); + }, + }); + }); + } + ); } }); @@ -279,114 +369,171 @@ document.addEventListener("turbolinks:load", function () { if ($('.self-employed-incomes-list .income').length) { e.preventDefault(); // prompt to delete all these dedcutions - $("#destroyAllSelfEmploymentIncomes").modal(); - - $("#destroyAllSelfEmploymentIncomes .modal-cancel-button").off('click'); - $('#destroyAllSelfEmploymentIncomes .modal-cancel-button').on('click', function(e) { - $("#destroyAllSelfEmploymentIncomes").modal('hide'); - $('#has_self_employment_income_true').prop('checked', true).trigger('change'); - }); - - $("#destroyAllSelfEmploymentIncomes .modal-continue-button").off('click'); - $('#destroyAllSelfEmploymentIncomes .modal-continue-button').on('click', function(e) { - $("#destroyAllSelfEmploymentIncomes").modal('hide'); - //$(self).prop('checked', false); - - $('#self_employed_incomes').find('.self-employed-incomes-list > .income').each(function (i, job_income) { - var url = $(job_income).attr('id').replace('income_', 'incomes/'); - $(job_income).remove(); - $.ajax({ - type: 'DELETE', - url: url - }); - }); - }); + $('#destroyAllSelfEmploymentIncomes').modal(); + + $('#destroyAllSelfEmploymentIncomes .modal-cancel-button').off('click'); + $('#destroyAllSelfEmploymentIncomes .modal-cancel-button').on( + 'click', + function (e) { + $('#destroyAllSelfEmploymentIncomes').modal('hide'); + $('#has_self_employment_income_true') + .prop('checked', true) + .trigger('change'); + } + ); + + $('#destroyAllSelfEmploymentIncomes .modal-continue-button').off( + 'click' + ); + $('#destroyAllSelfEmploymentIncomes .modal-continue-button').on( + 'click', + function (e) { + $('#destroyAllSelfEmploymentIncomes').modal('hide'); + //$(self).prop('checked', false); + + $('#self_employed_incomes') + .find('.self-employed-incomes-list > .income') + .each(function (i, job_income) { + var url = $(job_income) + .attr('id') + .replace('income_', 'incomes/'); + $(job_income).remove(); + $.ajax({ + type: 'DELETE', + url: url, + }); + }); + } + ); } }); /* edit existing incomes */ - $('.incomes-list').on('click', 'a.income-edit:not(.disabled)', function (e) { - e.preventDefault(); - var incomeEl = $(this).parents('.income'); - incomeEl.find('.display-income').addClass('hidden'); - incomeEl.find('.income-edit-form').removeClass('hidden'); - if (!disableSelectric) { - $(incomeEl).find('select').selectric(); + $('.incomes-list').on( + 'click', + 'a.income-edit:not(.disabled)', + function (e) { + e.preventDefault(); + var incomeEl = $(this).parents('.income'); + incomeEl.find('.display-income').addClass('hidden'); + incomeEl.find('.income-edit-form').removeClass('hidden'); + if (!disableSelectric) { + $(incomeEl).find('select').selectric(); + } + $(incomeEl).find('.datepicker-js').datepicker({ + dateFormat: 'mm/dd/yy', + changeMonth: true, + changeYear: true, + yearRange: '-110:+110', + }); + startEditingIncome($(this).parents('.income').attr('id')); } - $(incomeEl).find(".datepicker-js").datepicker({ dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true, yearRange: "-110:+110" }); - startEditingIncome($(this).parents('.income').attr('id')); - }); - + ); /* destroy existing job incomes */ - $('.incomes-list').on('click', 'a.income-delete:not(.disabled)', function (e) { - var self = this; - e.preventDefault(); - $("#DestroyJobIncomeWarning").modal(); - - $("#DestroyJobIncomeWarning .modal-cancel-button").off('click'); - $('#DestroyJobIncomeWarning .modal-cancel-button').on('click', function(e) { - $("#DestroyJobIncomeWarning").modal('hide'); - }); - - $("#DestroyJobIncomeWarning .modal-continue-button").off('click'); - $('#DestroyJobIncomeWarning .modal-continue-button').on('click', function(e) { - $("#DestroyJobIncomeWarning").modal('hide'); - $(self).parents('.income').remove(); + $('.incomes-list').on( + 'click', + 'a.income-delete:not(.disabled)', + function (e) { + var self = this; + e.preventDefault(); + $('#DestroyJobIncomeWarning').modal(); - var url = $(self).parents('.income').attr('id').replace('income_', 'incomes/') - $.ajax({ - type: 'delete', - url: url - }) - }); - }); + $('#DestroyJobIncomeWarning .modal-cancel-button').off('click'); + $('#DestroyJobIncomeWarning .modal-cancel-button').on( + 'click', + function (e) { + $('#DestroyJobIncomeWarning').modal('hide'); + } + ); + + $('#DestroyJobIncomeWarning .modal-continue-button').off('click'); + $('#DestroyJobIncomeWarning .modal-continue-button').on( + 'click', + function (e) { + $('#DestroyJobIncomeWarning').modal('hide'); + $(self).parents('.income').remove(); + + var url = $(self) + .parents('.income') + .attr('id') + .replace('income_', 'incomes/'); + $.ajax({ + type: 'delete', + url: url, + }); + } + ); + } + ); /* destroy existing Self Employed Incomes */ - $('.self-employed-incomes-list').on('click', 'a.self-employed-income-delete:not(.disabled)', function (e) { - var self = this; - e.preventDefault(); - $("#DestroySelfEmplyedIncomeWarning").modal(); - - $("#DestroySelfEmplyedIncomeWarning .modal-cancel-button").off('click'); - $('#DestroySelfEmplyedIncomeWarning .modal-cancel-button').on('click', function(e) { - $("#DestroySelfEmplyedIncomeWarning").modal('hide'); - }); - - $("#DestroySelfEmplyedIncomeWarning .modal-continue-button").off('click'); - $('#DestroySelfEmplyedIncomeWarning .modal-continue-button').on('click', function(e) { - $("#DestroySelfEmplyedIncomeWarning").modal('hide'); - $(self).parents('.income').remove(); - - var url = $(self).parents('.income').attr('id').replace('income_', 'incomes/') - $.ajax({ - type: 'delete', - url: url - }) - }); - }); - + $('.self-employed-incomes-list').on( + 'click', + 'a.self-employed-income-delete:not(.disabled)', + function (e) { + var self = this; + e.preventDefault(); + $('#DestroySelfEmplyedIncomeWarning').modal(); + $('#DestroySelfEmplyedIncomeWarning .modal-cancel-button').off('click'); + $('#DestroySelfEmplyedIncomeWarning .modal-cancel-button').on( + 'click', + function (e) { + $('#DestroySelfEmplyedIncomeWarning').modal('hide'); + } + ); + + $('#DestroySelfEmplyedIncomeWarning .modal-continue-button').off( + 'click' + ); + $('#DestroySelfEmplyedIncomeWarning .modal-continue-button').on( + 'click', + function (e) { + $('#DestroySelfEmplyedIncomeWarning').modal('hide'); + $(self).parents('.income').remove(); + + var url = $(self) + .parents('.income') + .attr('id') + .replace('income_', 'incomes/'); + $.ajax({ + type: 'delete', + url: url, + }); + } + ); + } + ); /* cancel income edits */ $('.incomes-list').on('click', 'a.income-cancel', function (e) { e.preventDefault(); var incomeEl = $(this).parents('.income'); - $(this).parents('.new-income-form').addClass("hidden"); + $(this).parents('.new-income-form').addClass('hidden'); incomeEl.find('.income-edit-form').addClass('hidden'); incomeEl.find('.display-income').removeClass('hidden'); var incomeList = this.closest('.incomes-list'); var incomeType = incomeList ? incomeList.parentNode.id : null; if (incomeType == 'job_income') { - if (document.querySelectorAll('.incomes-list:not(.self-employed-incomes-list) .income').length == 0) { + if ( + document.querySelectorAll( + '.incomes-list:not(.self-employed-incomes-list) .income' + ).length == 0 + ) { $('.new-income').addClass('hidden'); $('#has_job_income_false').prop('checked', true).trigger('change'); } } else if (incomeType == 'self_employed_incomes') { - if (document.querySelectorAll('.self-employed-incomes-list .income').length == 0) { + if ( + document.querySelectorAll('.self-employed-incomes-list .income') + .length == 0 + ) { $('.new-income-self-employed').addClass('hidden'); - $('#has_self_employment_income_false').prop('checked', true).trigger('change'); + $('#has_self_employment_income_false') + .prop('checked', true) + .trigger('change'); } } @@ -400,14 +547,28 @@ document.addEventListener("turbolinks:load", function () { stopEditingIncome(); var otherIncomeEl = $(this).parents('.other-income'); - if (otherIncomeEl.length) { // canceling edit of existing income + if (otherIncomeEl.length) { + // canceling edit of existing income otherIncomeEl.find('.other-income-show').removeClass('hidden'); otherIncomeEl.find('.edit-other-income-form').addClass('hidden'); - } else { // canceling edit of new income - if (!$(this).parents('.other-incomes-list').find('.other-income').length) { // the kind for the canceled new income has no existing incomes - $(this).parents('.other-income-kind').find('input[type="checkbox"]').prop('checked', false); - $(this).parents('.other-income-kind').find('.add-more-link').addClass('hidden'); - $(this).parents('.other-income-kind').find("a.interaction-click-control-add-more").addClass('hide'); + } else { + // canceling edit of new income + if ( + !$(this).parents('.other-incomes-list').find('.other-income').length + ) { + // the kind for the canceled new income has no existing incomes + $(this) + .parents('.other-income-kind') + .find('input[type="checkbox"]') + .prop('checked', false); + $(this) + .parents('.other-income-kind') + .find('.add-more-link') + .addClass('hidden'); + $(this) + .parents('.other-income-kind') + .find('a.interaction-click-control-add-more') + .addClass('hide'); } $(this).parents('.new-other-income-form').remove(); } @@ -418,15 +579,26 @@ document.addEventListener("turbolinks:load", function () { stopEditingIncome(); var unemploymentIncomeEl = $(this).parents('.unemployment-income'); - if (unemploymentIncomeEl.length) { // canceling edit of existing income - unemploymentIncomeEl.find('.unemployment-income-show').removeClass('hidden'); - unemploymentIncomeEl.find('.edit-unemployment-income-form').addClass('hidden'); - } else { // canceling edit of new income - if (!$('.unemployment-incomes-list').find('.unemployment-income').length) { // no other existing incomes - $("#add-more-link-unemployment").addClass('hidden'); - $("a.interaction-click-control-add-more").addClass('hide'); - - $('#has_unemployment_income_false').prop('checked', true).trigger('change'); + if (unemploymentIncomeEl.length) { + // canceling edit of existing income + unemploymentIncomeEl + .find('.unemployment-income-show') + .removeClass('hidden'); + unemploymentIncomeEl + .find('.edit-unemployment-income-form') + .addClass('hidden'); + } else { + // canceling edit of new income + if ( + !$('.unemployment-incomes-list').find('.unemployment-income').length + ) { + // no other existing incomes + $('#add-more-link-unemployment').addClass('hidden'); + $('a.interaction-click-control-add-more').addClass('hide'); + + $('#has_unemployment_income_false') + .prop('checked', true) + .trigger('change'); } $(this).parents('.new-unmployment-income-form').remove(); @@ -438,14 +610,19 @@ document.addEventListener("turbolinks:load", function () { stopEditingIncome(); var aiAnIncomeEl = $(this).parents('ai-an-income'); - if (aiAnIncomeEl.length) { // canceling edit of existing income + if (aiAnIncomeEl.length) { + // canceling edit of existing income aiAnIncomeEl.find('.ai-an-income-show').removeClass('hidden'); aiAnIncomeEl.find('.edit-ai-an-income-form').addClass('hidden'); - } else { // canceling edit of new income - if (!$('.ai-an-incomes-list').find('.ai-an-income').length) { // no other existing incomes - $("#add-more-link-ai").addClass('hidden'); - $("a.interaction-click-control-add-more").addClass('hide'); - $('#has_american_indian_alaskan_native_income_false').prop('checked', true).trigger('change'); + } else { + // canceling edit of new income + if (!$('.ai-an-incomes-list').find('.ai-an-income').length) { + // no other existing incomes + $('#add-more-link-ai').addClass('hidden'); + $('a.interaction-click-control-add-more').addClass('hide'); + $('#has_american_indian_alaskan_native_income_false') + .prop('checked', true) + .trigger('change'); } $(this).parents('.new-ai-an-income-form').remove(); @@ -455,38 +632,53 @@ document.addEventListener("turbolinks:load", function () { // this index is to ensure duplicate hidden forms aren't saved on submit var incomeIndex = 0; /* new job incomes */ - $(".new-income").off('click'); - $('.new-income').on('click', function(e) { + $('.new-income').off('click'); + $('.new-income').on('click', function (e) { e.preventDefault(); startEditingIncome($(this).parents('.income').attr('id')); var form = $(this).parents(); if ($(this).parents('#job_income').children('.new-income-form').length) { - var newIncomeForm = $(this).parents('#job_income').children('.new-income-form') + var newIncomeForm = $(this) + .parents('#job_income') + .children('.new-income-form'); } else { - var newIncomeForm = $(this).parents('#self_employed_incomes').children('.new-income-form') + var newIncomeForm = $(this) + .parents('#self_employed_incomes') + .children('.new-income-form'); } if ($(this).parents('#job_income').find('.incomes-list').length) { var incomeListEl = $(this).parents('#job_income').find('.incomes-list'); } else { - var incomeListEl = $(this).parents('#self_employed_incomes').find('.incomes-list'); + var incomeListEl = $(this) + .parents('#self_employed_incomes') + .find('.incomes-list'); } - if (newIncomeForm.find('select').data('selectric')) newIncomeForm.find('select').selectric('destroy'); + if (newIncomeForm.find('select').data('selectric')) + newIncomeForm.find('select').selectric('destroy'); var clonedForm = generateNewForm(newIncomeForm, incomeListEl); - if (incomeListEl.children().length > 1 && incomeListEl.children().first().attr('id') === 'hidden-income-form') { + if ( + incomeListEl.children().length > 1 && + incomeListEl.children().first().attr('id') === 'hidden-income-form' + ) { incomeListEl.children().first().remove(); } if (incomeIndex != 0) { var previousForm = clonedForm.prev('.new-income-form'); previousForm.remove(); } - var length = incomeListEl.find(".income").length; + var length = incomeListEl.find('.income').length; if (!disableSelectric) { $(clonedForm).find('select').selectric(); } //$(newIncomeForm).find(".datepicker-js").datepicker({ dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true}); - $(clonedForm).find(".datepicker-js").datepicker({ dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true, yearRange: "-110:+110" }); - clonedForm.find('.interaction-click-control-save').addClass("disabled"); + $(clonedForm).find('.datepicker-js').datepicker({ + dateFormat: 'mm/dd/yy', + changeMonth: true, + changeYear: true, + yearRange: '-110:+110', + }); + clonedForm.find('.interaction-click-control-save').addClass('disabled'); incomeIndex++; }); @@ -494,221 +686,311 @@ document.addEventListener("turbolinks:load", function () { var unemploymentIndex = 0; /* new unemployment incomes */ $('#new-unemployment-income').off('click'); - $('#new-unemployment-income').on('click', function(e) { + $('#new-unemployment-income').on('click', function (e) { e.preventDefault(); startEditingIncome($(this).parents('.unemployment-income').attr('id')); var form = $(this).parents(); - var newIncomeForm = $(this).parents('#unemployment_income').children('.new-unemployment-income-form') - var incomeListEl = $(this).parents('#unemployment_income').find('.unemployment-incomes-list'); - - if (newIncomeForm.find('select').data('selectric')) newIncomeForm.find('select').selectric('destroy'); + var newIncomeForm = $(this) + .parents('#unemployment_income') + .children('.new-unemployment-income-form'); + var incomeListEl = $(this) + .parents('#unemployment_income') + .find('.unemployment-incomes-list'); + + if (newIncomeForm.find('select').data('selectric')) + newIncomeForm.find('select').selectric('destroy'); const clonedForm = generateNewForm(newIncomeForm, incomeListEl); - if (incomeListEl.children().length > 1 && incomeListEl.children().first().attr('id') === 'hidden-income-form') { + if ( + incomeListEl.children().length > 1 && + incomeListEl.children().first().attr('id') === 'hidden-income-form' + ) { incomeListEl.children().first().remove(); } if (unemploymentIndex != 0) { var previousForm = clonedForm.prev('.new-unemployment-income-form'); previousForm.remove(); } - var length = incomeListEl.find(".unemployment-income").length; + var length = incomeListEl.find('.unemployment-income').length; if (!disableSelectric) { $(clonedForm).find('select').selectric(); } - $(clonedForm).find(".datepicker-js").datepicker({ dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true, yearRange: "-110:+110" }); - clonedForm.find('.interaction-click-control-save').addClass("disabled"); + $(clonedForm).find('.datepicker-js').datepicker({ + dateFormat: 'mm/dd/yy', + changeMonth: true, + changeYear: true, + yearRange: '-110:+110', + }); + clonedForm.find('.interaction-click-control-save').addClass('disabled'); unemploymentIndex++; }); /* new AI/AN incomes */ $('#new-ai-an-income').off('click'); - $('#new-ai-an-income').on('click', function(e) { + $('#new-ai-an-income').on('click', function (e) { e.preventDefault(); startEditingIncome($(this).parents('.ai-an-income').attr('id')); var form = $(this).parents(); - var newIncomeForm = $(this).parents('#ai_an_income').children('.new-ai-an-income-form') - var incomeListEl = $(this).parents('#ai_an_income').find('.ai-an-incomes-list'); - - if (newIncomeForm.find('select').data('selectric')) newIncomeForm.find('select').selectric('destroy'); + var newIncomeForm = $(this) + .parents('#ai_an_income') + .children('.new-ai-an-income-form'); + var incomeListEl = $(this) + .parents('#ai_an_income') + .find('.ai-an-incomes-list'); + + if (newIncomeForm.find('select').data('selectric')) + newIncomeForm.find('select').selectric('destroy'); const clonedForm = generateNewForm(newIncomeForm, incomeListEl); - var length = incomeListEl.find(".ai-an-income").length; + var length = incomeListEl.find('.ai-an-income').length; if (!disableSelectric) { $(clonedForm).find('select').selectric(); } - $(clonedForm).find(".datepicker-js").datepicker({ dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true, yearRange: "-110:+110" }); - clonedForm.find('.interaction-click-control-save').addClass("disabled"); + $(clonedForm).find('.datepicker-js').datepicker({ + dateFormat: 'mm/dd/yy', + changeMonth: true, + changeYear: true, + yearRange: '-110:+110', + }); + clonedForm.find('.interaction-click-control-save').addClass('disabled'); }); $('#has_job_income_true').off('click'); - $('#has_job_income_true').on('click', function(e) { + $('#has_job_income_true').on('click', function (e) { $('.new-income-job').removeClass('hidden'); startEditingIncome($(this).parents('.income').attr('id')); if ($('#job_income').children('.new-income-form').length) { - var newIncomeForm = $('#job_income').children('.new-income-form') + var newIncomeForm = $('#job_income').children('.new-income-form'); } if ($('#job_income').find('.incomes-list').length) { var incomeListEl = $('#job_income').find('.incomes-list'); } - if (newIncomeForm.find('select').data('selectric')) newIncomeForm.find('select').selectric('destroy'); + if (newIncomeForm.find('select').data('selectric')) + newIncomeForm.find('select').selectric('destroy'); var clonedForm = generateNewForm(newIncomeForm, incomeListEl); - if (incomeListEl.children().length > 1 && incomeListEl.children().first().attr('id') === 'hidden-income-form') { + if ( + incomeListEl.children().length > 1 && + incomeListEl.children().first().attr('id') === 'hidden-income-form' + ) { incomeListEl.children().first().remove(); } - var length = incomeListEl.find(".income").length; + var length = incomeListEl.find('.income').length; if (!disableSelectric) { $(clonedForm).find('select').selectric(); } - $(clonedForm).find(".datepicker-js").datepicker({ dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true, yearRange: "-110:+110" }); + $(clonedForm).find('.datepicker-js').datepicker({ + dateFormat: 'mm/dd/yy', + changeMonth: true, + changeYear: true, + yearRange: '-110:+110', + }); }); $('#has_unemployment_income_true').off('click'); - $('#has_unemployment_income_true').on('click', function(e) { + $('#has_unemployment_income_true').on('click', function (e) { startEditingIncome($(this).parents('.income').attr('id')); - if ($('#unemployment_income').children('.new-unemployment-income-form').length) { - var newIncomeForm = $('#unemployment_income').children('.new-unemployment-income-form') + if ( + $('#unemployment_income').children('.new-unemployment-income-form') + .length + ) { + var newIncomeForm = $('#unemployment_income').children( + '.new-unemployment-income-form' + ); } if ($('#unemployment_income').find('.unemployment-incomes-list').length) { - var incomeListEl = $('#unemployment_income').find('.unemployment-incomes-list'); + var incomeListEl = $('#unemployment_income').find( + '.unemployment-incomes-list' + ); } - if (newIncomeForm.find('select').data('selectric')) newIncomeForm.find('select').selectric('destroy'); - if (!$('.unemployment-incomes-list').children('.new-unemployment-income-form').length) { + if (newIncomeForm.find('select').data('selectric')) + newIncomeForm.find('select').selectric('destroy'); + if ( + !$('.unemployment-incomes-list').children( + '.new-unemployment-income-form' + ).length + ) { var clonedForm = generateNewForm(newIncomeForm, incomeListEl); } - var length = incomeListEl.find(".unemployment-income").length; + var length = incomeListEl.find('.unemployment-income').length; if (!disableSelectric) { $(clonedForm).find('select').selectric(); } - $(clonedForm).find(".datepicker-js").datepicker({ dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true, yearRange: "-110:+110" }); + $(clonedForm).find('.datepicker-js').datepicker({ + dateFormat: 'mm/dd/yy', + changeMonth: true, + changeYear: true, + yearRange: '-110:+110', + }); }); - $("#has_american_indian_alaskan_native_income_true").off('click'); - $('#has_american_indian_alaskan_native_income_true').on('click', function(e) { - startEditingIncome($(this).parents('.income').attr('id')); - if ($('#ai_an_income').children('.new-ai-an-income-form').length) { - var newIncomeForm = $('#ai_an_income').children('.new-ai-an-income-form') - } + $('#has_american_indian_alaskan_native_income_true').off('click'); + $('#has_american_indian_alaskan_native_income_true').on( + 'click', + function (e) { + startEditingIncome($(this).parents('.income').attr('id')); + if ($('#ai_an_income').children('.new-ai-an-income-form').length) { + var newIncomeForm = $('#ai_an_income').children( + '.new-ai-an-income-form' + ); + } - if ($('#ai_an_income').find('.ai-an-incomes-list').length) { - var incomeListEl = $('#ai_an_income').find('.ai-an-incomes-list'); - } - if (newIncomeForm.find('select').data('selectric')) newIncomeForm.find('select').selectric('destroy'); - if (!$('.ai-an-incomes-list').children('.new-ai-an-income-form').length) { - var clonedForm = generateNewForm(newIncomeForm, incomeListEl); - } - var length = incomeListEl.find(".ai-an-income").length; - if (!disableSelectric) { - $(clonedForm).find('select').selectric(); - $(clonedForm).find(".datepicker-js").datepicker({ dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true, yearRange: "-110:+110" }); + if ($('#ai_an_income').find('.ai-an-incomes-list').length) { + var incomeListEl = $('#ai_an_income').find('.ai-an-incomes-list'); + } + if (newIncomeForm.find('select').data('selectric')) + newIncomeForm.find('select').selectric('destroy'); + if ( + !$('.ai-an-incomes-list').children('.new-ai-an-income-form').length + ) { + var clonedForm = generateNewForm(newIncomeForm, incomeListEl); + } + var length = incomeListEl.find('.ai-an-income').length; + if (!disableSelectric) { + $(clonedForm).find('select').selectric(); + $(clonedForm).find('.datepicker-js').datepicker({ + dateFormat: 'mm/dd/yy', + changeMonth: true, + changeYear: true, + yearRange: '-110:+110', + }); + } } - }); + ); - $("#has_self_employment_income_true").off('click'); - $('#has_self_employment_income_true').on('click', function(e) { + $('#has_self_employment_income_true').off('click'); + $('#has_self_employment_income_true').on('click', function (e) { $('.new-income-self-employed').removeClass('hidden'); startEditingIncome($(this).parents('.income').attr('id')); if ($('#self_employed_incomes').children('.new-income-form').length) { - var newIncomeForm = $('#self_employed_incomes').children('.new-income-form') + var newIncomeForm = $('#self_employed_incomes').children( + '.new-income-form' + ); } if ($('#self_employed_incomes').find('.incomes-list').length) { var incomeListEl = $('#self_employed_incomes').find('.incomes-list'); } - if (newIncomeForm.find('select').data('selectric')) newIncomeForm.find('select').selectric('destroy'); - var clonedForm = generateNewForm(newIncomeForm, incomeListEl); - if (incomeListEl.children().length > 1 && incomeListEl.children().first().attr('id') === 'hidden-self-income-form') { + if (newIncomeForm.find('select').data('selectric')) + newIncomeForm.find('select').selectric('destroy'); + var clonedForm = generateNewForm(newIncomeForm, incomeListEl); + if ( + incomeListEl.children().length > 1 && + incomeListEl.children().first().attr('id') === 'hidden-self-income-form' + ) { incomeListEl.children().first().remove(); } if (!disableSelectric) { $(clonedForm).find('select').selectric(); } - $(clonedForm).find(".datepicker-js").datepicker({ dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true, yearRange: "-110:+110" }); + $(clonedForm).find('.datepicker-js').datepicker({ + dateFormat: 'mm/dd/yy', + changeMonth: true, + changeYear: true, + yearRange: '-110:+110', + }); }); /* Condtional Display Job Income Question */ - if (!$("#has_job_income_true").is(':checked')) $("#job_income").addClass('hidden'); - if (!$("#has_self_employment_income_true").is(':checked')) $("#self_employed_incomes").addClass('hidden'); - if (!$("#has_other_income_true").is(':checked')) $(".other_income_kinds").addClass('hidden'); - if (!$("#has_unemployment_income_true").is(':checked')) $("#unemployment_income").addClass('hidden'); - if (!$("#has_american_indian_alaskan_native_income_true").is(':checked')) $("#ai_an_income").addClass('hidden'); - - $("body").on("change", "#has_job_income_true", function () { + if (!$('#has_job_income_true').is(':checked')) + $('#job_income').addClass('hidden'); + if (!$('#has_self_employment_income_true').is(':checked')) + $('#self_employed_incomes').addClass('hidden'); + if (!$('#has_other_income_true').is(':checked')) + $('.other_income_kinds').addClass('hidden'); + if (!$('#has_unemployment_income_true').is(':checked')) + $('#unemployment_income').addClass('hidden'); + if (!$('#has_american_indian_alaskan_native_income_true').is(':checked')) + $('#ai_an_income').addClass('hidden'); + + $('body').on('change', '#has_job_income_true', function () { if ($('#has_job_income_true').is(':checked')) { - $("#job_income").removeClass('hidden'); + $('#job_income').removeClass('hidden'); } else { - $("#job_income").addClass('hidden'); + $('#job_income').addClass('hidden'); } }); - $("body").on("change", "#has_job_income_false", function () { + $('body').on('change', '#has_job_income_false', function () { if ($('#has_job_income_false').is(':checked')) { - $("#job_income").addClass('hidden'); - $("#new_income_form").remove(); + $('#job_income').addClass('hidden'); + $('#new_income_form').remove(); } else { - $("#job_income").removeClass('hidden'); + $('#job_income').removeClass('hidden'); } }); - $("body").on("change", "#has_unemployment_income_true", function () { + $('body').on('change', '#has_unemployment_income_true', function () { if ($('#has_unemployment_income_true').is(':checked')) { - $("#unemployment_income").removeClass('hidden'); + $('#unemployment_income').removeClass('hidden'); } else { - $("#unemployment_income").addClass('hidden'); + $('#unemployment_income').addClass('hidden'); } }); - $("body").on("change", "#has_unemployment_income_false", function () { + $('body').on('change', '#has_unemployment_income_false', function () { if ($('#has_unemployment_income_false').is(':checked')) { - $("#unemployment_income").addClass('hidden'); + $('#unemployment_income').addClass('hidden'); } else { - $("#unemployment_income").removeClass('hidden'); + $('#unemployment_income').removeClass('hidden'); } }); - $("body").on("change", "#has_american_indian_alaskan_native_income_true", function () { - if ($('#has_american_indian_alaskan_native_income_true').is(':checked')) { - $("#ai_an_income").removeClass('hidden'); - } else { - $("#ai_an_income").addClass('hidden'); + $('body').on( + 'change', + '#has_american_indian_alaskan_native_income_true', + function () { + if ( + $('#has_american_indian_alaskan_native_income_true').is(':checked') + ) { + $('#ai_an_income').removeClass('hidden'); + } else { + $('#ai_an_income').addClass('hidden'); + } } - }); - - $("body").on("change", "#has_american_indian_alaskan_native_income_false", function () { - if ($('#has_american_indian_alaskan_native_income_false').is(':checked')) { - $("#ai_an_income").addClass('hidden'); - } else { - $("#ai_an_income").removeClass('hidden'); + ); + + $('body').on( + 'change', + '#has_american_indian_alaskan_native_income_false', + function () { + if ( + $('#has_american_indian_alaskan_native_income_false').is(':checked') + ) { + $('#ai_an_income').addClass('hidden'); + } else { + $('#ai_an_income').removeClass('hidden'); + } } - }); + ); - $("body").on("change", "#has_self_employment_income_true", function () { + $('body').on('change', '#has_self_employment_income_true', function () { if ($('#has_self_employment_income_true').is(':checked')) { - $("#self_employed_incomes").removeClass('hidden'); + $('#self_employed_incomes').removeClass('hidden'); } else { - $("#self_employed_incomes").addClass('hidden'); + $('#self_employed_incomes').addClass('hidden'); } }); - $("body").on("change", "#has_self_employment_income_false", function () { + $('body').on('change', '#has_self_employment_income_false', function () { if ($('#has_self_employment_income_false').is(':checked')) { - $("#self_employed_incomes").addClass('hidden'); + $('#self_employed_incomes').addClass('hidden'); } else { - $("#self_employed_incomes").removeClass('hidden'); + $('#self_employed_incomes').removeClass('hidden'); } }); /* Condtional Display Other Income Question */ - $("body").on("change", "#has_other_income_true", function () { + $('body').on('change', '#has_other_income_true', function () { if ($('#has_other_income_true').is(':checked')) { - $(".other_income_kinds").removeClass('hidden'); + $('.other_income_kinds').removeClass('hidden'); } else { - $(".other_income_kinds").addClass('hidden'); + $('.other_income_kinds').addClass('hidden'); } }); - $("body").on("change", "#has_other_income_false", function () { + $('body').on('change', '#has_other_income_false', function () { if ($('#has_other_income_false').is(':checked')) { - $(".other_income_kinds").addClass('hidden'); + $('.other_income_kinds').addClass('hidden'); } else { - $(".other_income_kinds").removeClass('hidden'); + $('.other_income_kinds').removeClass('hidden'); } }); } @@ -717,7 +999,7 @@ document.addEventListener("turbolinks:load", function () { // otherincome checkbox fuctionality $(document).on('turbolinks:load', function () { function disableSave(form) { - form.find('.interaction-click-control-save').addClass("disabled"); + form.find('.interaction-click-control-save').addClass('disabled'); form.find('.interaction-click-control-save').attr('disabled', 'disabled'); } @@ -728,9 +1010,9 @@ $(document).on('turbolinks:load', function () { $(':input[required=""],:input[required]').on('change', function () { var form = $(this).closest('form'); if (validateForm(form)) { - enableSave(form) + enableSave(form); } else { - disableSave(form) + disableSave(form); } }); @@ -751,38 +1033,68 @@ $(document).on('turbolinks:load', function () { // return 'You have an unsaved income, are you sure you want to proceed?'; // }); $('input[name="other_income_kind"]').off('click'); - $('input[name="other_income_kind"]').on('click', function(e) { + $('input[name="other_income_kind"]').on('click', function (e) { var value = e.target.checked; self = this; - if (value) { // checked deduction kind - var newOtherIncomeFormEl = $(this).parents('.other-income-kind').children('.new-other-income-form').first(); - otherIncomeListEl = $(this).parents('.other-income-kind').find('.other-incomes-list'); - if (newOtherIncomeFormEl.find('select').data('selectric')) newOtherIncomeFormEl.find('select').selectric('destroy'); - const clonedForm = generateNewForm(newOtherIncomeFormEl, otherIncomeListEl); + if (value) { + // checked deduction kind + var newOtherIncomeFormEl = $(this) + .parents('.other-income-kind') + .children('.new-other-income-form') + .first(); + otherIncomeListEl = $(this) + .parents('.other-income-kind') + .find('.other-incomes-list'); + if (newOtherIncomeFormEl.find('select').data('selectric')) + newOtherIncomeFormEl.find('select').selectric('destroy'); + const clonedForm = generateNewForm( + newOtherIncomeFormEl, + otherIncomeListEl + ); startEditingIncome($(this).parents('.other-income-kind').attr('id')); if (!disableSelectric) { - $(clonedForm).find(".datepicker-js").datepicker({ dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true, yearRange: "-110:+110" }); + $(clonedForm).find('.datepicker-js').datepicker({ + dateFormat: 'mm/dd/yy', + changeMonth: true, + changeYear: true, + yearRange: '-110:+110', + }); $(clonedForm).find('select').selectric(); } - } else if (!$(self).parents('.other-income-kind').find('.other-incomes-list > .other-income').length) { // unchecked deduction kind with no created deductions + } else if ( + !$(self) + .parents('.other-income-kind') + .find('.other-incomes-list > .other-income').length + ) { + // unchecked deduction kind with no created deductions $(self).parents('.other-income-kind').find('.other-incomes-list').empty(); - $(self).parents('.other-income-kind').find('.add-more-link').addClass('hidden'); + $(self) + .parents('.other-income-kind') + .find('.add-more-link') + .addClass('hidden'); stopEditingIncome(); - } else { // unchecked deduction kind with created deductions + } else { + // unchecked deduction kind with created deductions // prompt to delete all these deductions e.preventDefault(); - $("#destroyAllOtherIncomesOfKind").modal(); - $("#destroyAllOtherIncomesOfKind .modal-cancel-button").off('click'); - $('#destroyAllOtherIncomesOfKind .modal-cancel-button').on('click', function(e) { - $("#destroyAllOtherIncomesOfKind").modal('hide'); - }); - - $("#destroyAllOtherIncomesOfKind .modal-continue-button").off('click'); - $('#destroyAllOtherIncomesOfKind .modal-continue-button').on('click', function(e) { - $("#destroyAllOtherIncomesOfKind").modal('hide'); - stopEditingIncome(); - deleteIncomes($(self).parents('.other-income-kind')) - }); + $('#destroyAllOtherIncomesOfKind').modal(); + $('#destroyAllOtherIncomesOfKind .modal-cancel-button').off('click'); + $('#destroyAllOtherIncomesOfKind .modal-cancel-button').on( + 'click', + function (e) { + $('#destroyAllOtherIncomesOfKind').modal('hide'); + } + ); + + $('#destroyAllOtherIncomesOfKind .modal-continue-button').off('click'); + $('#destroyAllOtherIncomesOfKind .modal-continue-button').on( + 'click', + function (e) { + $('#destroyAllOtherIncomesOfKind').modal('hide'); + stopEditingIncome(); + deleteIncomes($(self).parents('.other-income-kind')); + } + ); } }); @@ -791,40 +1103,57 @@ $(document).on('turbolinks:load', function () { var self = this; let other_incomes_exists = false; - document.querySelectorAll(".other_income_kinds .other-income-kind").forEach(function (kind) { - if (kind.querySelector('input[type="checkbox"]').checked) { - other_incomes_exists = true; - } - }); + document + .querySelectorAll('.other_income_kinds .other-income-kind') + .forEach(function (kind) { + if (kind.querySelector('input[type="checkbox"]').checked) { + other_incomes_exists = true; + } + }); if (other_incomes_exists) { e.preventDefault(); - $("#destroyAllOtherIncomes").modal(); - $("#destroyAllOtherIncomes .modal-cancel-button").off('click'); - $('#destroyAllOtherIncomes .modal-cancel-button').on('click', function(e) { - $("#destroyAllOtherIncomes").modal('hide'); - $('#has_other_income_true').prop('checked', true).trigger('change') - }); + $('#destroyAllOtherIncomes').modal(); + $('#destroyAllOtherIncomes .modal-cancel-button').off('click'); + $('#destroyAllOtherIncomes .modal-cancel-button').on( + 'click', + function (e) { + $('#destroyAllOtherIncomes').modal('hide'); + $('#has_other_income_true').prop('checked', true).trigger('change'); + } + ); - $("#destroyAllOtherIncomes .modal-continue-button").off('click'); - $('#destroyAllOtherIncomes .modal-continue-button').on('click', function(e) { - $("#destroyAllOtherIncomes").modal('hide'); + $('#destroyAllOtherIncomes .modal-continue-button').off('click'); + $('#destroyAllOtherIncomes .modal-continue-button').on( + 'click', + function (e) { + $('#destroyAllOtherIncomes').modal('hide'); - $(".other_income_kinds .other-income-kind").each(function (_, kind) { - deleteIncomes($(kind)); - }); - }); + $('.other_income_kinds .other-income-kind').each(function (_, kind) { + deleteIncomes($(kind)); + }); + } + ); } }); // this index is to ensure duplicate hidden forms aren't saved on submit var otherIndex = 0; - $(document).on('click', ".add_new_other_income_kind", function (e) { - var newOtherIncomeFormEl = $(this).parents('.other-income-kind').children('.new-other-income-form'), - otherIncomeListEl = $(this).parents('.other-income-kind').find('.other-incomes-list'); - if (newOtherIncomeFormEl.find('select').data('selectric')) newOtherIncomeFormEl.find('select').selectric('destroy'); + $(document).on('click', '.add_new_other_income_kind', function (e) { + var newOtherIncomeFormEl = $(this) + .parents('.other-income-kind') + .children('.new-other-income-form'), + otherIncomeListEl = $(this) + .parents('.other-income-kind') + .find('.other-incomes-list'); + if (newOtherIncomeFormEl.find('select').data('selectric')) + newOtherIncomeFormEl.find('select').selectric('destroy'); const clonedForm = generateNewForm(newOtherIncomeFormEl, otherIncomeListEl); - if (otherIncomeListEl.children().length > 1 && otherIncomeListEl.children().first().attr('id') === 'hidden-other-income-form') { + if ( + otherIncomeListEl.children().length > 1 && + otherIncomeListEl.children().first().attr('id') === + 'hidden-other-income-form' + ) { incomeListEl.children().first().remove(); } if (otherIndex != 0) { @@ -835,54 +1164,87 @@ $(document).on('turbolinks:load', function () { if (!disableSelectric) { $(clonedForm).find('select').selectric(); } - $(clonedForm).find(".datepicker-js").datepicker({ dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true, yearRange: "-110:+110" }); + $(clonedForm).find('.datepicker-js').datepicker({ + dateFormat: 'mm/dd/yy', + changeMonth: true, + changeYear: true, + yearRange: '-110:+110', + }); e.stopImmediatePropagation(); otherIndex++; }); /* edit existing other income */ $('.other-incomes-list').off('click', 'a.other-income-edit:not(.disabled)'); - $('.other-incomes-list').on('click', 'a.other-income-edit:not(.disabled)', function (e) { - e.preventDefault(); - var otherIncomeEl = $(this).parents('.other-income'); - otherIncomeEl.find('.other-income-show').addClass('hidden'); - otherIncomeEl.find('.edit-other-income-form').removeClass('hidden'); - startEditingIncome($(this).parents('.other-income-kind').attr('id')); + $('.other-incomes-list').on( + 'click', + 'a.other-income-edit:not(.disabled)', + function (e) { + e.preventDefault(); + var otherIncomeEl = $(this).parents('.other-income'); + otherIncomeEl.find('.other-income-show').addClass('hidden'); + otherIncomeEl.find('.edit-other-income-form').removeClass('hidden'); + startEditingIncome($(this).parents('.other-income-kind').attr('id')); - $(otherIncomeEl).find(".datepicker-js").datepicker({ dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true, yearRange: "-110:+110" }); - }); + $(otherIncomeEl).find('.datepicker-js').datepicker({ + dateFormat: 'mm/dd/yy', + changeMonth: true, + changeYear: true, + yearRange: '-110:+110', + }); + } + ); /* destroy existing other income */ - $('.other-incomes-list').on('click', 'a.other-income-delete:not(.disabled)', function (e) { - var self = this; - e.preventDefault(); - $("#destroyOtherIncome").modal(); + $('.other-incomes-list').on( + 'click', + 'a.other-income-delete:not(.disabled)', + function (e) { + var self = this; + e.preventDefault(); + $('#destroyOtherIncome').modal(); - $("#destroyOtherIncome .modal-cancel-button").off('click'); - $('#destroyOtherIncome .modal-cancel-button').on('click', function(e) { - $("#destroyOtherIncome").modal('hide'); - }); + $('#destroyOtherIncome .modal-cancel-button').off('click'); + $('#destroyOtherIncome .modal-cancel-button').on('click', function (e) { + $('#destroyOtherIncome').modal('hide'); + }); - $("#destroyOtherIncome .modal-continue-button").off('click'); - $('#destroyOtherIncome .modal-continue-button').on('click', function(e) { - $("#destroyOtherIncome").modal('hide'); + $('#destroyOtherIncome .modal-continue-button').off('click'); + $('#destroyOtherIncome .modal-continue-button').on('click', function (e) { + $('#destroyOtherIncome').modal('hide'); - var url = $(self).parents('.other-income').attr('id').replace('financial_assistance_income_', ''); - $.ajax({ - type: 'DELETE', - url: url, - dataType: 'script', - success: function() { - if ($(self).parents('.other-incomes-list').find('.other-income').length == 1) { - $(self).parents('.other-income-kind').find('input[type="checkbox"]').prop('checked', false); - $(self).parents('.other-income-kind').find('.add-more-link').addClass('hidden'); - $(self).parents('.other-income-kind').find("a.interaction-click-control-add-more").addClass('hide'); - } - $(self).parents('.other-income').remove(); - } - }) - }); - }); + var url = $(self) + .parents('.other-income') + .attr('id') + .replace('financial_assistance_income_', ''); + $.ajax({ + type: 'DELETE', + url: url, + dataType: 'script', + success: function () { + if ( + $(self).parents('.other-incomes-list').find('.other-income') + .length == 1 + ) { + $(self) + .parents('.other-income-kind') + .find('input[type="checkbox"]') + .prop('checked', false); + $(self) + .parents('.other-income-kind') + .find('.add-more-link') + .addClass('hidden'); + $(self) + .parents('.other-income-kind') + .find('a.interaction-click-control-add-more') + .addClass('hide'); + } + $(self).parents('.other-income').remove(); + }, + }); + }); + } + ); /* cancel other income edits */ $('.other-incomes-list').off('click', 'a.other-income-cancel'); @@ -891,128 +1253,218 @@ $(document).on('turbolinks:load', function () { stopEditingIncome(); var otherIncomeEl = $(this).parents('.other-income'); - if (otherIncomeEl.length) { // canceling edit of existing income + if (otherIncomeEl.length) { + // canceling edit of existing income otherIncomeEl.find('.other-income-show').removeClass('hidden'); otherIncomeEl.find('.edit-other-income-form').addClass('hidden'); - } else { // canceling edit of new income - if (!$(this).parents('.other-incomes-list').find('.other-income').length) { // the kind for the canceled new income has no existing incomes - $(this).parents('.other-income-kind').find('input[type="checkbox"]').prop('checked', false); - $(this).parents('.other-income-kind').find('.add-more-link').addClass('hidden'); - $(this).parents('.other-income-kind').find("a.interaction-click-control-add-more").addClass('hide'); + } else { + // canceling edit of new income + if ( + !$(this).parents('.other-incomes-list').find('.other-income').length + ) { + // the kind for the canceled new income has no existing incomes + $(this) + .parents('.other-income-kind') + .find('input[type="checkbox"]') + .prop('checked', false); + $(this) + .parents('.other-income-kind') + .find('.add-more-link') + .addClass('hidden'); + $(this) + .parents('.other-income-kind') + .find('a.interaction-click-control-add-more') + .addClass('hide'); } $(this).parents('.new-other-income-form').remove(); } }); /* edit existing unemployment income */ - $('.unemployment-incomes-list').off('click', 'a.unemployment-income-edit:not(.disabled)'); - $('.unemployment-incomes-list').on('click', 'a.unemployment-income-edit:not(.disabled)', function(e) { - e.preventDefault(); + $('.unemployment-incomes-list').off( + 'click', + 'a.unemployment-income-edit:not(.disabled)' + ); + $('.unemployment-incomes-list').on( + 'click', + 'a.unemployment-income-edit:not(.disabled)', + function (e) { + e.preventDefault(); - var unemploymentIncomeEl = $(this).parents('.unemployment-income'); - unemploymentIncomeEl.find('.unemployment-income-show').addClass('hidden'); - unemploymentIncomeEl.find('.edit-unemployment-income-form').removeClass('hidden'); + var unemploymentIncomeEl = $(this).parents('.unemployment-income'); + unemploymentIncomeEl.find('.unemployment-income-show').addClass('hidden'); + unemploymentIncomeEl + .find('.edit-unemployment-income-form') + .removeClass('hidden'); - startEditingIncome($(this).parents('.unemployment-income').attr('id')); + startEditingIncome($(this).parents('.unemployment-income').attr('id')); - $(unemploymentIncomeEl).find(".datepicker-js").datepicker({ dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true, yearRange: "-110:+110" }); - }); + $(unemploymentIncomeEl).find('.datepicker-js').datepicker({ + dateFormat: 'mm/dd/yy', + changeMonth: true, + changeYear: true, + yearRange: '-110:+110', + }); + } + ); /* destroy existing unemployment income */ - $('.unemployment-incomes-list').off('click', 'a.unemployment-income-delete:not(.disabled)'); - $('.unemployment-incomes-list').on('click', 'a.unemployment-income-delete:not(.disabled)', function(e) { - var self = this; - e.preventDefault(); - $("#destroyUnemploymentIncome").modal(); - - $("#destroyUnemploymentIncome .modal-cancel-button").off('click'); - $('#destroyUnemploymentIncome .modal-cancel-button').on('click', function(e) { - $("#destroyUnemploymentIncome").modal('hide'); - }); - - $("#destroyUnemploymentIncome .modal-continue-button").off('click'); - $('#destroyUnemploymentIncome .modal-continue-button').on('click', function(e) { - $("#destroyUnemploymentIncome").modal('hide'); + $('.unemployment-incomes-list').off( + 'click', + 'a.unemployment-income-delete:not(.disabled)' + ); + $('.unemployment-incomes-list').on( + 'click', + 'a.unemployment-income-delete:not(.disabled)', + function (e) { + var self = this; + e.preventDefault(); + $('#destroyUnemploymentIncome').modal(); - var url = $(self).parents('.unemployment-income').attr('id').replace('financial_assistance_income_', ''); - $.ajax({ - type: 'DELETE', - url: url, - dataType: 'script', - success: function() { - $(self).parents('.unemployment-income').remove(); - if (!$('.unemployment-incomes-list').find('.unemployment-income').length) { // no other existing incomes - $("#add-more-link-unemployment").addClass('hidden'); - $("a.interaction-click-control-add-more").addClass('hide'); - $('#has_unemployment_income_false').prop('checked', true).trigger('change'); - } + $('#destroyUnemploymentIncome .modal-cancel-button').off('click'); + $('#destroyUnemploymentIncome .modal-cancel-button').on( + 'click', + function (e) { + $('#destroyUnemploymentIncome').modal('hide'); } - }); - }); - }); + ); + + $('#destroyUnemploymentIncome .modal-continue-button').off('click'); + $('#destroyUnemploymentIncome .modal-continue-button').on( + 'click', + function (e) { + $('#destroyUnemploymentIncome').modal('hide'); + + var url = $(self) + .parents('.unemployment-income') + .attr('id') + .replace('financial_assistance_income_', ''); + $.ajax({ + type: 'DELETE', + url: url, + dataType: 'script', + success: function () { + $(self).parents('.unemployment-income').remove(); + if ( + !$('.unemployment-incomes-list').find('.unemployment-income') + .length + ) { + // no other existing incomes + $('#add-more-link-unemployment').addClass('hidden'); + $('a.interaction-click-control-add-more').addClass('hide'); + $('#has_unemployment_income_false') + .prop('checked', true) + .trigger('change'); + } + }, + }); + } + ); + } + ); /* cancel unemployment income edits */ - $('.unemployment-incomes-list').on('click', 'a.unemployment-income-cancel', function (e) { - e.preventDefault(); - stopEditingIncome(); + $('.unemployment-incomes-list').on( + 'click', + 'a.unemployment-income-cancel', + function (e) { + e.preventDefault(); + stopEditingIncome(); - var unemploymentIncomeEl = $(this).parents('.unemployment-income'); - if (unemploymentIncomeEl.length) { - $(this).closest('.unemployment-income-kind').find('a#add_new_unemployment_income_kind').removeClass("hidden"); - unemploymentIncomeEl.find('.unemployment-income-show').removeClass('hidden'); - unemploymentIncomeEl.find('.edit-unemployment-income-form').addClass('hidden'); - } else { - if (!$(this).parents('.unemployment-incomes-list > div.unemployment-income').length) { - $(this).parents('.unemployment-income-kind').find('input[type="checkbox"]').prop('checked', false); - $(this).closest('.unemployment-income-kind').find('a#add_new_unemployment_income_kind').addClass("hidden"); + var unemploymentIncomeEl = $(this).parents('.unemployment-income'); + if (unemploymentIncomeEl.length) { + $(this) + .closest('.unemployment-income-kind') + .find('a#add_new_unemployment_income_kind') + .removeClass('hidden'); + unemploymentIncomeEl + .find('.unemployment-income-show') + .removeClass('hidden'); + unemploymentIncomeEl + .find('.edit-unemployment-income-form') + .addClass('hidden'); + } else { + if ( + !$(this).parents( + '.unemployment-incomes-list > div.unemployment-income' + ).length + ) { + $(this) + .parents('.unemployment-income-kind') + .find('input[type="checkbox"]') + .prop('checked', false); + $(this) + .closest('.unemployment-income-kind') + .find('a#add_new_unemployment_income_kind') + .addClass('hidden'); + } + $(this).parents('.new-unemployment-income-form').remove(); + $(this).parents('.edit-unemployment-income-form').remove(); } - $(this).parents('.new-unemployment-income-form').remove(); - $(this).parents('.edit-unemployment-income-form').remove(); } - }); + ); /* edit existing AI/AN income */ - $('.ai-an-incomes-list').on('click', 'a.ai-an-income-edit:not(.disabled)', function (e) { - e.preventDefault(); - var aianIncomeEl = $(this).parents('.ai-an-income'); - aianIncomeEl.find('.ai-an-income-show').addClass('hidden'); - aianIncomeEl.find('.edit-ai-an-income-form').removeClass('hidden'); - startEditingIncome($(this).parents('.ai-an-income-kind').attr('id')); - - $(aianIncomeEl).find(".datepicker-js").datepicker({ dateFormat: 'mm/dd/yy', changeMonth: true, changeYear: true, yearRange: "-110:+110" }); - }); + $('.ai-an-incomes-list').on( + 'click', + 'a.ai-an-income-edit:not(.disabled)', + function (e) { + e.preventDefault(); + var aianIncomeEl = $(this).parents('.ai-an-income'); + aianIncomeEl.find('.ai-an-income-show').addClass('hidden'); + aianIncomeEl.find('.edit-ai-an-income-form').removeClass('hidden'); + startEditingIncome($(this).parents('.ai-an-income-kind').attr('id')); + + $(aianIncomeEl).find('.datepicker-js').datepicker({ + dateFormat: 'mm/dd/yy', + changeMonth: true, + changeYear: true, + yearRange: '-110:+110', + }); + } + ); /* destroy existing AI/AN income */ - $('.ai-an-incomes-list').on('click', 'a.ai-an-income-delete:not(.disabled)', function (e) { - var self = this; - e.preventDefault(); - $("#destroyAIANIncome").modal(); + $('.ai-an-incomes-list').on( + 'click', + 'a.ai-an-income-delete:not(.disabled)', + function (e) { + var self = this; + e.preventDefault(); + $('#destroyAIANIncome').modal(); - $("#destroyAIANIncome .modal-cancel-button").off('click'); - $('#destroyAIANIncome .modal-cancel-button').on('click', function(e) { - $("#destroyAIANIncome").modal('hide'); - }); + $('#destroyAIANIncome .modal-cancel-button').off('click'); + $('#destroyAIANIncome .modal-cancel-button').on('click', function (e) { + $('#destroyAIANIncome').modal('hide'); + }); - $("#destroyAIANIncome .modal-continue-button").off('click'); - $('#destroyAIANIncome .modal-continue-button').on('click', function(e) { - $("#destroyAIANIncome").modal('hide'); + $('#destroyAIANIncome .modal-continue-button').off('click'); + $('#destroyAIANIncome .modal-continue-button').on('click', function (e) { + $('#destroyAIANIncome').modal('hide'); - var url = $(self).parents('.ai-an-income').attr('id').replace('financial_assistance_income_', ''); - $.ajax({ - type: 'DELETE', - url: url, - dataType: 'script', - success: function() { - $(self).parents('.ai-an-income').remove(); - if (!$('.ai-an-incomes-list').find('.ai-an-income').length) { // no other existing incomes - $("#add-more-link-ai").addClass('hidden'); - $("a.interaction-click-control-add-more").addClass('hide'); - $('#has_american_indian_alaskan_native_income_false').prop('checked', true).trigger('change'); - } - } - }) - }); - }); + var url = $(self) + .parents('.ai-an-income') + .attr('id') + .replace('financial_assistance_income_', ''); + $.ajax({ + type: 'DELETE', + url: url, + dataType: 'script', + success: function () { + $(self).parents('.ai-an-income').remove(); + if (!$('.ai-an-incomes-list').find('.ai-an-income').length) { + // no other existing incomes + $('#add-more-link-ai').addClass('hidden'); + $('a.interaction-click-control-add-more').addClass('hide'); + $('#has_american_indian_alaskan_native_income_false') + .prop('checked', true) + .trigger('change'); + } + }, + }); + }); + } + ); /* cancel AI/AN income edits */ $('.ai-an-incomes-list').on('click', 'a.ai-an-income-cancel', function (e) { @@ -1021,13 +1473,22 @@ $(document).on('turbolinks:load', function () { var aianIncomeEl = $(this).parents('.ai-an-income'); if (aianIncomeEl.length) { - $(this).closest('.ai-an-income-kind').find('a#add_new_ai_an_income_kind').removeClass("hidden"); + $(this) + .closest('.ai-an-income-kind') + .find('a#add_new_ai_an_income_kind') + .removeClass('hidden'); aianIncomeEl.find('.ai-an-income-show').removeClass('hidden'); aianIncomeEl.find('.edit-ai-an-income-form').addClass('hidden'); } else { if (!$(this).parents('.ai-an-incomes-list > div.ai-an-income').length) { - $(this).parents('.ai-an-income-kind').find('input[type="checkbox"]').prop('checked', false); - $(this).closest('.ai-an-income-kind').find('a#add_new_ai_an_income_kind').addClass("hidden"); + $(this) + .parents('.ai-an-income-kind') + .find('input[type="checkbox"]') + .prop('checked', false); + $(this) + .closest('.ai-an-income-kind') + .find('a#add_new_ai_an_income_kind') + .addClass('hidden'); } $(this).parents('.new-ai-an-income-form').remove(); $(this).parents('.edit-ai-an-income-form').remove(); @@ -1035,7 +1496,7 @@ $(document).on('turbolinks:load', function () { }); // disable save button logic function disableSave(form) { - form.find('.interaction-click-control-save').addClass("disabled"); + form.find('.interaction-click-control-save').addClass('disabled'); form.find('.interaction-click-control-save').attr('disabled', 'disabled'); } @@ -1047,45 +1508,61 @@ $(document).on('turbolinks:load', function () { $(':input[required]').on('keyup change', function () { var form = $(this).closest('form'); if (validateForm(form)) { - enableSave(form) + enableSave(form); } else { - disableSave(form) + disableSave(form); } }); function validateForm(form) { var isValid = true; form.find(':input[required]').each(function () { - if ($(this).val() == '' || $(this).val() == '0.00' || $(this).val() == 'Choose') { + if ( + $(this).val() == '' || + $(this).val() == '0.00' || + $(this).val() == 'Choose' + ) { isValid = false; } }); return isValid; } - $(document).on('focus', '.new-income-form .phone_number', function() { - $(this).mask('(000) 000-0000'); - }); - - $('body').on('keyup keydown keypress', '#income_employer_phone_full_phone_number', function (e) { - var key = e.which || e.keyCode || e.charCode; + $(document).on('focus', '.new-income-form .phone_number', function () { $(this).mask('(000) 000-0000'); - return (key == 8 || - key == 9 || - key == 46 || - (key >= 37 && key <= 40) || - (key >= 48 && key <= 57) || - (key >= 96 && key <= 105)); }); - $('body').on('keyup keydown keypress', '#income_employer_address_zip', function (e) { - var key = e.which || e.keyCode || e.charCode; - $(this).attr('maxlength', '5'); - return (key == 8 || - key == 9 || - key == 46 || - (key >= 37 && key <= 40) || - (key >= 48 && key <= 57) || - (key >= 96 && key <= 105)); - }); + $('body').on( + 'keyup keydown keypress', + '#income_employer_phone_full_phone_number', + function (e) { + var key = e.which || e.keyCode || e.charCode; + $(this).mask('(000) 000-0000'); + return ( + key == 8 || + key == 9 || + key == 46 || + (key >= 37 && key <= 40) || + (key >= 48 && key <= 57) || + (key >= 96 && key <= 105) + ); + } + ); + + $('body').on( + 'keyup keydown keypress', + '#income_employer_address_zip', + function (e) { + var key = e.which || e.keyCode || e.charCode; + $(this).attr('maxlength', '5'); + return ( + key == 8 || + key == 9 || + key == 46 || + (key >= 37 && key <= 40) || + (key >= 48 && key <= 57) || + (key >= 96 && key <= 105) + ); + } + ); }); diff --git a/components/financial_assistance/app/views/financial_assistance/applications/_faa_progress_options.html.erb b/components/financial_assistance/app/views/financial_assistance/applications/_faa_progress_options.html.erb new file mode 100644 index 00000000000..49d674ebe71 --- /dev/null +++ b/components/financial_assistance/app/views/financial_assistance/applications/_faa_progress_options.html.erb @@ -0,0 +1,26 @@ +<% step = (defined? step) ? step.to_i : 1 %> + +<% content_for(:step) { step } %> +<% content_for(:show_exit_button) { "true" } %> +<% content_for(:show_previous_button) { "false" } %> +<% content_for(:show_account_button) { EnrollRegistry.feature_enabled?(:back_to_account_all_shop)&.to_s } %> +<% content_for(:show_help_button) { "true" } %> +<% content_for(:back_to_account_flag) { "true" } %> + +<% if @applicant.present? %> + <% content_for(:title) { l10n("faa.left_nav.my_household") } %> + <% content_for(:title_link) { edit_application_path(@application) } %> +<% else %> + <% content_for(:title) { l10n('faa.my_applications') } %> + <% content_for(:title_link) { financial_assistance.applications_path } %> + <% content_for(:nav_options) do %> + <% no_applicant_faa_nav_options(@application).each do |nav_option| %> + + <% end %> + <% end %> +<% end %> + diff --git a/components/financial_assistance/app/views/financial_assistance/shared/_date_warning.html.erb b/components/financial_assistance/app/views/financial_assistance/shared/_date_warning.html.erb index 1cb80bd0708..93662c40014 100644 --- a/components/financial_assistance/app/views/financial_assistance/shared/_date_warning.html.erb +++ b/components/financial_assistance/app/views/financial_assistance/shared/_date_warning.html.erb @@ -35,4 +35,4 @@
-<% end %> \ No newline at end of file +<% end %>