Update group selectors to use select2 instead of advmultiselect
authorColeman Watts <coleman@civicrm.org>
Thu, 17 Jul 2014 09:06:09 +0000 (10:06 +0100)
committerColeman Watts <coleman@civicrm.org>
Thu, 17 Jul 2014 09:06:09 +0000 (10:06 +0100)
CRM/Campaign/Form/Campaign.php
CRM/Contact/Form/Search/Custom/DateAdded.php
CRM/Contact/Form/Search/Custom/Group.php
CRM/Contact/Form/Search/Custom/RandomSegment.php

index b46d808dc829eb12dd6e4dab41d8c6160ce4f8ac..2ea0a12bd9d80c0cd8261673da6d9d0fa447de12 100644 (file)
@@ -259,17 +259,16 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
     //get the campaign groups.
     $groups = CRM_Core_PseudoConstant::group();
 
-    $inG = &$this->addElement('advmultiselect', 'includeGroups',
-      ts('Include Group(s)') . ' ',
+    $this->add('select', 'includeGroups',
+      ts('Include Group(s)'),
       $groups,
+      FALSE,
       array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
+        'multiple' => TRUE,
+        'class' => 'crm-select2 huge',
+        'placeholder' => ts('- none -'),
       )
     );
-    $inG->setButtonAttributes('add', array('value' => ts('Add >>')));
-    $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
 
     $this->addWysiwyg('goal_general', ts('Campaign Goals'), array('rows' => 2, 'cols' => 40));
     $this->add('text', 'goal_revenue', ts('Revenue Goal'), array('size' => 8, 'maxlength' => 12));
index f1d145cb4e07884aea62745b4951558b83739a8c..716b1333fcd864860787ae223fd5fd6d0545ccc6 100644 (file)
@@ -54,35 +54,34 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C
   }
 
   /**
-   * @param $form
+   * @param CRM_Core_Form $form
    */
   function buildForm(&$form) {
     $form->addDate('start_date', ts('Start Date'), FALSE, array('formatType' => 'custom'));
     $form->addDate('end_date', ts('End Date'), FALSE, array('formatType' => 'custom'));
 
     $groups = CRM_Core_PseudoConstant::group();
-    $inG = &$form->addElement('advmultiselect', 'includeGroups',
-      ts('Include Group(s)') . ' ', $groups,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+
+    $select2style = array(
+      'multiple' => TRUE,
+      'style' => 'width: 100%; max-width: 60em;',
+      'class' => 'crm-select2',
+      'placeholder' => ts('- select -'),
     );
 
-    $outG = &$form->addElement('advmultiselect', 'excludeGroups',
-      ts('Exclude Group(s)') . ' ', $groups,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+    $form->add('select', 'includeGroups',
+      ts('Include Group(s)'),
+      $groups,
+      FALSE,
+      $select2style
     );
 
-    $inG->setButtonAttributes('add', array('value' => ts('Add >>')));
-    $outG->setButtonAttributes('add', array('value' => ts('Add >>')));
-    $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
-    $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
+    $form->add('select', 'excludeGroups',
+      ts('Exclude Group(s)'),
+      $groups,
+      FALSE,
+      $select2style
+    );
 
     $this->setTitle('Search by date added to CiviCRM');
 
index f4f4aed558e32ead6deda58c46e2b7d3e0ef97b2..1de64dfa54c150403ebe68b9df21c5e63c9e55c6 100644 (file)
@@ -91,7 +91,7 @@ class CRM_Contact_Form_Search_Custom_Group
   }
 
   /**
-   * @param $form
+   * @param CRM_Core_Form $form
    */
   function buildForm(&$form) {
 
@@ -106,22 +106,25 @@ class CRM_Contact_Form_Search_Custom_Group
       CRM_Utils_System::redirect($url);
     }
 
-    $inG = &$form->addElement('advmultiselect', 'includeGroups',
-      ts('Include Group(s)') . ' ', $groups,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+    $select2style = array(
+      'multiple' => TRUE,
+      'style' => 'width: 100%; max-width: 60em;',
+      'class' => 'crm-select2',
+      'placeholder' => ts('- select -'),
     );
 
-    $outG = &$form->addElement('advmultiselect', 'excludeGroups',
-      ts('Exclude Group(s)') . ' ', $groups,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+    $form->add('select', 'includeGroups',
+      ts('Include Group(s)'),
+      $groups,
+      FALSE,
+      $select2style
+    );
+
+    $form->add('select', 'excludeGroups',
+      ts('Exclude Group(s)'),
+      $groups,
+      FALSE,
+      $select2style
     );
 
     $andOr = array(
@@ -130,36 +133,20 @@ class CRM_Contact_Form_Search_Custom_Group
     );
     $form->addRadio('andOr', ts('AND/OR'), $andOr, NULL, '<br />', TRUE);
 
-    $int = &$form->addElement('advmultiselect', 'includeTags',
-      ts('Include Tag(s)') . ' ', $tags,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+    $form->add('select', 'includeTags',
+      ts('Include Tag(s)'),
+      $tags,
+      FALSE,
+      $select2style
     );
 
-    $outt = &$form->addElement('advmultiselect', 'excludeTags',
-      ts('Exclude Tag(s)') . ' ', $tags,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+    $form->add('select', 'excludeTags',
+      ts('Exclude Tag(s)'),
+      $tags,
+      FALSE,
+      $select2style
     );
 
-    //add/remove buttons for groups
-    $inG->setButtonAttributes('add', array('value' => ts('Add >>')));;
-    $outG->setButtonAttributes('add', array('value' => ts('Add >>')));;
-    $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));;
-    $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));;
-
-    //add/remove buttons for tags
-    $int->setButtonAttributes('add', array('value' => ts('Add >>')));;
-    $outt->setButtonAttributes('add', array('value' => ts('Add >>')));;
-    $int->setButtonAttributes('remove', array('value' => ts('<< Remove')));;
-    $outt->setButtonAttributes('remove', array('value' => ts('<< Remove')));;
-
     /**
      * if you are using the standard template, this array tells the template what elements
      * are part of the search criteria
index 1601c7ebf496f00d0ffdcee69514deb7c2709d39..5718a7f3c9e133b8488ffa82f066113e28da8e0c 100644 (file)
@@ -74,7 +74,7 @@ class CRM_Contact_Form_Search_Custom_RandomSegment extends CRM_Contact_Form_Sear
   }
 
   /**
-   * @param $form
+   * @param CRM_Core_Form $form
    */
   function buildForm(&$form) {
     $form->add('text',
@@ -84,28 +84,27 @@ class CRM_Contact_Form_Search_Custom_RandomSegment extends CRM_Contact_Form_Sear
     );
 
     $groups = CRM_Core_PseudoConstant::group();
-    $inG = &$form->addElement('advmultiselect', 'includeGroups',
-      ts('Include Group(s)') . ' ', $groups,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+
+    $select2style = array(
+      'multiple' => TRUE,
+      'style' => 'width: 100%; max-width: 60em;',
+      'class' => 'crm-select2',
+      'placeholder' => ts('- select -'),
     );
 
-    $outG = &$form->addElement('advmultiselect', 'excludeGroups',
-      ts('Exclude Group(s)') . ' ', $groups,
-      array(
-        'size' => 5,
-        'style' => 'width:240px',
-        'class' => 'advmultiselect',
-      )
+    $form->add('select', 'includeGroups',
+      ts('Include Group(s)'),
+      $groups,
+      FALSE,
+      $select2style
     );
 
-    $inG->setButtonAttributes('add', array('value' => ts('Add >>')));
-    $outG->setButtonAttributes('add', array('value' => ts('Add >>')));
-    $inG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
-    $outG->setButtonAttributes('remove', array('value' => ts('<< Remove')));
+    $form->add('select', 'excludeGroups',
+      ts('Exclude Group(s)'),
+      $groups,
+      FALSE,
+      $select2style
+    );
 
     $this->setTitle('Create a random segment of contacts');