<!-- GUIPropertiesViewAndSortCustomizer -->
<div>
  <h2 id="page-heading" data-cy="UnitConverterHeading">
    <span jhiTranslate="resilientApp.unitConverter.home.title">Unit Converters</span>

    <div class="d-flex justify-content-end">
      <button class="btn btn-info me-2" (click)="load()" [disabled]="isLoading">
        <fa-icon icon="sync" [spin]="isLoading"></fa-icon>
        <span jhiTranslate="resilientApp.unitConverter.home.refreshListLabel">Refresh list</span>
      </button>

      <button
        id="jh-create-entity"
        data-cy="entityCreateButton"
        class="btn btn-primary jh-create-entity create-unit-converter"
        [routerLink]="['/unit-converter/new']"
      >
        <fa-icon icon="plus"></fa-icon>
        <span jhiTranslate="resilientApp.unitConverter.home.createLabel">Criar novo(a) Unit Converter</span>
      </button>
    </div>
  </h2>

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

  <jhi-alert></jhi-alert>

  @if (unitConverters && unitConverters.length >= 0) {
    <div class="table-responsive table-entities" id="entities">
    
    	{{ ' ' // Wrap the all table in a form. This is the only way reactiveforms will work }}
      <form id="searchForm" name="searchForm" novalidate (ngSubmit)="onSearch()" [formGroup]="searchForm">
    
        <table class="table table-striped" aria-describedby="page-heading">
        <thead>
          <tr jhiSort [sortState]="sortState" (sortChange)="navigateToWithComponentValues($event)">
            <th scope="col" jhiSortBy="fromUnit.name">
              <div class="d-flex">
                <span jhiTranslate="resilientApp.unitConverter.fromUnit">From Unit</span>
                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>
            <th scope="col" jhiSortBy="toUnit.name">
              <div class="d-flex">
                <span jhiTranslate="resilientApp.unitConverter.toUnit">To Unit</span>
                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>
            <th scope="col" jhiSortBy="name">
              <div class="d-flex">
                <span jhiTranslate="resilientApp.unitConverter.name">Name</span>

                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>

            <th scope="col"></th>
          </tr>
          
          {{ ' ' // Search row }}
          <tr class="search">
            <th>
              <select
                class="form-control"
                id="field_fromUnitId"
                data-cy="fromUnitId"
                name="fromUnitId"
                formControlName="fromUnitId"
                [compareWith]="compareUnit"
              >
                <option [ngValue]="null" selected style="color: gray;">Filter by From Unit</option>
                @for (unitOption of unitsSharedCollection; track $index) {
                  <option [ngValue]="unitOption.id">{{ unitOption.unitType?.name }} » {{ unitOption.name }}</option>
                }
              </select>
            </th>
            <th>
              <select
                class="form-control"
                id="field_toUnitId"
                data-cy="toUnitId"
                name="toUnitId"
                formControlName="toUnitId"
                [compareWith]="compareUnit"
              >
                <option [ngValue]="null" selected style="color: gray;">Filter by To Unit</option>
                @for (unitOption of unitsSharedCollection; track $index) {
                  <option [ngValue]="unitOption.id">{{ unitOption.unitType?.name }} » {{ unitOption.name }}</option>
                }
              </select>
            </th>
            <th>
              <input type="text" class="form-control" name="name" id="field_name" data-cy="name" formControlName="name" placeholder="Filter by name"/>
            </th>
            <th>
              <button class="btn btn-info me-2 w-100" type="submit" form="searchForm">Filter</button>
            </th>
          </tr>
        </thead>
        <tbody>
          @for (unitConverter of unitConverters; track trackId) {
            <tr data-cy="entityTable">
              <td>
                @if (unitConverter.fromUnit) {
                  <div>
                    <a [routerLink]="['/unit', unitConverter.fromUnit.id, 'view']">{{ unitConverter.fromUnit.name }}</a>
                  </div>
                }
              </td>
              <td>
                @if (unitConverter.toUnit) {
                  <div>
                    <a [routerLink]="['/unit', unitConverter.toUnit.id, 'view']">{{ unitConverter.toUnit.name }}</a>
                  </div>
                }
              </td>
              <td>{{ unitConverter.name }}</td>

              <td class="text-end">
                <div class="btn-group">
                  <a [routerLink]="['/unit-converter', unitConverter.id, 'view']" class="btn btn-info btn-sm" data-cy="entityDetailsButton">
                    <fa-icon icon="eye"></fa-icon>
                    <span class="d-none d-md-inline" jhiTranslate="entity.action.view">Visualizar</span>
                  </a>

                  <a [routerLink]="['/unit-converter', unitConverter.id, 'edit']" class="btn btn-primary btn-sm" data-cy="entityEditButton">
                    <fa-icon icon="pencil-alt"></fa-icon>
                    <span class="d-none d-md-inline" jhiTranslate="entity.action.edit">Editar</span>
                  </a>

                  <button type="submit" (click)="delete(unitConverter)" class="btn btn-danger btn-sm" data-cy="entityDeleteButton">
                    <fa-icon icon="times"></fa-icon>
                    <span class="d-none d-md-inline" jhiTranslate="entity.action.delete">Eliminar</span>
                  </button>
                </div>
              </td>
            </tr>
          }
        </tbody>
      </table>

      </form>
    </div>
  }
  
  @if (unitConverters?.length === 0) {
    <div class="alert alert-warning" id="no-result">
      <span jhiTranslate="resilientApp.unitConverter.home.notFound">Nenhum Unit Converters encontrado</span>
    </div>
  }
</div>
