<ion-header class="header-subpage" no-border>
    <ion-toolbar>
      <ion-title class="titolo-sezione-head">{{ 'interviste_titolo' | translate }}</ion-title>
    </ion-toolbar>
  </ion-header>


<ion-content class="chats">
  <!--<ion-menu side="start" menu-id="topics">
    <ion-header>
      <ion-toolbar color="primary">
        <ion-title>Topics</ion-title>
      </ion-toolbar>
    </ion-header>
    <ion-content>
      <ion-button expand="block" (click)="createNewTopics()">Crea nuovo Topic</ion-button>
      <ion-list *ngFor="let topic of topics; trackBy: trackByDoc">
        <ion-item (click)="apriTopic(topic.idRichiesta)">{{topic.titolo}}</ion-item>
      </ion-list>
    </ion-content>
  </ion-menu>-->

  <div class="contenitore-home">
    <div class="central-doc">
      <div [ngSwitch]="intervista" ngDefaultControl>

          <div *ngSwitchCase="'lista'">
            <ion-grid>
              <ion-row class="search-date">
                <div *ngIf="platform.is('desktop')" class="grigio all-row">
                  <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 }}">
                  <input type="text" name="calendar" [(ngModel)]="titolo" placeholder="Cerca titolo" title="{{ 'cerca' | translate }}" class="cerca-titolo">
                  <ion-button (click)="resetDate()" class="search-arrow-red" title="{{ 'reset_documenti' | translate }}"><ion-icon class="button-icon" slot="icon-only" name="close" title="{{ 'cerca_documenti' | translate }}"></ion-icon></ion-button>
                </div>
                <ion-row class="search-date" *ngIf="!platform.is('desktop')">
                    <span class="riga">
                      <span class="float-date">
                        <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>
                      </span>
                    <ion-button (click)="resetDate()" class="search-arrow-red search-arrow-dev" title="{{ 'reset_documenti' | translate }}"><ion-icon class="button-icon" slot="icon-only" name="close" title="{{ 'cerca_documenti' | translate }}"></ion-icon></ion-button></span>
                  </ion-row>
              </ion-row>
              <div *ngIf="!platform.is('desktop')">
                <input type="text" name="calendar" [(ngModel)]="titolo" placeholder="Cerca titolo" title="{{ 'cerca' | translate }}" class="cerca-titolo-cel">                  
              </div>
              <ion-row class="date-div">
                <div class="search-date float-date riga">
                  <ion-checkbox name="privacy" [(ngModel)]="archiviati" class="check"> </ion-checkbox>
                  <ion-label class="archivio-text"><span class="text">{{ 'visualizza_archiviati' | translate }}</span></ion-label>
                  <ion-button (click)="caricaRichieste()" class="search-arrow" title="{{ 'cerca' | translate }}"><ion-icon class="button-icon" slot="icon-only" name="arrow-round-forward" title="{{ 'cerca' | translate }}"></ion-icon></ion-button>
                  <div class="clr"></div>
    
                  <span class="item-no-border riga" id="buttonsInterviste" style="display:none">
                    <div *ngIf="!archiviati" class="text">
                      {{ 'archivia_interviste' | translate }}
                      <ion-button (click)="archiviaInterviste(true)" class="search-arrow" title="{{ 'archivia_interviste' | translate }}"><ion-icon class="button-icon-archivia" slot="icon-only" name="archive" title="{{ 'archivia_interviste' | translate }}"></ion-icon></ion-button>
                    </div>
                    <div *ngIf="archiviati" class="text">
                      {{ 'undo_archivio_interviste' | translate }}
                      <ion-button (click)="archiviaInterviste(false)" class="search-arrow" title="{{ 'riattiva_interviste' | translate }}"><ion-icon class="button-icon-archivia" slot="icon-only" name="undo" title="{{ 'riattiva_interviste' | translate }}"></ion-icon></ion-button>
                    </div>                
                  </span>
                </div>
              </ion-row>
              <span class="row-results">
                  <ion-list *ngFor="let topic of topics; trackBy: trackByDoc" class="row-results" (click)="selection?toggleGroup(topic.idRichiesta):selectItem(topic.idRichiesta)"
                  (press)="selectItem(topic.idRichiesta)" [ngStyle]="{'background-color': topic.checked ? '#c3ddec' : '#ffffff'}">
                    <ion-checkbox name="privacy" [(ngModel)]="topic.checked" class="check" (click)="checkSelected(topic.idRichiesta)"> </ion-checkbox>          
                    <div class="table-row">

                        <div class="row-download-special">
                            <div class="group-icon">
                              <ion-icon name="arrow-round-forward" (click)="apriTopic(topic.idRichiesta)" tappable title="{{ 'visualizza_dettagli' | translate }}"></ion-icon>
                              <ion-label>{{ 'apri' | translate }}</ion-label>
                            </div>
                            <div class="group-icon" >
                              <ion-icon name="refresh-circle" (click)="loadTopics('after')" tappable title="{{ 'aggiorna' | translate }}"></ion-icon>
                              <ion-label>{{ 'refresh' | translate }}</ion-label>
                            </div>
                          </div>

                      <div class="row-text data" text-wrap>
                        {{topic.data}}
                        <div text-wrap>{{topic.titolo}}</div>
                      </div>
                     
                      
                    </div>           
                  </ion-list>
              <!--<ion-list *ngFor="let topic of topics; trackBy: trackByDoc" class="chat-list table-row">-->
                <!--<ion-checkbox name="privacy" [(ngModel)]="topic.checked" class="check" (click)="checkSelected(topic.idRichiesta)"> </ion-checkbox>
                <div class="row-chat-list">
                  <div class="data" text-wrap>
                    {{topic.data}}
                    <a class="select" (click)="apriTopic(topic.idRichiesta)" tappable title="{{ 'visualizza_dettagli' | translate }}">
                      <ion-icon name="arrow-round-forward"></ion-icon>
                    </a>                  
                    <a class="select" (click)="loadTopics('after')" tappable title="{{ 'aggiorna' | translate }}">
                      <ion-icon name="refresh-circle"></ion-icon>
                    </a>
                    <div text-wrap>{{topic.titolo}}</div>
                  </div>
                </div>-->
                <!--<div class="row-download-special">
                  <div class="richieste-button group-icon3">        
                    <a class="select" (click)="loadTopics('after')" tappable title="{{ 'aggiorna' | translate }}">
                      <ion-icon name="refresh-circle"></ion-icon>
                    </a>
                    <ion-label>{{ 'refresh' | translate }}</ion-label>
                  </div>
                  <div class="richieste-button group-icon2">
                    <a class="select" (click)="apriTopic(topic.idRichiesta)" tappable title="{{ 'visualizza_dettagli' | translate }}">
                      <ion-icon name="arrow-round-forward"></ion-icon>
                    </a>
                    <ion-label>{{ 'apri' | translate }}</ion-label>
                  </div>
                </div>
                <ion-checkbox name="privacy" [(ngModel)]="topic.checked" class="check" (click)="checkSelected(topic.idRichiesta)"> </ion-checkbox>
                <div class="row-chat-list">
                  <div class="data" text-wrap>
                    {{topic.data}}
                    <div text-wrap>{{topic.titolo}}</div>
                  </div>
                </div>
              </ion-list>-->
              </span>
              <!--<div class="foo-button" center>
                <div class="round-btn">
                  <a (click)="createNuovoParere()" tappable>
                    <ion-icon name="add" [style.color]="'#FFFFFF'"></ion-icon>
                  </a>
                </div>
              </div>-->
            </ion-grid>
          </div>

          <div *ngSwitchCase="'dettaglio'">
            <ion-grid>
              <ion-row class="search-date">
                <div *ngIf="platform.is('desktop')" class="grigio riga">
                  <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 }}"> <ion-button (click)="caricaTopic()" class="search-arrow" title="Cerca interventi"><ion-icon class="button-icon" slot="icon-only" name="arrow-round-forward"></ion-icon></ion-button>
                </div>
                <ion-row class="float-date" *ngIf="!platform.is('desktop')" class="grigio riga" justify-content-center>
                  <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>
                  <ion-button (click)="caricaTopic()" class="search-arrow"><ion-icon class="button-icon" slot="icon-only" name="arrow-round-forward"></ion-icon></ion-button>
                </ion-row>
              </ion-row>
              <div class="back">
                <a (click)="apriLista()" tappable>
                  <ion-icon name="arrow-round-back" [style.color]="'#2b94d1'" title="{{ 'back_interviste' | translate }}"></ion-icon>
                </a>
              </div>
              <div class="quesito">
                {{topicAttivo.titolo}}
              </div>
              <div class="from-me" *ngIf="topicAttivo.testo != null">
                <div class="io">io - {{topicAttivo.data}}</div>
                <p>{{topicAttivo.testo}}</p>
              </div>
              <div class="clr"></div>
              <div *ngFor="let intervento of topicAttivo.interventi;">
                <div class="from-me" *ngIf="intervento.utente == null">
                  <div class="io">{{ 'io' | translate }} - {{intervento.data}}</div>
                  <p>{{intervento.testo}}</p>
                </div>
                <div class="from-them" *ngIf="intervento.utente != null">
                  <div class="operatore">{{intervento.utente}} - {{intervento.data}}</div>
                  <p>{{intervento.testo}}</p>
                </div>	
                <div class="clr"></div>
              </div>
            </ion-grid>
          </div>

          <div *ngSwitchCase="'new'">
            <div class="back">
              <a (click)="apriLista()" tappable>
                <ion-icon name="arrow-round-back" [style.color]="'#2b94d1'" title="{{ 'back_interviste' | translate }}"></ion-icon>
              </a>
            </div>
            <div class="clr"></div>
            <form #form="ngForm" (ngSubmit)="saveNewTopic(form)">
              <div>
                <ion-item class="title-question">
                  <ion-input class="item-no-border" name="title" type="text" placeholder="{{ 'inserire_titolo' | translate }}" ngModel required></ion-input>
                </ion-item>
              </div>
              <div>
                <ion-item class="question-extended item-no-border">
                  <ion-textarea name="question" placeholder="{{ 'inserire_domanda' | translate }}" ngModel required></ion-textarea>
                </ion-item>
              </div>
              <div class="send">
                <ion-button type="submit" size="large" [disabled]="form.invalid" expand="block" color="#fcc73d" class="form-button">{{ 'invia' | translate }}</ion-button>
              </div>
              <div class="undo">
                <ion-button size="large" expand="block" (click)="apriLista()" class="form-button">{{ 'annulla' | translate }}</ion-button>
              </div>
            </form>
          </div>

      </div>
    </div>
  </div>
</ion-content>

<ion-footer class="footer-parere" no-border *ngIf="bottoneVisibile" id="footer-interviste">
  <form #form="ngForm" *ngIf="formInserisciIntervento">
    <ion-grid>
      <ion-row>
        
          <ion-col size="10">
            <ion-input class="input-intervento" id= "message" type="text" placeholder="{{ 'digita_msg' | translate }}" name="message" [(ngModel)]="message"></ion-input> 
          </ion-col>
          <ion-col size="2">
            <ion-icon name="paper-plane" (click)="aggiungiIntervento(form)" tappable title="{{ 'inserisci_intervento' | translate }}" [style.color]="'#2b94d1'"></ion-icon>
          </ion-col>
          
      </ion-row>
    </ion-grid>
  </form>
  <div class="foo-button" center>
    <div class="round-btn">
      <a (click)="apriEdit()" tappable title="{{ 'inserisci_argomento' | translate }}">
        <ion-icon name="add" [style.color]="'#FFFFFF'"></ion-icon>
      </a>
    </div>
  </div>
</ion-footer>
