<div class="d-flex justify-content-center">
  <div class="col-8">
    <form name="editForm" novalidate (ngSubmit)="save()" [formGroup]="editForm">
      <h2
        id="jhi-variable-scope-heading"
        data-cy="VariableScopeCreateUpdateHeading"
        jhiTranslate="resilientApp.variableScope.home.createOrEditLabel"
      >
        Criar ou editar Variable Scope
      </h2>

      <div>
        <jhi-alert-error></jhi-alert-error>

        @if (editForm.controls.id.value !== null) {
          <div class="mb-3">
            <label class="form-label" for="field_id" jhiTranslate="resilientApp.variableScope.id">ID</label>
            <input type="number" class="form-control" name="id" id="field_id" data-cy="id" formControlName="id" [readonly]="true" />
          </div>
        }

        <div class="mb-3">
          <label
            class="form-label"
            for="field_code"
            [ngbTooltip]="'resilientApp.variableScope.help.code' | translate"
            jhiTranslate="resilientApp.variableScope.code"
            >Code</label
          >
          <input type="text" class="form-control" name="code" id="field_code" data-cy="code" formControlName="code" />
          @if (editForm.get('code')!.invalid && (editForm.get('code')!.dirty || editForm.get('code')!.touched)) {
            <div>
              @if (editForm.get('code')?.errors?.required) {
                <small class="form-text text-danger" jhiTranslate="entity.validation.required">O campo é obrigatório.</small>
              }
              @if (editForm.get('code')?.errors?.pattern) {
                <small class="form-text text-danger" jhiTranslate="entity.validation.pattern" [translateValues]="{ pattern: 'Code' }"
                  >Este campo deve estar dentro do seguinte padrão Code.</small
                >
              }
            </div>
          }
        </div>

        <div class="mb-3">
          <label
            class="form-label"
            for="field_name"
            [ngbTooltip]="'resilientApp.variableScope.help.name' | translate"
            jhiTranslate="resilientApp.variableScope.name"
            >Name</label
          >
          <input type="text" class="form-control" name="name" id="field_name" data-cy="name" formControlName="name" />
          @if (editForm.get('name')!.invalid && (editForm.get('name')!.dirty || editForm.get('name')!.touched)) {
            <div>
              @if (editForm.get('name')?.errors?.required) {
                <small class="form-text text-danger" jhiTranslate="entity.validation.required">O campo é obrigatório.</small>
              }
            </div>
          }
        </div>

        <div class="mb-3">
          <label
            class="form-label"
            for="field_description"
            [ngbTooltip]="'resilientApp.variableScope.help.description' | translate"
            jhiTranslate="resilientApp.variableScope.description"
            >Description</label
          >
          <input
            type="text"
            class="form-control"
            name="description"
            id="field_description"
            data-cy="description"
            formControlName="description"
          />
          @if (editForm.get('description')!.invalid && (editForm.get('description')!.dirty || editForm.get('description')!.touched)) {
            <div>
              @if (editForm.get('description')?.errors?.required) {
                <small class="form-text text-danger" jhiTranslate="entity.validation.required">O campo é obrigatório.</small>
              }
            </div>
          }
        </div>

        <div class="mb-3">
          <label
            class="form-label"
            for="field_version"
            [ngbTooltip]="'resilientApp.variableScope.help.version' | translate"
            jhiTranslate="resilientApp.variableScope.version"
            >Version</label
          >
          <input type="number" class="form-control" name="version" id="field_version" data-cy="version" formControlName="version" />
        </div>
      </div>

      <div>
        <button type="button" id="cancel-save" data-cy="entityCreateCancelButton" class="btn btn-secondary" (click)="previousState()">
          <fa-icon icon="ban"></fa-icon>&nbsp;<span jhiTranslate="entity.action.cancel">Cancelar</span>
        </button>

        <button
          type="submit"
          id="save-entity"
          data-cy="entityCreateSaveButton"
          [disabled]="editForm.invalid || isSaving"
          class="btn btn-primary"
        >
          <fa-icon icon="save"></fa-icon>&nbsp;<span jhiTranslate="entity.action.save">Guardar</span>
        </button>
      </div>
    </form>
  </div>
</div>
