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

Commit

Permalink
fix(tags): add actions for tag consisting of spaces (#1215)
Browse files Browse the repository at this point in the history
PR Close #1197
  • Loading branch information
HeyRoach authored Aug 29, 2018
1 parent 8f86cf8 commit 96559d9
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/shared/directives/forbidden-values-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function forbiddenValuesValidator(
forbiddenValues: Array<string>
): ValidatorFn {
return (c: AbstractControl) => {
const isValid = !forbiddenValues.find(_ => _ === c.value);
const isValid = !forbiddenValues.find(_ => _ === c.value && c.value.trim());

if (isValid) {
return null;
Expand Down
6 changes: 6 additions & 0 deletions src/app/tags/tag-edit/tag-edit.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h3 *ngIf="!loading" class="mat-dialog-title">
[forbiddenValues]="forbiddenKeys || []"
[placeholder]="'TAGS.TAG_KEY' | translate"
[maxlength]="maxKeyLength"
pattern="^\S.*$"
autofocus
required
#keyField="ngModel"
Expand All @@ -31,8 +32,13 @@ <h3 *ngIf="!loading" class="mat-dialog-title">
[(ngModel)]="value"
[placeholder]="'TAGS.TAG_VALUE' | translate"
[maxlength]="maxValueLength"
pattern="^\S.*$"
required
#valueField="ngModel"
>
<mat-error *ngIf="valueField.invalid && valueField.errors['pattern']">
{{ 'TAGS.TAG_START_FROM_SPACE' | translate }}
</mat-error>
<mat-hint align="end">
<cs-character-count
[value]="value"
Expand Down
2 changes: 2 additions & 0 deletions src/app/tags/tag-edit/tag-edit.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export class TagEditComponent {
public get keyFieldErrorMessage(): string {
if (this.keyField.errors && this.keyField.errors.forbiddenValuesValidator) {
return 'TAGS.TAG_ALREADY_EXISTS';
} else if (this.keyField.errors && this.keyField.errors.pattern) {
return 'TAGS.TAG_START_FROM_SPACE';
}

return '';
Expand Down
2 changes: 1 addition & 1 deletion src/app/tags/tag/tag.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

.left {
margin-right: 15px;
max-width: 70%
max-width: 70%;
}

.buttons {
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,8 @@
"TAG_KEY": "Key",
"TAG_VALUE": "Value",
"TAG_ALREADY_EXISTS": "Tag already exists",
"EDIT_TAG": "Edit tag"
"EDIT_TAG": "Edit tag",
"TAG_START_FROM_SPACE": "Field value must start with 'non-space' character"
},
"DISK_OFFERING_STORAGE_TYPE": {
"SHARED": "Shared",
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,8 @@
"TAG_KEY": "Ключ",
"TAG_VALUE": "Значение",
"TAG_ALREADY_EXISTS": "Тег уже существует",
"EDIT_TAG": "Редактировать тег"
"EDIT_TAG": "Редактировать тег",
"TAG_START_FROM_SPACE": "Значение не может начинаться с пробела"
},
"DISK_OFFERING_STORAGE_TYPE": {
"SHARED": "Общее",
Expand Down

0 comments on commit 96559d9

Please sign in to comment.