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-15901: Removes facilities not in user sections #16663

Merged
merged 2 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 10 additions & 3 deletions docroot/modules/custom/va_gov_backend/va_gov_backend.module
Original file line number Diff line number Diff line change
Expand Up @@ -419,12 +419,12 @@ function va_gov_backend_form_alter(&$form, FormStateInterface $form_state, $form
// Only run when on a node.
// Additionally, reduce the number of times called when editing a paragraph,
// which will have a triggering_element set.
if (isset($form['#entity_type'])
&& $form['#entity_type'] === 'node'
&& (!$form_state->getTriggeringElement())) {
$base_form_id = $form_state->getBuildInfo()['base_form_id'] ?? '';
if ((!$form_state->getTriggeringElement()) && ($base_form_id === "node_form")) {
$targets = [
'field_office',
'field_listing',
'field_facility_location',
];
_va_gov_backend_dropdown_field_access($form, $targets);
}
Expand Down Expand Up @@ -1045,6 +1045,13 @@ function _va_gov_backend_dropdown_field_access(array &$form, array $targets) {
}
}
}
elseif (!empty($option_header)) {
// If not an array, it's just an option.
// If not in the allowed items array, take it out.
if (!in_array($header_key, $allowed_options)) {
unset($form[$target]['widget']['#options'][$header_key]);
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@content_type__vba_facility_service
Feature: CMS User may effectively interact with the VBA Facility service form
In order to confirm that cms user have access to the necessary functionality
As anyone involved in the project
I need to have certain functionality available

Scenario: Log in and try to create a VBA Facility service as a VBA editor
When I am logged in as a user with the roles "content_creator_vba, content_publisher"
And my workbench access sections are set to "1065"
And I am at "/node/add/vba_facility_service"
Then I should see an option with the text "Columbia VA Regional Benefit Office" from dropdown with selector "#edit-field-office"
And I should not see an option with the text "Cheyenne VA Regional Benefit Office" from dropdown with selector "#edit-field-office"

Scenario: Log in and try to create a VBA Facility service as a VBA editor with 2 sections
When I am logged in as a user with the roles "content_creator_vba, content_publisher"
And my workbench access sections are set to "1065,1104"
And I am at "/node/add/vba_facility_service"
Then I should see an option with the text "Cheyenne VA Regional Benefit Office" from dropdown with selector "#edit-field-office"
And I should see an option with the text "Columbia VA Regional Benefit Office" from dropdown with selector "#edit-field-office"
And I should not see an option with the text "Denver VA Regional Benefit Office" from dropdown with selector "#edit-field-office"

Loading