<title>Marital Status</title>

<div class="container-fluid">
  <div class="row">
    <div class="col-sm-6">
      <app-breadcrumb [title]="'Marital Statuses'" [active_item]="'Marital Statuses'">
      </app-breadcrumb>
    </div>
    <div class="col-sm-6 text-right">
      <div ngbDropdown class="btn-group">
        <div class="ml-2">
          <a *ngIf="isWritePermission" title="{{ 'marital_status_tooltip_add_marital_status' |translate}}"
            href="javascript:;" class="btn btn-sm btn-info filterbtn" (click)="modalOpen(basicmodal)">
            <i class="icon-plus"></i>
          </a>
        </div>
      </div>
    </div>
    <div class="col-sm-12">
      <mat-drawer-container autosize>
        <div class="card">
          <ng-container *ngIf="maritalStatuses && maritalStatuses.length > 0 else NoMaritalStatuses">
            <div class="contentcard table-responsive userlist-table">
              <table mat-table [dataSource]="maritalStatuses"
                class=" maintable mat-elevation-z8 table-striped table-vcenter box-shadow-none" label="">
                <ng-container matColumnDef="status">
                  <th mat-header-cell *matHeaderCellDef>{{'lbl_marital_status'| translate}}</th>
                  <td mat-cell *matCellDef="let element">
                    <div *ngIf="element.status else NoValue">
                      {{element.status}}
                    </div>
                    <ng-template #NoValue>
                      --
                    </ng-template>
                  </td>
                </ng-container>
                <!-- <ng-container matColumnDef="isActive">
                  <th mat-header-cell *matHeaderCellDef translate>{{'lbl_status'| translate}}</th>
                  <td mat-cell *matCellDef="let element">
                    <ng-container *ngIf="element.isActive else InActive">
                      <span class="label text-success d-flex">
                        <div class="dot-label bg-success mr-1"></div>
                        <span>{{'lbl_active'| translate}}</span>
                      </span>
                    </ng-container>
                    <ng-template #InActive>
                      <span class="label text-warning d-flex">
                        <div class="dot-label bg-secondary mr-1"></div>
                        <span>{{'lbl_in_active'| translate}}</span>
                      </span>
                    </ng-template>
                  </td>
                </ng-container> -->
                <ng-container matColumnDef="Action">
                  <th mat-header-cell *matHeaderCellDef class="text-right" translate style="padding-right:48px;">
                    {{'lbl_action'| translate}}
                  </th>
                  <td mat-cell *matCellDef="let element" class="text-right" style="align-items: center;display: flex;">
                    <div class="media-body text-right icon-state">
                      <label title="{{ 'tooltip_lbl_change_status' |translate}}" class="switch" style="top:7px"
                        *ngIf="isEditPermission">
                        <input type="checkbox" (click)="changeStatus(element)" [(ngModel)]="element.isActive"><span
                          class="switch-state" [ngClass]="element.isActive ? 'bg-success' : 'bg-secondary'"></span>
                      </label>
                    </div>
                    <a *ngIf="isEditPermission" title="{{ 'marital_status_tooltip_edit_marital_status' |translate}}"
                      href="javascript:;" class="btn btn-sm btn-info filterbtn"
                      (click)="editDialog(element,basicmodal)">
                      <i class="icon-pencil"></i>
                    </a>
                  </td>
                </ng-container>
                <tr mat-header-row *matHeaderRowDef="displayColumns; sticky: true"></tr>
                <tr mat-row *matRowDef="let row; columns: displayColumns;" class="student-element-row"
                  style="cursor: pointer;"></tr>
              </table>
            </div>
          </ng-container>

          <ng-template #NoMaritalStatuses>
            <div class="d-flex vertical-center nodata">
            </div>
          </ng-template>

        </div>

      </mat-drawer-container>
    </div>
  </div>
</div>

<ng-template #basicmodal let-modal>
  <div>
    <form [formGroup]="maritalStatusform">
      <div class="modal-header">
        <h4 class="modal-title" id="modal-basic-title">{{title}}</h4>
        <button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body pd-20">

        <div class="form-group">
          <label for="status">{{'lbl_marital_status'| translate}} <span style="color: red;">*</span></label>
          <input class="form-control" type="text" id="status" formControlName="status" required onlyAlphabets>
          <mat-error
            *ngIf="(maritalStatusform.get('status') && !maritalStatusform.get('status')!.valid && maritalStatusform.get('status')!.touched)">
            {{'message_lbl_marital_status_is_required'| translate}}
          </mat-error>
        </div>

      </div>
      <div class="modal-footer">
        <button class="btn btn-sm btn-info filterbtn" (click)="insertMaritalStatus()">
          {{'button_lbl_save'| translate}}
        </button>
        <button class="btn btn-sm btn-secondary filterbtn" (click)="cancelUser()">
          {{'button_lbl_cancel'| translate}}
        </button>
      </div>
    </form>
  </div>
</ng-template>