This is an automated email from the ASF dual-hosted git repository.

dgnatyshyn pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git


The following commit(s) were added to refs/heads/develop by this push:
     new a30a923  [DLAB-1942]: Added validation for user adding to group (#863)
a30a923 is described below

commit a30a923cd4170a394128710e2bbba2bc8965d78d
Author: Dmytro Gnatyshyn <42860905+dg1...@users.noreply.github.com>
AuthorDate: Fri Aug 14 17:04:38 2020 +0300

    [DLAB-1942]: Added validation for user adding to group (#863)
    
    [DLAB-1942]: Added validation for user adding to the group
---
 .../webapp/src/app/administration/roles/roles.component.html      | 6 +++---
 .../webapp/src/app/administration/roles/roles.component.ts        | 8 ++++++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git 
a/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.html
 
b/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.html
index 5c73329..31199dc 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.html
+++ 
b/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.html
@@ -119,9 +119,9 @@
         <td mat-cell *matCellDef="let element" class="users-list ani">
           <mat-form-field class="chip-list">
             <input #user matInput placeholder="Enter user login" 
pattern="[@.-_0-9a-zA-Z]"
-              (keydown.enter)="addUser(user.value, element); user.value = ''">
-            <button mat-icon-button matSuffix (click)="addUser(user.value, 
element); user.value = ''">
-              <mat-icon>person_add</mat-icon>
+              (keydown.enter)="addUser(user.value, element); user.value = ''" 
(keyup)="checkIfUserAdded(element, user.value)">
+            <button mat-icon-button matSuffix (click)="addUser(user.value, 
element); user.value = ''" [disabled]="element.isUserAdded">
+              <mat-icon matTooltip="User allready added to this group" 
matTooltipPosition="above" 
[matTooltipDisabled]="!element.isUserAdded">person_add</mat-icon>
             </button>
           </mat-form-field>
           <div class="list-selected list-container ani">
diff --git 
a/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.ts
 
b/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.ts
index 884e1e2..a80aae6 100644
--- 
a/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.ts
+++ 
b/services/self-service/src/main/resources/webapp/src/app/administration/roles/roles.component.ts
@@ -276,6 +276,10 @@ export class RolesComponent implements OnInit {
   }
 
   public addUser(value: string, item): void {
+    if (item.users.includes(value)) {
+      return;
+    }
+
     if (value && value.trim()) {
       item.users instanceof Array ? item.users.push(value.trim()) : item.users 
= [value.trim()];
     }
@@ -301,6 +305,10 @@ export class RolesComponent implements OnInit {
      this.setupRoles = $event.model;
    }
   }
+
+  public checkIfUserAdded(element: any, value: string) {
+    element.isUserAdded = element.users.map(v => 
v.toLowerCase()).includes(value.toLowerCase());
+  }
 }
 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org
For additional commands, e-mail: commits-h...@dlab.apache.org

Reply via email to