Loop and Nested forms (#1282)

* Loop and Nested forms

* Updates

* Removed Implementation steps

* Removed Implementation steps

* remove conflict marker

---------

Co-authored-by: burnettk <burnettk@users.noreply.github.com>
This commit is contained in:
usama9500 2024-04-01 19:06:48 +05:00 committed by GitHub
parent 8b795f994e
commit 4c8ca01740
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 99 additions and 21 deletions

View File

@ -382,19 +382,17 @@ Below is an example JSON schema that includes the numeric range field:
"numericRange": {
"type": "object",
"title": "Numeric Range",
"properties": {
"min": {
"minimum": {
"type": "number",
"title": "Minimum Value"
},
"max": {
"maximum": {
"type": "number",
"title": "Maximum Value"
}
}
}
}
}
```
This schema defines a numeric range object with `min` and `max` properties, both of which are required.
@ -412,3 +410,45 @@ This schema defines a numeric range object with `min` and `max` properties, both
#### Validation
This will automatically validate that the max value cannot be less than the min value.
### Adding a New Button for Repeating Sections in Forms
Nested forms or repeating sections are designed to collect an array of objects, where each object represents a set of related information. For instance, in a task management form, you might need to collect multiple tasks, each with its title and completion status.
This structure can be represented in the form's schema as follows:
```json
{
"title": "Nested Form / Repeating Section",
"description": "Allow the form submitter to add multiple entries for a set of fields.",
"type": "object",
"properties": {
"tasks": {
"type": "array",
"title": "Tasks",
"items": {
"type": "object",
"required": ["title"],
"properties": {
"title": {
"type": "string",
"title": "Title",
"description": "Please describe the task to complete"
},
"done": {
"type": "boolean",
"title": "Done?",
"default": false
}
}
}
}
}
}
```
**Form Preview**:
![Nested Forms](images/Nested_form_display.png)
By usign this feature, you can effectively implement new buttons for nested forms or repeating sections improving the form's usability for collecting multiple related entries from users.

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -1,7 +1,7 @@
# Multi-instance Tasks
Multi-instance tasks in BPMN (Business Process Model and Notation) represent a powerful tool for modeling processes that require repetitive actions over a collection of items.
These tasks automate the iteration over a list, array, or collection, executing the specified activity for each element within. Multi-instance tasks can be configured to run either in parallel, where all instances are executed simultaneously, or sequentially, where each instance is executed one after the other.
Multi-instance tasks in BPMN (Business Process Model and Notation) are a powerful tool for modeling processes that require repetitive actions over a collection of items.
These tasks automate the iteration over a list, array, or collection, executing the specified activity for each element within.
Multi-instance tasks can be configured to run either in parallel, where all instances are executed simultaneously, or sequentially, where each instance is executed one after the other.
## **Sequential Execution**
@ -43,13 +43,10 @@ Specifically, the process manages a list of composers, their names, and genres,
### Process Overview:
1. **Start Event**: Marks the initiation of the process.
#### 1. **Start Event**:
Marks the initiation of the process.
#### 2. **Script Task - Create Dictionary**:
This task initializes a list (array) of dictionaries, each representing a composer with their name and associated genre. The script effectively sets up the data structure that will be manipulated in subsequent steps of the process.
2. **Script Task - Create Dictionary**: This task initializes a list (array) of dictionaries, each representing a composer with their name and associated genre. The script effectively sets up the data structure that will be manipulated in subsequent steps of the process.
![Multi_instance_example](images/multiinstance_example2.png)
@ -63,9 +60,7 @@ This task initializes a list (array) of dictionaries, each representing a compos
]
```
#### 3. **Multi-Instance Task - Edit Composer**:
This task is configured as a parallel multi-instance task that iterates over the `composers` array created by the previous script task. It allows for the editing of each composer's information within the array.
3. **Multi-Instance Task - Edit Composer**: This task is configured as a parallel multi-instance task that iterates over the `composers` array created by the previous script task. It allows for the editing of each composer's information within the array.
![Multi_instance_example](images/multiinstance_ex.png)
@ -80,9 +75,7 @@ This task is configured as a parallel multi-instance task that iterates over the
⚠ The completion condition and output element are left unspecified, indicating that the task completes after iterating over all elements in the input collection without additional conditions.
```
#### 4. **Manual Task - Display Edited Composers**:
This task presents the edited list of composers and their genres, using a loop to display each composer's name and genre in the format provided.
4. **Manual Task - Display Edited Composers**: This task presents the edited list of composers and their genres, using a loop to display each composer's name and genre in the format provided.
![Multi_instance_example](images/multiinstance_ex1.png)
@ -96,10 +89,55 @@ This task presents the edited list of composers and their genres, using a loop t
This templating syntax iterates over the `composers` array, displaying each composer's name and genre in a formatted list.
5. **End Event**:
Signifies the successful completion of the process instance, after the list of composers has been edited and displayed.
5. **End Event**: Signifies the successful completion of the process instance, after the list of composers has been edited and displayed.
### Summary:
This multi-instance example in a BPMN process highlights the capability to dynamically handle collections of data through scripting and manual tasks. By iterating over a list of composers, allowing for the editing of each item, and finally displaying the edited list, the process demonstrates how data can be manipulated and presented in a structured workflow, showcasing the flexibility and power of BPMN for data-driven processes.
## Loops
Standard loops in Business Process Model and Notation (BPMN) are a fundamental mechanism to model repetitive tasks within a workflow. These loops allow for the execution of a specific task or sequence of tasks repeatedly until a predefined condition is met, mirroring traditional loop constructs found in programming languages.
### Key Concepts
![Loop Configuration](images/Loop_Settings.png)
1. **Loop Marker**: A visual indicator (a small loop symbol) placed at the bottom center of an activity to denote that the activity is subject to repeated execution.
2. **Loop Condition**: A Boolean expression evaluated before or after each iteration of the loop. The loop continues as long as this condition evaluates to true.
3. **Loop Maximum**: An upper limit on the number of iterations a loop can execute, preventing infinite looping and ensuring process termination.
### Implementing a Standard Loop
To model a standard loop in BPMN, determine the activity or sequence of activities that need to be executed repeatedly. The next steps are:
1. **Configure the Loop Characteristics**:
- Add the loop marker to the activity symbol.
- Define the loop condition within the activitys properties. This condition dictates the continuation of the loop.
3. **Loop Execution**:
- The process engine evaluates the loop condition. If true, the looped activity is executed.
- After execution, the loop condition is re-evaluated to decide whether another iteration is required.
### Example: Incrementing a Counter
Consider a process designed to increment a counter variable until it reaches a specific value. This scenario is effectively managed using a standard loop in BPMN.
#### Process Overview
![Loop Example](images/loop_example1.png)
1. **Start Event**: Initiates the workflow.
2. **Script Task - Initialize Counter**: Initializes a counter variable, `counter`, to 0 and Script: `counter = 0;`
3. **Script Loop Task - Increment Counter**: Implement the Script Loop Task with a loop marker and configure the loop condition (`counter < 10`) and increment script (`counter = counter + 1;`). The process engine will increment the `counter` by 1 on each iteration.
![Loop Example](images/loop_example2.png)
The task is marked with a loop indicator, and the loop condition ensures the task repeats until `counter` reaches 10.
4. **End Event**: Marks the completion of the process once the loop condition is no longer satisfied.
This example illustrates the use of a standard loop in BPMN to model repetitive actions within a workflow, showcasing how loops can automate iterative tasks based on dynamic conditions.