<ng-include src="'augeas/templates/partials/radio_settings.html'"></ng-include>

<div class="panel panel-default"
  ng-controller="PartObjectNumbersController as partObjectNumbers"
  ng-show="partObjectNumbers.parts().length > 1 && partObjectNumbers.radioEnabled()">
  <div class="panel-heading">
    <h3 class="panel-title" translate>Объектовые номера разделов</h3>
  </div>

  <div class="panel-body">
    <form name="partObjectNumbersForm">
      <table class="table">
        <tr>
          <th class="col-md-6 text-right" style="border-top:none" translate>Раздел</th>
          <th class="col-md-6" style="padding-left: 0; border:none">
            <div class="col-md-12" translate>Номер объекта</div>
          </th>
        </tr>

        <tbody ng-repeat="partIndex in partObjectNumbers.parts()"
          ng-init="formName = 'objectNumberForm' + partIndex"
          ng-class="partObjectNumbersForm[formName].$invalid?'has-error':''"
          style="border:none">

          <tr>
            <td class="text-right" style="vertical-align:middle">
              <div>{[ partIndex + 1  ]}</div>
            </td>
            <td style="padding-left:0" ng-form="{[ formName ]}">

              <div class="col-md-4">
                <input type="text" class="form-control"
                  class="col-md-1"
                  ng-model="partObjectNumbers.numbers()[partIndex]"
                  ng-trim="true"
                  ng-pattern="/^\d*$/"
                  validate-using-function="{
                    'func': partObjectNumbers.validateObjectNumber,
                    key: 'num'
                  }"
                  ng-model-options="{
                    updateOn: 'default blur',
                    debounce: { default: 500, blur: 0 }
                  }">
              </div>
            </td>
          </tr>

          <tr ng-show="partObjectNumbersForm[formName].$invalid">
            <td style="border:none; padding-left:0 ;padding-top:0;"></td>
            <td style="border:none; padding-left:0 ;padding-top: 0;">
              <div class="help-block col-md-12" translate>
                Номер объекта должен быть числом в диапазоне 1…8192
              </div>
            </td>
          </tr>

        </tbody>

      </table>
    </form>
  </div>
</div>
