CRM-13929 Add contact icon to autocomplete results
authorColeman Watts <coleman@civicrm.org>
Fri, 14 Feb 2014 01:06:59 +0000 (17:06 -0800)
committerColeman Watts <coleman@civicrm.org>
Fri, 14 Feb 2014 01:06:59 +0000 (17:06 -0800)
api/v3/Contact.php
css/civicrm.css
js/Common.js

index 40535306545a62beab74d5cc6e46f3f690829d07..81c8662a34ff506d77c6ea9450a010b7ce53541d 100644 (file)
@@ -918,6 +918,7 @@ function _civicrm_api3_contact_getlist_params(&$request) {
   if(!in_array($searchField, $list)) {
     $list[] = $searchField;
   }
+  $list[] = 'contact_type';
   $request['params']['return'] = $list;
   $request['params']['options']['sort'] = 'sort_name';
   // Contact api doesn't support array(LIKE => 'foo') syntax
@@ -942,14 +943,17 @@ function _civicrm_api3_contact_getlist_output($result, $request) {
       );
       $description = array();
       foreach ($request['params']['return'] as $item) {
-        if (!strpos($item, '_name') && !empty($row[$item])) {
+        if (!strpos($item, '_name') && $item != 'contact_type' && !empty($row[$item])) {
           $description[] = $row[$item];
         }
       }
       $data['description'] = implode(' :: ', $description);
       if (!empty($request['image_field'])) {
         $data['image'] = isset($row[$request['image_field']]) ? $row[$request['image_field']] : '';
-      };
+      }
+      else {
+        $data['icon_class'] = $row['contact_type'];
+      }
       $output[] = $data;
     }
   }
index 8d655d50f493262a37b84d31d35403d87c8072f7..ee89d227f689643278e8d95158e357a76398c1c4 100644 (file)
@@ -3848,26 +3848,34 @@ div.m ul#civicrm-menu,
   background-position: -18px 1px;
 }
 /* Style autocomplete results */
-.select2-results table.crm-select2-row,
-.select2-results table.crm-select2-row tbody,
-.select2-results table.crm-select2-row tr,
-.select2-results table.crm-select2-row td {
+.crm-container .select2-results table.crm-select2-row,
+.crm-container .select2-results table.crm-select2-row tbody,
+.crm-container .select2-results table.crm-select2-row tr,
+.crm-container .select2-results table.crm-select2-row td {
   border: 0 none;
   padding: 0;
   margin: 0;
   border-collapse: collapse;
 }
-.select2-results table.crm-select2-row .crm-select2-row-label {
+.crm-container .select2-results table.crm-select2-row .crm-select2-row-label {
   font-size: 1.1em;
 }
-.select2-results table.crm-select2-row .crm-select2-row-description {
+.crm-container .select2-results table.crm-select2-row .crm-select2-row-description {
   font-size: 0.8em;
   line-height: 1.5em;
   color: #696969;
 }
-.select2-results .select2-highlighted table.crm-select2-row .crm-select2-row-description {
+.crm-container .select2-results .select2-highlighted table.crm-select2-row .crm-select2-row-description {
   color: #f0f0f0;
 }
+.crm-container .select2-results td.crm-select2-icon {
+  width: 20px;
+}
+.crm-container .select2-results td.crm-select2-icon .crm-icon {
+  width: 16px;
+  height: 16px;
+  margin: 0;
+}
 
 /* Special styling for specific form buttons */
 #crm-container span.crm-button_qf_Main_upload input,
index 8b74a64f0a786ecd4905e8b00f64a4b288206834..26356d123b78d9ddccd4e481b33857fc218b62bf 100644 (file)
@@ -278,6 +278,9 @@ CRM.validate = CRM.validate || {
     if (row.image !== undefined) {
       markup += '<td class="crm-select2-image"><img src="' + row.image + '"/></td>';
     }
+    else if (row.icon_class) {
+      markup += '<td class="crm-select2-icon"><div class="crm-icon ' + row.icon_class + '-icon"></div></td>';
+    }
     markup += '<td><div class="crm-select2-row-label">' + row.label + '</div>';
     markup += '<div class="crm-select2-row-description">' + (row.description || '') + '</div>';
     markup += '</td></tr></table>';