From 77ea31fbe3c687693d5cf261466b0eaf513401b0 Mon Sep 17 00:00:00 2001 From: meenahoda Date: Wed, 23 Feb 2022 12:34:06 +0000 Subject: [PATCH 1/4] feat: introducing ui listener --- lib/components/state-resources/awaiting-human-input/index.js | 2 ++ .../state-resources/awaiting-human-input/schema.json | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib/components/state-resources/awaiting-human-input/index.js b/lib/components/state-resources/awaiting-human-input/index.js index b251f71..0e28e20 100644 --- a/lib/components/state-resources/awaiting-human-input/index.js +++ b/lib/components/state-resources/awaiting-human-input/index.js @@ -15,6 +15,7 @@ class AwaitingHumanInput { this.uiName = resourceConfig.uiName this.uiType = resourceConfig.uiType this.uiRefresh = resourceConfig.uiRefresh + this.uiListener = resourceConfig.uiListener this.dataPath = resourceConfig.dataPath this.defaults = resourceConfig.defaults @@ -50,6 +51,7 @@ class AwaitingHumanInput { uiName: this.uiName, uiType: this.uiType, uiRefresh: this.uiRefresh, + uiListener: this.uiListener, data } diff --git a/lib/components/state-resources/awaiting-human-input/schema.json b/lib/components/state-resources/awaiting-human-input/schema.json index fc3e5a0..ffd984c 100644 --- a/lib/components/state-resources/awaiting-human-input/schema.json +++ b/lib/components/state-resources/awaiting-human-input/schema.json @@ -13,6 +13,10 @@ "type": "integer", "description": "If the uiType is progress, the suggest refresh time in seconds" }, + "uiListener": { + "type": "string", + "description": "Key value of event to listen for" + }, "dataPath": { "type": "string", "description": "Path to data" From d94a6b3fdaeb0b8c0d7948eda60f608591ff2a0c Mon Sep 17 00:00:00 2001 From: meenahoda Date: Wed, 2 Mar 2022 08:28:09 +0000 Subject: [PATCH 2/4] feat: resolve input paths of ui listener config --- lib/components/state-resources/awaiting-human-input/index.js | 3 ++- package.json | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/components/state-resources/awaiting-human-input/index.js b/lib/components/state-resources/awaiting-human-input/index.js index 0e28e20..f1d69ec 100644 --- a/lib/components/state-resources/awaiting-human-input/index.js +++ b/lib/components/state-resources/awaiting-human-input/index.js @@ -1,5 +1,6 @@ const jp = require('jsonpath') const _ = require('lodash') +const resolveInputPaths = require('@wmfs/json-path-input-resolver') const getFromObject = (obj, path, defaultValue) => { const result = String.prototype.split.call(path, /[,[\].]+?/) @@ -51,7 +52,7 @@ class AwaitingHumanInput { uiName: this.uiName, uiType: this.uiType, uiRefresh: this.uiRefresh, - uiListener: this.uiListener, + uiListener: resolveInputPaths(event, this.uiListener), data } diff --git a/package.json b/package.json index 468c9cf..4095f2c 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ }, "main": "./lib/index.js", "dependencies": { + "@wmfs/json-path-input-resolver": "1.0.0", "@wmfs/form-maker": "1.9.0", "jsonfile": "6.1.0", "jsonpath": "1.1.1", From 521550e891c5d6e8c5b896c520f05f2157ed1e2f Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 3 Mar 2022 08:07:00 +0000 Subject: [PATCH 3/4] fix: issue resolving ui listener config --- .../state-resources/awaiting-human-input/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/components/state-resources/awaiting-human-input/index.js b/lib/components/state-resources/awaiting-human-input/index.js index f1d69ec..f11da36 100644 --- a/lib/components/state-resources/awaiting-human-input/index.js +++ b/lib/components/state-resources/awaiting-human-input/index.js @@ -52,7 +52,7 @@ class AwaitingHumanInput { uiName: this.uiName, uiType: this.uiType, uiRefresh: this.uiRefresh, - uiListener: resolveInputPaths(event, this.uiListener), + uiListener: resolveUiListener(event, this.uiListener), data } @@ -94,4 +94,9 @@ class AwaitingHumanInput { } // run } // class AwaitingHumanInput +function resolveUiListener (data, config) { + if (!Array.isArray(config)) return [] + return config.map(c => resolveInputPaths(data, c)) +} + module.exports = AwaitingHumanInput From 68fd4ad2242ec221ae3304ba2156c11c082fb23f Mon Sep 17 00:00:00 2001 From: meenahoda Date: Thu, 3 Mar 2022 08:29:21 +0000 Subject: [PATCH 4/4] build(deps): update @wmfs/json-path-input-resolver to 1.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4095f2c..d3dc57b 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ }, "main": "./lib/index.js", "dependencies": { - "@wmfs/json-path-input-resolver": "1.0.0", + "@wmfs/json-path-input-resolver": "1.1.0", "@wmfs/form-maker": "1.9.0", "jsonfile": "6.1.0", "jsonpath": "1.1.1",