
<ol class="breadcrumb breadcrumb-arrow font-trirong">
  <li><a href="javascript://" [routerLink]="['/cns-portal/dashboard/order']"><clr-icon shape="home"></clr-icon></a></li>
  <li><a href="javascript://"><clr-icon shape="lock"></clr-icon>Security</a></li>
  <li><a href="javascript://">Access Type</a></li>
  <li><a href="javascript://">Modules</a></li>
</ol>



  <div class="clr-row">
    <div class="clr-col-8">
      <h3>Modules</h3>
  </div>
    <div class="clr-col-4" style="text-align: right;">
      <button id="add"   class="btn btn-primary" (click)="goToAdd()">
        <clr-icon shape="plus"></clr-icon>ADD
      </button>

    </div>
  </div>


  <clr-datagrid [clrDgLoading]="loading"  [(clrDgSelected)]="selected">
    <clr-dg-placeholder><ng-template #loadingSpinner><clr-spinner>Loading ... </clr-spinner></ng-template>
      <div *ngIf="error;else loadingSpinner">{{error}}</div></clr-dg-placeholder>

    <clr-dg-column > <ng-container *clrDgHideableColumn="{hidden: false}">
      Modules
    </ng-container></clr-dg-column>
    <clr-dg-column > <ng-container *clrDgHideableColumn="{hidden: false}">
      Description
    </ng-container></clr-dg-column>
    <clr-dg-column > <ng-container *clrDgHideableColumn="{hidden: false}">
     Access Exclusive
    </ng-container></clr-dg-column>



    <clr-dg-row *clrDgItems="let user of data;let i = index" [clrDgItem]="user">
      <clr-dg-cell >{{user.modules}}</clr-dg-cell>
      <clr-dg-cell >{{user.description}}</clr-dg-cell>
      <clr-dg-cell >{{user.access_exclusive}}</clr-dg-cell>


      <clr-dg-action-overflow>

        <button class="action-item"   (click)="goToEdit(user)">Edit <clr-icon shape="edit" class="is-error"></clr-icon></button>
        <button class="action-item"  (click)="onDelete(user)">Delete<clr-icon shape="trash" class="is-error"></clr-icon></button>
                </clr-dg-action-overflow>


    </clr-dg-row>

    <clr-dg-footer>
      <clr-dg-pagination #pagination [clrDgPageSize]="10">
        <clr-dg-page-size [clrPageSizeOptions]="[10,20,50,100]">Users per page</clr-dg-page-size>
        {{pagination.firstItem + 1}} - {{pagination.lastItem + 1}}
        of {{pagination.totalItems}} users
      </clr-dg-pagination>
    </clr-dg-footer>
  </clr-datagrid>

  <clr-modal [(clrModalOpen)]="modalAdd" [clrModalSize]="'md'" [clrModalStaticBackdrop]="true">
    <h3 class="modal-title">Add Modules</h3>
    <div class="modal-body">
          <form [formGroup]="entryForm" (ngSubmit)="onSubmit()">
        <div class="clr-row">

          <div class="clr-col-sm-12">
            <label for="name">Module<span class="required-field">*</span></label>
           <input type="text" class="clr-input" formControlName="modules" name="menuId">
           <div *ngIf="submitted && entryForm.controls.modules.errors" class="error_mess">
            <div *ngIf="submitted && entryForm.controls.modules.errors.required" class="error_mess">*This field is Required</div>
        </div>
          </div>

          <div class="clr-col-sm-12">
            <label for="tags">Description</label>
            <input type="text" class="clr-input" formControlName="description">
            <div *ngIf="submitted && entryForm.controls.description.errors" class="error_mess">
              <div *ngIf="submitted && entryForm.controls.description.errors.required" class="error_mess">*This field is Required</div>
          </div>
            </div>
            <div class="clr-col-sm-12">
              <label for="tags">Access Exclusive</label>
              <input type="text" class="clr-input" formControlName="access_exclusive">
              <div *ngIf="submitted && entryForm.controls.access_exclusive.errors" class="error_mess">
                <div *ngIf="submitted && entryForm.controls.access_exclusive.errors.required" class="error_mess">*This field is Required</div>
            </div>
              </div>
        </div>
        <br>
        <div class="modal-footer">
          <button type="button" class="btn btn-outline" (click)="modalAdd = false">Cancel</button>
          <button type="submit" class="btn btn-primary" >ADD</button>
          </div>
  </form>
    </div>

  </clr-modal>

  <clr-modal [(clrModalOpen)]="modaldelete" [clrModalSize]="'lg'" [clrModalStaticBackdrop]="true">

    <div class="modal-body" *ngIf="rowSelected.id">
      <h1 class="delete">Are You Sure Want to delete?</h1>
      <h2 class="heading">{{rowSelected.id}}</h2>
      <div class="modal-footer">
        <button type="button" class="btn btn-outline" (click)="modaldelete = false">Cancel</button>
      <button type="submit" (click)="delete(rowSelected.id)" class="btn btn-primary" >Delete</button>
      </div>
    </div>
  </clr-modal>


  <clr-modal [(clrModalOpen)]="modaledit" [clrModalSize]="'md'" [clrModalStaticBackdrop]="true">
    <h3 class="modal-title">Update Modules</h3>
    <div class="modal-body" *ngIf="rowSelected.id">
      <h2 class="heading">{{rowSelected.id}}</h2>
          <form (ngSubmit)="onUpdate(rowSelected.id)">
        <div class="clr-row">

          <div class="clr-col-sm-12">
            <label for="name">Module<span class="required-field">*</span></label>
           <input type="text" class="clr-input" name="modules" [(ngModel)]="rowSelected.modules">
          </div>

          <div class="clr-col-sm-12">
            <label for="tags">Description</label>
            <input type="text" class="clr-input" name="description" [(ngModel)]="rowSelected.description">
            </div>
            <div class="clr-col-sm-12">
              <label for="tags">Access Exclusive</label>
              <input type="text" class="clr-input" name="access_exclusive" [(ngModel)]="rowSelected.access_exclusive">
              </div>

        </div>
        <br>
        <div class="modal-footer">
          <button type="button" class="btn btn-outline" (click)="modaledit = false">Cancel</button>
          <button type="submit" class="btn btn-primary" >Update</button>
          </div>
  </form>
    </div>

  </clr-modal>
