<?php

/**
 * @file
 * The farmOS UI Locations module.
 */

use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function farm_ui_location_help($route_name, RouteMatchInterface $route_match) {
  $output = '';

  // Locations overview help text.
  if ($route_name == 'farm.locations') {
    $output .= '<p>' . t('Locations represent places of interest. They are assets, and assets can be moved to them. Logs can reference them.') . '</p>';
    $output .= '<p>' . t('Locations can be organized into a hierarchy with parent relationships.') . '</p>';
  }

  // Child locations help text.
  if ($route_name == 'farm.asset.locations') {
    $output .= '<p>' . t('This page shows the sub-hierarchy of this location. It includes all location assets that list this location as their parent, as well as all of their children.') . '</p>';
  }

  // Drag and drop help text.
  if (in_array($route_name, ['farm.locations', 'farm.asset.locations'])) {
    $output .= '<p>' . t('To change the hierarchy, either click on individual assets and edit their parent, or click %toggle_button below to enable drag and drop editing on this page. The %save_button button will save changes, and %reset_button will reset them.', ['%toggle_button' => t('Toggle drag and drop'), '%save_button' => t('Save'), '%reset_button' => t('Reset')]) . '</p>';
  }

  return $output;
}
