Modified page titles to give more info
Also removed conditional link back to case list from a case - it only appears sometimes, so it is more confusing to have it than not.
This commit is contained in:
parent
c909a51c1c
commit
c1c981fddd
@ -7,6 +7,32 @@
|
||||
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_page_title
|
||||
*
|
||||
* Modify the page title to include more information
|
||||
*/
|
||||
function opencase_preprocess_page_title(&$variables) {
|
||||
|
||||
$route_name = \Drupal::routeMatch()->getRouteName();
|
||||
switch ($route_name) {
|
||||
case 'entity.oc_case.canonical':
|
||||
$case = \Drupal::routeMatch()->getParameter('oc_case');
|
||||
$variables['title'] = $case->getName() . ": Case Details and Files";
|
||||
break;
|
||||
case 'view.cases.page_1':
|
||||
$actor_id = \Drupal::routeMatch()->getParameter('actor_id');
|
||||
$actor = \Drupal::entityTypeManager()->getStorage('oc_actor')->load($actor_id);
|
||||
$variables['title'] = $actor->getName() . ": Cases";
|
||||
break;
|
||||
case 'view.activities.page_1':
|
||||
$case_id = \Drupal::routeMatch()->getParameter('case_id');
|
||||
$case = \Drupal::entityTypeManager()->getStorage('oc_case')->load($case_id);
|
||||
$variables['title'] = $case->getName() . ": Activities";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
*/
|
||||
|
@ -76,27 +76,12 @@ class ContextualMenu extends BlockBase {
|
||||
|
||||
/**
|
||||
* Contextual menu for Case page
|
||||
* - Link to case list if user has just come from there
|
||||
* - Link to Activity list for that case
|
||||
*/
|
||||
private function casePage() {
|
||||
|
||||
$links = [];
|
||||
|
||||
// Ascertain if user has come from a case list and if so link back
|
||||
// This is fragle code, it needs doing better.
|
||||
$referer = \Drupal::request()->headers->get('referer');
|
||||
$parts = parse_url($referer);
|
||||
$path_parts= explode('/', $parts[path]);
|
||||
if ($path_parts[4] == 'case_list') {
|
||||
$actor = \Drupal::entityTypeManager()->getStorage('oc_actor')->load($path_parts[3]);
|
||||
$links[] = $this->getCaseListLink($actor);
|
||||
}
|
||||
|
||||
// Now get the link to the activity list for the case.
|
||||
$case = \Drupal::routeMatch()->getParameter('oc_case');
|
||||
$links[] = $this->getActivityListLink($case);
|
||||
return $this->asNavLinks($links);
|
||||
$link = $this->getActivityListLink($case);
|
||||
return $this->asNavLinks([$link]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,7 +92,7 @@ class ContextualMenu extends BlockBase {
|
||||
private function activityListPage() {
|
||||
$case_id = \Drupal::routeMatch()->getParameter('case_id');
|
||||
$case = \Drupal::entityTypeManager()->getStorage('oc_case')->load($case_id);
|
||||
$link = Link::fromTextAndUrl(t($case->getName() .": Details and Files"), $case->toUrl())->toString();
|
||||
$link = Link::fromTextAndUrl(t($case->getName() .": Case Details and Files"), $case->toUrl())->toString();
|
||||
$markup = $this->asNavLinks([$link]);
|
||||
$current_path = \Drupal::service('path.current')->getPath();
|
||||
return $markup . Utils::generateAddLinks('oc_activity', "Add activity", ['case_id' => $case_id, 'destination' => $current_path]);
|
||||
@ -138,7 +123,7 @@ class ContextualMenu extends BlockBase {
|
||||
*/
|
||||
private function getCaseListLink($actor) {
|
||||
$url = Url::fromRoute('view.cases.page_1', array('actor_id' => $actor->id()));
|
||||
return Link::fromTextAndUrl(t("Case List for " . $actor->getName()), $url)->toString();
|
||||
return Link::fromTextAndUrl(t($actor->getName(). ": Cases"), $url)->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,6 @@ class GlobalMenu extends BlockBase {
|
||||
$markup .= Utils::generateAddLinks('oc_actor', 'Add new');
|
||||
$build['global_menu'] = [
|
||||
'#markup' => "<div id='opencase_global_menu'>$markup</div",
|
||||
'#cache' => ['max-age' => 0]
|
||||
];
|
||||
return $build;
|
||||
}
|
||||
|
Reference in New Issue
Block a user