<div class="form-group">
  <label for="field">
    Field
  </label>

  <ui-select
    name="field"
    required
    class="vis-editor-field-ui-select"
    ng-show="indexedFields.length"
    ng-model="agg.params.field"
    on-select="aggParam.onChange(agg)"
    uis-open-close="limit = 100"
  >
    <ui-select-match placeholder="Select a field">
      {{$select.selected.displayName}}
    </ui-select-match>
    <ui-select-choices
      group-by="'type'"
      kbn-scroll-bottom="limit = limit + 100"
      repeat="field in indexedFields | filter: { displayName: $select.search } | sortPrefixFirst:$select.search:'name' | limitTo: limit"
    >
      <div ng-bind-html="field.displayName | highlight: $select.search"></div>
    </ui-select-choices>
  </ui-select>

  <div class="hintbox" ng-if="!indexedFields.length">
    <p>
      <i class="fa fa-danger text-danger"></i>
      <strong>No Compatible Fields:</strong> The "{{ vis.indexPattern.title }}" index pattern does not contain any of the following field types: {{ agg.type.params.byName.field.filterFieldTypes | commaList:false }}
    </p>
  </div>

</div>
