Added case list link to add-new-case page

This commit is contained in:
naomi 2018-05-08 13:21:12 +02:00
parent 555087f3b2
commit 80f42c7bf3
3 changed files with 40 additions and 3 deletions

View File

@ -79,7 +79,7 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface {
* id from the URL.
*/
public static function defaultVal() {
return \Drupal::request()->query->get('actor_id');;
return \Drupal::request()->query->get('actor_id');
}
/**

View File

@ -19,12 +19,17 @@ function opencase_block_access(\Drupal\block\Entity\Block $block, $operation, \D
$route_name = \Drupal::routeMatch()->getRouteName();
$routes_where_it_should_be_shown = [
'entity.oc_actor.canonical',
'entity.oc_actor.edit_form',
'entity.oc_actor.add_form',
'view.cases.page_1',
'entity.oc_case.canonical',
'entity.oc_case.edit_form',
'entity.oc_case.add_form',
'view.activities.page_1',
'entity.oc_activity.canonical'
'entity.oc_activity.canonical',
'entity.oc_activity.edit_form',
'entity.oc_activity.add_form'
];
error_log(!in_array($route_name, $routes_where_it_should_be_shown));
return \Drupal\Core\Access\AccessResult::forbiddenIf(!in_array($route_name, $routes_where_it_should_be_shown))
->addCacheableDependency($block);
}

View File

@ -28,20 +28,29 @@ class ContextualMenu extends BlockBase {
$route_name = \Drupal::routeMatch()->getRouteName();
switch ($route_name) {
case 'entity.oc_actor.canonical':
case 'entity.oc_actor.edit_form':
$markup = $this->actorPage();
break;
case 'view.cases.page_1':
$markup = $this->caseListPage();
break;
case 'entity.oc_case.canonical':
case 'entity.oc_case.edit_form':
$markup = $this->casePage();
break;
case 'entity.oc_case.add_form':
$markup = $this->caseAddPage();
break;
case 'view.activities.page_1':
$markup = $this->activityListPage();
break;
case 'entity.oc_activity.canonical':
case 'entity.oc_activity.edit_form':
$markup = $this->activityPage();
break;
case 'entity.oc_activity.add_form':
$markup = $this->activityAddPage();
break;
}
$build = [];
@ -87,6 +96,17 @@ class ContextualMenu extends BlockBase {
return $this->asNavLinks([$link]);
}
/**
* Contextual menu for Add-New-Case page
* - Link to Case list for the actor
*/
private function caseAddPage() {
$actor_id = \Drupal::request()->query->get('actor_id');
$actor = \Drupal::entityTypeManager()->getStorage('oc_actor')->load($actor_id);
$link = $this->getCaseListLink($actor);
return $this->asNavLinks([$link]);
}
/**
* Contextual menu for Activity list page
* - Link to the case that the activity list is for
@ -113,6 +133,18 @@ class ContextualMenu extends BlockBase {
}
/**
* Contextual menu for Add-New-Activity page
* - Links to the activity list for the case
*/
private function activityAddPage() {
$case_id = \Drupal::request()->query->get('case_id');
$case = \Drupal::entityTypeManager()->getStorage('oc_case')->load($case_id);
$link = $this->getActivityListLink($case);
return $this->asNavLinks([$link]);
}
/**
* Given an case entity, returns a link to the activity list
*/