<h1 class="unboxed">
  <span ng-show="isNew">Create a new entity</span>
  <span ng-hide="isNew">Edit: {{entity.properties.name.value}}</span>
</h1>

<gn-entity-frame section="edit" entity="entity" project="project">
  <form class="form-horizontal" role="form" name="newEntity" ng-submit="save(newEntity)">
    <div class="form-group" ng-class="{'has-error': newEntity.schema.$invalid}">
      <label class="col-sm-3 control-label" for="schema">Schema</label>
      <div class="col-sm-9">
        <select class="form-control" name="schema" ng-model="entity.schema"
          ng-options="s.label for s in schemata"></select>
        <p class="help-block" ng-show="newEntity.schema.$invalid" ng-bind="newEntity.schema.$message"></p>
        <span class="help-block">Select an appropriate type for this entity, this will determine which fields are available.</span>
      </div>
    </div>

    <div class="form-group" ng-repeat="attr in schemaAttributes">
      <label class="col-sm-3 control-label" for="{{attr.name}}">{{attr.label}}</label>
      <div class="col-sm-9">
        <gn-property-edit property="entity.properties[attr.name]" attribute="attr"></gn-property-edit>
      </div>
    </div>

    <div class="form-group">
      <div class="col-sm-offset-3 col-sm-9">
        <button type="submit" class="btn btn-primary" ng-disabled="!canSave()">Save</button>
      </div>
    </div>
  </form>
</gn-entity-frame>
