Api Explorer - Show marker for required fields
authorColeman Watts <coleman@civicrm.org>
Tue, 17 Mar 2015 13:28:50 +0000 (09:28 -0400)
committerColeman Watts <coleman@civicrm.org>
Tue, 17 Mar 2015 13:28:50 +0000 (09:28 -0400)
templates/CRM/Admin/Page/APIExplorer.js
templates/CRM/Admin/Page/APIExplorer.tpl

index b83eab833b4c8ecb35fc0b2398056127786096a8..b28273168b36d438982a5b8d58a7e4603b476e98 100644 (file)
     var $row = $('tr:last-child', '#api-params');
     $('input.api-param-name', $row).crmSelect2({
       data: fields.concat({id: '-', text: ts('Other') + '...', description: ts('Choose a field not in this list')}),
+      formatSelection: function(field) {
+        return field.text +
+          (field.required ? ' <span class="crm-marker">*</span>' : '');
+      },
       formatResult: function(field) {
-        return field.text + '<div class="api-field-desc">' + field.description + '</div>';
+        return field.text +
+          (field.required ? ' <span class="crm-marker">*</span>' : '') +
+          '<div class="api-field-desc">' + field.description + '</div>';
       }
     }).change();
   }
       params.placeholder = ts('Select field');
       params.multiple = false;
     }
-    $('#api-params').prepend($(returnTpl({title: title})));
+    $('#api-params').prepend($(returnTpl({title: title, required: action == 'getvalue'})));
     $('#api-return-value').crmSelect2(params);
   }
 
index e6d5865e158449aa136b4389112e952c92a64269..98cea80bc7ee54dfa63f4d09bc82b9107cd88ae4 100644 (file)
@@ -92,7 +92,8 @@
     color: #828282;
     line-height: 1.3em;
   }
-  .select2-highlighted .api-field-desc {
+  .select2-highlighted .api-field-desc,
+  .select2-highlighted .crm-marker {
     color: #fcfcfc;
   }
   .api-param-op[readonly] {
 <script type="text/template" id="api-return-tpl">
   <tr class="api-return-row">
     <td colspan="3">
-      <label for="api-return-value"><%- title %>:</label> &nbsp;
+      <label for="api-return-value">
+        <%- title %>:
+        <% if(required) {ldelim} %> <span class="crm-marker">*</span> <% {rdelim} %>
+      </label> &nbsp;
       <input type="hidden" class="api-param-name" value="return" />
       <input style="width: 50%;" id="api-return-value" class="crm-form-text api-param-value api-input"/>
     </td>