CRM-18652 - Show 'no matches' if quick search returns no results
authorEffy Elden <git@effy.is>
Sun, 22 May 2016 05:19:32 +0000 (01:19 -0400)
committerSeamus Lee <seamuslee001@gmail.com>
Sun, 5 Jun 2016 08:53:35 +0000 (18:53 +1000)
----------------------------------------
* CRM-18652: Quick search should provide feedback to user if no matches are found
  https://issues.civicrm.org/jira/browse/CRM-18652

templates/CRM/common/navigation.js.tpl

index 9745d715028272fe58df8fd78a5730eda58e5a50..5210fcc424d6c0dd0d3f04340d93df09b9694bf5 100644 (file)
@@ -103,10 +103,12 @@ $('#civicrm-menu').ready(function() {
           };
         CRM.api3('contact', 'getquick', params).done(function(result) {
           var ret = [];
-          if (result.values) {
+          if (result.values.length > 0) {
             $.each(result.values, function(k, v) {
               ret.push({value: v.id, label: v.data});
-            })
+            });
+          } else {
+            ret.push({value: '0', label: 'No matches'});
           }
           response(ret);
         })
@@ -115,7 +117,9 @@ $('#civicrm-menu').ready(function() {
         return false;
       },
       select: function (event, ui) {
-        document.location = CRM.url('civicrm/contact/view', {reset: 1, cid: ui.item.value});
+        if (ui.item.value > 0) {
+          document.location = CRM.url('civicrm/contact/view', {reset: 1, cid: ui.item.value});
+        }
         return false;
       },
       create: function() {