<main class="main-container animated fadeIn">
  <app-btn-navigate navigate="/sam/GIST/ASDO" nameButton="Fichas descriptivas de los artículos" />
  <mat-card class="override-card override-elevation-z8">
      <section class="override-section">
          <nav class="override-nav">
              <div class="w-100 align-center pv-15">
                  <span class="title-card">Asociación de documentos del stock #{{ idStock }}</span>
              </div>
              <div class="override-actions">
                  <app-search-card 
                      [dataSource]="dataSource" 
                      [disabled]="isLoading || isLoadingForm" 
                      (dataValue)="dataSource = $event" />
  
                  <div class="override-buttons">
                      <app-btn-resize 
                          class="mr-8"
                          (click)="goForm('REG')"
                          [disabled]="isLoading || isLoadingForm"
                          [backgroundColor]="'primary raised-button-background'" 
                          [textColor]="'white_font'" 
                          [nameButton]="'Nuevo'" 
                          [icon]="'add'"/>
                      <button 
                          mat-mini-fab 
                          matTooltip="Actualizar datos"
                          (click)="getDocumentsByStock()"
                          class="orange_primary_background white_font override_no_shadow ml-8">
                          <mat-icon>refresh</mat-icon>
                      </button>
                  </div>
              </div>
          </nav>
  
          <app-loading-card 
              [isLoading]="isLoading" 
              [isLoadingForm]="isLoadingForm" 
              [txtLoading]="'Cargando documentos'"
          />
  
          <div class="override-table">
              <table mat-table matSort [dataSource]="dataSource" class="animated fadeIn" [style.display]="isLoading ? 'none' : 'revert'">
                  <ng-container matColumnDef="DOCUMENTO">
                      <th mat-header-cell *matHeaderCellDef mat-sort-header> Nombre del documento </th>
                      <td mat-cell *matCellDef="let element"> {{ resourcesService.resizeText(element.DOCUMENTO, 27)  }} </td>
                  </ng-container>
                  <ng-container matColumnDef="EXTENSION">
                      <th mat-header-cell *matHeaderCellDef mat-sort-header> Extensión </th>
                      <td mat-cell *matCellDef="let element"> {{ element.EXTENSION }} </td>
                  </ng-container>
                  <ng-container matColumnDef="CLASIFICACION">
                      <th mat-header-cell *matHeaderCellDef mat-sort-header> Clasificación </th>
                      <td mat-cell *matCellDef="let element"> {{ element.CLASIFICACION }} </td>
                  </ng-container>
                  <ng-container matColumnDef="VERSION">
                      <th mat-header-cell *matHeaderCellDef mat-sort-header> Versión </th>
                      <td mat-cell *matCellDef="let element"> {{ element.VERSION }} </td>
                  </ng-container>
                  <ng-container matColumnDef="TAMANO">
                      <th mat-header-cell *matHeaderCellDef mat-sort-header> Tamaño </th>
                      <td mat-cell *matCellDef="let element"> {{ element.TAMANO }} </td>
                  </ng-container>
                  <ng-container matColumnDef="USUARIO_MODIFICA">
                      <th mat-header-cell *matHeaderCellDef mat-sort-header> Usuario modificación </th>
                      <td mat-cell *matCellDef="let element"> {{ element.USUARIO_MODIFICA }} </td>
                  </ng-container>
                  <ng-container matColumnDef="FECHA_MODIFICA">
                      <th mat-header-cell *matHeaderCellDef mat-sort-header> Fecha de actualización </th>
                      <td mat-cell *matCellDef="let element"> {{ element.FECHA_MODIFICA }} </td>
                  </ng-container>
                  <ng-container matColumnDef="ESTADO">
                      <th mat-header-cell *matHeaderCellDef mat-sort-header> Estado </th>
                      <td mat-cell *matCellDef="let element"> 
                        <button mat-flat-button class="white_font" [class]="resourcesService.setChipList(element.ESTADO)">
                          {{ element.ESTADO }} 
                        </button>
                      </td>
                  </ng-container>
                  <ng-container matColumnDef="ACCIONES">
                      <th mat-header-cell *matHeaderCellDef mat-sort-header> Acciones </th>
                      <td mat-cell *matCellDef="let element">
                          <button 
                              mat-mini-fab 
                              color="primary white_font green_primary_background"
                              class="override_no_shadow ml-4" 
                              matTooltip="Descargar"  
                              (click)="alert('DOW', element)"
                              [disabled]="isLoadingForm">
                              <mat-icon>file_download</mat-icon>
                          </button>
                      </td>
                  </ng-container>
  
                  <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
                  <tr mat-row *matRowDef="let row; columns: displayedColumns"></tr>
  
                  <tr class="mat-row" *matNoDataRow>
                      <td class="mat-cell p-20 align-center" colspan="12">
                      <object data="assets/img/empty_data.svg" width="150"></object>
                      <h2>Sin datos</h2>
                      </td>
                  </tr>
  
              </table>
          </div>
      </section>
      <mat-paginator [pageSizeOptions]="[10, 20, 50]" class="override-paginator" showFirstLastButtons></mat-paginator>
  </mat-card>
</main>