<section class="content">
  <div class="container-fluid">

    <div class="row align-items-center">
      <!-- Left-hand side: Title -->
      <div class="col-md-6 mb-2">
        <span class="mb-0 page-title">{{'ROLE_USER' | translate}}</span>
        <app-page-help-text [code]="'ROLE_USER'"></app-page-help-text>
      </div>
    </div>
    <div class="card">
      <div class="body">
        <div class="form-group row">
          <form class="col-md-5">
            <div class="form-group">
              <label>{{'SELECT_ROLE' | translate}}</label>
              <mat-select panelClass="mat-select-control" class="form-control" name="selectedRole" [(ngModel)]="selectedRoleId"
                (selectionChange)="onRoleChange()">
                <mat-option *ngFor="let role of roles" [value]="role.id">
                  {{role.name}}
                </mat-option>
              </mat-select>
            </div>
          </form>
        </div>
        <div class="row">
          <div class="col-sm-12">
            <span class="font-weight-bold text-danger">
              {{'NOTE_IN_ORDER_TO_ADD_USER_TO_ROLE_PLEASE_DRAG_IT_FROM_ALL_USERS_TO_ROLE_USERS' | translate}}
            </span>
          </div>
        </div>
        <div *ngIf="selectedRole">
          <div class="row">
            <div class="col-sm-5">
              <h5 class="text-primary">{{'ALL_USERS' | translate}}</h5>
              <div cdkDropList #doneList="cdkDropList" cdkDropListLockAxis="true" [cdkDropListData]="otherUsers"
                [cdkDropListConnectedTo]="[todoList]" class="example-list" (cdkDropListDropped)="removeUser($event)">
                <div class="example-box" *ngFor="let item of otherUsers" cdkDrag>
                  <span>{{item.firstName}} {{item.lastName}} ({{item.userName}}) </span>
                </div>
              </div>
            </div>
            <div class="col-sm-5">
              <h5 class="text-primary">{{'ROLE_USERS' | translate}}</h5>
              <div cdkDropList #todoList="cdkDropList" [cdkDropListData]="roleUsers"
                [cdkDropListConnectedTo]="[doneList]" class="example-list" (cdkDropListDropped)="addUser($event)">
                <div class="example-box" *ngFor="let item of roleUsers" cdkDrag>
                  <span>{{item.firstName}} {{item.lastName}} ({{item.userName}})</span>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</section>