CRM-15472 - Freeze activity target field if too many contacts
authorColeman Watts <coleman@civicrm.org>
Wed, 22 Oct 2014 15:03:56 +0000 (11:03 -0400)
committerColeman Watts <coleman@civicrm.org>
Wed, 22 Oct 2014 15:03:56 +0000 (11:03 -0400)
CRM/Activity/Form/Activity.php
templates/CRM/Activity/Form/Activity.tpl

index 4f82a425a8ce86ed0371dda0b0e37888d57315f3..4f6fad8acccd8d34b36683f9f3d84a60a025b5b8 100644 (file)
@@ -567,6 +567,14 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       $defaults['target_contact_id'] = $this->_contactIds;
     }
 
+    // CRM-15472 - 50 is around the practial limit of how many items a select2 entityRef can handle
+    if (!empty($defaults['target_contact_id'])) {
+      $count = count(is_array($defaults['target_contact_id']) ? $defaults['target_contact_id'] : explode(',', $defaults['target_contact_id']));
+      if ($count > 50) {
+        $this->freeze(array('target_contact_id'));
+      }
+    }
+
     if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
       $this->assign('delName', CRM_Utils_Array::value('subject', $defaults));
     }
index 8d6a6a24411b9601144de2f45a578e437ae61a01..62a3a2ee0d025b06486543846a5f40eaeacc4775 100644 (file)
       <td>
         {$form.assignee_contact_id.html}
         {if $action neq 4}
-          <a href="#" class="crm-hover-button" id="swap_target_assignee" title="{ts}Swap Target and Assignee Contacts{/ts}" style="position:relative; bottom: 1em;">
-            <span><div class="icon swap-icon"></div></span>
-          </a>
+          {if !$form.target_contact_id.frozen}
+            <a href="#" class="crm-hover-button" id="swap_target_assignee" title="{ts}Swap Target and Assignee Contacts{/ts}" style="position:relative; bottom: 1em;">
+              <span class="icon ui-icon-shuffle"></span>
+            </a>
+          {/if}
           {if $activityAssigneeNotification}
             <br />
             <span class="description"><span class="icon email-icon"></span>{ts}A copy of this activity will be emailed to each Assignee.{/ts}</span>