From: Coleman Watts Date: Tue, 22 Jan 2019 17:35:13 +0000 (-0500) Subject: Hide gender & deceased filters for non-individual entityRef X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=7fd621e8996c10fb3b6ba95e7baa290b40e7d918;p=civicrm-core.git Hide gender & deceased filters for non-individual entityRef --- diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 195d224063..a472f3a2fc 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -837,18 +837,18 @@ class CRM_Core_Resources { array('key' => 'status_id', 'value' => ts('Activity Status')), ); - $filters['contact'] = array( - array('key' => 'contact_type', 'value' => ts('Contact Type')), - array('key' => 'group', 'value' => ts('Group'), 'entity' => 'group_contact'), - array('key' => 'tag', 'value' => ts('Tag'), 'entity' => 'entity_tag'), - array('key' => 'state_province', 'value' => ts('State/Province'), 'entity' => 'address'), - array('key' => 'country', 'value' => ts('Country'), 'entity' => 'address'), - array('key' => 'gender_id', 'value' => ts('Gender')), - array('key' => 'is_deceased', 'value' => ts('Deceased')), - array('key' => 'contact_id', 'value' => ts('Contact ID'), 'type' => 'text'), - array('key' => 'external_identifier', 'value' => ts('External ID'), 'type' => 'text'), - array('key' => 'source', 'value' => ts('Contact Source'), 'type' => 'text'), - ); + $filters['contact'] = [ + ['key' => 'contact_type', 'value' => ts('Contact Type')], + ['key' => 'group', 'value' => ts('Group'), 'entity' => 'group_contact'], + ['key' => 'tag', 'value' => ts('Tag'), 'entity' => 'entity_tag'], + ['key' => 'state_province', 'value' => ts('State/Province'), 'entity' => 'address'], + ['key' => 'country', 'value' => ts('Country'), 'entity' => 'address'], + ['key' => 'gender_id', 'value' => ts('Gender'), 'condition' => ['contact_type' => 'Individual']], + ['key' => 'is_deceased', 'value' => ts('Deceased'), 'condition' => ['contact_type' => 'Individual']], + ['key' => 'contact_id', 'value' => ts('Contact ID'), 'type' => 'text'], + ['key' => 'external_identifier', 'value' => ts('External ID'), 'type' => 'text'], + ['key' => 'source', 'value' => ts('Contact Source'), 'type' => 'text'], + ]; if (in_array('CiviCase', $config->enableComponents)) { $filters['case'] = array( diff --git a/js/Common.js b/js/Common.js index 2eeec554d6..54ffa13c34 100644 --- a/js/Common.js +++ b/js/Common.js @@ -725,6 +725,10 @@ if (!CRM.vars) CRM.vars = {}; var filter = $.extend({type: 'select', 'attributes': {}, entity: entity}, this); $.extend(this, filter); if (!params[filter.key]) { + // Filter out options if params don't match its condition + if (filter.condition && !_.isMatch(params, _.pick(filter.condition, _.keys(params)))) { + return; + } result.push(filter); } else if (filter.key == 'contact_type' && typeof params.contact_sub_type === 'undefined') {