Api explorer improvements
authorColeman Watts <coleman@civicrm.org>
Sat, 24 Jan 2015 21:27:27 +0000 (16:27 -0500)
committerColeman Watts <coleman@civicrm.org>
Sat, 24 Jan 2015 21:27:27 +0000 (16:27 -0500)
templates/CRM/Admin/Page/APIExplorer.js

index 428ba07e73151f6f64ceb6342c4cb233eed52c23..4243705e4903c1837d538e4fc3591e4a157b3191 100644 (file)
@@ -13,6 +13,9 @@
     returnTpl = _.template($('#api-return-tpl').html()),
     chainTpl = _.template($('#api-chain-tpl').html()),
 
+    // These types of entityRef don't require any input to open
+    OPEN_IMMEDIATELY = ['RelationshipType', 'Event', 'Group', 'Tag'],
+
     // Operators with special properties
     BOOL = ['IS NULL', 'IS NOT NULL'],
     TEXT = ['LIKE', 'NOT LIKE'],
       }
       // Select options
       if (options[name]) {
-
         $valField.select2({
           multiple: (operatorType === 'multi'),
           data: _.map(options[name], function (value, key) {
       }
       // EntityRef
       else {
+        console.log($.inArray(getFieldData[name].FKApiName, OPEN_IMMEDIATELY));
         $valField.crmEntityRef({
           entity: getFieldData[name].FKApiName,
-          select: {multiple: (operatorType === 'multi')}
+          select: {
+            multiple: (operatorType === 'multi'),
+            minimumInputLength: $.inArray(getFieldData[name].FKApiName, OPEN_IMMEDIATELY) > -1 ? 0 : 1
+          }
         });
       }
       return;
     $('#api-params')
       .on('change', 'input.api-param-name, select.api-param-op', renderValueField)
       .on('change', 'input.api-param-name, .api-option-name', function() {
-        if ($(this).val() === '-') {
+        if ($(this).val() === '-' && $(this).data('select2')) {
           $(this).select2('destroy');
           $(this).val('').focus();
         }