<ion-header class="ion-no-border">
  <app-header > </app-header>
</ion-header>

<div class="ion-page d-none" id="main-content">
  <ion-menu-button></ion-menu-button>
</div>

<ion-content class="container-wrapper">
  <div class="main-content d-flex height-100 overflow-hidden">
    <div class="content d-flex flex-column" *ngIf="task">
      <div class="main-header" style="overflow: unset !important;">
        <div class="title-content width-100 d-flex justify-between">
          <div class="font-30 cursor-pointer" (click)="goBack()" defaultHref="#">
            <ion-icon  *ngIf="ThemeService.currentTheme == 'default' " slot="end" src='assets/images/icons-arrow-arrow-left.svg'></ion-icon>
            <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " slot="end" src='assets/images/theme/gov/icons-calendar-arrow-left.svg'></ion-icon>
          </div>
          <div class="middle flex-grow-1">
            <ion-label class="title">{{ task.Folio}}</ion-label>
          </div>
          <div class="menu-ptions">
            <button class="btn-no-color" (click)="openOptions()">
              <ion-icon *ngIf="ThemeService.currentTheme == 'default' " src="assets/images/icons-menu.svg"></ion-icon>
              <ion-icon *ngIf="ThemeService.currentTheme == 'gov' " src="assets/images/theme/gov/icons-menu.svg"></ion-icon>
            </button>
          </div>
        </div>
      </div>
      <div class="upper-content" style="overflow: unset !important;">
        <div class="content-details">
          <ion-label>
            <p><span class="date">{{customDate}}</span><span class="label">{{ task.activityInstanceName }}</span></p>
          </ion-label>
        </div>
      </div>
      <div class="line"></div>

      <div class="overflow-y-auto">
        <div class="middle-content">
          <!-- <h5 *ngIf="intervenientes">Intervenientes</h5>
          <ion-item class="ion-no-margin ion-no-padding">
            <ion-label>
              <div *ngFor="let interveniente of intervenientes">
                <p>{{interveniente.Name}}</p>
              </div>
            </ion-label>
          </ion-item> -->
          <div *ngIf="cc.length > 0">
            <h5>Com conhecimento</h5>
            <ion-item class="ion-no-margin ion-no-padding">
              <ion-label>
                <div *ngFor="let c of cc">
                  <p>{{c.Name}}</p>
                </div>
              </ion-label>
            </ion-item>
          </div>
          <div *ngIf="fulltask.workflowInstanceDataFields.TaskMessage">
            <h5>Detalhes</h5>
            <ion-item class="ion-no-margin ion-no-padding">
                <p [innerHTML]="fulltask.workflowInstanceDataFields.TaskMessage"></p>
            </ion-item>
          </div>
        </div>

        <div class="bottom-content width-100">
          <ion-list>
            <h5>Documentos Anexados</h5>
            <ion-item class="ion-no-margin ion-no-padding cursor-pointer" *ngFor="let Document of fulltask.Documents">
              <ion-label class="d-block" (click)="viewDocument(Document.DocId, Document)">
                <p class="attach-title-item">{{ Document.Assunto }}<span class="span-right color-red btn-size"><ion-icon hidden name="close"></ion-icon></span></p>
                <p><span class="span-left">{{ Document.Sender}}</span><span class="span-right">{{ Document.DocDate | date: 'dd/MM/yyyy HH:mm' }}</span></p>
              </ion-label>
            </ion-item>
          </ion-list>
        </div>

        <div *ngIf="eventsList">
          <h3 class="h3-event-title">Eventos Associados</h3>
          <ion-list>
            <div *ngIf="eventsList">
              <ion-item-sliding>
                <ion-item
                  class="Rectangle" lines="none"
                  *ngFor="let event of eventsList"
                  (click)="viewEventDetail(event.EventId)"
                >

                    <div class="content-{{profile}}-{{event.CalendarName}} width-100 ">
                      <div class="approve-event-time">
                        <p>{{event.StartDate | date: 'HH:mm'}}</p>
                        <p>{{event.EndDate | date: 'HH:mm'}}</p>
                      </div>
                      <div class="approve-event-detail">
                        <p *ngIf="event.StartDate != event.EndDate">{{event.StartDate | date: 'd/M/yy' }} - {{ event.EndDate | date: 'dd/mm/yy'}}  |  {{event.Location}}</p>
                        <p *ngIf="event.StartDate == event.EndDate">{{event.StartDate | date: 'd/M/yy' }}  |  {{event.Location}}</p>
                        <h3>{{event.Subject}}</h3>
                      </div>
                    </div>
                  </ion-item>
              </ion-item-sliding>
            </div>
          </ion-list>
        </div>

      </div>
    </div>

    <div *ngIf="task" class="aside-right flex-column height-100 overflow-y-auto">
      <div *ngIf="loggeduser.Profile =='MDGPR' " class="buttons">
        <button (click)="openAddNoteModal('Aprovar')" class="btn-cancel" shape="round" >Aprovar</button>
        <button (click)="openAddNoteModal('Revisão')" class="btn-cancel" shape="round" >Mandar para Revisão</button>
        <div class="solid"></div>
        <button (click)="distartExpedientModal('descartar')" class="btn-cancel" shape="round" >Descartar</button>
        <div hidden class="solid"></div>
        <button hidden class="btn-cancel" shape="round" >Delegar</button>
        <button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" class="btn-cancel" shape="round" >Enviar para Pendentes</button>
        <button (click)="attachDocument()" class="btn-cancel" shape="round" >Anexar Documento <br />(Gestão Documental)</button>
      </div>
      <div *ngIf="loggeduser.Profile =='PR' " class="buttons">
        <button (click)="openExpedientActionsModal('0', fulltask)" class="btn-cancel" shape="round" >Efetuar Despacho</button>
        <button (click)="distartExpedientModal('descartar')" class="btn-cancel" shape="round" >Descartar</button>
        <div class="solid"></div>
        <button (click)="openExpedientActionsModal('1',fulltask)" class="btn-cancel" shape="round" >Solicitar Parecer</button>
        <button (click)="openBookMeetingModal(task)" class="btn-cancel" shape="round" >Marcar Reunião</button>
        <button (click)="sendExpedienteToPending()" *ngIf="task.Status != 'Pending'" class="btn-cancel" shape="round" >Enviar para Pendentes</button>
        <div hidden class="solid"></div>
        <button hidden class="btn-cancel" shape="round" >Delegar</button>
      </div>
    </div>

    <div class="width-100" *ngIf="!task">
      <ion-list>
        <ion-list-header>
          <ion-label>
            <ion-skeleton-text animated style="width: 50%"></ion-skeleton-text>
          </ion-label>
        </ion-list-header>
        <ion-item>
          <ion-label>
            <h3>
              <ion-skeleton-text animated style="width: 50%"></ion-skeleton-text>
            </h3>
            <p>
              <ion-skeleton-text animated style="width: 80%"></ion-skeleton-text>
            </p>
          </ion-label>
        </ion-item>
        <ion-item>
          <ion-label>
            <h3>
              <ion-skeleton-text animated style="width: 50%"></ion-skeleton-text>
            </h3>
            <p><ion-skeleton-text animated style="width: 80%"></ion-skeleton-text></p>
          </ion-label>
        </ion-item>
        <ion-item>
          <ion-label>
            <h3>
              <ion-skeleton-text animated style="width: 50%"></ion-skeleton-text>
            </h3>
            <p>
              <ion-skeleton-text animated style="width: 80%"></ion-skeleton-text>
            </p>
          </ion-label>
        </ion-item>
      </ion-list>
    </div>

  </div>
</ion-content>

