diff --git a/app/assets/javascripts/short-form/ShortFormApplicationController.js.coffee b/app/assets/javascripts/short-form/ShortFormApplicationController.js.coffee index 87a4948b1..9455a4463 100644 --- a/app/assets/javascripts/short-form/ShortFormApplicationController.js.coffee +++ b/app/assets/javascripts/short-form/ShortFormApplicationController.js.coffee @@ -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 @@ -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' diff --git a/app/assets/javascripts/short-form/ShortFormApplicationService.js.coffee b/app/assets/javascripts/short-form/ShortFormApplicationService.js.coffee index a5b6d849a..0022c893c 100644 --- a/app/assets/javascripts/short-form/ShortFormApplicationService.js.coffee +++ b/app/assets/javascripts/short-form/ShortFormApplicationService.js.coffee @@ -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 ############################################################################################ diff --git a/app/assets/javascripts/short-form/ShortFormDataService.js.coffee b/app/assets/javascripts/short-form/ShortFormDataService.js.coffee index ec2bce39c..09ebb18c1 100644 --- a/app/assets/javascripts/short-form/ShortFormDataService.js.coffee +++ b/app/assets/javascripts/short-form/ShortFormDataService.js.coffee @@ -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) diff --git a/app/assets/javascripts/short-form/ShortFormNavigationService.js.coffee b/app/assets/javascripts/short-form/ShortFormNavigationService.js.coffee index 1ec0afc8f..fb24f889f 100644 --- a/app/assets/javascripts/short-form/ShortFormNavigationService.js.coffee +++ b/app/assets/javascripts/short-form/ShortFormNavigationService.js.coffee @@ -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'} @@ -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() diff --git a/app/views/layouts/application-angular.html.slim b/app/views/layouts/application-angular.html.slim index 3a23f449c..76cfb5f62 100644 --- a/app/views/layouts/application-angular.html.slim +++ b/app/views/layouts/application-angular.html.slim @@ -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']}"