This repository was archived by the owner on Mar 25, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +14
-4
lines changed Expand file tree Collapse file tree 6 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export function forbiddenValuesValidator(
55 forbiddenValues : Array < string >
66) : ValidatorFn {
77 return ( c : AbstractControl ) => {
8- const isValid = ! forbiddenValues . find ( _ => _ === c . value ) ;
8+ const isValid = ! forbiddenValues . find ( _ => _ === c . value && c . value . trim ( ) ) ;
99
1010 if ( isValid ) {
1111 return null ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ <h3 *ngIf="!loading" class="mat-dialog-title">
1212 [forbiddenValues] ="forbiddenKeys || [] "
1313 [placeholder] ="'TAGS.TAG_KEY' | translate "
1414 [maxlength] ="maxKeyLength "
15+ pattern ="^\S.*$ "
1516 autofocus
1617 required
1718 #keyField ="ngModel "
@@ -31,8 +32,13 @@ <h3 *ngIf="!loading" class="mat-dialog-title">
3132 [(ngModel)] ="value "
3233 [placeholder] ="'TAGS.TAG_VALUE' | translate "
3334 [maxlength] ="maxValueLength "
35+ pattern ="^\S.*$ "
3436 required
37+ #valueField ="ngModel "
3538 >
39+ < mat-error *ngIf ="valueField.invalid && valueField.errors['pattern'] ">
40+ {{ 'TAGS.TAG_START_FROM_SPACE' | translate }}
41+ </ mat-error >
3642 < mat-hint align ="end ">
3743 < cs-character-count
3844 [value] ="value "
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ export class TagEditComponent {
4545 public get keyFieldErrorMessage ( ) : string {
4646 if ( this . keyField . errors && this . keyField . errors . forbiddenValuesValidator ) {
4747 return 'TAGS.TAG_ALREADY_EXISTS' ;
48+ } else if ( this . keyField . errors && this . keyField . errors . pattern ) {
49+ return 'TAGS.TAG_START_FROM_SPACE' ;
4850 }
4951
5052 return '' ;
Original file line number Diff line number Diff line change 2121
2222.left {
2323 margin-right : 15px ;
24- max-width : 70%
24+ max-width : 70% ;
2525}
2626
2727.buttons {
Original file line number Diff line number Diff line change 15711571 "TAG_KEY" : " Key" ,
15721572 "TAG_VALUE" : " Value" ,
15731573 "TAG_ALREADY_EXISTS" : " Tag already exists" ,
1574- "EDIT_TAG" : " Edit tag"
1574+ "EDIT_TAG" : " Edit tag" ,
1575+ "TAG_START_FROM_SPACE" : " Field value must start with 'non-space' character"
15751576 },
15761577 "DISK_OFFERING_STORAGE_TYPE" : {
15771578 "SHARED" : " Shared" ,
Original file line number Diff line number Diff line change 15671567 "TAG_KEY" : " Ключ" ,
15681568 "TAG_VALUE" : " Значение" ,
15691569 "TAG_ALREADY_EXISTS" : " Тег уже существует" ,
1570- "EDIT_TAG" : " Редактировать тег"
1570+ "EDIT_TAG" : " Редактировать тег" ,
1571+ "TAG_START_FROM_SPACE" : " Значение не может начинаться с пробела"
15711572 },
15721573 "DISK_OFFERING_STORAGE_TYPE" : {
15731574 "SHARED" : " Общее" ,
You can’t perform that action at this time.
0 commit comments