From 8a938c69396c9e4b5d5703d37ddef7afbdcfcfbd Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 21 Apr 2015 13:25:11 -0600 Subject: [PATCH] CRM-16323 - Show repeating info in entityRef fields --- CRM/Event/BAO/Query.php | 5 ----- api/v3/Activity.php | 7 +++++++ api/v3/Event.php | 7 +++++++ js/Common.js | 8 +++++--- templates/CRM/Event/Form/Search/Common.tpl | 4 ++-- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/CRM/Event/BAO/Query.php b/CRM/Event/BAO/Query.php index c27adb1358..16dea8eed8 100644 --- a/CRM/Event/BAO/Query.php +++ b/CRM/Event/BAO/Query.php @@ -546,11 +546,6 @@ class CRM_Event_BAO_Query { 'entity' => 'event', 'placeholder' => ts('- any -'), 'select' => array('minimumInputLength' => 0), - 'api' => array( - 'params' => array( - 'api.RecurringEntity.getcount' => array('entity_id' => "\$value.id", 'entity_table' => "civicrm_event"), - ), - ), ) ); $form->addEntityRef('event_type_id', ts('Event Type'), array( diff --git a/api/v3/Activity.php b/api/v3/Activity.php index efa238d10a..0d724b224f 100644 --- a/api/v3/Activity.php +++ b/api/v3/Activity.php @@ -483,6 +483,13 @@ function _civicrm_api3_activity_getlist_output($result, $request) { 1 => CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $row['source_contact_id'], 'display_name'), )); } + // Add repeating info + $repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['id'], 'civicrm_activity'); + $data['extra']['is_recur'] = FALSE; + if ($repeat) { + $data['suffix'] = ts('(%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])); + $data['extra']['is_recur'] = TRUE; + } $output[] = $data; } } diff --git a/api/v3/Event.php b/api/v3/Event.php index 79993cda4b..4728270b45 100644 --- a/api/v3/Event.php +++ b/api/v3/Event.php @@ -259,6 +259,13 @@ function _civicrm_api3_event_getlist_output($result, $request) { if (!empty($row['summary'])) { $data['description'][] = $row['summary']; } + // Add repeating info + $repeat = CRM_Core_BAO_RecurringEntity::getPositionAndCount($row['id'], 'civicrm_event'); + $data['extra']['is_recur'] = FALSE; + if ($repeat) { + $data['suffix'] = ts('(%1 of %2)', array(1 => $repeat[0], 2 => $repeat[1])); + $data['extra']['is_recur'] = TRUE; + } $output[] = $data; } } diff --git a/js/Common.js b/js/Common.js index c77d649635..6591172036 100644 --- a/js/Common.js +++ b/js/Common.js @@ -429,7 +429,7 @@ CRM.strings = CRM.strings || {}; minimumInputLength: 1, formatResult: CRM.utils.formatSelect2Result, formatSelection: function(row) { - return row.label; + return (row.prefix !== undefined ? row.prefix + ' ' : '') + row.label + (row.suffix !== undefined ? ' ' + row.suffix : ''); }, escapeMarkup: function (m) {return m;}, initSelection: function($el, callback) { @@ -670,8 +670,10 @@ CRM.strings = CRM.strings || {}; else if (row.icon_class) { markup += '
'; } - markup += '
' + row.label + '
'; - markup += '
'; + markup += '
' + + (row.prefix !== undefined ? row.prefix + ' ' : '') + row.label + (row.suffix !== undefined ? ' ' + row.suffix : '') + + '
' + + '
'; $.each(row.description || [], function(k, text) { markup += '

' + text + '

'; }); diff --git a/templates/CRM/Event/Form/Search/Common.tpl b/templates/CRM/Event/Form/Search/Common.tpl index 832a5a5cd4..8e1208f803 100644 --- a/templates/CRM/Event/Form/Search/Common.tpl +++ b/templates/CRM/Event/Form/Search/Common.tpl @@ -91,9 +91,9 @@ CRM.$(function($) { // In case select2 widget hasn't been initialized yet, we have to get the data from the dom // FIXME: waiting for select2 initialization would be better, but not sure how if ($(this).data('select2')) { - isRepeating = $(this).select2('data')['api.RecurringEntity.getcount']; + isRepeating = $(this).select2('data').extra.is_recur; } else { - isRepeating = $(this).data('entityValue')[0]['api.RecurringEntity.getcount']; + isRepeating = $(this).data('entityValue')[0].extra.is_recur; } } if (isRepeating) { -- 2.25.1