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 4a5c4f5 [DLAB-1942]: Improved validation for user adding to the group (#874) 4a5c4f5 is described below commit 4a5c4f5980e83e86cdb65f4c5601c20cb2a9dbcc Author: Dmytro Gnatyshyn <42860905+dg1...@users.noreply.github.com> AuthorDate: Wed Aug 26 14:13:40 2020 +0300 [DLAB-1942]: Improved validation for user adding to the group (#874) [DLAB-1942]: Improved validation for user adding to the group --- .../src/app/administration/roles/roles.component.html | 6 +++--- .../webapp/src/app/administration/roles/roles.component.ts | 13 +++++++------ 2 files changed, 10 insertions(+), 9 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 31199dc..9170e86 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 = ''" (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> + (keydown.enter)="addUser(user, element);" (keyup)="checkIfUserAdded(element, user.value)"> + <button mat-icon-button matSuffix (click)="addUser(user, element); user.value = ''" [disabled]="element.isUserAdded"> + <mat-icon matTooltip="User is already 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 a80aae6..0472e28 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 @@ -17,7 +17,7 @@ * under the License. */ -import { Component, OnInit, Output, EventEmitter, Inject } from '@angular/core'; +import {Component, OnInit, Output, EventEmitter, Inject, ViewChild} from '@angular/core'; import { ValidatorFn, FormControl } from '@angular/forms'; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { ToastrService } from 'ngx-toastr'; @@ -275,14 +275,15 @@ export class RolesComponent implements OnInit { list.splice(list.indexOf(item), 1); } - public addUser(value: string, item): void { - if (item.users.includes(value)) { + public addUser(user, item): void { + if (item.isUserAdded) { + if (!this.toastr.toasts.length) this.toastr.error('User is already added to this group', 'Oops!'); return; } - - if (value && value.trim()) { - item.users instanceof Array ? item.users.push(value.trim()) : item.users = [value.trim()]; + if (user.value && user.value.trim()) { + item.users instanceof Array ? item.users.push(user.value.trim()) : item.users = [user.value.trim()]; } + user.value = ''; } private getEnvironmentHealthStatus() { --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org For additional commands, e-mail: commits-h...@dlab.apache.org