Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VACMS-17426: Requires VA facility location when the event is using a VA facility location type #17859

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docroot/modules/custom/va_gov_events/js/eventFormHelpers.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
const fieldFacilityLocation = document.getElementById(
"edit-field-facility-location-0-target-id"
);
const fieldFacilityLocationLabel = document.querySelector(
"label[for='edit-field-facility-location-0-target-id']"
);
const fieldLocationTypeOnline = document.getElementById(
"edit-field-location-type-online"
);
Expand Down Expand Up @@ -292,11 +295,22 @@
}
};

const toggleFacilityLocationRequiredFields = (enableDisable, addRemove) => {
dsasser marked this conversation as resolved.
Show resolved Hide resolved
// Facility location field.
if (fieldFacilityLocation) {
fieldFacilityLocation.setAttribute("required", "required");
}
if (fieldFacilityLocationLabel) {
fieldFacilityLocationLabel.classList[addRemove]("form-required");
}
};

const toggleLocationElements = () => {
targetLocationElements.forEach((element) => {
element.style.display = "none";
});
toggleAddressRequiredFields(false, "remove");
toggleFacilityLocationRequiredFields(false, "remove");
if (fieldLocationTypeFacility.checked) {
fieldFacilityLocationWrapper.style.display = "block";
fieldLocationHumanreadableWrapper.style.display = "block";
Expand All @@ -305,6 +319,7 @@
fieldAddressLine2.value = "";
fieldAddressLocality.value = "";
fieldAddressAdminArea.value = "";
toggleFacilityLocationRequiredFields(true, "add");
}
if (fieldLocationTypeNonFacility.checked) {
fieldLocationHumanreadableWrapper.style.display = "block";
Expand Down
11 changes: 11 additions & 0 deletions docroot/modules/custom/va_gov_events/js/eventFormHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
var targetLocationElements = document.querySelectorAll("#edit-field-facility-location-wrapper, #edit-field-url-of-an-online-event-wrapper, #edit-field-location-humanreadable-wrapper, #edit-field-address-wrapper");
var fieldFacilityLocationWrapper = document.getElementById("edit-field-facility-location-wrapper");
var fieldFacilityLocation = document.getElementById("edit-field-facility-location-0-target-id");
var fieldFacilityLocationLabel = document.querySelector("label[for='edit-field-facility-location-0-target-id']");
var fieldLocationTypeOnline = document.getElementById("edit-field-location-type-online");
var fieldAddressWrapper = document.getElementById("edit-field-address-wrapper");
var fieldUrlOfOnlineEvent = document.getElementById("edit-field-url-of-an-online-event-0-uri");
Expand Down Expand Up @@ -135,11 +136,20 @@
fieldAddressAdminAreaLabel.classList[addRemove]("form-required");
}
};
var toggleFacilityLocationRequiredFields = function toggleFacilityLocationRequiredFields(enableDisable, addRemove) {
if (fieldFacilityLocation) {
fieldFacilityLocation.setAttribute("required", "required");
}
if (fieldFacilityLocationLabel) {
fieldFacilityLocationLabel.classList[addRemove]("form-required");
}
};
var toggleLocationElements = function toggleLocationElements() {
targetLocationElements.forEach(function (element) {
element.style.display = "none";
});
toggleAddressRequiredFields(false, "remove");
toggleFacilityLocationRequiredFields(false, "remove");
if (fieldLocationTypeFacility.checked) {
fieldFacilityLocationWrapper.style.display = "block";
fieldLocationHumanreadableWrapper.style.display = "block";
Expand All @@ -148,6 +158,7 @@
fieldAddressLine2.value = "";
fieldAddressLocality.value = "";
fieldAddressAdminArea.value = "";
toggleFacilityLocationRequiredFields(true, "add");
}
if (fieldLocationTypeNonFacility.checked) {
fieldLocationHumanreadableWrapper.style.display = "block";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Feature: Content Type: Event
And I fill in autocomplete field with selector "#edit-field-url-of-an-online-event-0-uri" with value "https://va.gov"
And I select the "At a VA facility" radio button
Then an element with the selector "#edit-field-facility-location-0-target-id" should be empty
And the element with selector "#edit-field-facility-location-0-target-id" should have attribute "required"
When I select the "At a non-VA location" radio button
Then an element with the selector "#edit-field-address-0-address-address-line1" should be empty
And an element with the selector "#edit-field-address-0-address-locality" should be empty
Expand Down
Loading