From a54e1c0a62ee73bceebf8ef46ed9faa2c777187d Mon Sep 17 00:00:00 2001 From: Michael Stenta Date: Mon, 20 Sep 2021 16:42:36 -0400 Subject: [PATCH] Add help text to /assets, /logs, /quantities, and /plans. --- modules/core/ui/views/farm_ui_views.module | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/modules/core/ui/views/farm_ui_views.module b/modules/core/ui/views/farm_ui_views.module index 3996c83a..db4717f0 100644 --- a/modules/core/ui/views/farm_ui_views.module +++ b/modules/core/ui/views/farm_ui_views.module @@ -6,8 +6,58 @@ */ use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\Core\Url; use Drupal\views\ViewExecutable; +/** + * Implements hook_help(). + */ +function farm_ui_views_help($route_name, RouteMatchInterface $route_match) { + $output = ''; + + // Define route names and URLs for primary entity types. + $entity_routes = [ + 'asset' => 'entity.asset.collection', + 'log' => 'entity.log.collection', + 'quantity' => 'view.farm_quantity.page', + 'plan' => 'entity.plan.collection', + 'people' => 'view.farm_people.page', + ]; + $entity_urls = [ + 'asset' => Url::fromRoute($entity_routes['asset'])->toString(), + 'log' => Url::fromRoute($entity_routes['log'])->toString(), + 'quantity' => Url::fromRoute($entity_routes['quantity'])->toString(), + 'plan' => Url::fromRoute($entity_routes['plan'])->toString(), + 'people' => Url::fromRoute($entity_routes['people'])->toString(), + ]; + + // Assets View. + if ($route_name == $entity_routes['asset']) { + $output .= '

' . t('Assets represent things that are being tracked or managed. They store high-level information, but most historical data is stored in the logs that reference them.', [':logs' => $entity_urls['log']]) . '

'; + $output .= '

' . t('Assets that are no longer active can be archived. Archived assets will be hidden from most lists, but are preserved and searchable for posterity.') . '

'; + } + + // Logs View. + if ($route_name == $entity_routes['log']) { + $output .= '

' . t('Logs represent events that take place in relation to assets and other records. They have a timestamp to represent when they take place, and can be marked as "Pending" or "Done" for planning purposes.', [':assets' => $entity_urls['asset']]) . '

'; + $output .= '

' . t('Logs can be assigned to people for task management purposes.', [':people' => $entity_urls['people']]) . '

'; + } + + // Quantities View. + if ($route_name == $entity_routes['quantity']) { + $output .= '

' . t('Quantities are granular units of quantitative data that represent a single data point within a log.', [':logs' => $entity_urls['log']]) . '

'; + $output .= '

' . t('All quantities can optionally include a measure, value, units, and label. Specific quantity types may collect additional information.') . '

'; + } + + // Plans View. + if ($route_name == $entity_routes['plan']) { + $output .= '

' . t('Plans provide features for planning, managing, and organizing assets, logs, and people around a particular goal.', [':assets' => $entity_urls['asset'], ':logs' => $entity_urls['log'], ':people' => $entity_urls['people']]) . '

'; + } + + return $output; +} + /** * Implements hook_entity_type_build(). */