Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GDD Type invoke-action #11

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,32 @@ 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 script to execute/invoke in the template
// Example: "myCustomHello(\"world\", $path)"
"invoke": string
}
}
```

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

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"`.
Expand All @@ -392,6 +418,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;
}
Expand Down