Skip to content

Commit

Permalink
187141008 preferences and submit (#3935)
Browse files Browse the repository at this point in the history
* started removing step pattern from benefits

* add pundit back for step

* start removing step pattern from deductions

* clean up deductions controller

* start moving preferences page out of step pattern

* more work on getting out of step pattern

* fix redirect

* controller specs

* pundit policies

* preferences page cucumbers

* finish up cucumbers

* rubocop

* appscan

---------

Signed-off-by: kristinmerbach <[email protected]>
  • Loading branch information
kristinmerbach authored Jun 13, 2024
1 parent 55a03cb commit 0ec06d1
Show file tree
Hide file tree
Showing 9 changed files with 493 additions and 852 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
module FinancialAssistance
# IAP application controller
class ApplicationsController < FinancialAssistance::ApplicationController

before_action :set_current_person
before_action :set_family
before_action :find_application, :except => [:index, :index_with_filter, :new, :review, :raw_application]
Expand All @@ -12,7 +11,6 @@ class ApplicationsController < FinancialAssistance::ApplicationController
around_action :cache_current_hbx, :only => [:index_with_filter]

include ActionView::Helpers::SanitizeHelper
include ::UIHelpers::WorkflowController
include Acapi::Notifiers
include FinancialAssistance::L10nHelper
include ::FileUploadHelper
Expand Down Expand Up @@ -70,64 +68,70 @@ def edit
respond_to :html
end

# rubocop:disable Metrics/AbcSize
def step
def preferences
authorize @application, :preferences?

save_faa_bookmark(request.original_url)
respond_to :html
end

def save_preferences
raise ActionController::UnknownFormat unless request.format.html?

authorize @application, :step?
save_faa_bookmark(request.original_url.gsub(%r{/step.*}, "/step/#{@current_step.to_i}"))
authorize @application, :save_preferences?
if params[:application].present?
@application.assign_attributes(permit_params(params[:application]))

if @application.save
redirect_to submit_your_application_application_path(@application)
else
@application.save!(validate: false)
flash[:error] = build_error_messages(@application).join(", ")
render 'preferences'
end
else
render 'preferences'
end
end

def submit_your_application
authorize @application, :submit_your_application?
save_faa_bookmark(request.original_url)
set_admin_bookmark_url
flash[:error] = nil
model_name = @model.class.to_s.split('::').last.downcase
model_params = params[model_name]
@model.clean_conditional_params(model_params) if model_params.present?
@model.assign_attributes(permit_params(model_params)) if model_params.present?
@model.attributes = @model.attributes.except(:_id) unless @model.persisted?

# rubocop:disable Metrics/BlockNesting
if params.key?(model_name)
if @model.save
@current_step = @current_step.next_step if @current_step.next_step.present?
@model.update_attributes!(workflow: { current_step: @current_step.to_i })
if params[:commit] == "Submit Application"
if @application.imported?
redirect_to application_publish_error_application_path(@application), flash: { error: "Submission Error: Imported Application can't be submitted for Eligibity" }
return
end
if @application.complete?
publish_result = determination_request_class.new.call(application_id: @application.id)
if publish_result.success?
redirect_to wait_for_eligibility_response_application_path(@application)
else
@application.unsubmit! if @application.may_unsubmit?
flash_message = case publish_result.failure
when Dry::Validation::Result
{ error: validation_errors_parser(publish_result.failure) }
when Exception
{ error: publish_result.failure.message }
else
{ error: "Submission Error: #{publish_result.failure}" }
end
redirect_to application_publish_error_application_path(@application), flash: flash_message
end
else
redirect_to application_publish_error_application_path(@application), flash: { error: build_error_messages(@model) }
end
else
render 'workflow/step'
end
respond_to :html
end

def submit
raise ActionController::UnknownFormat unless request.format.html?

authorize @application, :submit?

if params[:application].present?
@application.assign_attributes(permit_params(params[:application]))

if @application.save
redirect_to submit_and_publish_application_redirect_path[:path], flash: submit_and_publish_application_redirect_path[:flash]
else
@model.assign_attributes(workflow: { current_step: @current_step.to_i })
@model.save!(validate: false)
flash[:error] = build_error_messages(@model).join(", ")
render 'workflow/step'
@application.save!(validate: false)
flash[:error] = build_error_messages(@application).join(", ")
render 'submit_your_application'
end
else
render 'workflow/step'
render 'submit_your_application'
end
end

def step
raise ActionController::UnknownFormat unless request.format.html?

authorize @application, :step?

if params[:id] == 1
redirect_to preferences_application_path(@application)
else
redirect_to submit_your_application_application_path(@application)
end
# rubocop:enable Metrics/BlockNesting
end
# rubocop:enable Metrics/AbcSize

def copy
authorize @application, :copy?
Expand Down Expand Up @@ -380,7 +384,7 @@ def enable_bs4_layout

def resolve_layout
case action_name
when "edit", "step", "review_and_submit", "eligibility_response_error", "application_publish_error"
when "edit", "step", "review_and_submit", "eligibility_response_error", "application_publish_error", "preferences", "submit_your_application"
"financial_assistance_nav"
when "application_year_selection", "application_checklist"
EnrollRegistry.feature_enabled?(:bs4_consumer_flow) ? "financial_assistance_progress" : "financial_assistance"
Expand Down Expand Up @@ -562,6 +566,27 @@ def build_applicants_name_by_hbx_id_hash
hash[applicant.person_hbx_id] = applicant.full_name
end
end

def submit_and_publish_application_redirect_path
return { path: application_publish_error_application_path(@application), flash: { error: "Submission Error: Imported Application can't be submitted for Eligibity" } } if @application.imported?
return { path: application_publish_error_application_path(@application), flash: { error: build_error_messages(@application) } } unless @application.complete?

publish_result = determination_request_class.new.call(application_id: @application.id)

return { path: wait_for_eligibility_response_application_path(@application), flash: nil } if publish_result.success?

@application.unsubmit! if @application.may_unsubmit?

flash_message = case publish_result.failure
when Dry::Validation::Result
{ error: validation_errors_parser(publish_result.failure) }
when Exception
{ error: publish_result.failure.message }
else
{ error: "Submission Error: #{publish_result.failure}" }
end
{ path: application_publish_error_application_path(@application), flash: flash_message }
end
end
end

Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,38 @@ def step?
edit?
end

# Determines if the current user has permission to get to the preferences page of the application.
# The user can proceed if they have permission to edit the application.
#
# @return [Boolean] Returns true if the user has permission to proceed to get to the preferences page of the application, false otherwise.
def preferences?
edit?
end

# Determines if the current user has permission to save the preferences page of the application.
# The user can proceed if they have permission to edit the application.
#
# @return [Boolean] Returns true if the user has permission to proceed to save the preferences page of the application, false otherwise.
def save_preferences?
edit?
end

# Determines if the current user has permission to get to the submit your application page of the application.
# The user can proceed if they have permission to edit the application.
#
# @return [Boolean] Returns true if the user has permission to proceed to get to the submit your application page of the application, false otherwise.
def submit_your_application?
edit?
end

# Determines if the current user has permission to submit the application.
# The user can proceed if they have permission to edit the application.
#
# @return [Boolean] Returns true if the user has permission to submit the application, false otherwise.
def submit?
edit?
end

# Determines if the current user has permission to copy the application.
# The user can copy the application if they have permission to edit it.
#
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<%= form_for @application, url: {action: "save_preferences"}, method: :put do |f| %>
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-12 row">
<div class="col-md-9">
<div class="">
<p class="alert alert-error hide"></p>
<div class="row">
<div class="col-md-10">
<h2 class="fa-darkblue">Your Preferences</h2>
</div>
</div>
<p>Tell us your preferences. When you're finished, select CONTINUE.</p>
<p class="memo">* = required field</p>
<div class="focus_effect module">
<div class="margin-bottom-30">
<div class="row row-form-wrapper radio-align no-buffer row-height yml-row small-padding-top-bottom">
<div class="col-md-6">
To make it easier to determine my eligibility for premium reductions in future years, I agree to allow <short-name-placeholder> to use my income data, including information from tax returns, for the next five years. <short-name-placeholder> will send me a notice, let me make any changes, and I can opt out at any time. *<br>
</div>
<div class="col-md-3">
<%= f.radio_button("is_renewal_authorized", true, class: "radio-yml", id: "eligibility_easier_yes") %>
<label class="radio-yml" for="eligibility_easier_yes">I agree</label>
</div>
<div class='col-md-3'>
<%= f.radio_button("is_renewal_authorized", false, class: "radio-yml", id: "eligibility_easier_no") %>
<label class="radio-yml" for="eligibility_easier_no">I disagree</label>
</div>
</div>
<div class="row row-form-wrapper radio-align no-buffer row-height yml-row small-padding-top-bottom">
<div class="col-md-12">
When it’s time to renew or change coverage, I authorize <%= ::EnrollRegistry[:enroll_app].setting(:short_name).item %> to automatically check my federal income tax returns for the sole purpose of redetermining my eligibility.
</div>
</div>
<div class="row row-form-wrapper radio-align no-buffer row-height yml-row small-padding-top-bottom">
<div class="col-md-12">
How long would you like your eligibility for premium reductions to be renewed? *
</div>
<div class="col-md-12">
<%= f.radio_button("years_to_renew", 5, class: "radio-yml") %>
<label class="radio-yml span-text">5 years</label>
</div>
<div class="col-md-12">
<%= f.radio_button("years_to_renew", 4, class: "radio-yml") %>
<label class="radio-yml span-text">4 years</label>
</div>
<div class="col-md-12">
<%= f.radio_button("years_to_renew", 3, class: "radio-yml") %>
<label class="radio-yml span-text">3 years</label>
</div>
<div class="col-md-12">
<%= f.radio_button("years_to_renew", 2, class: "radio-yml") %>
<label class="radio-yml span-text">2 years</label>
</div>
<div class="col-md-12">
<%= f.radio_button("years_to_renew", 1, class: "radio-yml") %>
<label class="radio-yml span-text">1 years</label>
</div>
<div class="col-md-12">
<%= f.radio_button("years_to_renew", 0, class: "radio-yml") %>
<label class="radio-yml span-text radio-inline-override label-max-width-renew">None. I understand that this means I won't get cost savings in future years unless I change my mind and tell <%= ::EnrollRegistry[:enroll_app].setting(:short_name).item %>.</label>
</div>
</div>
</div>
<% if FinancialAssistanceRegistry.feature_enabled?(:voter_registration_through_hbx) %>
<div class="margin-bottom-30 clear mt-4">
<h2 class="darkblue">Voter Registration</h2>
<div class="row row-form-wrapper radio-align no-buffer row-height yml-row small-padding-top-bottom">
<div class="col-md-8">
Would you like to register to vote in <%= aca_state_abbreviation %> or update your current registration? * (A form will be mailed to you)
</div>
<div class="col-md-2">
<%= f.radio_button("is_requesting_voter_registration_application_in_mail", true, class: "radio-yml", id: "mailed_yes") %>
<label class="radio-yml" for="mailed_yes">Yes</label>
</div>
<div class="col-md-2">
<%= f.radio_button("is_requesting_voter_registration_application_in_mail", false, class: "radio-yml", id: "mailed_no") %>
<label class="radio-yml" for="mailed_no">No</label>
</div>
</div>
<div class="row row-form-wrapper radio-align no-buffer row-height yml-row small-padding-top-bottom">
<div class="col-md-12">
<b>PLEASE NOTE:</b> If you select 'No' you will be considered to have decided not to have requested a voter registration form at this time.<br><br>
You may file a complaint if you believe that someone has interfered with: <br><br>
* Your right to register or not register to vote <br>
* Your right to privacy in deciding whether or not to register to vote <br>
* Your right to choose your own political party or other political choice <br><br>

<b>To file a complaint, contact:</b><br>
<%= Settings.contact_center.board_of_elections_entity %> <br>
<%= h(raw(Settings.contact_center.board_of_elections_address)) %> <br>
<%= Settings.contact_center.board_of_elections_email %> <br>
Phone: <%= Settings.contact_center.board_of_elections_phone_number %>
</div>
</div>
</div>
<% end %>
<% if FinancialAssistanceRegistry.feature_enabled?(:voter_registration_through_ext_url) %>
<div class="margin-bottom-30 clear mt-4">
<h2 class="darkblue">Voter Registration</h2>
<div class="row row-form-wrapper radio-align no-buffer row-height yml-row small-padding-top-bottom">
<div class="col-md-12">
If you are not registered to vote where you live now and would like to apply to register to vote, visit: <a href='https://www.maine.gov/sos/cec/elec/voter-info/voterguide.html?ref=voteusa' target='_blank' rel='noopener noreferrer'>https://www.maine.gov/sos/cec/elec/voter-info/voterguide.html?ref=voteusa</a>.
</div>
</div>
</div>
<% end %>
</div>
<div class="row">
<div class="col-xs-12">
<div class="back-link">
<i class="fa fa-caret-left fa-2x" aria-hidden="true"></i>
<a href="javascript:void(0);" onclick="notifyUserPrompt(this)" data-path="<%= financial_assistance.edit_application_path(@application) %>"> <b>BACK TO ALL HOUSEHOLD MEMBERS</b> </a> <span>(Go back and work on another person)</span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<%= submit_tag 'CONTINUE', :class => "btn btn-lg btn-primary btn-block" %>
<p class="small-left-margin very-small-margin-top faded">
<ul class='list-unstyled list-right-section'>
<li>
<%= h(link_to(financial_assistance.review_and_submit_application_path(@application)) do %>
PREVIOUS
<% end) %>
</li>
<li>
<a href="#">
SAVE &amp; EXIT
</a>
<br>
<br>
</li>
<li>
<p>
If you select Save &amp; Exit, you can save your work and continue where you left off the next time you login.
</p>
</li>
<br class="clear">
</ul>
</p>
<div id="help_me_sign_up" tabindex="0" onkeydown="handleButtonKeyDown(event, 'help_me_sign_up')" class="btn btn-default btn-block help-me-sign-up" data-target="#help_with_plan_shopping" data-toggle="modal">
Help me sign up
</div>
<%= render partial: './ui-components/v1/modals/help_with_plan' %>
</div>
</div>
<% end %>

<%= render partial: '/financial_assistance/shared/to_previous_modal' %>
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,6 @@
</div>

<div class='col-md-3'>
<%= render partial: 'financial_assistance/shared/right_nav', locals: {previous_url: @application.active_applicants.count > 1 ? financial_assistance.application_relationships_path(@application) : edit_application_path(@application), next_url: go_to_step_application_path(@application, 1), disabled: @application.incomplete_applicants? ? 'true' : false} %>
<%= render partial: 'financial_assistance/shared/right_nav', locals: {previous_url: @application.active_applicants.count > 1 ? financial_assistance.application_relationships_path(@application) : edit_application_path(@application), next_url: preferences_application_path(@application), disabled: @application.incomplete_applicants? ? 'true' : false} %>
</div>
</div>
Loading

0 comments on commit 0ec06d1

Please sign in to comment.