Filtering types in AddActivity block by actor type
This commit is contained in:
parent
e5b01eac53
commit
559ff4d83b
@ -81,6 +81,7 @@ module:
|
||||
views_aggregator: 0
|
||||
views_aggregator_more_functions: 0
|
||||
views_autosubmit: 0
|
||||
views_contextual_filters_or: 0
|
||||
views_data_export: 0
|
||||
views_summarize: 0
|
||||
views_ui: 0
|
||||
|
@ -155,6 +155,71 @@ display:
|
||||
multi_type: separator
|
||||
separator: ', '
|
||||
field_api_classes: false
|
||||
oc_target:
|
||||
id: oc_target
|
||||
table: oc_activity_field_data
|
||||
field: oc_target
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
entity_type: oc_activity
|
||||
entity_field: oc_target
|
||||
plugin_id: field
|
||||
label: Target
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: true
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
click_sort_column: target_id
|
||||
type: entity_reference_label
|
||||
settings:
|
||||
link: true
|
||||
group_column: target_id
|
||||
group_columns: { }
|
||||
group_rows: true
|
||||
delta_limit: 0
|
||||
delta_offset: 0
|
||||
delta_reversed: false
|
||||
delta_first_last: false
|
||||
multi_type: separator
|
||||
separator: ', '
|
||||
field_api_classes: false
|
||||
oc_provider:
|
||||
id: oc_provider
|
||||
table: oc_activity_field_data
|
||||
@ -426,6 +491,44 @@ display:
|
||||
validate_options: { }
|
||||
break_phrase: false
|
||||
not: false
|
||||
oc_provider:
|
||||
id: oc_provider
|
||||
table: oc_activity_field_data
|
||||
field: oc_provider
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
entity_type: oc_activity
|
||||
entity_field: oc_provider
|
||||
plugin_id: numeric
|
||||
default_action: default
|
||||
exception:
|
||||
value: all
|
||||
title_enable: false
|
||||
title: All
|
||||
title_enable: false
|
||||
title: ''
|
||||
default_argument_type: raw
|
||||
default_argument_options:
|
||||
index: 2
|
||||
use_alias: false
|
||||
default_argument_skip_url: false
|
||||
summary_options:
|
||||
base_path: ''
|
||||
count: true
|
||||
override: false
|
||||
items_per_page: 25
|
||||
summary:
|
||||
sort_order: asc
|
||||
number_of_records: 0
|
||||
format: default_summary
|
||||
specify_validation: false
|
||||
validate:
|
||||
type: none
|
||||
fail: 'not found'
|
||||
validate_options: { }
|
||||
break_phrase: false
|
||||
not: false
|
||||
filters: { }
|
||||
style:
|
||||
type: table
|
||||
@ -434,11 +537,51 @@ display:
|
||||
row_class: ''
|
||||
default_row_class: true
|
||||
columns:
|
||||
type: type
|
||||
activity_date_time: activity_date_time
|
||||
oc_target: oc_target
|
||||
oc_provider: oc_provider
|
||||
name: name
|
||||
description: description
|
||||
default: '-1'
|
||||
info:
|
||||
type:
|
||||
sortable: true
|
||||
default_sort_order: asc
|
||||
align: ''
|
||||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
activity_date_time:
|
||||
sortable: true
|
||||
default_sort_order: desc
|
||||
align: ''
|
||||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
oc_target:
|
||||
sortable: true
|
||||
default_sort_order: asc
|
||||
align: ''
|
||||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
oc_provider:
|
||||
sortable: true
|
||||
default_sort_order: asc
|
||||
align: ''
|
||||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
name:
|
||||
sortable: false
|
||||
sortable: true
|
||||
default_sort_order: asc
|
||||
align: ''
|
||||
separator: ''
|
||||
empty_column: false
|
||||
responsive: ''
|
||||
description:
|
||||
sortable: true
|
||||
default_sort_order: asc
|
||||
align: ''
|
||||
separator: ''
|
||||
@ -465,6 +608,7 @@ display:
|
||||
distinct: false
|
||||
replica: false
|
||||
query_tags: { }
|
||||
contextual_filters_or: true
|
||||
relationships: { }
|
||||
header: { }
|
||||
footer: { }
|
||||
|
@ -127,6 +127,19 @@ function opencase_entity_field_access($operation, \Drupal\Core\Field\FieldDefini
|
||||
return AccessResult::neutral();
|
||||
}
|
||||
|
||||
/*
|
||||
Implementation of hook_relevant_activity_type_ids which is a custom hook invoked in the AddActivity block.
|
||||
*/
|
||||
function opencase_relevant_activity_type_ids($actorTypeID) {
|
||||
switch ($actorTypeID) {
|
||||
case 'volunteer':
|
||||
return ['email', 'phone_call', 'supervision'];
|
||||
case 'client':
|
||||
return ['email', 'lete', 'phone_call', 'case_note', 'destitution_funds_provided', 'research', 'application'];
|
||||
case 'staff_member':
|
||||
return ['application', 'interview'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_form_alter()
|
||||
|
@ -19,9 +19,11 @@ class AddActivity extends BlockBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build():array {
|
||||
$target_id = \Drupal::routeMatch()->getParameter('oc_actor')->id();
|
||||
$activity_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('oc_activity');
|
||||
$actor = \Drupal::routeMatch()->getParameter('oc_actor');
|
||||
$target_id = $actor->id();
|
||||
$actorType = $actor->bundle();
|
||||
$markup = "<ul>";
|
||||
$activity_types = $this->getActivityTypesToDisplay($actorType);
|
||||
foreach($activity_types as $id => $info) {
|
||||
$label = $info['label'];
|
||||
$markup .= "<li><a href='/opencase/oc_activity/add/$id?target_id=$target_id&destination=/opencase/oc_actor/$target_id'>$label</a></li>";
|
||||
@ -34,4 +36,17 @@ class AddActivity extends BlockBase {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function getActivityTypesToDisplay(string $actorType): array {
|
||||
// Client modules will provide a list of what activity types (bundles) are relevant for each actor type.
|
||||
// Check if they are implemented, and if so display them.
|
||||
$implemented_activity_types = \Drupal::service('entity_type.bundle.info')->getBundleInfo('oc_activity');
|
||||
$relevant_activity_type_ids = \Drupal::moduleHandler()->invokeAll('relevant_activity_type_ids', [$actorType]);
|
||||
$activity_types_to_display = [];
|
||||
foreach ($relevant_activity_type_ids as $type_id) {
|
||||
if (array_key_exists($type_id, $implemented_activity_types)) {
|
||||
$activity_types_to_display[$type_id] = $implemented_activity_types[$type_id];
|
||||
}
|
||||
}
|
||||
return $activity_types_to_display;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user