<kbn-settings-app section="objects">
  <kbn-settings-objects-view class="container">
    <div class="pull-right" style="margin-top: 20px;">
      <a href="{{ link }}" class="btn btn-primary">View {{ title }}</a>
      <a confirm-click="delete()" class="btn btn-danger"><i class="fa fa-trash-o"></i> Delete {{ title }} Object</a>
    </div>
    <h1>Edit {{ title }} Object</h1>
    <div class="bs-callout bs-callout-danger" ng-if="notFound">
      <h4>There is a problem with that saved object</h4>

      <p ng-if="notFound === 'search'">The saved search associated with this object no longer exists.</p>
      <p ng-if="notFound === 'index-pattern'">The index pattern associated with this object no longer exists.</p>
      <p ng-if="notFound === 'index-pattern-field'">A field associated with this object no longer exists in the index pattern.</p>

      <p>If you know what this error means, go ahead and fix it - otherwise click the delete button above.</p>
    </div>
    <div class="bs-callout bs-callout-warning">
      <h4>Proceed with caution</h4>

      <p>Modifying objects is for advanced users only. Object properties are not validated and invalid objects could cause errors, data loss, or worse. Unless someone with intimate knowledge of the code told you to be in here, you probably shouldn't be.</p>
    </div>
    <form role="form" name="objectForm" ng-submit="submit()">
      <div class="form-group" ng-repeat="field in fields">
        <label>{{ field.name }}</label>
        <textarea rows="1" msd-elastic=" " ng-if="field.type === 'text'" ng-model="field.value" class="form-control span12"/>
        <input ng-if="field.type === 'number'"  type="number" ng-model="field.value" class="form-control span12"/>
        <div ng-if="field.type === 'json' || field.type === 'array'" ui-ace="{ onLoad: aceLoaded, mode: 'json' }" id="{{field.name}}" ng-model="field.value" class="form-control"></div>
        <input ng-if="field.type === 'boolean'" type="checkbox" ng-model="field.value" ng-checked="field.value">
      </div>
    </form>
    <div class="form-group">
      <button aria-label="Cancel" class="btn btn-primary" ng-click="cancel()">Cancel</button>
      <button aria-label="Save {{ title }} Object" class="btn btn-success" ng-click="submit()" ng-disabled="objectForm.$invalid || aceInvalidEditors.length !==0">Save {{ title }} Object</button>
    </div>
  </kbn-settings-objects-view>
</kbn-settings-app>