CRM-16071 - Expose field descriptions to api & explorer
authorColeman Watts <coleman@civicrm.org>
Sat, 7 Mar 2015 16:53:55 +0000 (11:53 -0500)
committerColeman Watts <coleman@civicrm.org>
Sat, 7 Mar 2015 18:27:24 +0000 (13:27 -0500)
templates/CRM/Admin/Page/APIExplorer.js
templates/CRM/Admin/Page/APIExplorer.tpl
xml/templates/dao.tpl

index 3a635df59ecb5592211b2c151b63041d1eea35e9..72d8999d8675ae8d2224e6cf3dad4a6b0308f980 100644 (file)
     $('#api-params').append($(fieldTpl({name: name || ''})));
     var $row = $('tr:last-child', '#api-params');
     $('input.api-param-name', $row).crmSelect2({
-      data: fields.concat({id: '-', text: ts('Other') + '...'})
+      data: fields.concat({id: '-', text: ts('Other') + '...', description: ts('Choose a field not in this list')}),
+      formatResult: function(field) {
+        return field.text + '<div class="api-field-desc">' + field.description + '</div>';
+      }
     }).change();
   }
 
             id: field.name,
             text: field.title || field.name,
             multi: !!field['api.multiple'],
+            description: field.description || '',
             required: !(!field['api.required'] || field['api.required'] === '0')
           });
           if (field['api.required'] && field['api.required'] !== '0') {
index 76f87483a0842db59f50b71b1d451e848ec62127..5ff402c142530202e1e2a6c74451d8a805c846c2 100644 (file)
     background-image: url("{/literal}{$config->resourceBase}{literal}/i/icons/jquery-ui-52534D.png");
     opacity: .8;
   }
+  .api-field-desc {
+    font-size: .8em;
+    color: #828282;
+    line-height: 1.3em;
+  }
+  .select2-highlighted .api-field-desc {
+    color: #fcfcfc;
+  }
+  .api-param-op[readonly] {
+    width: 4em;
+  }
   pre ol.linenums li {
     list-style-type: decimal;
     color: #CFCFCF;
index e025bc898009bd2adfe7fb753d6a72dd2cc6f01c..cd590f6c6c2ad219028ef59eb6d23be97a9c7c59 100644 (file)
@@ -164,6 +164,9 @@ class {$table.className} extends CRM_Core_DAO {ldelim}
 {if $field.title}
                                                                       'title'     => ts('{$field.title}'),
 {/if}
+{if $field.comment}
+                                                                      'description'     => '{$field.comment|replace:"'":"\'"}',
+{/if}
 {if $field.required}
                                         'required'  => {$field.required},
 {/if} {* field.required *}