From 5f043615787de43e49e299b591f6720aca939ae6 Mon Sep 17 00:00:00 2001 From: puresyntax71 <34715246+puresyntax71@users.noreply.github.com> Date: Thu, 28 Dec 2023 15:56:26 +0800 Subject: [PATCH] Add workaround for views activity related fields. --- civicrm_entity.views.inc | 9 +++++++++ src/CivicrmEntityViewsData.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/civicrm_entity.views.inc b/civicrm_entity.views.inc index 5f60e404..e71f4f32 100644 --- a/civicrm_entity.views.inc +++ b/civicrm_entity.views.inc @@ -144,6 +144,15 @@ function civicrm_entity_views_data_alter(&$data) { $data['civicrm_contact']['current_employer']['real field'] = 'organization_name'; $data['civicrm_contact']['employer_id']['field']['id'] = 'standard'; $data['civicrm_contribution']['contribution_source']['real field'] = 'source'; + + $service = \Drupal::service('entity_field.manager'); + $field_definitions = $service->getFieldDefinitions('civicrm_activity', 'civicrm_activity'); + + foreach (['status_id', 'activity_type_id'] as $key) { + $data['civicrm_activity'][$key]['filter']['id'] = 'in_operator'; + $data['civicrm_activity'][$key]['filter']['options callback'] = 'civicrm_entity_pseudoconstant_options'; + $data['civicrm_activity'][$key]['filter']['options arguments'] = [$field_definitions[$key]]; + } } /** diff --git a/src/CivicrmEntityViewsData.php b/src/CivicrmEntityViewsData.php index 4fc66ce5..5f046b98 100644 --- a/src/CivicrmEntityViewsData.php +++ b/src/CivicrmEntityViewsData.php @@ -500,7 +500,7 @@ protected function processViewsDataForSpecialFields(array &$views_field, $base_t $views_field['civicrm_contact']['reverse__civicrm_website__contact_id']['relationship']['id'] = 'civicrm_entity_reverse_website_type'; $views_field['civicrm_contact']['reverse__civicrm_website__contact_id']['relationship']['label'] = $this->t('Website'); } - + break; case 'civicrm_address': if (isset($views_field['civicrm_contact']['reverse__civicrm_address__contact_id']['relationship'])) {