Moved everything relating to cases into opencase_cases module
This commit is contained in:
parent
2895dcdab8
commit
5afbeb956b
12
modules/opencase_cases/opencase_cases.links.action.yml
Normal file
12
modules/opencase_cases/opencase_cases.links.action.yml
Normal 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
|
||||||
|
|
@ -5,3 +5,21 @@ opencase_cases.manage_case_types:
|
|||||||
parent: opencase.opencase_admin_menu
|
parent: opencase.opencase_admin_menu
|
||||||
url: internal:/admin/opencase/oc_case_type
|
url: internal:/admin/opencase/oc_case_type
|
||||||
weight: 2
|
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
|
||||||
|
|
||||||
|
|
||||||
|
23
modules/opencase_cases/opencase_cases.links.task.yml
Normal file
23
modules/opencase_cases/opencase_cases.links.task.yml
Normal 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
|
@ -31,6 +31,17 @@ function opencase_cases_theme() {
|
|||||||
'opencase_cases' => [
|
'opencase_cases' => [
|
||||||
'render element' => 'children',
|
'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;
|
$case_id = $form_state->getFormObject()->getEntity()->oc_case->target_id;
|
||||||
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_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);
|
||||||
|
}
|
||||||
|
@ -6,3 +6,4 @@ package: 'OpenCase'
|
|||||||
dependencies:
|
dependencies:
|
||||||
- opencase_defaults
|
- opencase_defaults
|
||||||
- opencase_reporting
|
- opencase_reporting
|
||||||
|
- opencase_cases
|
||||||
|
@ -9,17 +9,6 @@ entity.oc_actor_type.add_form:
|
|||||||
appears_on:
|
appears_on:
|
||||||
- entity.oc_actor_type.collection
|
- 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:
|
entity.oc_activity.add_form:
|
||||||
route_name: entity.oc_activity.add_page
|
route_name: entity.oc_activity.add_page
|
||||||
title: 'Add Activity'
|
title: 'Add Activity'
|
||||||
|
@ -17,24 +17,6 @@ entity.oc_actor_type.collection:
|
|||||||
weight: 99
|
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
|
# Activity menu items definition
|
||||||
entity.oc_activity.collection:
|
entity.oc_activity.collection:
|
||||||
title: 'Activity list'
|
title: 'Activity list'
|
||||||
|
@ -21,28 +21,6 @@ entity.oc_actor.delete_form:
|
|||||||
title: Delete
|
title: Delete
|
||||||
weight: 10
|
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
|
# Activity routing definition
|
||||||
|
|
||||||
|
@ -42,16 +42,6 @@ function opencase_entities_theme() {
|
|||||||
'variables' => ['content' => NULL],
|
'variables' => ['content' => NULL],
|
||||||
'file' => 'oc_actor.page.inc',
|
'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'] = [
|
$theme['oc_activity'] = [
|
||||||
'render element' => 'elements',
|
'render element' => 'elements',
|
||||||
'file' => 'oc_activity.page.inc',
|
'file' => 'oc_activity.page.inc',
|
||||||
@ -101,22 +91,6 @@ function opencase_entities_theme_suggestions_oc_actor(array $variables) {
|
|||||||
return $suggestions;
|
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().
|
* Implements hook_theme_suggestions_HOOK().
|
||||||
*/
|
*/
|
||||||
@ -133,32 +107,6 @@ function opencase_entities_theme_suggestions_oc_activity(array $variables) {
|
|||||||
return $suggestions;
|
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().
|
* Implements hook_theme_suggestions_HOOK().
|
||||||
|
Reference in New Issue
Block a user