<ion-content>
  <!-- Edit event for Inicio -->
  <div class="main-content height-100 d-flex">

    <div class="content d-flex flex-column width-md-100 height-100">

      <div class="main-header pt-30 px-20 background-white pb-15">
        <ion-header>
          <div class="title-content">
            <div class="middle">
              <ion-label class="title">Editar evento por aprovar</ion-label>
            </div>
          </div>
        </ion-header>
      </div>
      <ion-item-sliding class="overflow-y-auto">
        <div class="px-20">
          <div class="ion-item-container width-100">
            <ion-input  placeholder="Assunto*" [(ngModel)]="eventProcess.workflowInstanceDataFields.Subject"></ion-input>
          </div>
          <div class="container-div width-100">
            <div class="ion-item-class-2">
              <div class="ion-icon-class">
                <ion-icon slot="start" src="assets/images/icons-location.svg"></ion-icon>
              </div>
              <div class="ion-input-class">
                <ion-input placeholder="Localização*" [(ngModel)]="eventProcess.workflowInstanceDataFields.Location"></ion-input>
              </div>
            </div>
            <!-- Error messages -->
            <!-- <span class="error ion-padding" >
              Campo obrigatório
            </span> -->

          </div>

          <div class="container-div width-100">
            <div class="ion-item-class-2">
              <div class="ion-icon-class">
                <ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
              </div>
              <div class="ion-input-class">

                <ion-select disabled  placeholder="Selecione agenda*"
                  class="d-block d-md-none"
                  selectedText="{{eventProcess.workflowInstanceDataFields.Agenda}}"
                  [(ngModel)]="eventProcess.workflowInstanceDataFields.Agenda"
                  interface="action-sheet" Cancel-text="Cancelar"
                  required
                >
                  <ion-select-option value="Oficial">Oficial</ion-select-option>
                  <ion-select-option value="Pessoal">Pessoal</ion-select-option>
                </ion-select>


                <mat-form-field appearance="none"  class="d-none d-md-block width-100" >
                  <mat-select placeholder="Selecione agenda" [(ngModel)]="eventProcess.workflowInstanceDataFields.Agenda" >
                    <mat-option value="Oficial">
                      Oficial
                    </mat-option>
                    <mat-option value="Pessoal">
                      Pessoal
                    </mat-option>
                  </mat-select>
                </mat-form-field>

              </div>
            </div>
          </div>

          <div class="container-div width-100">
            <div class="ion-item-class-2 width-100">
              <div class="ion-icon-class">
                <ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
              </div>
              <div class="ion-input-class width-100">
                <ion-datetime
                  class="d-block d-md-none"
                  placeholder="Início"
                  [(ngModel)]="startDate"
                  displayFormat="D MMM YYYY H:mm"
                  minuteValues="0,15,30,45"
                  monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"
                  min="{{minDate}}"
                  max="2022"
                >
                </ion-datetime>

                <mat-form-field appearance="none"
                class="width-100 date-hour-picker d-none d-md-block">
                  <input matInput [ngxMatDatetimePicker]="picker1"
                    placeholder="Choose a date"
                    [(ngModel)]="startDate"
                    [min]="minDate" [max]="maxDate"
                    [disabled]="disabled"
                  >
                  <mat-datepicker-toggle id="new-inicio" matSuffix [for]="picker1"></mat-datepicker-toggle>
                  <ngx-mat-datetime-picker #picker1
                    [showSpinners]="showSpinners"
                    [showSeconds]="showSeconds"
                    [stepHour]="stepHour" [stepMinute]="stepMinute"
                    [stepSecond]="stepSecond"
                    [touchUi]="touchUi">
                  </ngx-mat-datetime-picker>
                </mat-form-field>
              </div>
            </div>
          </div>

          <div class="container-div width-100">
            <div class="ion-item-class-2">
              <div class="ion-icon-class">
                <ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
              </div>
              <div class="ion-input-class width-100">
                <ion-datetime
                  class="d-block d-md-none"
                  placeholder="Fim"
                  [(ngModel)]="endDate"
                  displayFormat="D MMM YYYY H:mm"
                  minuteValues="0,15,30,45"
                  monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"
                  min="{{minDate}}"
                  max="2025"
                >
                </ion-datetime>

                <mat-form-field appearance="none"
                class="width-100 date-hour-picker d-none d-md-block">
                  <input matInput [ngxMatDatetimePicker]="fim"
                    placeholder="Choose a date"
                    [(ngModel)]="endDate"
                    [min]="minDate" [max]="maxDate"
                    [disabled]="disabled"
                  >
                  <mat-datepicker-toggle id="new-fim" matSuffix [for]="fim"></mat-datepicker-toggle>
                  <ngx-mat-datetime-picker #fim
                    [showSpinners]="showSpinners"
                    [showSeconds]="showSeconds"
                    [stepHour]="stepHour" [stepMinute]="stepMinute"
                    [stepSecond]="stepSecond"
                    [touchUi]="touchUi">
                  </ngx-mat-datetime-picker>
                </mat-form-field>

              </div>
            </div>
          </div>

          <div class="container-div width-100">
            <div class="ion-item-class-2">
              <div class="ion-icon-class">
                <ion-icon slot="start" src="assets/images/icons-refresh.svg"></ion-icon>
              </div>
              <div class="ion-input-class">
                <ion-select
                placeholder="Selecione repetição"
                class="d-block d-md-none"
                [(ngModel)]="eventProcess.workflowInstanceDataFields.OccurrenceType"
                (ngModelChange)="onSelectedRecurringChanged($event)"
                interface="action-sheet"
                Cancel-text="Cancelar" required>
                <ion-select-option *ngFor="let recurring of recurringTypes" value="{{recurring.Code}}">{{recurring.Description}}</ion-select-option>
                </ion-select>

                <mat-form-field
                  class="width-100 d-none d-md-block"
                  placeholder="Selecione repetição"
                  value="false"
                  interface="action-sheet"
                  required
                  appearance="none"
                >
                <mat-select [(ngModel)]="eventProcess.workflowInstanceDataFields.OccurrenceType"
                  (ngModelChange)="onSelectedRecurringChanged($event)"
                  >
                    <mat-option
                    *ngFor="let recurring of recurringTypes" value="{{recurring.Code}}"
                    >
                    {{recurring.Description}}
                    </mat-option>
                  </mat-select>
                </mat-form-field>

              </div>
            </div>
          </div>

          <div *ngIf="eventProcess.workflowInstanceDataFields.OccurrenceType != '-1'"
            class="container-div width-100">
            <div class="ion-item-class-2 d-flex">
              <div class="ion-icon-class">
                <ion-icon slot="start" src="assets/images/icons-calendar.svg"></ion-icon>
              </div>
              <div class="ion-input-class flex-grow-1">

                <ion-datetime
                class="d-block d-md-none"
                  placeholder="Última ocorrência"
                  [(ngModel)]="eventProcess.workflowInstanceDataFields.LastOccurrence"
                  displayFormat="D MMM YYYY H:mm"
                  minuteValues="0,15,30,45"
                  monthShortNames="Jan, Fev, Mar, Abr, Mai, Jun, Jul, Aug, Sep, Out, Nov, Dez"
                  min="2021"
                  max="2025"
                >
                </ion-datetime>

                <mat-form-field class="date-hour-picker d-none d-md-block">
                  <input matInput [ngxMatDatetimePicker]="occurrrence"
                    placeholder="Choose a date"
                    [(ngModel)]="eventProcess.workflowInstanceDataFields.LastOccurrence"
                    [disabled]="disabled"
                  >
                  <mat-datepicker-toggle id="last-occurrence" matSuffix [for]="occurrrence"></mat-datepicker-toggle>
                  <ngx-mat-datetime-picker #occurrrence
                    [showSpinners]="showSpinners"
                    [showSeconds]="showSeconds"
                    [stepHour]="stepHour" [stepMinute]="stepMinute"
                    [stepSecond]="stepSecond"
                    [touchUi]="touchUi"
                    >
                  </ngx-mat-datetime-picker>
                </mat-form-field>

              </div>
            </div>
          </div>

          <div class="container-div width-100">
            <div class="ion-item-class-2">
              <div class="ion-icon-class">
                <ion-icon slot="start" src="assets/images/icons-person.svg"></ion-icon>
              </div>
              <div (click)="addParticipants()" class="ion-input-class-no-height d-flex">
                <div class="list-people flex-grow-1">
                  <ion-item lines="none">
                    <ion-list>
                      <ion-label *ngIf="taskParticipants?.length < 1" class="list-people-title">Adicionar intervenientes*</ion-label>
                      <ion-label *ngFor="let participant of taskParticipants">{{participant.Name}}</ion-label>
                    </ion-list>
                  </ion-item>
                </div>
                <div class="add-people cursor-pointer">
                  <ion-icon slot="start" src="assets/images/icons-arrow-forward.svg"></ion-icon>
                </div>
              </div>
            </div>
          </div>

          <div class="container-div width-100">
            <div class="ion-item-class-2">
              <div class="ion-icon-class">
                <ion-icon slot="start" src="assets/images/icons-person.svg"></ion-icon>
              </div>
              <div class="ion-input-class-no-height d-flex">
                <div class="list-people flex-grow-1">
                  <ion-item lines="none">
                    <ion-list>
                      <ion-label *ngIf="taskParticipantsCc?.length < 1" class="list-people-title">Adicionar intervenientes</ion-label>
                      <ion-label *ngFor="let participant of taskParticipantsCc">{{participant.Name}}</ion-label>
                    </ion-list>
                  </ion-item>
                </div>
                <div class="add-people cursor-pointer" (click)="addParticipantsCC()">
                  <ion-icon  slot="start" src="assets/images/icons-arrow-forward.svg"></ion-icon>
                </div>
              </div>
            </div>
          </div>

          <div class="container-div d-flex width-100">
            <div class="ion-item-class-2 d-flex width-100">
              <div class="ion-icon-class">
                <ion-icon slot="start" src="assets/images/icons-description.svg"></ion-icon>
              </div>
              <div class="ion-input-class-no-height width-100 flex-grow-1">
                <ion-textarea [(ngModel)]="eventProcess.workflowInstanceDataFields.Body"  placeholder="Detalhes" rows="6" cols="20"></ion-textarea>
              </div>
            </div>
          </div>

          <div (click)="getDoc()" class="cursor-pointer d-flex container-div width-100 ion-item-container-no-border" >
            <ion-label>
              <div class="attach-icon">
                <ion-icon src="assets/images/icons-attach-doc.svg"></ion-icon>
              </div>
              <div class="attach-document">
                <ion-label>Adicionar documentos</ion-label>
              </div>
            </ion-label>
          </div>

          <div class="d-flex container-div width-100"  >
            <ion-list class="width-100 ">
              <ion-item class="width-100"   *ngFor="let document of loadedAttachments; let i = index">
                <ion-label class="width-100 d-block list" *ngIf="document.action != 'delete' ">
                  <p class="d-flex ion-justify-content-between">
                    <span class="attach-title-item">{{document.SourceName}}</span>
                    <span class="app-name" *ngIf="document.ApplicationId  == 8"> Correspondencia </span>
                    <span class="app-name" *ngIf="document.ApplicationId == 386"> AccoesPresidenciais </span>
                    <span class="app-name" *ngIf="document.ApplicationId == 361 "> ArquivoDespachoElect </span>
                    <span class="close-button text-black cursor-pointer" (click)="deleteAttachment(document, i)" >
                      <ion-icon class="font-20" src="assets/images/icons-delete-25.svg"></ion-icon>
                    </span>
                  </p>
                  <p><span class="span-left">{{document.Stakeholders}}</span><span class="span-right"> {{document.CreateDate | date: 'dd-MM-yyyy HH:mm'}} </span></p>
                </ion-label>
              </ion-item>
            </ion-list>
          </div>

        </div>
      </ion-item-sliding>

    </div>

    <app-attendee-modal class="aside-right flex-column height-100 d-none d-md-flex pt-10"
      *ngIf="showAttendees"
      [taskParticipants]="taskParticipants"
      [taskParticipantsCc]="taskParticipantsCc"
      [adding]="adding"
      [footer]="false"
      (dynamicSetIntervenient)="dynamicSetIntervenient($event)"
    ></app-attendee-modal>

  </div>
</ion-content>

<ion-footer class="background-whit">
  <div class="buttons">
    <button class="btn-cancel cursor-pointer" shape="round" (click)="close()">Cancelar</button>
    <button class="btn-ok cursor-pointer" shape="round" (click)="save()">Gravar</button>
  </div>
</ion-footer>
