<ion-header class="header-subpage" no-border>
  <ion-toolbar>
    <ion-title class="titolo-sezione-head">{{ 'titolo_documenti' | translate }}</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' | translate }}</strong> {{ 'da' | translate }} <input type="date" name="calendar" [(ngModel)]="date1" title="{{ 'seleziona_data' | translate }}"> {{ 'a' | translate }} <input type="date" name="calendar" [(ngModel)]="date2" title="{{ 'seleziona_data' | translate }}">
          </div>
          <div class="float-date" *ngIf="!platform.is('desktop')">
            <span class="date-text"><strong>{{ 'cerca' | translate }}</strong> {{ 'da' | translate }} </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' | translate }}</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">
          <span class="riga"><strong>{{ 'cerca' | translate }}</strong> {{ 'titolo' | translate }} <input type="text" name="calendar" [(ngModel)]="titolo" title="{{ 'ricerca_titolo' | translate }}">
          <ion-button (click)="cercaDocumenti()" class="search-arrow" title="{{ 'cerca_documenti' | translate }}"><ion-icon class="button-icon" slot="icon-only" name="arrow-round-forward" title="{{ 'cerca_documenti' | translate }}"></ion-icon></ion-button></span>
        </ion-row>
        <ion-row class="search-date" id="buttonsDoc" style="display:none"> 
            <div><span class="condividi-text">{{ 'condividi' | translate }}</span>
            <ion-button (click)="condividiDocumenti()" class="search-arrow" title="{{ 'condividi_doc' | translate }}"><ion-icon class="button-icon" slot="icon-only" name="share" title="{{ 'condividi_doc' | translate }}"></ion-icon></ion-button></div>
        </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">
              <strong>{{documento.titolo}}</strong>
              <div class="detail">
                {{documento.data}}
              </div>
            </div>
            <div class="row-download item-no-border">
              <a *ngIf="platform.is('desktop')" href="{{documento.url}}" target="_blank" download tappable title="{{ 'scarica_doc' | translate }}">
                <ion-icon name="cloud-download" title="{{ 'scarica_doc' | translate }}"></ion-icon>
              </a>
              <!--<a *ngIf="platform.is('desktop')" href="{{documento.url}}" target="_blank" download>Clicca per scaricare il documento</a>-->
              <ion-icon name="share-alt" *ngIf="!platform.is('desktop')" (click)="getDocumento(documento.idDocumento, documento.nomeFile);" target="_blank" download tappable title="{{ 'condividi_documento' | translate }}"></ion-icon>
            </div>
          </div>
          <div class="clr"></div>
        </ion-list>
      </ion-grid>
    </div>
  </div>
</ion-content>
