Moved everything relating to cases into opencase_cases module

This commit is contained in:
naomi 2021-02-08 17:27:18 +00:00
parent 2895dcdab8
commit 5afbeb956b
38 changed files with 107 additions and 103 deletions

View File

@ -0,0 +1,12 @@
entity.oc_case.add_form:
route_name: entity.oc_case.add_page
title: 'Add Case'
appears_on:
- entity.oc_case.collection
entity.oc_case_type.add_form:
route_name: entity.oc_case_type.add_form
title: 'Add Case type'
appears_on:
- entity.oc_case_type.collection

View File

@ -5,3 +5,21 @@ opencase_cases.manage_case_types:
parent: opencase.opencase_admin_menu
url: internal:/admin/opencase/oc_case_type
weight: 2
# Case menu items definition
entity.oc_case.collection:
title: 'Case list'
route_name: entity.oc_case.collection
description: 'List Case entities'
parent: system.admin_structure
weight: 100
# Case type menu items definition
entity.oc_case_type.collection:
title: 'Case type'
route_name: entity.oc_case_type.collection
description: 'List Case type (bundles)'
parent: system.admin_structure
weight: 99

View File

@ -0,0 +1,23 @@
# Case routing definition
entity.oc_case.canonical:
route_name: entity.oc_case.canonical
base_route: entity.oc_case.canonical
title: 'View'
entity.oc_case.edit_form:
route_name: entity.oc_case.edit_form
base_route: entity.oc_case.canonical
title: 'Edit'
entity.oc_case.version_history:
route_name: entity.oc_case.version_history
base_route: entity.oc_case.canonical
title: 'Revisions'
entity.oc_case.delete_form:
route_name: entity.oc_case.delete_form
base_route: entity.oc_case.canonical
title: Delete
weight: 10

View File

@ -31,6 +31,17 @@ function opencase_cases_theme() {
'opencase_cases' => [
'render element' => 'children',
],
'oc_case' => [
'render element' => 'elements',
'file' => 'oc_case.page.inc',
'template' => 'oc_case',
]
'oc_case_content_add_list' => [
'render element' => 'content',
'variables' => ['content' => NULL],
'file' => 'oc_case.page.inc',
]
];
];
}
@ -85,3 +96,45 @@ function _opencase_cases_delete_activity_redirect($form, &$form_state) {
$case_id = $form_state->getFormObject()->getEntity()->oc_case->target_id;
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]);
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function opencase_cases_theme_suggestions_oc_case(array $variables) {
$suggestions = [];
$entity = $variables['elements']['#oc_case'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'oc_case__' . $sanitized_view_mode;
$suggestions[] = 'oc_case__' . $entity->bundle();
$suggestions[] = 'oc_case__' . $entity->bundle() . '__' . $sanitized_view_mode;
$suggestions[] = 'oc_case__' . $entity->id();
$suggestions[] = 'oc_case__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
}
function opencase_views_query_alter(Drupal\views\ViewExecutable $view, $query) {
if ($view->getBaseEntityType() && $view->getBaseEntityType()->id() == 'oc_case') {
$query->addTag('oc_case_access');
}
if ($view->getBaseEntityType() && $view->getBaseEntityType()->id() == 'oc_activity') {
$query->addTag('oc_activity_access');
}
}
function opencase_query_oc_case_access_alter($query) {
if (\Drupal::currentUser()->hasPermission('view published case entities')) {
return;
}
$linked_actor_id = CaseInvolvement::getLinkedActorId(\Drupal::currentUser());
$query->addJoin('INNER', 'oc_case__actors_involved', 'access_filter', 'access_filter.entity_id = oc_case_field_data.id');
$query->condition('access_filter.actors_involved_target_id', $linked_actor_id);
}
function opencase_query_oc_activity_access_alter($query) {
if (\Drupal::currentUser()->hasPermission('view published case entities')) {
return;
}
$linked_actor_id = CaseInvolvement::getLinkedActorId(\Drupal::currentUser());
$query->addJoin('INNER', 'oc_case__actors_involved', 'access_filter', 'access_filter.entity_id = oc_activity_field_data.oc_case');
$query->condition('access_filter.actors_involved_target_id', $linked_actor_id);
}

View File

@ -6,3 +6,4 @@ package: 'OpenCase'
dependencies:
- opencase_defaults
- opencase_reporting
- opencase_cases

View File

@ -9,17 +9,6 @@ entity.oc_actor_type.add_form:
appears_on:
- entity.oc_actor_type.collection
entity.oc_case.add_form:
route_name: entity.oc_case.add_page
title: 'Add Case'
appears_on:
- entity.oc_case.collection
entity.oc_case_type.add_form:
route_name: entity.oc_case_type.add_form
title: 'Add Case type'
appears_on:
- entity.oc_case_type.collection
entity.oc_activity.add_form:
route_name: entity.oc_activity.add_page
title: 'Add Activity'

View File

@ -17,24 +17,6 @@ entity.oc_actor_type.collection:
weight: 99
# Case menu items definition
entity.oc_case.collection:
title: 'Case list'
route_name: entity.oc_case.collection
description: 'List Case entities'
parent: system.admin_structure
weight: 100
# Case type menu items definition
entity.oc_case_type.collection:
title: 'Case type'
route_name: entity.oc_case_type.collection
description: 'List Case type (bundles)'
parent: system.admin_structure
weight: 99
# Activity menu items definition
entity.oc_activity.collection:
title: 'Activity list'

View File

@ -21,28 +21,6 @@ entity.oc_actor.delete_form:
title: Delete
weight: 10
# Case routing definition
entity.oc_case.canonical:
route_name: entity.oc_case.canonical
base_route: entity.oc_case.canonical
title: 'View'
entity.oc_case.edit_form:
route_name: entity.oc_case.edit_form
base_route: entity.oc_case.canonical
title: 'Edit'
entity.oc_case.version_history:
route_name: entity.oc_case.version_history
base_route: entity.oc_case.canonical
title: 'Revisions'
entity.oc_case.delete_form:
route_name: entity.oc_case.delete_form
base_route: entity.oc_case.canonical
title: Delete
weight: 10
# Activity routing definition

View File

@ -42,16 +42,6 @@ function opencase_entities_theme() {
'variables' => ['content' => NULL],
'file' => 'oc_actor.page.inc',
];
$theme['oc_case'] = [
'render element' => 'elements',
'file' => 'oc_case.page.inc',
'template' => 'oc_case',
];
$theme['oc_case_content_add_list'] = [
'render element' => 'content',
'variables' => ['content' => NULL],
'file' => 'oc_case.page.inc',
];
$theme['oc_activity'] = [
'render element' => 'elements',
'file' => 'oc_activity.page.inc',
@ -101,22 +91,6 @@ function opencase_entities_theme_suggestions_oc_actor(array $variables) {
return $suggestions;
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function opencase_entities_theme_suggestions_oc_case(array $variables) {
$suggestions = [];
$entity = $variables['elements']['#oc_case'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'oc_case__' . $sanitized_view_mode;
$suggestions[] = 'oc_case__' . $entity->bundle();
$suggestions[] = 'oc_case__' . $entity->bundle() . '__' . $sanitized_view_mode;
$suggestions[] = 'oc_case__' . $entity->id();
$suggestions[] = 'oc_case__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
@ -133,32 +107,6 @@ function opencase_entities_theme_suggestions_oc_activity(array $variables) {
return $suggestions;
}
function opencase_views_query_alter(Drupal\views\ViewExecutable $view, $query) {
if ($view->getBaseEntityType() && $view->getBaseEntityType()->id() == 'oc_case') {
$query->addTag('oc_case_access');
}
if ($view->getBaseEntityType() && $view->getBaseEntityType()->id() == 'oc_activity') {
$query->addTag('oc_activity_access');
}
}
function opencase_query_oc_case_access_alter($query) {
if (\Drupal::currentUser()->hasPermission('view published case entities')) {
return;
}
$linked_actor_id = CaseInvolvement::getLinkedActorId(\Drupal::currentUser());
$query->addJoin('INNER', 'oc_case__actors_involved', 'access_filter', 'access_filter.entity_id = oc_case_field_data.id');
$query->condition('access_filter.actors_involved_target_id', $linked_actor_id);
}
function opencase_query_oc_activity_access_alter($query) {
if (\Drupal::currentUser()->hasPermission('view published case entities')) {
return;
}
$linked_actor_id = CaseInvolvement::getLinkedActorId(\Drupal::currentUser());
$query->addJoin('INNER', 'oc_case__actors_involved', 'access_filter', 'access_filter.entity_id = oc_activity_field_data.oc_case');
$query->condition('access_filter.actors_involved_target_id', $linked_actor_id);
}
/**
* Implements hook_theme_suggestions_HOOK().