<ol class="breadcrumb breadcrumb-arrow font-trirong">
  <li><a href="javascript://"> Forma</a></li>
</ol>
<section class="ug-hero">
  <div class="ug-hero__content">
    <div class="ug-hero__icon"><clr-icon shape="users"></clr-icon></div>
    <div>
      <h2 class="ug-hero__title">Forma</h2>
    </div>
  </div>
  <div class="ug-hero__actions"> 
    <button id="add" class="ug-btn ug-btn-primary" (click)="goToAdd()">
      <clr-icon shape="plus"></clr-icon>
      <span class="ug-btn-text">ADD</span>
    </button>
   
  </div>
</section>


<div class="ug-toolbar">
  <div class="ug-toolbar__left">
    <div class="ug-search">
      <clr-icon shape="search"></clr-icon>
      <input class="ug-search__input" type="text" placeholder="SEARCH" [(ngModel)]="filterText" />
    </div>
  </div>
  <div class="ug-toolbar__right">
    <div class="ug-view-toggle">
      <button class="ug-btn ug-btn-sm" [class.ug-btn-primary]="viewMode==='cards'" (click)="setViewMode('cards')">
        <clr-icon shape="view-cards"></clr-icon>
      </button>
      <button class="ug-btn ug-btn-sm" [class.ug-btn-primary]="viewMode==='table'" (click)="setViewMode('table')">
        <clr-icon shape="table"></clr-icon>
      </button>
    </div>
  </div>
</div> 
<clr-datagrid class="ug-grid" [clrDgLoading]="loading" *ngIf="viewMode==='table'">
  <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 [clrDgField]="'name'">
    <ng-container *clrDgHideableColumn="{hidden: false}">
      Name
    </ng-container>
  </clr-dg-column>




 <clr-dg-column [clrDgField]="'description'">
    <ng-container *clrDgHideableColumn="{hidden: false}">
      Description
    </ng-container>
  </clr-dg-column>

 
 <!-- who column -->
      <clr-dg-column> <ng-container *clrDgHideableColumn="{hidden: false}">
        <clr-icon shape="bars"></clr-icon> Action
      </ng-container></clr-dg-column>
      <!-- end --> 
  <clr-dg-row *clrDgItems="let user of filteredGroups;let i = index" [clrDgItem]="user">

<clr-dg-cell>{{user.name }}</clr-dg-cell>


<clr-dg-cell (click)="goToReplaceStringdescription (user.description)" style="cursor: pointer; align-items: center;"><clr-icon shape="details"></clr-icon>
</clr-dg-cell>

 
  <!-- who column -->
<clr-dg-cell>
  <clr-signpost>
   <span style="cursor: pointer;" clrSignpostTrigger><clr-icon shape="help" class="success" style="color: rgb(0, 130, 236);"></clr-icon></span>
   <clr-signpost-content [clrPosition]="'left-middle'" *clrIfOpen>
     <h5 style="margin-top: 0">Who Column</h5>
           <div>Account ID: <code class="clr-code">{{user.accountId}}</code></div>
           <div>Created At: <code class="clr-code">{{user.createdAt| date}}</code></div>
           <div>Created By: <code class="clr-code">{{user.createdBy}}</code></div>
           <div>Updated At: <code class="clr-code">{{user.updatedAt | date}}</code></div>
           <div>Updated By: <code class="clr-code">{{user.updatedBy}}</code></div>
   </clr-signpost-content>
 </clr-signpost>
 </clr-dg-cell>
 
 <!-- who colmn --> 
 
 
    <clr-dg-action-overflow>
      <!-- <button class="ug-action-item" *ngIf="medit == 'true' || medit == true" (click)="onEdit(user)">
        <clr-icon shape="edit"></clr-icon>
        EDIT
      </button> -->
      <button class="ug-action-item" (click)="onEdit(user)">
        <clr-icon shape="edit"></clr-icon>
        EDIT
      </button>
      <button class="ug-action-item ug-btn-error" (click)="onDelete(user)">
        <clr-icon shape="trash"></clr-icon>
 DELETE
      </button>
    </clr-dg-action-overflow>

</clr-dg-row>

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

<div class="ug-cards" *ngIf="viewMode==='cards'">
  <div class="ug-card-item" *ngFor="let user of filteredGroups; let i = index">
 <div class="ug-card-item__body"> 
    
      <div class="ug-kv"><span>Name</span><strong>{{user.name}}</strong></div>


      <div class="ug-kv"><span>Description</span><strong>{{user.description}}</strong></div>


 </div>
    <div class="ug-card-item__footer">
      
      <button class="ug-btn ug-btn-sm ug-btn-outline" (click)="onEdit(user)">
        <clr-icon shape="edit"></clr-icon> Edit
      </button>
      <button class="ug-btn ug-btn-sm ug-btn-error" (click)="onDelete(user)">
        <clr-icon shape="trash"></clr-icon> Delete
      </button>
    </div>
  </div>
</div>


<clr-modal [(clrModalOpen)]="rsModaldescription" [clrModalSize]="'xl'" [clrModalStaticBackdrop]="true">
						  <div class="modal-body">
						    <textarea class="form-control" style="width:100%; height: 400px;" readonly>{{rowSelected}}</textarea>
						  </div></clr-modal>

<clr-modal [(clrModalOpen)]="modalAdd" [clrModalSize]="'md'" [clrModalStaticBackdrop]="true">
  <h3 class="modal-title">Add Forma</h3>
  <div class="modal-body">
    <form [formGroup]="entryForm" (ngSubmit)="onSubmit()">
<div class="form-row">
            <div class="form-col">
<div class="ug-form-group">
        <label for="name" class="ug-form-label">Name<span class="required-field">*</span></label>
        <input type="text" id="name" class="ug-form-input" formControlName="name">
        <div *ngIf="submitted && entryForm.controls.name.errors" class="ug-form-error">
          <div *ngIf="submitted && entryForm.controls.name.errors.required">*This field is Required</div>
        </div>
      </div>
</div>
            </div>


<div class="form-row">
            <div class="form-col">
 <div class="ug-form-group">
              <label for="description" class="ug-form-label">Description</label>
              <textarea 
                id="description" 
                class="ug-form-input" 
                formControlName="description" 
                placeholder="Enter text" 
                rows="3"></textarea>
            </div>
</div>
            </div>


      <div class="modal-footer">
        <button type="button" class="ug-btn ug-btn-outline" (click)="modalAdd = false">Cancel</button>
        <button type="submit" class="ug-btn ug-btn-primary">ADD</button>
      </div>
    </form>
  </div>
</clr-modal>

<clr-modal [(clrModalOpen)]="modalEdit" [clrModalSize]="'md'" [clrModalStaticBackdrop]="true">
  <h3 class="modal-title">Update Forma</h3>
  <div class="modal-body" *ngIf="rowSelected.id">
    



<div class="form-row">
            <div class="form-col">
              <div class="ug-form-group">
                <label for="name" class="ug-form-label">Name<span class="required-field">*</span></label>
                <input type="text" id="name" class="ug-form-input" [(ngModel)]="rowSelected.name" name="name"
                  placeholder="Enter Name">
              </div>
            </div>
          </div>


            <div class="form-col">
              <div class="ug-form-group">
                <label for="description" class="ug-form-label">Description</label>
                <textarea id="description" class="ug-form-input" [(ngModel)]="rowSelected.description"
                  name="description" placeholder="Enter text" rows="3"></textarea>
              </div>
            </div>
           


    <div class="modal-footer">
      <button type="button" class="ug-btn ug-btn-outline" (click)="modalEdit = false">Cancel</button>
      <button type="submit" (click)="onUpdate(rowSelected.id)" class="ug-btn ug-btn-primary">Update</button>
    </div>

<clr-modal [(clrModalOpen)]="modaldelete" [clrModalSize]="'lg'" [clrModalStaticBackdrop]="true">
  <div class="modal-body" *ngIf="rowSelected.id">
    <div class="ug-delete-header">
      <div class="ug-delete-icon">
        <clr-icon shape="exclamation-triangle" size="48"></clr-icon>
      </div>
      <h1 class="ug-delete-title">Are You Sure Want to Delete?</h1>
      <p class="ug-delete-subtitle">This action cannot be undone</p>
    </div>

<div class="ug-delete-details"><div class="ug-delete-detail-item">
        <span class="ug-delete-detail-label">Name:</span>
        <span class="ug-delete-detail-value">{{rowSelected.name}}</span>
      </div>

<div class="ug-delete-detail-item">
        <span class="ug-delete-detail-label">Description:</span>
        <span class="ug-delete-detail-value">{{rowSelected.description}}</span>
      </div>

 
    </div>

    <div class="modal-footer">
      <button type="button" class="ug-btn ug-btn-outline" (click)="modaldelete = false">Cancel</button>
      <button type="submit" (click)="delete(rowSelected.id)" class="ug-btn ug-btn-error">Delete</button>
    </div>
  </div>
</clr-modal>

<clr-modal [(clrModalOpen)]="modalCsv" [clrModalSize]="'sm'" [clrModalStaticBackdrop]="false">
  <h3 class="modal-title">Import File</h3>
  <div class="modal-body">
    <div class="ug-form-group">
      <label class="ug-form-label">Select CSV File</label>
      <input type="file" name="file" class="ug-file-input" (change)="selectFile($event)"
        accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel">
    </div>
  </div>
  <div class="modal-footer">
    <button class="ug-btn ug-btn-outline" type="button" (click)="modalCsv = false">Cancel</button>
    <button class="ug-btn ug-btn-primary" type="button" [disabled]="!selectedFiles" (click)="saveCsv()">Import</button>
  </div>
</clr-modal>



  <!-- htmlpopup -->
