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-13214: Alphabetize all services and identify archived and draft services #17402

Merged
merged 3 commits into from
Mar 6, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.field--name-field-clinical-health-services a.node--unpublished {
padding: unset;
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,49 @@ public function __construct(
*/
public function entityViewAlter(EntityViewAlterEvent $event):void {
$this->showUnspecifiedWhenSystemEhrNumberEmpty($event);
$this->alterAppendedSystemHealthServices($event);

}

/**
* Alters health service titles appended to VAMC system view page.
*
* @param \Drupal\core_event_dispatcher\Event\Entity\EntityViewAlterEvent $event
* The entity view alter service.
*/
public function alterAppendedSystemHealthServices(EntityViewAlterEvent $event):void {
$display = $event->getDisplay();
if (($display->getTargetBundle() === 'health_care_region_page') && ($display->getOriginalMode() === 'full')) {
$build = &$event->getBuild();
$services = $build['field_clinical_health_services'] ?? [];

$services_copy = [];
foreach ($services as $key => $service) {
// If there are services (because their keys are numeric).
if (is_numeric($key) && !empty($service['#options']['entity'])) {
// Copy build array.
$services_copy[] = $build['field_clinical_health_services'][$key];
unset($build['field_clinical_health_services'][$key]);
$service_node = $services_copy[$key]['#options']['entity'];
$moderationState = $service_node->get('moderation_state')->value;
// Identify archive and draft in temp array.
if ($moderationState === 'archived' || $moderationState === 'draft') {
$services_copy[$key]['#attributes'] = ['class' => 'node--unpublished'];
$services_copy[$key]['#title'] .= ' (' . ucfirst($moderationState) . ')';
}
}
}
omahane marked this conversation as resolved.
Show resolved Hide resolved
// Sort temp array.
usort($services_copy, function ($x, $y) {
return strcasecmp($x['#title'], $y['#title']);
});
// Copy temporary array back to build array.
foreach ($services_copy as $key => $temp) {
$build['field_clinical_health_services'][$key] = $services_copy[$key];
}
$build['field_clinical_health_services']['#attached']['library'][] = 'va_gov_vamc/set_vamc_system_health_service';
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ set_covid_term_text:
css/set_covid_term_text.css: {}
js:
js/set_covid_term_text.js: {}

set_vamc_system_health_service:
css:
component:
css/set_vamc_system_health_service.css: {}
Loading