<!-- Generates the list of dropdown options for a data source -->
<optgroup label="<%= source['name'] %>">
  <option data-type="all" value="<%= source_param_name %>">
    All <%= source['name'] %> Fields
  </option>
</optgroup>

<!-- Displays the groups for each field type -->
<% text_types = ["Title", "Description", "Short Text", "Medium Text",
     "Long Text", "Shorter Text", "Tiny Text"] %>
<% if !get_matching_fields(text_types, source).empty? %>
  <optgroup label="Text">
    <%= raw(load_field_options_for_type(text_types, source, "string")) %>
  </optgroup>
<% end %>

<% if !get_matching_fields(["Date", "DateTime"], source).empty? %>
  <optgroup label="Date">
    <%= raw(load_field_options_for_type(["Date"], source, "date")) %>
    <%= raw(load_field_options_for_type(["DateTime"], source, "datetime")) %>
   </optgroup>
<% end %>

<% if !get_matching_fields(["Number"], source).empty? %>
  <optgroup label="Number">
     <%= raw(load_field_options_for_type(["Number"], source, "number")) %>
  </optgroup>
<% end %>

<% if !get_matching_fields(["Category"], source).empty? %>
  <optgroup label="Categories">
    <%= raw(load_field_options_for_type(["Category"], source, "string")) %>
  </optgroup>
<% end %>
