From 58fdc6b47d3f5c18590b4ab28a51646c04a431f5 Mon Sep 17 00:00:00 2001 From: Johan Nyman Date: Sat, 8 Oct 2022 20:34:40 +0200 Subject: [PATCH 1/3] Add GDD Type invoke-action. Co-authored by imaretic Co-authored by Tuomo Kulomaa --- README.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/README.md b/README.md index 5590c51..77cf865 100644 --- a/README.md +++ b/README.md @@ -367,6 +367,30 @@ Example: } ``` +### Special GDD Type: "Invoke Action" + +Some templates support invoking custom functions during their life-time. +This GDD Type should be rendered as a Button in the GUI so that the user can click it to invoke the action. + + +Example: +```typescript +{ + "title": string, // [Mandatory] A short title / label of the action + "description": "", // [Optional] A longer description of the action + "type": "null", + "gddType": "invoke-action", + "gddOptions": { + // [mandatory] The function to invoke in the template + // Example: myCustomHello("world", $path) + "invoke": string + } +} +``` + +Note: `$path` is a special token which will be substituted at runtime with the path of the action. This is useful when having an action inside an array, since this would cause multiple actions to render (one per row in the data). An example of a path would be `people.2` for the action in the 3rd row of an array called `people`. + + ## For GUI Developers When implementing a GUI to support the GDD definitions, you don't have to implement support for all GDD Types - since the GDD Types are designed to degrade gracefully. The only types that are mandatory to implement are the basic types `"boolean"`, `"string"`, `"number"`, `"integer"`, `"array"`and `"object"`. @@ -392,6 +416,7 @@ function determineComponent(prop) { if (basicType === "integer") return componentInteger(prop); if (basicType === "array") return componentArray(prop); if (basicType === "object") return componentObject(prop); + if (basicType === "null") return null return null; } From b925b2ff8fed372f3ee43b910ba8f9085ab47572 Mon Sep 17 00:00:00 2001 From: Johan Nyman Date: Fri, 28 Oct 2022 10:41:22 +0200 Subject: [PATCH 2/3] chore: specify that the $path is a JSONPath --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 77cf865..282c8e9 100644 --- a/README.md +++ b/README.md @@ -388,7 +388,9 @@ Example: } ``` -Note: `$path` is a special token which will be substituted at runtime with the path of the action. This is useful when having an action inside an array, since this would cause multiple actions to render (one per row in the data). An example of a path would be `people.2` for the action in the 3rd row of an array called `people`. +Note: `$path` is a special token which will be substituted at runtime with the [JSONPath](https://goessner.net/articles/JsonPath/) of the action. +This is useful when having an action inside an array, since this would cause multiple actions to render (one per row in the data). +An example of a path would be `myData.people[2]` for the action in the 3rd row of an array called `people` in an object called `myData`. ## For GUI Developers From 305092c1ba1eeaaadd7ac9dc45093edb39314969 Mon Sep 17 00:00:00 2001 From: Johan Nyman Date: Fri, 28 Oct 2022 10:42:01 +0200 Subject: [PATCH 3/3] chore: clarify gddType invoke-action --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 282c8e9..2f90adf 100644 --- a/README.md +++ b/README.md @@ -381,8 +381,8 @@ Example: "type": "null", "gddType": "invoke-action", "gddOptions": { - // [mandatory] The function to invoke in the template - // Example: myCustomHello("world", $path) + // [mandatory] The script to execute/invoke in the template + // Example: "myCustomHello(\"world\", $path)" "invoke": string } }