<h3 ng-if="editModalIsNew">
  <translate>applications.applications.create</translate>
</h3>
<h3 ng-if="!editModalIsNew">
  <translate>applications.applications.edit</translate>
</h3>

<form ng-submit="editApplication();closeThisDialog()" class="form app-edition" role="form">
  <div class="form-group clearfix">
    <div class="col-sm-6" ng-class="{'has-error': !validForm.name}">
      <label><translate>applications.applications.name</translate></label>

      <validate-input
        data-restrict="['&',' ']"
        data-validated="validFields.name"
        data-value="edit_resource.name"
        is-disabled="!editModalIsNew"
        ng-init="validateName()"
        required
      ></validate-input>

      <div class="alert inlinealert alert-danger" ng-if="!validForm.name">
        <p ng-show="nameExists">
          <translate>applications.applications.already_exist</translate>
        </p>
        <p ng-show="!validFields.name">
          <translate>applications.applications.forbidden_characters</translate>
        </p>
      </div>
    </div>
    <div class="col-sm-6">
      <label translate>applications.applications.type</label>
      <!--    <select

                    ng-model="edit_resource.type"
                    ng-options="x.key  as (x.icon + ' '+ (x.label | translate)) for x in applicationTypes"
                    id="inputtype"
                    class="form-control"
                    ng-disabled="!editModalIsNew" required>-->
      <button
        type="button"
        class="btn btn-default applicationPicker"
        ng-model="edit_resource.type"
        data-html="1"
        data-toggle="true"
        ng-disabled="!editModalIsNew"
        bs-options="x.key as displayApp(x) for x in applicationTypes"
        bs-select
      ></button>
      <!-- </select> -->
    </div>
  </div>

  <!--{{edit_resource.type}}-->
  <!-- <div ng-if="edit_resource.type =='FormApp'">
          <div class="row">

                    <div class="col-xs-12">
                        <div class="btn btn-default pull-right btn-sm" ng-click="openConfigBrowser()" style="margin: 2px;">
                            ...
                        </div>
                        <div class="input-group" >
                            <span class="input-group-addon" > <i class="fa fa-folder-o"></i></span>
                            <input type="text" class="form-control"  ng-model="lks.config.templatedir">
                            <span class="input-group-addon"><i class="fa fa-cube"></i> </span>
                            <input type="text" class="form-control"   ng-model="lks.config.templateform">
                        </div>
                    </div>
                </div>

    </div>-->
  <div class="form-group clearfix">
    <div class="col-xs-12">
      <div dual-list-box
        data="dLBRolesData"
        addfilters="true"
        >
      </div>
    </div>
  </div>

  <div ng-if="appTypeIsMap();">
    <div class="form-group clearfix">
      <div class="col-xs-12">
        <label for="inputsrid"
          ><translate>applications.applications.outsrid</translate></label >

        <input
          id="inputsrid"
          type="text"
          class="form-control"
          ng-model="edit_resource.outsrid"
          bs-options="srid for srid in srids"
          placeholder="ex: EPSG:3857, EPSG:2154, EPSG:4326..."
          limit="25"
          bs-typeahead
          required
        />
      </div>
    </div>
    <div>
      <label class="normal">
        <input type="checkbox" ng-model="edit_resource.params.mapModelSelector">
        <span translate>applications.applications.displayMapModelSelector</span>
      </label>
    </div>
  </div>

  <div ng-show="edit_resource.type!='Indigau'">
    <label class="form-check-label">
      <input type="checkbox" ng-model="edit_resource.params.operis" />
      <span translate>applications.applications.connectionDDC</span>
    </label>
  </div>
  <div ng-show="appTypeIsMap()  || edit_resource.type=='Indigau'">
    <label class="form-check-label">
      <input
        type="checkbox"
        ng-true-value="'yes'"
        ng-false-value="'no'"
        ng-model="edit_resource.wmswfs"
      />
      <span translate>applications.applications.accessWmsWfs</span>
    </label>
  </div>

  <div ng-show="appTypeIsMap();">
    <input
      type="checkbox"
      ng-true-value="'yes'"
      ng-false-value="'no'"
      ng-model="scaleMgr.showScaleTool"
    />
    <label class="form-check-label">
      <translate>applications.applications.showScaleTool</translate>
    </label>
  </div>
  <div ng-show="(appTypeIsMap() || edit_resource.type=='Indigau') && scaleMgr.showScaleTool=='yes'">
    <label>
      &nbsp;&nbsp;&nbsp;<translate
        >applications.applications.scales4scaleSelector</translate>
    </label>
    <button
      class="btn btn-default"
      type="button"
      ng-click="showScaleManager();"
      ng-attr-title="{{fullScaleListAsString}}"
    >
      {{scaleListAsString}}
    </button>
  </div>
  <div ng-show="appTypeIsHpO();">
    <input type="checkbox" 
    	ng-init="edit_resource.hpoSimplifyVisualize=(edit_resource.hpoSimplifyVisualize)?edit_resource.hpoSimplifyVisualize:'yes'" 
    	ng-true-value="'yes'" ng-false-value="'no'" ng-model="edit_resource.hpoSimplifyVisualize"/>
    <label class="form-check-label" >
        <translate>applications.applications.hpoSimplifyVisualize</translate>
    </label>
  </div>

  <div class="form-group text-right clearfix">
    <div class="col-xs-12">
      <div class="col-xs-3">
        <button
          type="button"
          ng-if="!editModalIsNew&&edit_resource.type=='MapApp'"
          ng-disabled="!cancreate"
          class="btn btn-default pull-left"
          data-template="js/XG/modules/applications/views/modals/popover.copy.application.html"
          data-placement="right"
          data-animation="am-flip-x"
          data-auto-close="1"
          ng-click="copy_app.name=''"
          bs-popover
        >
          <translate>common.copy</translate>
        </button>
      </div>
      <div class="col-xs-5" ng-if="appTypeIsMap();">
        <geocatalogue-filter></geocatalogue-filter>
      </div>
      <div class="col-xs-4 pull-right">
        <close-modale-button></close-modale-button>
        <button class="btn btn-primary" ng-disabled="!validForm.name||typeExists">
          <translate>common.save</translate>
        </button>
      </div>
    </div>
  </div>
</form>
