Skip to content

Commit

Permalink
feat: DAH-3007 Skip application demographics page if autofilled (#2458)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimlin-sfgov authored Dec 16, 2024
1 parent 701811a commit 21e6f4d
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ ShortFormApplicationController = (
ShortFormNavigationService.goToApplicationPage('dahlia.short-form-application.general-lottery-notice')
else
# otherwise go to the Review section
ShortFormNavigationService.goToSection('Review')
$scope.goToDemographicsPageUnlessAutofilled()

$scope.checkPreferenceEligibility = (type = 'liveWorkInSf') ->
# this mainly gets used as one of the submit callbacks for relevant pages in ShortFormNavigationService
Expand Down Expand Up @@ -762,6 +762,12 @@ ShortFormApplicationController = (
page = ShortFormNavigationService.getPostHomeAndCommunityBasedServicesPage($scope.listing)
ShortFormNavigationService.goToApplicationPage("dahlia.short-form-application.#{page}")

$scope.goToDemographicsPageUnlessAutofilled = ->
if ShortFormApplicationService.APPLICATION_AUTOFILL_IMPROVEMENTS && ShortFormApplicationService.demographicsAreAutofilled()
ShortFormNavigationService.goToApplicationPage("dahlia.short-form-application.review-summary")
else
ShortFormNavigationService.goToApplicationPage("dahlia.short-form-application.review-optional")

$scope.hasHomeAndCommunityBasedServicesYes = ->
$scope.application.hasHomeAndCommunityBasedServices == 'Yes'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,13 @@ ShortFormApplicationService = (
Service.getProjectIdForBoundaryMatching = ->
ListingDataService.getProjectIdForBoundaryMatching(Service.listing)

Service.demographicsAreAutofilled = ->
Service.application.autofill &&
Service.application.applicant &&
_.some(ShortFormDataService.demographicFields, (field) -> !!Service.application.applicant[field])

Service.APPLICATION_AUTOFILL_IMPROVEMENTS = $window.APPLICATION_AUTOFILL_IMPROVEMENTS

return Service

############################################################################################
Expand Down
19 changes: 19 additions & 0 deletions app/assets/javascripts/short-form/ShortFormDataService.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,25 @@ ShortFormDataService = (ListingDataService, ListingConstantsService, ListingPref
'isVeteran',
]

Service.demographicFields = [
'asianOther',
'blackOther',
'gender',
'genderOther',
'indigenousCentralSouthAmericaGroup',
'indigenousNativeAmericanGroup',
'indigenousOther',
'latinoOther',
'menaOther',
'otherLanguage',
'pacificIslanderOther',
'primaryLanguage'
'raceEthnicity',
'sexualOrientation',
'sexualOrientationOther'
'whiteOther',
]

Service.showVeteransApplicationQuestion = ->
SharedService.showVeteransApplicationQuestion(ListingDataService.listing)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ ShortFormNavigationService = (
'veterans-preference': {scopedCallbacks: [{func: 'checkAfterVeteransPreference'}]}
'custom-preferences': {scopedCallbacks: [{func: 'checkForCustomProofPreferences'}]}
'custom-proof-preferences': {scopedCallbacks: [{func: 'checkForCustomProofPreferences'}]}
'general-lottery-notice': {callbacks: [Service.goToSection.bind(null, 'Review')]}
'general-lottery-notice': {scopedCallbacks: [{func: 'goToDemographicsPageUnlessAutofilled'}]}
# review
# TODO -> not sure what this does, just says the next page?
'review-optional': {path: 'review-summary'}
Expand Down Expand Up @@ -351,6 +351,8 @@ ShortFormNavigationService = (
,'alternate-contact-phone-address'
,'household-overview'
,'preferences-intro'
# prev page is not deterministic for review-summary (we may skip demographics page)
# but it doesn't matter because we hide the back button for this page
,'review-summary'
,'review-terms'
Service._getPreviousPage()
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/application-angular.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,4 @@ html lang="en" ng-app="dahlia" ng-strict-di="" ng-controller="SharedController"
var AUTOSAVE = "#{ENV['AUTOSAVE']}"
// Add react feature flags below this line
var ACCOUNT_INFORMATION_PAGES_REACT = "#{ENV['ACCOUNT_INFORMATION_PAGES_REACT']}"
var APPLICATION_AUTOFILL_IMPROVEMENTS = "#{ENV['APPLICATION_AUTOFILL_IMPROVEMENTS']}"

0 comments on commit 21e6f4d

Please sign in to comment.