<!--label class="label label-danger" >restrictions :  <span ng-repeat="restriction in restrictions">{{restriction}}</span></label-->
<div class="attribute_restriction">
  <div ng-if="restrictions[0]=='Interval'" class="interval_rest">
    <input
      type="number"
      min="{{intervalmin}}"
      max="{{intervalmax}}"
      ng-model="res[attributeToSet]"
      ng-change="deleteNullDefaultValues()"
      ng-if="!fieldData.readonly"
    />
    <input
        type="number"
        min="{{intervalmin}}"
        max="{{intervalmax}}"
        ng-model="res[attributeToSet]"
        ng-if="fieldData.readonly "
        disabled
    />
    <div
      range-slider
      min="intervalmin"
      max="intervalmax"
      model-max="res[attribute.name]"
      pin-handle="min"
      ng-if="!fieldData.readonly"
    ></div>
  </div>
  <div
    ng-if="restrictions[0]=='inputSize'"
    class="size_rest"
    ng-class="{'err' : !res[attribute.name] || res[attribute.name].length<restmin || res[attribute.name].length>restmax, 'ok' : res[attribute.name].length>=restmin && res[attribute.name].length<=restmax}"
  >
    <input
      type="{{typeInput}}"
      class="form-control"
      ng-model="res[attributeToSet]"
      pattern="{{pattern}}"
      ng-required="restrictions[0]=='inputSize'"
      ng-change="deleteNullDefaultValues()"
    />
    <small class="pull-right">
      <i class="resticon"></i>
      {{patternDetail}} <translate>common.characters</translate>
    </small>
  </div>

  <div
    ng-if="restrictions[0]=='Domain'">
    <span ng-if="!displayAsText">
      <input
        type="text"
        class="form-control ruleValue"
        ng-if="domainRestrictionAllowDifferentValues==true"
        ng-model="res[attributeToSet]"
        data-min-length="0"
        data-html="1"
        data-auto-select="true"
        data-animation="am-flip-x"
        ng-disabled="fieldData.readonly && !alwaysEnable"
        bs-options="v.val as v.translationKey | translate  for v in listofValues"
        bs-typeahead
        ng-change="deleteNullDefaultValues()"
      />

      <select
        ng-model="res[attributeToSet]"
        ng-change="resValueChanged()"
        class="form-control ruleValue"
        ng-disabled="fieldData.readonly && !alwaysEnable"
        ng-options="v.val as v.translated | translate  for v in listofValues | orderBy:'translated'"
        ng-show="!fieldData.inputcfg&&domainRestrictionAllowDifferentValues==false"
        id="listofValues"
      >
        <option value="">-----------------</option>
      </select>

      <select
        ng-model="res[attributeToSet]"
        ng-change="resValueChanged()"
        ng-disabled="fieldData.readonly && !alwaysEnable"
        class="form-control ruleValue"
        ng-options="v.val as v.translated | translate  for v in listofValues | orderBy:'translated'"
        ng-if="fieldData.inputcfg=='default'&&domainRestrictionAllowDifferentValues==false"
        id="listofValues-default"
      >
        <option value="">-----------------</option>
      </select>

      <!-- Old weird version used in formbuilder, probably should use aliases like listvalueEfAnc -->
      <div
        ng-if="fieldData.inputcfg=='listvalue'"
        class="attrRestrictionListValue ruleValue"
      >
        <div ng-repeat="v in listofValues" style="margin-left:25px">
          <label>
            <input type="radio" ng-model="res[attributeToSet]" ng-value="v.val"
            ng-disabled="fieldData.readonly && !alwaysEnable" />
            {{v.val}} </label
          ><br />
        </div>
      </div>

      <div
        ng-if="fieldData.inputcfg=='listvalueEfAnc'"
        class="attrRestrictionListValue"
      >
        <div ng-repeat="v in listofValues" style="margin-left:15px">
          <label>
            <input
              type="radio"
              uncheckable-radio
              ng-disabled="fieldData.readonly && !alwaysEnable"
              ng-model="res[attributeToSet]"
              ng-value="v.val"
              ng-change="deleteNullDefaultValues()"
            />
            {{v.translated}}
          </label>
        </div>
      </div>
    </span>
    <span ng-if="displayAsText">
      {{getValueFromKeyDomaineRestriction(res[attributeToSet])}}
    </span>
  </div>
  <div ng-if="restrictions[0]=='Tables'" class="table_rest">
    <div class="input-group ruleValue"
      ng-if="!displayAsText">
      <input
        ng-if="!displaySmallVersion"
        type="text"
        class="form-control"
        ng-model="labelDisplayed"
        disabled
        ng-change="deleteNullDefaultValues()"
      />
      <span class="input-group-btn">
        <button
          type="button"
          class="btn btn-default"
          ng-class="{'btn-xs':displaySmallVersion}"
          ng-click="selectRestrictedValue(true)"
          ng-disabled="fieldData.readonly && !alwaysEnable"
          title>
          <i class="fa fa-list"></i>
        </button>
        <button
          class="btn btn-default"
          type="button"
          ng-if="showCleanValueButton"
          ng-click="cleanRestrictedValue()"
          ng-disabled="fieldData.readonly && !alwaysEnable"
          title>
          <i class="fa fa-remove"></i>
        </button>
      </span>
    </div>
    <span ng-if="displayAsText">
      {{labelDisplayed}}
    </span>
  </div>

  <div ng-if="restrictions[0]==='User'" class="table_rest">
    <div class="input-group ruleValue">
      <input
          type="text"
          class="form-control"
          ng-model="labelDisplayed"
          disabled
          ng-change="deleteNullDefaultValues()"
      />
      <span class="input-group-btn">
        <button
            type="button"
            class="btn btn-default "
            ng-click="selectUserRestrictedValue()"
            ng-disabled="fieldData.readonly && !alwaysEnable"
        >
          <i class="fa fa-list"></i>
        </button>
      </span>
    </div>
  </div>

</div>
