From de0a3b3cb109c9b495237fe40479e23db042f7b4 Mon Sep 17 00:00:00 2001 From: jmeyer Date: Mon, 3 Jun 2019 18:27:37 -0600 Subject: [PATCH 1/2] fixing output of array of objects to display the object --- modules/st2-auto-form/fields/array.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/st2-auto-form/fields/array.js b/modules/st2-auto-form/fields/array.js index 35e0e80b5..50969194a 100644 --- a/modules/st2-auto-form/fields/array.js +++ b/modules/st2-auto-form/fields/array.js @@ -27,6 +27,10 @@ const jsonCheck = (value) => { return true; }; +const jsonInArrayCheck = (value) => { + return value.every(item => typeof(item) === 'object' ); +}; + const typeChecks = (type, value) => { const v = String(value); switch (type) { @@ -35,7 +39,7 @@ const typeChecks = (type, value) => { case 'integer': return !validator.isInt(v) && `'${v}' is not an integer`; case 'object': - return !_.isPlainObject(v) && `'${v}' is not an object`; + return !_.isPlainObject(value) && `'${v}' is not an object`; case 'string': default: return false; @@ -93,6 +97,10 @@ export default class ArrayField extends BaseTextField { return v; } + if (Array.isArray(v) && jsonInArrayCheck(v)) { + return JSON.stringify(v); + } + const { secret } = this.props.spec || {}; if (secret && v && !Array.isArray(v)) { return v; From fdd66719205264ba022c69f3bf0d91a70687c4c8 Mon Sep 17 00:00:00 2001 From: Jacob Floyd Date: Sat, 2 Apr 2022 00:28:18 -0500 Subject: [PATCH 2/2] fix merge --- modules/st2-auto-form/fields/array.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/st2-auto-form/fields/array.js b/modules/st2-auto-form/fields/array.js index dd7389a0b..8bb6c059c 100644 --- a/modules/st2-auto-form/fields/array.js +++ b/modules/st2-auto-form/fields/array.js @@ -113,6 +113,7 @@ export default class ArrayField extends BaseTextField { /* string which is YAQL */ if (isYaql(v)) { return v; + } if (Array.isArray(v) && jsonInArrayCheck(v)) { return JSON.stringify(v);