<div class="form-group clearfix feature-edition-general-tab">
  <div class="col-xs-12">
    <label>
      <translate>model.featuretypes.type</translate>
    </label>
  </div>
  <div class="col-xs-6 geometry-type-container">
    <div
      class="btn-group"
      ng-class="{'disabled': isEsriFeature || readonlystructure || edit_resource.typeInfo=='MULTIPOINT'}"
      bs-radio-group
    >
      <label
        class="btn btn-default"
        ng-class="{'disabled': isNewResource === false}"
      >
        <input
          type="radio"
          class="feature-type"
          name="geometry-type"
          value="NG"
          ng-model="edit_resource.typeInfo"
          ng-disabled="isEsriFeature || readonlystructure || edit_resource.typeInfo=='MULTIPOINT' || isNewResource === false"
          required
        />
        <translate>model.featuretypes.types.ng</translate>
      </label>
      <label
        class="btn btn-default"
        ng-class="{'disabled': isNewResource === false}"
      >
        <input
          type="radio"
          class="feature-type"
          name="geometry-type"
          value="POINT"
          ng-model="edit_resource.typeInfo"
          ng-disabled="isEsriFeature || readonlystructure || edit_resource.typeInfo=='MULTIPOINT' || isNewResource === false"
          required
        />
        <translate>model.featuretypes.types.point</translate>
      </label>
      <label
        class="btn btn-default"
        ng-class="{'disabled': isNewResource === false}"
      >
        <input
          type="radio"
          class="feature-type"
          name="geometry-type"
          value="LINE"
          ng-model="edit_resource.typeInfo"
          ng-disabled="isEsriFeature || readonlystructure || edit_resource.typeInfo=='MULTIPOINT' || isNewResource === false"
          required
        />
        <translate>model.featuretypes.types.line</translate>
      </label>
      <label
        class="btn btn-default"
        ng-class="{'disabled': isNewResource === false}"
      >
        <input
          type="radio"
          class="feature-type"
          name="geometry-type"
          value="POLYGON"
          ng-model="edit_resource.typeInfo"
          ng-disabled="isEsriFeature || readonlystructure || edit_resource.typeInfo=='MULTIPOINT' || isNewResource === false"
          required
        />
        <translate>model.featuretypes.types.polygon</translate>
      </label>
      <label
        class="btn btn-default"
        ng-if="edit_resource.typeInfo=='MULTIPOINT'"
        ng-class="{'disabled': isNewResource === false}"
      >
        <input
          type="radio"
          class="feature-type"
          name="geometry-type"
          value="MULTIPOINT"
          ng-model="edit_resource.typeInfo"
          ng-disabled="isEsriFeature || readonlystructure || edit_resource.typeInfo=='MULTIPOINT' || isNewResource === false"
          required
        />
        <translate>model.featuretypes.types.multipoint</translate>
      </label>
      <label
        class="btn btn-default"
        ng-if="edit_resource.typeInfo=='GEOMETRY'"
        ng-class="{'disabled': isNewResource === false}"
      >
        <input
          type="radio"
          class="feature-type"
          name="geometry-type"
          value="GEOMETRY"
          ng-model="edit_resource.typeInfo"
          ng-disabled="isEsriFeature || readonlystructure || edit_resource.typeInfo=='GEOMETRY' || isNewResource === false"
          required
        />
        <translate>model.featuretypes.types.geometry</translate>
      </label>
    </div>
  </div>
  <div class="col-xs-6">
    <div class="checkbox">
      <label>
        <input type="checkbox" ng-model="edit_resource.hasPopup" />
        <translate>model.featuretypes.hasPopup</translate>
      </label>
    </div>
  </div>
</div>
<div class="form-group clearfix">
  <div class="col-xs-6" ng-class="{'has-error': !validForm.name}">
    <label>
      <span>{{ 'model.featuretypes.name' | translate}}</span>
    </label>
    <validate-input
      ng-if="!isEsriFeature"
      data-restrict="[' ']"
      data-validated="validFields.name"
      data-value="edit_resource.name"
      is-disabled="(!edit_resource.storeName && !edit_resource.published && isNewResource ) ||
		edit_resource.published"
      ng-init="validateName()"
      on-blur="fillAliasWithNameIfEmpty(currentFeatureType)"
      required
    >
    </validate-input>
    <validate-input
      ng-if="isEsriFeature"
      data-validated="validFields.name"
      data-value="edit_resource.name"
      is-disabled="(!edit_resource.storeName && !edit_resource.published && isNewResource ) ||
		edit_resource.published"
      ng-init="validateName()"
      required
    ></validate-input>
    <div class="alert inlinealert alert-danger" ng-if="!validForm.name">
      <p ng-show="nameExists">
        <translate>model.featuretypes.already_exist</translate>
      </p>
      <p ng-show="!validFields.name">
        <translate>model.featuretypes.forbidden_characters</translate>
      </p>
      <p ng-show="verifyStartWithNumber">
        <translate>model.featuretypes.startWithNumber</translate>
      </p>
    </div>

    <!-- <input type="text" class="form-control" id="inputname" ng-disabled="!isNewFeatureType" ng-model="edit_resource.name" ng-init="validateName()" required>-->
    <!--<div class="alert inlinealert alert-danger" ng-if="!validForm.name">
            <translate>model.featuretypes.already_exist</translate>
        </div>-->
  </div>
  <div class="col-xs-6">
    <label for="inputStoreName">
      <translate>model.featuretypes.storeName</translate>
    </label>
    <select
      ng-model="edit_resource.storeName"
      ng-options="dataStore.name as dataStore.name for dataStore in dataStores | filter:noEsriDataStoreForNewFeature"
      id="inputStoreName"
      ng-disabled="(!isNewResource && edit_resource.published) || (featuresInDatabase.indexOf(edit_resource.name) !== -1 && edit_resource.attributes.length > 0)"
      class="form-control"
      required
    >
      <option ng-if="isNewResource" value=""
        >{{'model.datastores.please_select'|translate}}</option
      >
    </select>
  </div>
</div>

<div class="form-group clearfix">
  <div class="col-xs-6">
    <label for="inputalias">
      <translate>model.featuretypes.alias</translate>
    </label>
    <input
      type="text"
      class="form-control"
      id="inputalias"
      ng-model="edit_resource.alias"
      ng-disabled="isEsriFeature"
      required
    />
  </div>
  <div class="col-xs-6">
    <label for="inputsrid">
      <translate>model.featuretypes.srid</translate>
    </label>

    <div class="input-group">
      <input
        type="text"
        class="form-control"
        id="inputsrid"
        ng-model="edit_resource.srid"
        disabled
      />
      <span class="input-group-btn">
        <button
          class="btn btn-default"
          type="button"
          ng-click="sridModal()"
          ng-disabled="edit_resource.geographic==false || isEsriFeature || readonlystructure || edit_resource.typeInfo ==='NG'"
          ng-if="editModalIsNew"
        >
          <span class="glyphicon glyphicon-list"></span>
        </button>
      </span>
    </div>
    <div
      class="alert inlinealert alert-danger"
      ng-if="!edit_resource.srid && !(edit_resource.geographic==false || isEsriFeature || readonlystructure ||edit_resource.typeInfo ==='NG')"
    >
      <p>
        <translate>model.featuretypes.field_mandatory</translate>
      </p>
    </div>
  </div>
</div>

<div class="form-group clearfix">
  <div class="col-xs-6">
    <!--<label for="inputname"><translate>model.featuretypes.theme</translate></label>
        <input type="text" class="form-control" id="inputname" ng-model="edit_resource.theme" required>-->
    <div class="form-group">
      <div class="col-xs-12">
        <label>
          <translate>model.featuretypes.theme</translate>
        </label>

        <div
          class="btn btn-xs pull-right btn-default"
          ng-click="addThemeDisplay.v=!addThemeDisplay.v"
          ng-show="!addThemeDisplay.v"
        >
          <translate>model.featuretypes.add_a_theme</translate>
        </div>
        <div
          class="btn btn-xs pull-right btn-success"
          ng-click="addTheme()"
          ng-show="addThemeDisplay.v"
          style="margin-left: 5px;"
        >
          <i class="fa fa-plus"></i>
        </div>
        <div
          class="btn btn-xs pull-right btn-danger"
          ng-click="newtheme.name='';addThemeDisplay.v=false"
          ng-show="addThemeDisplay.v"
        >
          <i class="fa fa-times"></i>
        </div>
        <div class="addFeatureTypeTheme" ng-show="addThemeDisplay.v">
          <input
            type="text"
            class="form-control input-sm"
            ng-model="newtheme.name"
            style="margin-bottom: 5px;"
          />
        </div>

        <select
          ng-model="edit_resource.theme"
          ng-options="theme as theme for theme in themesList"
          id="inputtype"
          class="form-control"
          required
        >
        </select>
      </div>
    </div>
  </div>
  <div class="col-xs-6">
    <label for="inputprimaryKey">
      <translate>model.featuretypes.primaryKey</translate>
    </label>
    <input
      type="text"
      class="form-control"
      id="inputprimaryKey"
      ng-model="edit_resource.primaryKey"
      disabled
    />
  </div>
</div>
<!-- BBOX -->
<div id="bbox_wrapper">
  <div class="form-group clearfix">
    <div class="col-xs-12">
      <div class="checkbox">
        <label for="inputbboxselection">
          <input
            type="checkbox"
            id="inputbboxselection"
            ng-model="edit_resource.bboxselection"
          />
          <translate>model.featuretypes.bbox.selection</translate>
        </label>
      </div>
    </div>
  </div>

  <div ng-show="edit_resource.bboxselection">
    <div class="form-group clearfix has-feedback">
      <div class="col-xs-5 col-xs-offset-4">
        <input
          type="number"
          step="any"
          class="form-control input-sm"
          id="inputy1"
          ng-model="edit_resource.bbox[3]"
          ng-disabled="!edit_resource.bboxselection"
        />
        <i class="form-control-feedback">
          <translate>model.featuretypes.bbox.y_max</translate>
        </i>
      </div>
    </div>

    <!-- X MIN + X MAX -->
    <div class="form-group clearfix has-feedback">
      <div class="col-xs-5 col-xs-offset-1">
        <input
          type="number"
          step="any"
          class="form-control input-sm"
          id="inputx1"
          ng-model="edit_resource.bbox[0]"
          ng-disabled="!edit_resource.bboxselection"
        />
        <i class="form-control-feedback">
          <translate>model.featuretypes.bbox.x_min</translate>
        </i>
      </div>
      <div class="col-xs-5">
        <input
          type="number"
          step="any"
          class="form-control input-sm"
          id="inputx2"
          ng-model="edit_resource.bbox[2]"
          ng-disabled="!edit_resource.bboxselection"
        />
        <i class="form-control-feedback">
          <translate>model.featuretypes.bbox.x_max</translate>
        </i>
      </div>
    </div>

    <!-- Y MIN -->
    <div class="form-group clearfix has-feedback">
      <div class="col-xs-5 col-xs-offset-4">
        <input
          type="number"
          step="any"
          class="form-control input-sm"
          id="inputy2"
          ng-model="edit_resource.bbox[1]"
          ng-disabled="!edit_resource.bboxselection"
        />
        <i class="form-control-feedback">
          <translate>model.featuretypes.bbox.y_min</translate>
        </i>
      </div>
    </div>
  </div>
  <!-- Y MAX -->
</div>

<div ng-show="!isEsriFeature">
  <div class="form-group clearfix">
    <div class="col-xs-6" id="layerMiscData">
      <div>
        <label>
          <translate>model.featuretypes.published</translate>
        </label>
        <span ng-bind-html="edit_resource.published | booleanToCheck"></span>
      </div>
      <div>
        <label>
          <translate>model.featuretypes.geographic</translate>
        </label>
        <span ng-bind-html="edit_resource.geographic | booleanToCheck"></span>
      </div>
      <div>
        <label>
          <translate>model.featuretypes.inElasticSearch</translate>
        </label>
        <span
          ng-bind-html="edit_resource.inElasticSearch | booleanToCheck"
        ></span>
      </div>
    </div>
    <div class="col-xs-6 text-center">
      <div style="margin-bottom: 7.5px;">
        <button
          class="btn btn-default"
          type="button"
          ng-click="publishFeatureType()"
          ng-disabled="isNewResource"
        >
          <i class="fa fa-google-wallet"></i>
          <translate>model.featuretypes.publish</translate>
        </button>
      </div>
      <div>
        <button
          class="btn btn-default"
          type="button"
          ng-click="indexFeatureType()"
          ng-disabled="!inElasticSearch"
        >
          <i class="fa fa-italic"></i>
          <translate>model.featuretypes.elasticsearch.index</translate>
        </button>
      </div>
    </div>
  </div>
</div>

<div class="form-group clearfix" ng-show="ftiSourceIsPostGIS()">
  <div class="col-xs-12">
    <div class="checkbox">
      <label for="inputsharedwitharcgis">
        <input type="checkbox" id="inputsharedwitharcgis"
          ng-model="edit_resource.sharedWithArcGIS" />
        <translate>model.featuretypes.shared_with_arcgis</translate>
      </label>
    </div>
  </div>
</div>
