From 11cac30623014cf41c8e9b0e707ad199a486f445 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 17 Jul 2014 10:06:09 +0100 Subject: [PATCH] Update group selectors to use select2 instead of advmultiselect --- CRM/Campaign/Form/Campaign.php | 13 ++-- CRM/Contact/Form/Search/Custom/DateAdded.php | 37 +++++----- CRM/Contact/Form/Search/Custom/Group.php | 69 ++++++++----------- .../Form/Search/Custom/RandomSegment.php | 37 +++++----- 4 files changed, 70 insertions(+), 86 deletions(-) diff --git a/CRM/Campaign/Form/Campaign.php b/CRM/Campaign/Form/Campaign.php index b46d808dc8..2ea0a12bd9 100644 --- a/CRM/Campaign/Form/Campaign.php +++ b/CRM/Campaign/Form/Campaign.php @@ -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)); diff --git a/CRM/Contact/Form/Search/Custom/DateAdded.php b/CRM/Contact/Form/Search/Custom/DateAdded.php index f1d145cb4e..716b1333fc 100644 --- a/CRM/Contact/Form/Search/Custom/DateAdded.php +++ b/CRM/Contact/Form/Search/Custom/DateAdded.php @@ -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'); diff --git a/CRM/Contact/Form/Search/Custom/Group.php b/CRM/Contact/Form/Search/Custom/Group.php index f4f4aed558..1de64dfa54 100644 --- a/CRM/Contact/Form/Search/Custom/Group.php +++ b/CRM/Contact/Form/Search/Custom/Group.php @@ -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, '
', 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 diff --git a/CRM/Contact/Form/Search/Custom/RandomSegment.php b/CRM/Contact/Form/Search/Custom/RandomSegment.php index 1601c7ebf4..5718a7f3c9 100644 --- a/CRM/Contact/Form/Search/Custom/RandomSegment.php +++ b/CRM/Contact/Form/Search/Custom/RandomSegment.php @@ -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'); -- 2.25.1