<div>
  <h2 id="page-heading" data-cy="MetadataValueHeading">
    <span jhiTranslate="resilientApp.metadataValue.home.title">Metadata Values</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.metadataValue.home.refreshListLabel">Refresh list</span>
      </button>

      <button
        id="jh-create-entity"
        data-cy="entityCreateButton"
        class="btn btn-primary jh-create-entity create-metadata-value"
        [routerLink]="['/metadata-value/new']"
      >
        <fa-icon icon="plus"></fa-icon>
        <span jhiTranslate="resilientApp.metadataValue.home.createLabel">Criar novo(a) Metadata Value</span>
      </button>
    </div>
  </h2>

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

  <jhi-alert></jhi-alert>

  @if (metadataValues?.length === 0) {
    <div class="alert alert-warning" id="no-result">
      <span jhiTranslate="resilientApp.metadataValue.home.notFound">Nenhum Metadata Values encontrado</span>
    </div>
  }

  @if (metadataValues && metadataValues.length > 0) {
    <div class="table-responsive table-entities" id="entities">
      <table class="table table-striped" aria-describedby="page-heading">
        <thead>
          <tr jhiSort [sortState]="sortState" (sortChange)="navigateToWithComponentValues($event)">
            <th scope="col" jhiSortBy="id">
              <div class="d-flex">
                <span jhiTranslate="global.field.id">Código</span>

                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>
            <th scope="col" jhiSortBy="metadataPropertyCode">
              <div class="d-flex">
                <span jhiTranslate="resilientApp.metadataValue.metadataPropertyCode">Metadata Property Code</span>

                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>
            <th scope="col" jhiSortBy="targetDomainKey">
              <div class="d-flex">
                <span jhiTranslate="resilientApp.metadataValue.targetDomainKey">Target Domain Key</span>

                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>
            <th scope="col" jhiSortBy="targetDomainId">
              <div class="d-flex">
                <span jhiTranslate="resilientApp.metadataValue.targetDomainId">Target Domain Id</span>

                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>
            <th scope="col" jhiSortBy="value">
              <div class="d-flex">
                <span jhiTranslate="resilientApp.metadataValue.value">Value</span>

                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>
            <th scope="col" jhiSortBy="version">
              <div class="d-flex">
                <span jhiTranslate="resilientApp.metadataValue.version">Version</span>

                <fa-icon class="p-1" icon="sort"></fa-icon>
              </div>
            </th>
            <th scope="col"></th>
          </tr>
        </thead>
        <tbody>
          @for (metadataValue of metadataValues; track trackId) {
            <tr data-cy="entityTable">
              <td>
                <a [routerLink]="['/metadata-value', metadataValue.id, 'view']">{{ metadataValue.id }}</a>
              </td>
              <td>{{ metadataValue.metadataPropertyCode }}</td>
              <td>{{ metadataValue.targetDomainKey }}</td>
              <td>{{ metadataValue.targetDomainId }}</td>
              <td>{{ metadataValue.value }}</td>
              <td>{{ metadataValue.version }}</td>
              <td class="text-end">
                <div class="btn-group">
                  <a [routerLink]="['/metadata-value', metadataValue.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]="['/metadata-value', metadataValue.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(metadataValue)" 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>
    </div>
  }
</div>
