forked from iisaphd/enroll
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Run eligibility check feature (#2463) * Eligibility check backend changes (#2460) * adds run eligibility check controller action and routes * adds specs * adds run eligibility route * Eligibility check authorization (#2465) * adds pundit policy for admin access only * fixes typo * fixes spec failures * Run eligibility check front (#2464) * Implement eligibility checks in front-end UI * removed placeholder button * Fixed failing specs * fixed mistyped javascript * Rails renders button_tag as a form with an input field, why selector was not being found. Working specs * Added Specs for Eligibility Check Partial * Moved Eligibility Spec to its correct directory * Added Translations for Run Eligibility button * resolved rubocop errors for files that aren't slim templates * fixed more rubocop issues, more are failing * removed comment * fixed route mispell * Added translations for the response text * fixed UI breaking from translations update --------- Co-authored-by: Utkarsh Shukla <utkarsh7989@gmail.com> * adds condition to display the button during OE period * PR revisions * fixes the row alignment issue --------- Co-authored-by: TonyHasIdeas <118292503+TonyHasIdeas@users.noreply.github.com> Co-authored-by: Antonio Irizarry <antonio.irizarry@ideacrew.com> Co-authored-by: Sri Harsha <sriharsha.poosa@gmail.com> * Wellsense provider search changes flash message (#2484) * adds wellsense flash message in benefit package and plan shopping pages * adds translation * adds wellsense flash message in bqt --------- Co-authored-by: Utkarsh Shukla <utkarsh7989@gmail.com> Co-authored-by: TonyHasIdeas <118292503+TonyHasIdeas@users.noreply.github.com> Co-authored-by: Antonio Irizarry <antonio.irizarry@ideacrew.com>
- Loading branch information
1 parent
69c038b
commit 7a74ce3
Showing
15 changed files
with
336 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
app/views/ui-components/v1/cards/_eligibility_check.html.slim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
.panel.panel-default#employee-enrollments | ||
.panel-body | ||
.run-eligibility-check-btn-container | ||
= button_to l10n("employers.plan_years.eligibility_button_text"), '/', class: "btn btn-default", id: "eligibilityCheckButton", data: { url: profiles_employers_employer_profile_run_eligibility_check_path(@employer_profile) } | ||
.col-xs-12.loading.run-eligibility-processing(style="display: none;") | ||
i.fa.fa-spinner.fa-spin.fa-2x | ||
.run-eligibility-check-response-container(style="display: none;") | ||
span.eligibility-response-close-icon | ||
| X | ||
.run-eligibility-check-response | ||
p.eligibility-status-text.minimum-participation | ||
=> l10n("employers.plan_years.minimum_participation_text") | ||
| | ||
span.not-eligible | ||
| ❌ | ||
span.is-eligible-checkmark style="display:none;" | ||
| ✔ | ||
p.eligibility-status-text.non-business-owner-eligibility-count | ||
=> l10n("employers.plan_years.non-business_owner_eligibility_count_text") | ||
| | ||
span.not-eligible | ||
| ❌ | ||
span.is-eligible-checkmark style="display:none;" | ||
| ✔ | ||
p.eligibility-status-text.minimum-eligible-member-count | ||
=> l10n("employers.plan_years.minimum_eligible_member_count_text") | ||
| | ||
span.not-eligible | ||
| ❌ | ||
span.is-eligible-checkmark style="display:none;" | ||
| ✔ | ||
|
||
|
||
javascript: | ||
document.getElementById('eligibilityCheckButton').addEventListener('click', function() { | ||
this.disabled = true; | ||
// Show Spinner | ||
$('#eligibilityCheckButton').hide(); | ||
$('.run-eligibility-processing').show(); | ||
// Fetch the URL from the data attribute | ||
var url = this.getAttribute('data-url'); | ||
$.ajax({ | ||
type: 'GET', | ||
data: {}, | ||
url: url, | ||
}).done(function(response) { | ||
$('.run-eligibility-processing').hide(); | ||
$('.run-eligibility-check-response-container').show(); | ||
interpretResponse = interpretValidation(response); | ||
updateEligibilityUI(interpretResponse); | ||
}); | ||
function interpretValidation(response) { | ||
// List of all attributes we are checking | ||
const attributes = ['minimum_participation_rule', 'non_business_owner_enrollment_count', 'minimum_eligible_member_count']; | ||
let result = {}; | ||
for (let attribute of attributes) { | ||
// If the attribute exists in the response and its value is 'validated successfully', then it's valid. | ||
if (response[attribute] && response[attribute] === 'validated successfully') { | ||
result[attribute] = true; | ||
} else if (response[attribute]) { // If the attribute exists in the response and its value isn't 'validated successfully', then it's invalid. | ||
result[attribute] = false; | ||
} else { // If the attribute doesn't exist in the response, then it's valid. | ||
result[attribute] = true; | ||
} | ||
} | ||
return result; | ||
} | ||
}); | ||
function updateEligibilityUI(interpretedResponse) { | ||
// Getting all the p tags within the parent div | ||
const eligibilityStatusElements = document.querySelectorAll(".run-eligibility-check-response .eligibility-status-text"); | ||
eligibilityStatusElements.forEach(element => { | ||
// Based on the class of the p tag, deciding which attribute we are currently processing | ||
let attribute; | ||
if (element.classList.contains("minimum-participation")) { | ||
attribute = "minimum_participation_rule"; | ||
} else if (element.classList.contains("non-business-owner-eligibility-count")) { | ||
attribute = "non_business_owner_enrollment_count"; | ||
} else if (element.classList.contains("minimum-eligible-member-count")) { | ||
attribute = "minimum_eligible_member_count"; | ||
} | ||
if (interpretedResponse[attribute]) { | ||
// If true, show the checkmark and hide the cross | ||
element.querySelector('.is-eligible-checkmark').style.display = 'inline'; | ||
element.querySelector('.not-eligible').style.display = 'none'; | ||
} else { | ||
// If false, show the cross and hide the checkmark | ||
element.querySelector('.is-eligible-checkmark').style.display = 'none'; | ||
element.querySelector('.not-eligible').style.display = 'inline'; | ||
} | ||
}); | ||
} | ||
document.querySelector('.eligibility-response-close-icon').addEventListener('click', function() { | ||
// Hide the container | ||
$('.run-eligibility-check-response-container').hide(); | ||
// Hide the 'is-eligible-checkmark' and show the 'not-eligible' icon (original state) | ||
$('.is-eligible-checkmark').hide(); | ||
$('.not-eligible').show(); | ||
// Show the button and activate | ||
$('#eligibilityCheckButton').show().prop('disabled', false); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.