From 6aac2db8b48e58f1baa5efa1cdd8603de91ef79f Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 22 Feb 2014 10:55:33 -0500 Subject: [PATCH] CRM-13966 - Migrate event type to select2 --- CRM/Event/BAO/Query.php | 14 ++++++++-- CRM/Event/Form/Search.php | 31 +--------------------- CRM/Event/Page/AJAX.php | 28 ------------------- CRM/Event/xml/Menu/Event.xml | 5 ---- templates/CRM/Event/Form/Search/Common.tpl | 9 ++----- 5 files changed, 15 insertions(+), 72 deletions(-) diff --git a/CRM/Event/BAO/Query.php b/CRM/Event/BAO/Query.php index 92a137e1e8..193776249e 100644 --- a/CRM/Event/BAO/Query.php +++ b/CRM/Event/BAO/Query.php @@ -539,6 +539,9 @@ class CRM_Event_BAO_Query { return $properties; } + /** + * @param CRM_Core_Form $form + */ static function buildSearchForm(&$form) { $dataURLEvent = CRM_Utils_System::url('civicrm/ajax/event', "reset=1", @@ -558,12 +561,19 @@ class CRM_Event_BAO_Query { $form->assign('dataURLEventFee', $dataURLEventFee); $eventId = &$form->add('text', 'event_name', ts('Event Name')); - $eventType = &$form->add('text', 'event_type', ts('Event Type')); + $eventType = $form->addEntityRef('event_type_id', ts('Event Type'), array( + 'entity' => 'option_value', + 'placeholder' => ts('- any -'), + 'select' => array('minimumInputLength' => 0), + 'api' => array( + 'params' => array('option_group_id' => 'event_type'), + ), + ) + ); $participantFee = &$form->add('text', 'participant_fee_level', ts('Fee Level')); //elements for assigning value operation $eventNameId = &$form->add('hidden', 'event_id', '', array('id' => 'event_id')); - $eventTypeId = &$form->add('hidden', 'event_type_id', '', array('id' => 'event_type_id')); $participantFeeId = &$form->add('hidden', 'participant_fee_id', '', array('id' => 'participant_fee_id')); CRM_Core_Form_Date::buildDateRange($form, 'event', 1, '_start_date_low', '_end_date_high', ts('From'), FALSE); diff --git a/CRM/Event/Form/Search.php b/CRM/Event/Form/Search.php index 463cefdcc3..eeffc5875d 100644 --- a/CRM/Event/Form/Search.php +++ b/CRM/Event/Form/Search.php @@ -445,36 +445,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form { * @access public * @see valid_date */ - function addRules() { - $this->addFormRule(array('CRM_Event_Form_Search', 'formRule')); - } - - /** - * global validation rules for the form - * - * @param array $fields posted values of the form - * @param array $errors list of errors to be posted back to the form - * - * @return void - * @static - * @access public - */ - static function formRule($fields) { - $errors = array(); - - if ($fields['event_name'] && !is_numeric($fields['event_id'])) { - $errors['event_id'] = ts('Please select valid event.'); - } - - if ($fields['event_type'] && !is_numeric($fields['event_type_id'])) { - $errors['event_type'] = ts('Please select valid event type.'); - } - if (!empty($errors)) { - return $errors; - } - - return TRUE; - } + function addRules() {} /** * Set the default form values diff --git a/CRM/Event/Page/AJAX.php b/CRM/Event/Page/AJAX.php index 44addaac0d..36a558a25b 100644 --- a/CRM/Event/Page/AJAX.php +++ b/CRM/Event/Page/AJAX.php @@ -83,34 +83,6 @@ class CRM_Event_Page_AJAX { CRM_Core_Page_AJAX::autocompleteResults($results); } - /** - * Function for building Event Type combo box - */ - function eventType() { - $name = trim(CRM_Utils_Type::escape($_GET['s'], 'String')); - if (!$name) { - $name = '%'; - } - $whereClause = " v.label LIKE '$name%' "; - - $query = " -SELECT v.label ,v.value -FROM civicrm_option_value v, - civicrm_option_group g -WHERE v.option_group_id = g.id -AND g.name = 'event_type' -AND v.is_active = 1 -AND {$whereClause} -ORDER by v.weight"; - - $dao = CRM_Core_DAO::executeQuery($query); - $results = array(); - while ($dao->fetch()) { - $results[$dao->value] = $dao->label; - } - CRM_Core_Page_AJAX::autocompleteResults($results); - } - /** * Function for building EventFee combo box */ diff --git a/CRM/Event/xml/Menu/Event.xml b/CRM/Event/xml/Menu/Event.xml index 82dbe7cf6b..a987287983 100644 --- a/CRM/Event/xml/Menu/Event.xml +++ b/CRM/Event/xml/Menu/Event.xml @@ -265,11 +265,6 @@ CRM_Event_Page_AJAX::event access CiviCRM,access CiviEvent - - civicrm/ajax/eventType - CRM_Event_Page_AJAX::eventType - access CiviCRM,access CiviEvent - civicrm/ajax/eventFee CRM_Event_Page_AJAX::eventFee diff --git a/templates/CRM/Event/Form/Search/Common.tpl b/templates/CRM/Event/Form/Search/Common.tpl index d60220f30a..7ddc0b6d07 100644 --- a/templates/CRM/Event/Form/Search/Common.tpl +++ b/templates/CRM/Event/Form/Search/Common.tpl @@ -24,8 +24,8 @@ +--------------------------------------------------------------------+ *} - {$form.event_name.label}
{$form.event_name.html|crmAddClass:huge} - {$form.event_type.label}
{$form.event_type.html} + {$form.event_name.label}
{$form.event_name.html|crmAddClass:huge} + {$form.event_type_id.label}
{$form.event_type_id.html} @@ -90,17 +90,12 @@ campaignTrClass='' campaignTdClass='crm-event-form-block-participant_campaign_id {literal}