diff options
author | KAPIL SINGAL <ks220y@att.com> | 2020-12-15 20:12:47 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-12-15 20:12:47 +0000 |
commit | a0c98da2730a1e7883ff29f461db27506189a843 (patch) | |
tree | 1562d049a2eb9ccc76dee04060924b76919c72d6 /cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts | |
parent | 3b5fe8ee609afae620268b591f6b707a377b1e81 (diff) | |
parent | fc1e10df3b4be3520092f4dafa11f85efe4594a6 (diff) |
Merge "handle json inputs in function attributes"
Diffstat (limited to 'cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts')
-rw-r--r-- | cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts index f46004b0b..8780621ea 100644 --- a/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts +++ b/cds-ui/designer-client/src/app/modules/feature-modules/packages/designer/functions-attribute/functions-attribute.component.ts @@ -139,7 +139,7 @@ export class FunctionsAttributeComponent implements OnInit, OnDestroy { if (inputs) { for (const [key, value] of Object.entries(inputs)) { console.log(key + ' - ' + value); - if (typeof value === 'object') { + if (this.isValidJson(value)) { this.currentFuncion.inputs[key] = JSON.stringify(value); } else { this.currentFuncion.inputs[key] = value; @@ -154,6 +154,25 @@ export class FunctionsAttributeComponent implements OnInit, OnDestroy { } } } + + isValidJson(val) { + try { + JSON.parse(val); + return true; + } catch (e) { } + return false; + } + + jsonToStr(json) { + return JSON.stringify(json); + } + + bind(key, e) { + const val = JSON.parse(e.target.value); + this.currentFuncion.inputs[key] = { + ...val + }; + } ngOnDestroy() { this.ngUnsubscribe.next(); this.ngUnsubscribe.complete(); |