Browse Source

Added icon to the JSON field + change validation logic in JSON directive

pull/6434/head
kalutkaz 5 years ago
parent
commit
21599386df
  1. 7
      ui-ngx/src/app/shared/components/directives/tb-json-to-string.directive.ts
  2. 2
      ui-ngx/src/app/shared/models/constants.ts

7
ui-ngx/src/app/shared/components/directives/tb-json-to-string.directive.ts

@ -26,6 +26,7 @@ import {
Validator
} from '@angular/forms';
import { ErrorStateMatcher } from '@angular/material/core';
import {isObject} from "@core/utils";
@Directive({
selector: '[tb-json-to-string]',
@ -53,7 +54,11 @@ export class TbJsonToStringDirective implements ControlValueAccessor, Validator,
@HostListener('input', ['$event.target.value']) input(newValue: any): void {
try {
this.data = JSON.parse(newValue);
this.parseError = false;
if (isObject(this.data)) {
this.parseError = false;
} else {
this.parseError = true;
}
} catch (e) {
this.parseError = true;
}

2
ui-ngx/src/app/shared/models/constants.ts

@ -200,7 +200,7 @@ export const valueTypesMap = new Map<ValueType, ValueTypeData>(
ValueType.JSON,
{
name: 'value.json',
icon: 'mdi:json'
icon: 'mdi:code-json'
}
]
]

Loading…
Cancel
Save