Skip to content
This repository was archived by the owner on Mar 25, 2023. It is now read-only.

Commit 96559d9

Browse files
authored
fix(tags): add actions for tag consisting of spaces (#1215)
PR Close #1197
1 parent 8f86cf8 commit 96559d9

File tree

6 files changed

+14
-4
lines changed

6 files changed

+14
-4
lines changed

src/app/shared/directives/forbidden-values-validator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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;

src/app/tags/tag-edit/tag-edit.component.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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"

src/app/tags/tag-edit/tag-edit.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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 '';

src/app/tags/tag/tag.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
.left {
2323
margin-right: 15px;
24-
max-width: 70%
24+
max-width: 70%;
2525
}
2626

2727
.buttons {

src/i18n/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,8 @@
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",

src/i18n/ru.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,8 @@
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": "Общее",

0 commit comments

Comments
 (0)