<ion-header class="header-subpage" no-border>
  <ion-toolbar>
    <ion-title class="titolo-sezione-head">i miei documenti</ion-title>
  </ion-toolbar>
</ion-header>

<ion-content>
  <div class="contenitore-home">
    <div class="central-doc">
      <ion-grid>
        <ion-row class="search-date">
          <div *ngIf="platform.is('desktop')">
            <strong>Cerca</strong> da <input type="date" name="calendar" [(ngModel)]="date1" title="Seleziona una data"> a <input type="date" name="calendar" [(ngModel)]="date2" title="Seleziona la data">
          </div>
          <div class="float-date" *ngIf="!platform.is('desktop')">
            <span class="date-text"><strong>Cerca</strong> da </span>
            <ion-icon class="element-date date-icon" name="calendar" (click)="setDateDa()"></ion-icon>
            <div class="element-date item-no-border date-text">
              {{date1}}
            </div> 
            <span class="date-text">a</span>
            <ion-icon floating class="element-date date-icon" name="calendar" (click)="setDateA()"></ion-icon>
            <div floating class="element-date item-no-border date-text">
              {{date2}}
            </div>
          </div>
        </ion-row>
        <ion-row class="search-date">
          <div><strong>Cerca</strong> titolo <input type="text" name="calendar" [(ngModel)]="titolo" title="Seleziona una data">
          <ion-button (click)="cercaDocumenti()" class="search-arrow" title="Cerca documenti"><ion-icon class="button-icon" slot="icon-only" name="arrow-round-forward" title="Cerca documenti"></ion-icon></ion-button></div>
        </ion-row>
        <ion-row class="search-date" id="buttons" style="display:none"> 
            <div>Condividi documenti su whatsapp</div>
            <ion-button (click)="condividiDocumenti()" class="search-arrow" title="Condividi documenti"><ion-icon class="button-icon" slot="icon-only" name="share-alt" title="Condividi documenti"></ion-icon></ion-button>
        </ion-row>
        <ion-row class="search-date-border">
        </ion-row>
        <!--<ion-row class="search-date" *ngIf="!platform.is('desktop')">
          <ion-col>
            <ion-grid>
              <ion-row text-center center>
                <ion-label floating class="element-date"><strong>Cerca</strong> da</ion-label>
                <ion-icon floating class="element-date" name="calendar" (click)="setDateDa()"></ion-icon>
                <ion-item floating class="element-date">
                  {{date1}}
                </ion-item>
                <ion-label floating class="element-date">a</ion-label>
                <ion-icon floating class="element-date" name="calendar" (click)="setDateA()"></ion-icon>
                <ion-item floating class="element-date">
                  {{date2}}
                </ion-item>
                <ion-button floating fill="clear" class="search-arrow" (click)="cercaDocumenti()">
                  <ion-icon class="button-icon" slot="icon-only" name="arrow-round-forward"></ion-icon>
                </ion-button>
              </ion-row>
            </ion-grid>
          </ion-col>
          <ion-col></ion-col>
        </ion-row>-->
        <!--<ion-row>
          <ion-col>
            <ion-grid>
              <ion-row text-center center>
                <ion-col>
                  <ion-label floating>Da:</ion-label>
                </ion-col>
                <ion-col>
                  <ion-datetime displayFormat="DD-MM-YYYY" [(ngModel)]="date1"></ion-datetime>
                </ion-col>
                <ion-col>
                  <ion-label floating>A:</ion-label>
                </ion-col>
                <ion-col>
                  <ion-datetime displayFormat="DD-MM-YYYY" [(ngModel)]="date2"></ion-datetime> 
                </ion-col>
                <ion-col>
                  <ion-button color="light" (click)="cercaDocumenti()">Cerca</ion-button>
                </ion-col>
              </ion-row>
            </ion-grid>
          </ion-col>
          <ion-col></ion-col>
        </ion-row>-->
        <ion-list *ngFor="let documento of documenti.documenti; trackBy: trackByDoc" class="row-results">
          <ion-checkbox name="privacy" *ngIf="!platform.is('desktop')" [(ngModel)]="documento.checked" class="check" (click)="checkSelected(documento.idDocumento)"> </ion-checkbox>
          <div class="table-row">
            <div class="row-text">
              {{documento.titolo}}
              <div class="detail">
                {{documento.data}}
              </div>
            </div>
            <ion-item class="row-download item-no-border">
              <a *ngIf="platform.is('desktop')" href="{{documento.url}}" target="_blank" download tappable>
                <ion-icon name="cloud-download" title="Scarica documento"></ion-icon>
              </a>
              <!--<a *ngIf="platform.is('desktop')" href="{{documento.url}}" target="_blank" download>Clicca per scaricare il documento</a>-->
              <ion-icon name="cloud-download" *ngIf="!platform.is('desktop')" (click)="getDocumento(documento.idDocumento, documento.nomeFile);" target="_blank" download tappable>Clicca per scaricare il documento</ion-icon>
            </ion-item>
          </div>
          <div class="clr"></div>
        </ion-list>
      </ion-grid>
    </div>
  </div>
</ion-content>
