Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Michaël St-Georges committed Nov 2, 2024
1 parent 671fffd commit 41890d7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# Budibase-foreach
This is a readme for your new Budibase plugin.
# ForEach Plugin

# Description
ForEach component for Budibase
Budibase ForEach plugin.

Find out more about [Budibase](https://github.com/Budibase/budibase).

## Instructions
This plugin can be used to run actions on every row of a datasource. You could also leverage the plugin to execute actions on binding changes.


To build your new plugin run the following in your Budibase CLI:
```
budi plugins --build
```
## Instructions

You can also re-build everytime you make a change to your plugin with the command:
```
budi plugins --watch
```
Install the plugin and add the component to your application. The component requires a "row number" binding and an event to trigger when this "row number" changes. The event handler will fire on every change of the "row number" binding, except if the "row number" binding is not parseable as a number or parses to a negative number. If the datasource binding is set, the event handler will also receive the object from the datasource at the selected row. The plugin also exposes the current "row number" and the current row data (If dataprovider is set) as context variables if you want to track the status.

### ForEach Flow
To implement a full "ForEach", the following is the recommended implementation:
- Bind a *selectedRow* state variable to the **Next Line Number** setting.
- Bind your data provider to the **Data Provider** setting.
- Add the following actions to the **Event** setting:
1. ...Some custom action
2. Set the *selectedRow* state variable to the following binding `{{ add Line Number 1 }}`
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "budibase-foreach",
"version": "1.0.0",
"version": "1.0.1",
"description": "ForEach component for Budibase",
"license": "MIT",
"svelte": "index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/Component.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
function nextLineChanged(nextLineNumber: string) {
currentLineNumber = parseInt(nextLineNumber, 10);
if (isNaN(currentLineNumber)) {
if (isNaN(currentLineNumber) || currentLineNumber < 0 || currentLineNumber >= dataProvider?.rows.length) {
currentLineNumber = null;
currentLineData = null;
}
Expand Down

0 comments on commit 41890d7

Please sign in to comment.