Skip to content

Commit

Permalink
Merge branch 'main' into 20140-editors-receiving-warning-about-accept…
Browse files Browse the repository at this point in the history
…ing-cookies-in-the-browser
  • Loading branch information
timcosgrove authored Jan 9, 2025
2 parents 315680a + 3ce85b1 commit 920c028
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 31 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
"symfony/phpunit-bridge": "^7.1",
"symfony/process": "^6.3",
"symfony/routing": "^6.3",
"va-gov/content-build": "^0.0.3659",
"va-gov/content-build": "^0.0.3660",
"vlucas/phpdotenv": "^5.6",
"webflo/drupal-finder": "1.3.1",
"webmozart/path-util": "^2.3",
Expand Down
6 changes: 3 additions & 3 deletions composer.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "f9cd350a249e3227e672591dc48416f7",
"content-hash": "7b2474a144b44203d4b8453a2d4ce1de",
"packages": [
{
"name": "asm89/stack-cors",
Expand Down Expand Up @@ -26902,7 +26902,7 @@
},
{
"name": "va-gov/content-build",
"version": "v0.0.3659",
"version": "v0.0.3660",
"source": {
"type": "git",
"url": "https://github.com/department-of-veterans-affairs/content-build.git",
Expand Down Expand Up @@ -26938,7 +26938,7 @@
"description": "Front-end for VA.gov. This repository contains the code that generates the www.va.gov website. It contains a Metalsmith static site builder that uses a Drupal CMS for content. This file is here to publish releases to https://packagist.org/packages/va-gov/content-build, so that the CMS CI system can install it and update it using standard composer processes, and so that we can run tests across both systems. See https://github.com/department-of-veterans-affairs/va.gov-cms for the CMS repo, and stand by for more documentation.",
"support": {
"issues": "https://github.com/department-of-veterans-affairs/content-build/issues",
"source": "https://github.com/department-of-veterans-affairs/content-build/tree/v0.0.3659"
"source": "https://github.com/department-of-veterans-affairs/content-build/tree/v0.0.3660"
},
"time": "2025-01-07T17:22:23+00:00"
},
Expand Down
1 change: 0 additions & 1 deletion config/sync/feature_toggle.features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ _core:
default_config_hash: daCVJgiGNXHoQmWA2-cvaQEapbq7AGlBQtopOWTqqlw
features:
feature_all_hub_side_navs: FEATURE_ALL_HUB_SIDE_NAVS
feature_email_update_widget: FEATURE_EMAIL_UPDATE_WIDGET
feature_health_connect_number: FEATURE_HEALTH_CONNECT_NUMBER
feature_next_story_preview: FEATURE_NEXT_STORY_PREVIEW
feature_decision_review_rum: FEATURE_DECISION_REVIEW_RUM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drupal\Core\Config\Entity\ConfigEntityType;
use Drupal\Core\Entity\EntityTypeManager;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\core_event_dispatcher\EntityHookEvents;
use Drupal\core_event_dispatcher\Event\Entity\EntityPresaveEvent;
Expand Down Expand Up @@ -239,6 +240,8 @@ public function lockCentralizedContentFields(array &$form) {
public function formWidgetAlter(WidgetSingleElementFormAlterEvent $event): void {
$form = &$event->getElement();
$this->removeCollapseButton($form);
$form_state = $event->getFormState();
$this->removePhoneLabel($form, $form_state);
}

/**
Expand All @@ -253,4 +256,49 @@ public function removeCollapseButton(array &$form) {
}
}

/**
* Removes the phone label from certain forms.
*
* @param array $form
* The form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The form_state.
*/
public function removePhoneLabel(array &$form, FormStateInterface $form_state): void {
if (!empty($form['#field_parents']) && in_array('field_telephone', $form['#field_parents'])) {

if ($form['#title'] === 'Label') {
$form_id = $form_state->getFormObject()->getFormId();

// The forms that should not have phone labels.
$forms_without_phone_labels = [
'node_person_profile_form',
'node_person_profile_edit_form',
'node_health_care_local_facility_form',
'node_health_care_local_facility_edit_form',
'node_vamc_system_billing_insurance_form',
'node_vamc_system_billing_insurance_edit_form',
];

if (in_array($form_id, $forms_without_phone_labels)) {
// Hide the field on the form.
$form['#access'] = FALSE;
// Set the default value to 'Label' to satisfy the required field.
// Otherwise, it will throw an validation error.
switch ($form_id) {
case 'node_health_care_local_facility_form':
case 'node_health_care_local_facility_edit_form':
$form['value']['#default_value'] = 'Mental health phone';
break;

default:
$form['value']['#default_value'] = 'Phone';
break;

}
}
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public function entityTypeAlter(EntityTypeAlterEvent $event): void {
*/
public function alterstaffProfileNodeForm(FormIdAlterEvent $event): void {
$this->addStateManagementToBioFields($event);
$this->removePhoneLabel($event);
}

/**
Expand Down Expand Up @@ -131,15 +130,4 @@ public function addStateManagementToBioFields(FormIdAlterEvent $event) {
];
}

/**
* Removes the phone label on staff profile content type forms.
*
* @param \Drupal\core_event_dispatcher\Event\Form\FormIdAlterEvent $event
* The form event.
*/
private function removePhoneLabel(FormIdAlterEvent $event): void {
$form = &$event->getForm();
$form['field_telephone']['widget'][0]['subform']['field_phone_label']['#access'] = FALSE;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -304,17 +304,6 @@ public function addCovidStatusData(array &$form, FormStateInterface $form_state)
}
}

/**
* Removes the phone label on VAMC facility content type forms.
*
* @param \Drupal\core_event_dispatcher\Event\Form\FormIdAlterEvent $event
* The event.
*/
private function removePhoneLabel(FormIdAlterEvent $event): void {
$form = &$event->getForm();
$form['field_telephone']['widget'][0]['subform']['field_phone_label']['#access'] = FALSE;
}

/**
* Alter VAMC Facility node form.
*
Expand All @@ -325,7 +314,6 @@ public function alterFacilityNodeForm(FormIdAlterEvent $event): void {
$form = &$event->getForm();
$form_state = $event->getFormState();
$this->addCovidStatusData($form, $form_state);
$this->removePhoneLabel($event);
}

/**
Expand Down Expand Up @@ -359,7 +347,6 @@ public function alterTopTaskNodeForm(FormIdAlterEvent $event): void {
*/
public function alterVamcSystemBillingAndInsuranceForm(FormIdAlterEvent $event) {
$this->alterTopTaskNodeForm($event);
$this->removePhoneLabel($event);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,15 @@ Scenario: Log in and create a Person Profile with attention to conditional field
And I fill in "Last name" with "Smith"
And I click the "Add Phone number" button
And I wait "5" seconds
And I fill in field with selector "[data-drupal-selector='edit-field-telephone-0-subform-field-phone-number-0-value']" with value "402-867-5309"
And I fill in field with selector "[data-drupal-selector*='subform-field-phone-number-0-value']" with value "402-867-5309"
And I fill in field with selector "#edit-revision-log-0-value" with value "[Test Data] Revision log message."
And I click the "Remove" button
And I wait "5" seconds
And I click the "Confirm removal" button
And I wait "5" seconds
And I click the "Add Phone number" button
And I wait "5" seconds
And I fill in field with selector "[data-drupal-selector*='subform-field-phone-number-0-value']" with value "402-867-5309"
And I click the "Save" button
Then I should see "Staff Profile James Smith has been created."

Expand Down

0 comments on commit 920c028

Please sign in to comment.